From e4ae265184db659ec8cd860a706aecc52b9549bb Mon Sep 17 00:00:00 2001 From: Brian Beck Date: Mon, 9 Mar 2026 12:38:40 -0700 Subject: [PATCH] begin live server support --- .dockerignore | 147 + .env.example | 26 + .gitignore | 4 + CLAUDE.md | 14 + README.md | 87 + app/page.tsx | 291 +- docs/404.html | 2 +- docs/404/index.html | 2 +- docs/__next.__PAGE__.txt | 8 +- docs/__next._full.txt | 8 +- docs/__next._head.txt | 2 +- docs/__next._index.txt | 2 +- docs/__next._tree.txt | 6 +- .../_buildManifest.js | 0 .../_clientMiddlewareManifest.json | 0 .../_ssgManifest.js | 0 docs/_next/static/chunks/037fbc56cebf7caa.js | 1 + docs/_next/static/chunks/07f1e4bb8e7d8066.js | 1 - docs/_next/static/chunks/0be79f7f5e0597a7.css | 2 - docs/_next/static/chunks/0c29da8d7ee18a67.js | 89 + docs/_next/static/chunks/12261e943ff623d2.js | 397 ++ ...7999e46d7efb4.css => 12ed5d454f7c6ac3.css} | 10 +- docs/_next/static/chunks/13f8b467e8aa89cb.js | 166 - docs/_next/static/chunks/14c6376ae0b23060.js | 38 + docs/_next/static/chunks/164bc8495505bc95.js | 174 + docs/_next/static/chunks/1a2c6dc513278881.js | 8 + docs/_next/static/chunks/1cf33c843f96e1c9.js | 1 - docs/_next/static/chunks/1fe5719635cf5984.js | 1 + docs/_next/static/chunks/20b7c805b0b1f5f3.js | 362 -- docs/_next/static/chunks/2400be5b6a2e4806.js | 1 + docs/_next/static/chunks/2677e6a5750bb60c.js | 1 + docs/_next/static/chunks/29cbf5720c3c6313.js | 38 - docs/_next/static/chunks/2edeeda5ca6dc680.js | 1 + docs/_next/static/chunks/3a7943ba4f8effca.css | 1 - docs/_next/static/chunks/44bbdd420cb3ec27.js | 362 -- docs/_next/static/chunks/49bf5eb2ca42014f.js | 1 + docs/_next/static/chunks/53a9c1169e187e33.js | 52 - docs/_next/static/chunks/576b06837c0cb7a0.js | 17 + docs/_next/static/chunks/629d98e413c0344a.js | 397 ++ docs/_next/static/chunks/687860f86433eb04.js | 1 + docs/_next/static/chunks/6f1c1038c8b3b80c.js | 75 + docs/_next/static/chunks/718b5c36c0eed37e.js | 1 + docs/_next/static/chunks/796073b9f885dcbc.js | 166 + docs/_next/static/chunks/818dce712bc45cb4.js | 174 + docs/_next/static/chunks/88a5cf0ea7f16af4.js | 1 + docs/_next/static/chunks/8c435435e00c1d09.js | 75 - docs/_next/static/chunks/90c5f23d057a7dda.js | 174 - docs/_next/static/chunks/91476c9d2f29d071.js | 211 -- docs/_next/static/chunks/94212136ebe55507.js | 52 - docs/_next/static/chunks/99bc9f3ae93187f1.css | 1 + docs/_next/static/chunks/9eaea0ae086bad69.js | 1 + docs/_next/static/chunks/aed6ada67562a5fc.js | 1 + docs/_next/static/chunks/b07469fc6c6cd3bb.js | 1 + docs/_next/static/chunks/bd03a29a57c8ca45.css | 5 + docs/_next/static/chunks/c0475cead0a67c33.js | 8 - docs/_next/static/chunks/ca289845e0f08110.js | 1 + docs/_next/static/chunks/d96f10e4606ed566.js | 609 ---- docs/_next/static/chunks/e16c267496b8de91.js | 1 + docs/_next/static/chunks/e1a8caa90a5343cf.js | 17 + docs/_next/static/chunks/e5617268e3c7a140.js | 1 + docs/_next/static/chunks/ee88398bb27ad4a1.js | 521 +++ docs/_next/static/chunks/fe8d2153bfb8c263.js | 8 - docs/_not-found/__next._full.txt | 2 +- docs/_not-found/__next._head.txt | 2 +- docs/_not-found/__next._index.txt | 2 +- .../_not-found/__next._not-found.__PAGE__.txt | 2 +- docs/_not-found/__next._not-found.txt | 2 +- docs/_not-found/__next._tree.txt | 2 +- docs/_not-found/index.html | 2 +- docs/_not-found/index.txt | 2 +- .../Classic_maps_v1.vl2/shapes/borg11.glb | Bin 6404 -> 6436 bytes .../@vl2/T2csri.vl2/t2csri/authconnect.cs | 157 +- .../@vl2/T2csri.vl2/t2csri/authinterface.cs | 15 +- .../base/@vl2/T2csri.vl2/t2csri/autoupdate.cs | 111 + docs/base/@vl2/T2csri.vl2/t2csri/bans.cs | 93 + docs/base/@vl2/T2csri.vl2/t2csri/base64.cs | 164 + docs/base/@vl2/T2csri.vl2/t2csri/certstore.rb | 43 + .../base/@vl2/T2csri.vl2/t2csri/clientSide.cs | 221 +- .../@vl2/T2csri.vl2/t2csri/clientSideClans.cs | 2 - docs/base/@vl2/T2csri.vl2/t2csri/crypto.rb | 492 +++ docs/base/@vl2/T2csri.vl2/t2csri/glue.cs | 9 + docs/base/@vl2/T2csri.vl2/t2csri/ipv4.cs | 20 +- docs/base/@vl2/T2csri.vl2/t2csri/rubyUtils.cs | 31 + .../base/@vl2/T2csri.vl2/t2csri/serverSide.cs | 157 +- .../@vl2/T2csri.vl2/t2csri/serverSideClans.cs | 20 +- .../base/@vl2/T2csri.vl2/t2csri/serverglue.cs | 6 + .../TR2final105-client.vl2/shapes/TR2flag.glb | Bin 6776 -> 6808 bytes .../shapes/TR2heavy_male.glb | Bin 759904 -> 760140 bytes .../shapes/TR2light_female.glb | Bin 717780 -> 718016 bytes .../shapes/TR2light_male.glb | Bin 110692 -> 110796 bytes .../shapes/TR2medium_female.glb | Bin 729428 -> 729664 bytes .../shapes/TR2medium_male.glb | Bin 752480 -> 752724 bytes .../shapes/TR2weapon_chaingun.glb | Bin 55836 -> 55880 bytes .../shapes/TR2weapon_disc.glb | Bin 23340 -> 23396 bytes .../shapes/TR2weapon_grenade_launcher.glb | Bin 29724 -> 29764 bytes .../shapes/TR2weapon_mortar.glb | Bin 52552 -> 52584 bytes .../shapes/TR2weapon_shocklance.glb | Bin 41852 -> 41896 bytes .../@vl2/shapes.vl2/shapes/ammo_plasma.glb | Bin 12236 -> 12268 bytes .../@vl2/shapes.vl2/shapes/banner_honor.glb | Bin 6220 -> 6248 bytes .../shapes.vl2/shapes/banner_strength.glb | Bin 6224 -> 6256 bytes .../@vl2/shapes.vl2/shapes/banner_unity.glb | Bin 6220 -> 6248 bytes docs/base/@vl2/shapes.vl2/shapes/beacon.glb | Bin 7328 -> 7356 bytes .../@vl2/shapes.vl2/shapes/bioderm_heavy.glb | Bin 987432 -> 987716 bytes .../@vl2/shapes.vl2/shapes/bioderm_light.glb | Bin 940924 -> 941228 bytes .../@vl2/shapes.vl2/shapes/bioderm_medium.glb | Bin 971932 -> 972224 bytes docs/base/@vl2/shapes.vl2/shapes/borg12.glb | Bin 4388 -> 4420 bytes docs/base/@vl2/shapes.vl2/shapes/borg13.glb | Bin 8692 -> 8724 bytes docs/base/@vl2/shapes.vl2/shapes/borg2.glb | Bin 37816 -> 37848 bytes docs/base/@vl2/shapes.vl2/shapes/borg3.glb | Bin 5120 -> 5152 bytes docs/base/@vl2/shapes.vl2/shapes/camera.glb | Bin 18192 -> 18256 bytes .../@vl2/shapes.vl2/shapes/chaingun_shot.glb | Bin 7716 -> 7748 bytes .../@vl2/shapes.vl2/shapes/deploy_ammo.glb | Bin 32480 -> 32516 bytes .../shapes.vl2/shapes/deploy_inventory.glb | Bin 68232 -> 68292 bytes .../shapes/deploy_sensor_motion.glb | Bin 19108 -> 19160 bytes .../shapes.vl2/shapes/deploy_sensor_pulse.glb | Bin 24312 -> 24360 bytes docs/base/@vl2/shapes.vl2/shapes/disc.glb | Bin 11196 -> 11240 bytes .../@vl2/shapes.vl2/shapes/disc_explosion.glb | Bin 17236 -> 17268 bytes .../shapes/effect_plasma_explosion.glb | Bin 6700 -> 6732 bytes .../@vl2/shapes.vl2/shapes/energy_bolt.glb | Bin 9220 -> 9252 bytes .../shapes.vl2/shapes/energy_explosion.glb | Bin 3532 -> 3564 bytes .../@vl2/shapes.vl2/shapes/ext_flagstand.glb | Bin 22620 -> 22660 bytes docs/base/@vl2/shapes.vl2/shapes/flag.glb | Bin 8712 -> 8744 bytes .../@vl2/shapes.vl2/shapes/gravemarker_1.glb | Bin 23960 -> 23992 bytes docs/base/@vl2/shapes.vl2/shapes/grenade.glb | Bin 13456 -> 13496 bytes .../@vl2/shapes.vl2/shapes/grenade_flare.glb | Bin 24604 -> 24640 bytes .../@vl2/shapes.vl2/shapes/grenade_flash.glb | Bin 13832 -> 13864 bytes .../shapes.vl2/shapes/grenade_projectile.glb | Bin 5084 -> 5116 bytes .../@vl2/shapes.vl2/shapes/heavy_male.glb | Bin 840944 -> 841228 bytes .../@vl2/shapes.vl2/shapes/light_female.glb | Bin 882752 -> 883060 bytes .../@vl2/shapes.vl2/shapes/light_male.glb | Bin 829028 -> 829344 bytes .../@vl2/shapes.vl2/shapes/medium_female.glb | Bin 875300 -> 875600 bytes .../@vl2/shapes.vl2/shapes/medium_male.glb | Bin 840672 -> 840972 bytes docs/base/@vl2/shapes.vl2/shapes/mine.glb | Bin 30080 -> 30116 bytes .../shapes.vl2/shapes/mortar_explosion.glb | Bin 9544 -> 9576 bytes .../shapes.vl2/shapes/mortar_projectile.glb | Bin 6516 -> 6548 bytes .../@vl2/shapes.vl2/shapes/nexus_effect.glb | Bin 14136 -> 14184 bytes .../base/@vl2/shapes.vl2/shapes/nexusbase.glb | Bin 41684 -> 41728 bytes docs/base/@vl2/shapes.vl2/shapes/nexuscap.glb | Bin 42716 -> 42760 bytes .../shapes.vl2/shapes/pack_deploy_ammo.glb | Bin 10452 -> 10484 bytes .../shapes/pack_deploy_sensor_motion.glb | Bin 13648 -> 13680 bytes .../shapes/pack_deploy_sensor_pulse.glb | Bin 20604 -> 20636 bytes .../shapes/pack_upgrade_cloaking.glb | Bin 33476 -> 33504 bytes .../shapes.vl2/shapes/pack_upgrade_energy.glb | Bin 28280 -> 28312 bytes .../shapes.vl2/shapes/pack_upgrade_repair.glb | Bin 26836 -> 26868 bytes .../shapes/pack_upgrade_satchel.glb | Bin 31404 -> 31440 bytes .../shapes/pack_upgrade_sensorjammer.glb | Bin 21112 -> 21140 bytes .../shapes.vl2/shapes/pack_upgrade_shield.glb | Bin 22028 -> 22060 bytes .../@vl2/shapes.vl2/shapes/plasmabolt.glb | Bin 3064 -> 3096 bytes .../@vl2/shapes.vl2/shapes/repair_kit.glb | Bin 16872 -> 16904 bytes .../@vl2/shapes.vl2/shapes/repair_patch.glb | Bin 10972 -> 11000 bytes .../shapes.vl2/shapes/sensor_pulse_large.glb | Bin 30960 -> 31008 bytes .../shapes.vl2/shapes/sensor_pulse_medium.glb | Bin 24420 -> 24468 bytes .../@vl2/shapes.vl2/shapes/solarpanel.glb | Bin 21004 -> 21048 bytes .../shapes/station_generator_large.glb | Bin 54256 -> 54304 bytes .../shapes.vl2/shapes/station_inv_human.glb | Bin 41332 -> 41392 bytes .../shapes.vl2/shapes/station_inv_mpb.glb | Bin 12080 -> 12124 bytes .../shapes.vl2/shapes/station_teleport.glb | Bin 15432 -> 15484 bytes docs/base/@vl2/shapes.vl2/shapes/switch.glb | Bin 39572 -> 39604 bytes .../@vl2/shapes.vl2/shapes/teamlogo_bd.glb | Bin 9284 -> 9312 bytes .../@vl2/shapes.vl2/shapes/teamlogo_be.glb | Bin 8664 -> 8696 bytes .../@vl2/shapes.vl2/shapes/teamlogo_ds.glb | Bin 9028 -> 9060 bytes .../@vl2/shapes.vl2/shapes/teamlogo_hb.glb | Bin 9200 -> 9232 bytes .../@vl2/shapes.vl2/shapes/teamlogo_inf.glb | Bin 10336 -> 10368 bytes .../shapes.vl2/shapes/teamlogo_projector.glb | Bin 7784 -> 7816 bytes .../@vl2/shapes.vl2/shapes/teamlogo_storm.glb | Bin 8780 -> 8812 bytes .../@vl2/shapes.vl2/shapes/teamlogo_sw.glb | Bin 8104 -> 8132 bytes .../shapes.vl2/shapes/turret_aa_large.glb | Bin 37848 -> 37908 bytes .../shapes/turret_assaulttank_mortar.glb | Bin 27944 -> 28024 bytes .../shapes/turret_assaulttank_plasma.glb | Bin 21120 -> 21180 bytes .../shapes.vl2/shapes/turret_base_large.glb | Bin 59568 -> 59636 bytes .../shapes.vl2/shapes/turret_base_mpb.glb | Bin 37656 -> 37720 bytes .../shapes/turret_belly_barrell.glb | Bin 4072 -> 4112 bytes .../shapes/turret_belly_barrelr.glb | Bin 4072 -> 4112 bytes .../shapes.vl2/shapes/turret_belly_base.glb | Bin 15640 -> 15696 bytes .../shapes.vl2/shapes/turret_elf_large.glb | Bin 68460 -> 68504 bytes .../shapes.vl2/shapes/turret_fusion_large.glb | Bin 32272 -> 32324 bytes .../shapes/turret_indoor_deployc.glb | Bin 49984 -> 50056 bytes .../shapes/turret_indoor_deployf.glb | Bin 49872 -> 49948 bytes .../shapes/turret_indoor_deployw.glb | Bin 54104 -> 54180 bytes .../shapes/turret_missile_large.glb | Bin 36164 -> 36216 bytes .../shapes.vl2/shapes/turret_mortar_large.glb | Bin 71768 -> 71824 bytes .../shapes/turret_outdoor_deploy.glb | Bin 58700 -> 58776 bytes .../@vl2/shapes.vl2/shapes/turret_sentry.glb | Bin 51864 -> 51932 bytes .../shapes/turret_tank_barrelchain.glb | Bin 12680 -> 12732 bytes .../shapes/turret_tank_barrelmortar.glb | Bin 9020 -> 9064 bytes .../shapes.vl2/shapes/turret_tank_base.glb | Bin 7816 -> 7872 bytes .../shapes.vl2/shapes/vehicle_air_bomber.glb | Bin 62112 -> 62176 bytes .../shapes.vl2/shapes/vehicle_air_hapc.glb | Bin 67624 -> 67696 bytes .../shapes.vl2/shapes/vehicle_air_scout.glb | Bin 47104 -> 47168 bytes .../shapes.vl2/shapes/vehicle_grav_scout.glb | Bin 45348 -> 45392 bytes .../shapes.vl2/shapes/vehicle_grav_tank.glb | Bin 65296 -> 65348 bytes .../shapes/vehicle_grav_tank_wreck.glb | Bin 43196 -> 43232 bytes .../shapes/vehicle_land_assault.glb | Bin 30732 -> 30772 bytes .../shapes/vehicle_land_assault_wreck.glb | Bin 43196 -> 43232 bytes .../shapes.vl2/shapes/vehicle_land_mpbase.glb | Bin 414744 -> 414884 bytes .../@vl2/shapes.vl2/shapes/vehicle_pad.glb | Bin 119668 -> 119708 bytes .../shapes.vl2/shapes/vehicle_pad_station.glb | Bin 57388 -> 57440 bytes .../shapes.vl2/shapes/weapon_chaingun.glb | Bin 36760 -> 36804 bytes .../@vl2/shapes.vl2/shapes/weapon_disc.glb | Bin 24052 -> 24108 bytes .../@vl2/shapes.vl2/shapes/weapon_energy.glb | Bin 19412 -> 19464 bytes .../shapes/weapon_grenade_launcher.glb | Bin 22796 -> 22836 bytes .../@vl2/shapes.vl2/shapes/weapon_missile.glb | Bin 14944 -> 14976 bytes .../@vl2/shapes.vl2/shapes/weapon_mortar.glb | Bin 52812 -> 52840 bytes .../@vl2/shapes.vl2/shapes/weapon_plasma.glb | Bin 42232 -> 42284 bytes .../@vl2/shapes.vl2/shapes/weapon_repair.glb | Bin 43872 -> 43912 bytes .../shapes.vl2/shapes/weapon_shocklance.glb | Bin 43640 -> 43684 bytes .../@vl2/shapes.vl2/shapes/weapon_sniper.glb | Bin 23608 -> 23648 bytes docs/base/@vl2/shapes.vl2/shapes/xorg2.glb | Bin 8432 -> 8464 bytes docs/base/@vl2/shapes.vl2/shapes/xorg4.glb | Bin 5576 -> 5608 bytes .../CTF/Classic_maps_v1.vl2/shapes/borg11.glb | Bin 6404 -> 6436 bytes .../z_DMP2-V0.6.vl2/shapes/buildStation.glb | Bin 46128 -> 46168 bytes .../z_DMP2-V0.6.vl2/shapes/cannonTip.glb | Bin 10112 -> 10144 bytes .../z_DMP2-V0.6.vl2/shapes/dsFlame.glb | Bin 4144 -> 4176 bytes .../z_DMP2-V0.6.vl2/shapes/dsPlane.glb | Bin 111116 -> 111144 bytes .../z_DMP2-V0.6.vl2/shapes/faceBox.glb | Bin 957568 -> 957600 bytes .../z_DMP2-V0.6.vl2/shapes/faceSphere.glb | Bin 2540032 -> 2540060 bytes .../z_DMP2-V0.6.vl2/shapes/hellFireGun.glb | Bin 4748 -> 4780 bytes .../z_DMP2-V0.6.vl2/shapes/hellFireTurret.glb | Bin 36644 -> 36696 bytes .../z_DMP2-V0.6.vl2/shapes/t1CMDStation.glb | Bin 22228 -> 22272 bytes .../z_DMP2-V0.6.vl2/shapes/t1Chaingun.glb | Bin 14176 -> 14220 bytes .../z_DMP2-V0.6.vl2/shapes/t1DepAmmo.glb | Bin 51832 -> 51876 bytes .../z_DMP2-V0.6.vl2/shapes/t1DepInvy.glb | Bin 21272 -> 21316 bytes .../shapes/t1GrenadeLauncher.glb | Bin 7472 -> 7504 bytes .../z_DMP2-V0.6.vl2/shapes/t1LSensor.glb | Bin 35728 -> 35768 bytes .../z_DMP2-V0.6.vl2/shapes/t1MisTurret.glb | Bin 38916 -> 38968 bytes .../z_DMP2-V0.6.vl2/shapes/t1PowerGen.glb | Bin 16600 -> 16640 bytes .../z_DMP2-V0.6.vl2/shapes/t1RemoteTurret.glb | Bin 42996 -> 43052 bytes .../z_DMP2-V0.6.vl2/shapes/t1RepairPack.glb | Bin 14172 -> 14204 bytes .../shapes/t1RepairPackGun.glb | Bin 10496 -> 10528 bytes .../z_DMP2-V0.6.vl2/shapes/t1Sentry.glb | Bin 21544 -> 21596 bytes .../z_DMP2-V0.6.vl2/shapes/t1Solar.glb | Bin 18036 -> 18072 bytes .../z_DMP2-V0.6.vl2/shapes/t1TargetLaser.glb | Bin 7204 -> 7236 bytes .../z_DMP2-V0.6.vl2/shapes/t1VehPad.glb | Bin 26948 -> 26984 bytes .../z_DMP2-V0.6.vl2/shapes/t1VehStation.glb | Bin 35020 -> 35064 bytes .../z_DMP2-V0.6.vl2/shapes/t1ammopad.glb | Bin 31152 -> 31196 bytes .../z_DMP2-V0.6.vl2/shapes/t1blaster.glb | Bin 19032 -> 19064 bytes .../z_DMP2-V0.6.vl2/shapes/t1disc.glb | Bin 7704 -> 7764 bytes .../z_DMP2-V0.6.vl2/shapes/t1elfTurret.glb | Bin 26940 -> 26992 bytes .../z_DMP2-V0.6.vl2/shapes/t1flyer.glb | Bin 9712 -> 9744 bytes .../z_DMP2-V0.6.vl2/shapes/t1flyer2.glb | Bin 9716 -> 9748 bytes .../z_DMP2-V0.6.vl2/shapes/t1hpc.glb | Bin 15924 -> 15956 bytes .../shapes/t1inventorystation.glb | Bin 25172 -> 25220 bytes .../z_DMP2-V0.6.vl2/shapes/t1lpc.glb | Bin 12136 -> 12168 bytes .../z_DMP2-V0.6.vl2/shapes/t1mSensor.glb | Bin 25076 -> 25112 bytes .../z_DMP2-V0.6.vl2/shapes/t1mortar.glb | Bin 7000 -> 7032 bytes .../z_DMP2-V0.6.vl2/shapes/t1pGen.glb | Bin 24632 -> 24668 bytes .../z_DMP2-V0.6.vl2/shapes/t1plasma.glb | Bin 7492 -> 7524 bytes .../z_DMP2-V0.6.vl2/shapes/t2DepAmmo.glb | Bin 57056 -> 57100 bytes docs/index.html | 2 +- docs/index.txt | 8 +- docs/shapes/__next._full.txt | 6 +- docs/shapes/__next._head.txt | 2 +- docs/shapes/__next._index.txt | 2 +- docs/shapes/__next._tree.txt | 4 +- docs/shapes/__next.shapes.__PAGE__.txt | 6 +- docs/shapes/__next.shapes.txt | 2 +- docs/shapes/index.html | 2 +- docs/shapes/index.txt | 6 +- eslint.config.mjs | 5 +- fly.toml | 39 + package-lock.json | 359 +- package.json | 15 +- relay/BitStreamWriter.ts | 136 + relay/Dockerfile | 17 + relay/HuffmanWriter.ts | 223 ++ relay/auth.ts | 385 ++ relay/crc.ts | 175 + relay/gameConnection.ts | 850 +++++ relay/logger.ts | 25 + relay/masterQuery.ts | 308 ++ relay/protocol.ts | 546 +++ relay/server.ts | 369 ++ relay/types.ts | 64 + scripts/check-mount-points.ts | 2 +- scripts/convert-wav.ts | 2 +- scripts/t2-login.ts | 322 ++ scripts/t2-server-list.ts | 69 + src/components/AudioContext.tsx | 20 +- src/components/AudioEmitter.tsx | 154 +- src/components/Camera.tsx | 29 +- src/components/CamerasProvider.tsx | 2 +- src/components/ChatSoundPlayer.tsx | 20 +- src/components/CloudLayers.tsx | 46 +- src/components/DemoEntities.tsx | 204 -- src/components/DemoPlayback.tsx | 8 +- ...reaming.tsx => DemoPlaybackController.tsx} | 315 +- ...le.css => DemoPlaybackControls.module.css} | 0 ...oControls.tsx => DemoPlaybackControls.tsx} | 32 +- src/components/DialogButton.module.css | 54 + src/components/EntityRenderer.tsx | 263 ++ src/components/EntityScene.tsx | 293 ++ src/components/FeaturesProvider.tsx | 40 + src/components/FlagMarker.tsx | 13 +- src/components/FogProvider.tsx | 29 + src/components/ForceFieldBare.tsx | 260 +- src/components/GenericShape.tsx | 536 ++- src/components/InspectorControls.module.css | 26 +- src/components/InspectorControls.tsx | 31 +- src/components/InteriorInstance.tsx | 55 +- src/components/Item.tsx | 74 - src/components/JoinServerButton.module.css | 29 + src/components/JoinServerButton.tsx | 53 + src/components/KeyboardOverlay.tsx | 8 +- src/components/LiveConnection.tsx | 266 ++ src/components/LiveObserver.tsx | 328 ++ src/components/LoadDemoButton.tsx | 22 +- src/components/MapInfoDialog.module.css | 23 +- src/components/MapInfoDialog.tsx | 6 +- src/components/Mission.tsx | 27 +- src/components/MissionContext.tsx | 2 - src/components/MissionSelect.tsx | 2 +- src/components/ObserverControls.tsx | 24 +- ...articleEffects.tsx => ParticleEffects.tsx} | 45 +- src/components/PlayerHUD.tsx | 18 +- .../{DemoPlayerModel.tsx => PlayerModel.tsx} | 264 +- src/components/PlayerNameplate.tsx | 31 +- .../{DemoProjectiles.tsx => Projectiles.tsx} | 14 +- ...DemoProvider.tsx => RecordingProvider.tsx} | 30 +- src/components/RuntimeProvider.tsx | 8 +- src/components/SceneLighting.tsx | 81 + src/components/ServerBrowser.module.css | 178 + src/components/ServerBrowser.tsx | 194 + src/components/ShapeInfoProvider.tsx | 4 +- .../{DemoShapeModel.tsx => ShapeModel.tsx} | 54 +- src/components/ShapeSelect.tsx | 2 +- src/components/SimGroup.tsx | 62 - src/components/SimObject.tsx | 110 - src/components/Sky.tsx | 60 +- src/components/StaticShape.tsx | 31 - src/components/Sun.tsx | 41 +- src/components/TSStatic.tsx | 36 +- src/components/TerrainBlock.tsx | 143 +- src/components/TerrainTile.tsx | 8 +- src/components/Turret.tsx | 5 - src/components/WaterBlock.tsx | 38 +- src/components/WayPoint.tsx | 15 +- src/demo/streaming.ts | 3189 ----------------- src/file.vert | 112 - src/manifest.ts | 15 - src/scene/coordinates.spec.ts | 211 ++ src/scene/coordinates.ts | 113 + src/scene/crossValidation.spec.ts | 171 + src/scene/ghostToScene.spec.ts | 159 + src/scene/ghostToScene.ts | 231 ++ src/scene/index.ts | 25 + src/scene/misToScene.spec.ts | 248 ++ src/scene/misToScene.ts | 288 ++ src/scene/types.ts | 131 + src/state/engineStore.ts | 24 +- src/state/gameEntityStore.ts | 298 ++ src/state/gameEntityTypes.ts | 241 ++ src/state/index.ts | 42 +- src/state/streamPlaybackStore.ts | 44 + src/stream/StreamEngine.ts | 1868 ++++++++++ src/stream/demoStreaming.ts | 948 +++++ src/stream/entityBridge.ts | 185 + src/stream/entityClassification.ts | 69 + src/stream/liveStreaming.ts | 555 +++ src/stream/missionEntityBridge.ts | 297 ++ .../playbackUtils.ts} | 117 +- src/{demo => stream}/playerAnimation.ts | 13 - src/stream/relayClient.ts | 197 + src/stream/streamHelpers.ts | 468 +++ src/{demo => stream}/types.ts | 121 +- src/{demo => stream}/weaponStateMachine.ts | 0 src/terrainHeight.ts | 11 +- src/torqueScript/shapeConstructor.ts | 2 + tsconfig.json | 2 +- 368 files changed, 17756 insertions(+), 7738 deletions(-) create mode 100644 .dockerignore create mode 100644 .env.example rename docs/_next/static/{6xhnTWazjCi9htjLDl3f1 => JablvlklHXp4NGWk4TTlC}/_buildManifest.js (100%) rename docs/_next/static/{6xhnTWazjCi9htjLDl3f1 => JablvlklHXp4NGWk4TTlC}/_clientMiddlewareManifest.json (100%) rename docs/_next/static/{6xhnTWazjCi9htjLDl3f1 => JablvlklHXp4NGWk4TTlC}/_ssgManifest.js (100%) create mode 100644 docs/_next/static/chunks/037fbc56cebf7caa.js delete mode 100644 docs/_next/static/chunks/07f1e4bb8e7d8066.js delete mode 100644 docs/_next/static/chunks/0be79f7f5e0597a7.css create mode 100644 docs/_next/static/chunks/0c29da8d7ee18a67.js create mode 100644 docs/_next/static/chunks/12261e943ff623d2.js rename docs/_next/static/chunks/{3e57999e46d7efb4.css => 12ed5d454f7c6ac3.css} (78%) delete mode 100644 docs/_next/static/chunks/13f8b467e8aa89cb.js create mode 100644 docs/_next/static/chunks/14c6376ae0b23060.js create mode 100644 docs/_next/static/chunks/164bc8495505bc95.js create mode 100644 docs/_next/static/chunks/1a2c6dc513278881.js delete mode 100644 docs/_next/static/chunks/1cf33c843f96e1c9.js create mode 100644 docs/_next/static/chunks/1fe5719635cf5984.js delete mode 100644 docs/_next/static/chunks/20b7c805b0b1f5f3.js create mode 100644 docs/_next/static/chunks/2400be5b6a2e4806.js create mode 100644 docs/_next/static/chunks/2677e6a5750bb60c.js delete mode 100644 docs/_next/static/chunks/29cbf5720c3c6313.js create mode 100644 docs/_next/static/chunks/2edeeda5ca6dc680.js delete mode 100644 docs/_next/static/chunks/3a7943ba4f8effca.css delete mode 100644 docs/_next/static/chunks/44bbdd420cb3ec27.js create mode 100644 docs/_next/static/chunks/49bf5eb2ca42014f.js delete mode 100644 docs/_next/static/chunks/53a9c1169e187e33.js create mode 100644 docs/_next/static/chunks/576b06837c0cb7a0.js create mode 100644 docs/_next/static/chunks/629d98e413c0344a.js create mode 100644 docs/_next/static/chunks/687860f86433eb04.js create mode 100644 docs/_next/static/chunks/6f1c1038c8b3b80c.js create mode 100644 docs/_next/static/chunks/718b5c36c0eed37e.js create mode 100644 docs/_next/static/chunks/796073b9f885dcbc.js create mode 100644 docs/_next/static/chunks/818dce712bc45cb4.js create mode 100644 docs/_next/static/chunks/88a5cf0ea7f16af4.js delete mode 100644 docs/_next/static/chunks/8c435435e00c1d09.js delete mode 100644 docs/_next/static/chunks/90c5f23d057a7dda.js delete mode 100644 docs/_next/static/chunks/91476c9d2f29d071.js delete mode 100644 docs/_next/static/chunks/94212136ebe55507.js create mode 100644 docs/_next/static/chunks/99bc9f3ae93187f1.css create mode 100644 docs/_next/static/chunks/9eaea0ae086bad69.js create mode 100644 docs/_next/static/chunks/aed6ada67562a5fc.js create mode 100644 docs/_next/static/chunks/b07469fc6c6cd3bb.js create mode 100644 docs/_next/static/chunks/bd03a29a57c8ca45.css delete mode 100644 docs/_next/static/chunks/c0475cead0a67c33.js create mode 100644 docs/_next/static/chunks/ca289845e0f08110.js delete mode 100644 docs/_next/static/chunks/d96f10e4606ed566.js create mode 100644 docs/_next/static/chunks/e16c267496b8de91.js create mode 100644 docs/_next/static/chunks/e1a8caa90a5343cf.js create mode 100644 docs/_next/static/chunks/e5617268e3c7a140.js create mode 100644 docs/_next/static/chunks/ee88398bb27ad4a1.js delete mode 100644 docs/_next/static/chunks/fe8d2153bfb8c263.js create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/autoupdate.cs create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/bans.cs create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/base64.cs create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/certstore.rb create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/crypto.rb create mode 100644 docs/base/@vl2/T2csri.vl2/t2csri/rubyUtils.cs create mode 100644 fly.toml create mode 100644 relay/BitStreamWriter.ts create mode 100644 relay/Dockerfile create mode 100644 relay/HuffmanWriter.ts create mode 100644 relay/auth.ts create mode 100644 relay/crc.ts create mode 100644 relay/gameConnection.ts create mode 100644 relay/logger.ts create mode 100644 relay/masterQuery.ts create mode 100644 relay/protocol.ts create mode 100644 relay/server.ts create mode 100644 relay/types.ts create mode 100644 scripts/t2-login.ts create mode 100644 scripts/t2-server-list.ts delete mode 100644 src/components/DemoEntities.tsx rename src/components/{DemoPlaybackStreaming.tsx => DemoPlaybackController.tsx} (64%) rename src/components/{DemoControls.module.css => DemoPlaybackControls.module.css} (100%) rename src/components/{DemoControls.tsx => DemoPlaybackControls.tsx} (81%) create mode 100644 src/components/DialogButton.module.css create mode 100644 src/components/EntityRenderer.tsx create mode 100644 src/components/EntityScene.tsx create mode 100644 src/components/FeaturesProvider.tsx delete mode 100644 src/components/Item.tsx create mode 100644 src/components/JoinServerButton.module.css create mode 100644 src/components/JoinServerButton.tsx create mode 100644 src/components/LiveConnection.tsx create mode 100644 src/components/LiveObserver.tsx rename src/components/{DemoParticleEffects.tsx => ParticleEffects.tsx} (97%) rename src/components/{DemoPlayerModel.tsx => PlayerModel.tsx} (73%) rename src/components/{DemoProjectiles.tsx => Projectiles.tsx} (93%) rename src/components/{DemoProvider.tsx => RecordingProvider.tsx} (65%) create mode 100644 src/components/SceneLighting.tsx create mode 100644 src/components/ServerBrowser.module.css create mode 100644 src/components/ServerBrowser.tsx rename src/components/{DemoShapeModel.tsx => ShapeModel.tsx} (92%) delete mode 100644 src/components/SimGroup.tsx delete mode 100644 src/components/SimObject.tsx delete mode 100644 src/components/StaticShape.tsx delete mode 100644 src/demo/streaming.ts delete mode 100644 src/file.vert create mode 100644 src/scene/coordinates.spec.ts create mode 100644 src/scene/coordinates.ts create mode 100644 src/scene/crossValidation.spec.ts create mode 100644 src/scene/ghostToScene.spec.ts create mode 100644 src/scene/ghostToScene.ts create mode 100644 src/scene/index.ts create mode 100644 src/scene/misToScene.spec.ts create mode 100644 src/scene/misToScene.ts create mode 100644 src/scene/types.ts create mode 100644 src/state/gameEntityStore.ts create mode 100644 src/state/gameEntityTypes.ts create mode 100644 src/state/streamPlaybackStore.ts create mode 100644 src/stream/StreamEngine.ts create mode 100644 src/stream/demoStreaming.ts create mode 100644 src/stream/entityBridge.ts create mode 100644 src/stream/entityClassification.ts create mode 100644 src/stream/liveStreaming.ts create mode 100644 src/stream/missionEntityBridge.ts rename src/{demo/demoPlaybackUtils.ts => stream/playbackUtils.ts} (85%) rename src/{demo => stream}/playerAnimation.ts (99%) create mode 100644 src/stream/relayClient.ts create mode 100644 src/stream/streamHelpers.ts rename src/{demo => stream}/types.ts (72%) rename src/{demo => stream}/weaponStateMachine.ts (100%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..12fd26d5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,147 @@ +# flyctl launch added from .gitignore +# Logs +**/logs +**/*.log +**/npm-debug.log* +**/yarn-debug.log* +**/yarn-error.log* +**/lerna-debug.log* +**/.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +**/report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +**/pids +**/*.pid +**/*.seed +**/*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +**/lib-cov + +# Coverage directory used by tools like istanbul +**/coverage +**/*.lcov + +# nyc test coverage +**/.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +**/.grunt + +# Bower dependency directory (https://bower.io/) +**/bower_components + +# node-waf configuration +**/.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +**/build/Release + +# Dependency directories +**/node_modules +**/jspm_packages + +# Snowpack dependency directory (https://snowpack.dev/) +**/web_modules + +# TypeScript cache +**/*.tsbuildinfo + +# Optional npm cache directory +**/.npm + +# Optional eslint cache +**/.eslintcache + +# Optional stylelint cache +**/.stylelintcache + +# Microbundle cache +**/.rpt2_cache +**/.rts2_cache_cjs +**/.rts2_cache_es +**/.rts2_cache_umd + +# Optional REPL history +**/.node_repl_history + +# Output of 'npm pack' +**/*.tgz + +# Yarn Integrity file +**/.yarn-integrity + +# dotenv environment variable files +**/.env +**/.env.development.local +**/.env.test.local +**/.env.production.local +**/.env.local + +# parcel-bundler cache (https://parceljs.org/) +**/.cache +**/.parcel-cache + +# Next.js build output +**/.next +**/out + +# Nuxt.js build / generate output +**/.nuxt +**/dist +!.yalc/**/dist + +# Gatsby files +**/.cache +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +**/.vuepress/dist + +# vuepress v2.x temp and cache directory +**/.temp +**/.cache + +# Docusaurus cache and generated files +**/.docusaurus + +# Serverless directories +**/.serverless + +# FuseBox cache +**/.fusebox + +# DynamoDB Local files +**/.dynamodb + +# TernJS port file +**/.tern-port + +# Stores VSCode versions used for testing VSCode extensions +**/.vscode-test + +# yarn v2 +**/.yarn/cache +**/.yarn/unplugged +**/.yarn/build-state.yml +**/.yarn/install-state.gz +**/.pnp.* + +**/.DS_Store +**/.tshy + +# yalc +#**/.yalc + +# GameData folder with actual .vl2 files (unextracted) in it. Some scripts like +# `extract-assets` and `generate-manifest` look at this to extract or build the +# list of files. Once someone builds this, it's not really necessary for other +# developers to have this folder. +**/GameData + +**/docs/dev +fly.toml diff --git a/.env.example b/.env.example new file mode 100644 index 00000000..1852c903 --- /dev/null +++ b/.env.example @@ -0,0 +1,26 @@ +# Tribes 2 account credentials. +# Only username and password are needed — run `npm run login` to download +# the certificate and encrypted key from the TribesNext auth server. +# The login script writes everything to .env.local automatically. +T2_ACCOUNT_NAME= +T2_ACCOUNT_PASSWORD= + +# These are populated automatically by `npm run login`: +# T2_ACCOUNT_CERTIFICATE= +# T2_ACCOUNT_ENCRYPTED_KEY= + +# Server addresses (defaults shown) +# T2_AUTH_SERVER=tribesnext.thyth.com:60659 +# T2_MASTER_SERVER=master.tribesnext.com + +# Relay WebSocket port (default: 8765) +# RELAY_PORT=8765 + +# Path to game assets (default: docs/base relative to relay/) +# GAME_BASE_PATH=/data/base + +# Path to manifest.json (default: public/manifest.json relative to project root) +# MANIFEST_PATH=/app/public/manifest.json + +# Relay URL for the browser client (default: ws://localhost:8765) +# NEXT_PUBLIC_RELAY_URL=ws://localhost:8765 diff --git a/.gitignore b/.gitignore index f4e29066..6014a181 100644 --- a/.gitignore +++ b/.gitignore @@ -76,6 +76,7 @@ web_modules/ .env .env.development.local .env.test.local +.env.production .env.production.local .env.local @@ -132,6 +133,9 @@ dist .DS_Store .tshy +# yalc +.yalc + # GameData folder with actual .vl2 files (unextracted) in it. Some scripts like # `extract-assets` and `generate-manifest` look at this to extract or build the # list of files. Once someone builds this, it's not really necessary for other diff --git a/CLAUDE.md b/CLAUDE.md index 97037129..f81bf6c6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -81,6 +81,20 @@ to a React component tree. more). Refer to official documentation or the actual Torque3D SDK, which contains the official grammar and source code. Check the `TorqueEngineResources` folder for related materials. +- Normally, most TorqueScript `.cs` files live in VL2 files (deflate encoded, + basically .zip) inside Tribes 2's various folders. For this project, since we + don't want to have to decompress those VL2 files all the time, they've been + pre-extracted. You can find these under the `docs/base` folder. + +### t2-demo-parser + +- This is a custom package developed locally and published via `yalc`. +- If you need to see how it works, I don't recommend reading its `dist` files; + instead focus on its `src` files and README. +- You may update it, but be careful. Verify any changes you make carefully and + add regression tests. +- To make changes visible to `t2-mapper`, make sure you run `npm run build` and + `yalc push` in `t2-demo-parser`. ## Code Conventions diff --git a/README.md b/README.md index be1dbf04..38e3a348 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,93 @@ Run the dev server: npm start ``` +### Relay Server + +The relay server bridges WebSocket connections from the browser to Tribes 2 game +servers via UDP. This is necessary because browsers can't open UDP sockets +directly. + +#### Local development + +First, obtain TribesNext account credentials: + +```console +npm run login +``` + +This prompts for your TribesNext username and password, downloads the account +certificate and encrypted key, and writes them to `.env.local`. + +Then run the relay (or use `npm run start:both` to run it alongside the Next.js +dev server): + +```console +npm run relay:dev +``` + +#### Deploying to Fly.io + +The relay is configured for [Fly.io](https://fly.io) deployment via +`relay/Dockerfile` and `fly.toml`. It needs a persistent volume to hold game +assets (~1.5 GB) used for the CRC integrity check. + +**1. Create the app and volume:** + +```console +fly launch # creates the app (adjust app name in fly.toml if needed) +fly volumes create gamedata --region ord --size 3 +``` + +**2. Set account credentials as secrets:** + +Run `npm run login` locally first if you haven't already, then copy the values +from `.env.local`: + +```console +fly secrets set \ + T2_ACCOUNT_NAME=... \ + T2_ACCOUNT_PASSWORD=... \ + T2_ACCOUNT_CERTIFICATE=... \ + T2_ACCOUNT_ENCRYPTED_KEY=... +``` + +**3. Deploy:** + +```console +fly deploy +``` + +**4. Populate game assets on the volume:** + +SSH into the running machine and clone the repo to get `docs/base/`: + +```console +fly ssh console +``` + +Then inside the machine: + +```sh +apt-get update && apt-get install -y git +git clone --depth 1 --filter=blob:none --sparse \ + https://github.com/exogen/t2-mapper.git /tmp/t2-mapper +cd /tmp/t2-mapper +git sparse-checkout set docs/base +mv docs/base /data/base +rm -rf /tmp/t2-mapper +``` + +This only needs to be done once — the volume persists across deploys. + +**Environment variables** (all optional, with defaults): + +| Variable | Default | Description | +| --- | --- | --- | +| `RELAY_PORT` | `8765` | WebSocket listen port | +| `GAME_BASE_PATH` | `docs/base` relative to relay | Path to extracted game assets | +| `MANIFEST_PATH` | `public/manifest.json` relative to project root | Path to resource manifest | +| `T2_MASTER_SERVER` | `master.tribesnext.com` | Master server for server list queries | + ### Running scripts [tsx](https://tsx.is) is included to run TypeScript files directly. diff --git a/app/page.tsx b/app/page.tsx index e9c35156..669d1baf 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -30,18 +30,49 @@ import { AudioProvider } from "@/src/components/AudioContext"; import { DebugElements } from "@/src/components/DebugElements"; import { CamerasProvider } from "@/src/components/CamerasProvider"; import { - DemoProvider, - useDemoActions, - useDemoRecording, -} from "@/src/components/DemoProvider"; -import { DemoPlayback } from "@/src/components/DemoPlayback"; -import { DemoControls } from "@/src/components/DemoControls"; + RecordingProvider, + usePlaybackActions, + useRecording, +} from "@/src/components/RecordingProvider"; +import { EntityScene } from "@/src/components/EntityScene"; +import { TickProvider } from "@/src/components/TickProvider"; +import { SceneLighting } from "@/src/components/SceneLighting"; import { PlayerHUD } from "@/src/components/PlayerHUD"; -import { ChatSoundPlayer } from "@/src/components/ChatSoundPlayer"; +import { + LiveConnectionProvider, + useLiveConnection, +} from "@/src/components/LiveConnection"; +import { ServerBrowser } from "@/src/components/ServerBrowser"; +import { + FeaturesProvider, + useFeatures, +} from "@/src/components/FeaturesProvider"; + +// Lazy-load demo and live streaming modules — they pull in heavy dependencies +// (demo parser, streaming engine, particles) that aren't needed for mission-only mode. +const DemoPlayback = lazy(() => + import("@/src/components/DemoPlayback").then((mod) => ({ + default: mod.DemoPlayback, + })), +); +const DemoPlaybackControls = lazy(() => + import("@/src/components/DemoPlaybackControls").then((mod) => ({ + default: mod.DemoPlaybackControls, + })), +); +const LiveObserver = lazy(() => + import("@/src/components/LiveObserver").then((mod) => ({ + default: mod.LiveObserver, + })), +); +const ChatSoundPlayer = lazy(() => + import("@/src/components/ChatSoundPlayer").then((mod) => ({ + default: mod.ChatSoundPlayer, + })), +); import { getMissionList, getMissionInfo, - findMissionByDemoName, } from "@/src/manifest"; import { createParser, parseAsBoolean, useQueryState } from "nuqs"; import styles from "./page.module.css"; @@ -120,10 +151,36 @@ function MapInspector() { ); const isTouch = useTouchDevice(); + const features = useFeatures(); + const live = useLiveConnection(); const { missionName, missionType } = currentMission; const [mapInfoOpen, setMapInfoOpen] = useState(false); - const [loadingProgress, setLoadingProgress] = useState(0); + const [serverBrowserOpen, setServerBrowserOpen] = useState(false); + const [missionLoadingProgress, setMissionLoadingProgress] = useState(0); const [showLoadingIndicator, setShowLoadingIndicator] = useState(true); + + // During live join, show progress based on connection status. + // Relay status order: connecting → challenging → authenticating → connected. + // Once liveReady (first ghost arrives), loading is complete. + const liveLoadingProgress = live.adapter != null + ? live.liveReady + ? 1 + : live.gameStatus === "connected" ? 0.8 + : live.gameStatus === "authenticating" ? 0.6 + : live.gameStatus === "challenging" ? 0.3 + : live.gameStatus === "connecting" ? 0.2 + : 0.1 + : null; + + // Reset stale mission progress when live mode takes over, so it can't + // flash through if liveLoadingProgress briefly becomes null. + useEffect(() => { + if (liveLoadingProgress != null) { + setMissionLoadingProgress(0); + } + }, [liveLoadingProgress != null]); // eslint-disable-line react-hooks/exhaustive-deps + + const loadingProgress = liveLoadingProgress ?? missionLoadingProgress; const isLoading = loadingProgress < 1; // Keep the loading indicator visible briefly after reaching 100% @@ -174,7 +231,7 @@ function MapInspector() { const handleLoadingChange = useCallback( (_loading: boolean, progress: number = 0) => { - setLoadingProgress(progress); + setMissionLoadingProgress(progress); }, [], ); @@ -188,7 +245,7 @@ function MapInspector() { return (
- + + - + + - - - + - + {isTouch && ( setMapInfoOpen(true)} + onOpenServerBrowser={features.live ? () => setServerBrowserOpen(true) : undefined} cameraRef={cameraRef} isTouch={isTouch} /> @@ -272,83 +331,56 @@ function MapInspector() { /> )} - setServerBrowserOpen(false)} /> - + - +
); } -/** Map from Tribes 2 game type display names to manifest mission type codes. */ -const GAME_TYPE_TO_MISSION_TYPE: Record = { - "Capture the Flag": "CTF", - "Capture and Hold": "CnH", - Deathmatch: "DM", - "Team Deathmatch": "TDM", - Siege: "Siege", - Bounty: "Bounty", - Rabbit: "Rabbit", -}; - /** - * When a demo recording is loaded, switch to the mission it was recorded on. + * Only mount Mission (TorqueScript runtime, .mis loading) when NOT streaming. + * During demo/live playback, all scene data comes from ghosts — no need for + * the heavy TorqueScript execution pipeline. */ -function DemoMissionSync({ - changeMission, - currentMission, +function MissionWhenIdle({ + missionName, + missionType, + onLoadingChange, }: { - changeMission: (mission: CurrentMission) => void; - currentMission: CurrentMission; + missionName: string; + missionType: string; + onLoadingChange: (isLoading: boolean, progress?: number) => void; }) { - const recording = useDemoRecording(); + const recording = useRecording(); + const { adapter: liveAdapter } = useLiveConnection(); + const isStreaming = recording != null || liveAdapter != null; - useEffect(() => { - if (!recording?.missionName) return; + if (isStreaming) return null; - const missionName = findMissionByDemoName(recording.missionName); - if (!missionName) { - console.warn( - `Demo mission "${recording.missionName}" not found in manifest`, - ); - return; - } - - const info = getMissionInfo(missionName); - const missionTypeCode = recording.gameType - ? GAME_TYPE_TO_MISSION_TYPE[recording.gameType] - : undefined; - const missionType = - missionTypeCode && info.missionTypes.includes(missionTypeCode) - ? missionTypeCode - : info.missionTypes[0]; - - // Skip if we're already on the correct mission to avoid unnecessary - // remount cascades (e.g. after a Suspense boundary restores). - if ( - currentMission.missionName === missionName && - currentMission.missionType === missionType - ) { - return; - } - - changeMission({ missionName, missionType }); - }, [recording, changeMission, currentMission]); - - return null; + return ( + + ); } /** - * Disables observer/touch controls when a demo recording is loaded so they - * don't fight the animated camera. + * In-Canvas components that depend on streaming mode. Mounts the appropriate + * controller (DemoPlayback or LiveObserver) and disables observer controls + * during streaming. */ -function DemoAwareControls({ +function StreamingComponents({ isTouch, joystickStateRef, joystickZoneRef, @@ -361,25 +393,96 @@ function DemoAwareControls({ lookJoystickStateRef: React.RefObject; lookJoystickZoneRef: React.RefObject; }) { - const recording = useDemoRecording(); - if (recording) return null; - if (isTouch === null) return null; - if (isTouch) { - return ( - - ); - } - return ; + const recording = useRecording(); + const live = useLiveConnection(); + const isLive = live.adapter != null; + const isStreaming = recording != null || isLive; + + // Show ObserverControls for: non-streaming mode, OR live mode. + // During live, ObserverControls provides the same camera controls + // (pointer lock, drag-to-rotate, WASD fly) and LiveObserver intercepts + // click-while-locked to cycle observed players instead of nextCamera. + // During demo playback, the demo drives the camera so no controls needed. + const showObserverControls = !isStreaming || isLive; + + return ( + <> + {recording && ( + + + + )} + {isLive && ( + + + + )} + {isStreaming && ( + + + + )} + {showObserverControls && isTouch !== null && ( + isTouch ? ( + + ) : ( + + ) + )} + + ); +} + +/** HUD overlay — shown during streaming (demo or live). */ +function StreamingHUD() { + const recording = useRecording(); + const live = useLiveConnection(); + if (!recording && !live.adapter) return null; + return ; +} + +/** Playback controls overlay — only shown during demo playback. */ +function StreamingOverlay() { + const recording = useRecording(); + const live = useLiveConnection(); + if (!recording || live.adapter != null) return null; + return ( + + + + ); +} + +/** Server browser dialog connected to live state. */ +function ServerBrowserDialog({ + open, + onClose, +}: { + open: boolean; + onClose: () => void; +}) { + const live = useLiveConnection(); + return ( + live.joinServer(address)} + wsPing={live.wsPing} + /> + ); } /** Exposes `window.loadDemoRecording` for automation/testing. */ function DemoWindowAPI() { - const { setRecording } = useDemoActions(); + const { setRecording } = usePlaybackActions(); useEffect(() => { window.loadDemoRecording = setRecording; @@ -394,7 +497,11 @@ function DemoWindowAPI() { export default function HomePage() { return ( - + + + + + ); } diff --git a/docs/404.html b/docs/404.html index b69d086f..cfbe476a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file diff --git a/docs/404/index.html b/docs/404/index.html index b69d086f..cfbe476a 100644 --- a/docs/404/index.html +++ b/docs/404/index.html @@ -1 +1 @@ -404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file diff --git a/docs/__next.__PAGE__.txt b/docs/__next.__PAGE__.txt index 6621acc6..0ded516e 100644 --- a/docs/__next.__PAGE__.txt +++ b/docs/__next.__PAGE__.txt @@ -1,11 +1,11 @@ 1:"$Sreact.fragment" 2:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -3:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/94212136ebe55507.js"],"default"] +3:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","/t2-mapper/_next/static/chunks/164bc8495505bc95.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","/t2-mapper/_next/static/chunks/629d98e413c0344a.js","/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js"],"default"] 6:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] 7:"$Sreact.suspense" -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -:HL["/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","async":true}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","async":true}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","async":true}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","async":true}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","async":true}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","async":true}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/94212136ebe55507.js","async":true}]],["$","$L6",null,{"children":["$","$7",null,{"name":"Next.MetadataOutlet","children":"$@8"}]}]]}],"loading":null,"isPartial":false} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +:HL["/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","style"] +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","async":true}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/164bc8495505bc95.js","async":true}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","async":true}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","async":true}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","async":true}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/629d98e413c0344a.js","async":true}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","async":true}],["$","script","script-9",{"src":"/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","async":true}],["$","script","script-10",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true}],["$","script","script-11",{"src":"/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js","async":true}]],["$","$L6",null,{"children":["$","$7",null,{"name":"Next.MetadataOutlet","children":"$@8"}]}]]}],"loading":null,"isPartial":false} 4:{} 5:"$0:rsc:props:children:0:props:serverProvidedParams:params" 8:null diff --git a/docs/__next._full.txt b/docs/__next._full.txt index f349044e..0f7d73dd 100644 --- a/docs/__next._full.txt +++ b/docs/__next._full.txt @@ -3,16 +3,16 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 5:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -6:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/94212136ebe55507.js"],"default"] +6:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","/t2-mapper/_next/static/chunks/164bc8495505bc95.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","/t2-mapper/_next/static/chunks/629d98e413c0344a.js","/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js"],"default"] 9:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] a:"$Sreact.suspense" c:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ViewportBoundary"] e:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 10:I[68027,[],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -:HL["/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/94212136ebe55507.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +:HL["/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","style"] +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/164bc8495505bc95.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/629d98e413c0344a.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","async":true,"nonce":"$undefined"}],["$","script","script-9",{"src":"/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","async":true,"nonce":"$undefined"}],["$","script","script-10",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true,"nonce":"$undefined"}],["$","script","script-11",{"src":"/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} 7:{} 8:"$0:f:0:1:1:children:0:props:children:0:props:serverProvidedParams:params" d:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] diff --git a/docs/__next._head.txt b/docs/__next._head.txt index 171861f4..462067a2 100644 --- a/docs/__next._head.txt +++ b/docs/__next._head.txt @@ -3,4 +3,4 @@ 3:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 4:"$Sreact.suspense" 5:I[27201,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"IconMark"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} diff --git a/docs/__next._index.txt b/docs/__next._index.txt index f8230d2e..42eb3c22 100644 --- a/docs/__next._index.txt +++ b/docs/__next._index.txt @@ -3,4 +3,4 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} diff --git a/docs/__next._tree.txt b/docs/__next._tree.txt index 27a59536..616cc1b4 100644 --- a/docs/__next._tree.txt +++ b/docs/__next._tree.txt @@ -1,4 +1,4 @@ :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -:HL["/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +:HL["/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","style"] +0:{"buildId":"JablvlklHXp4NGWk4TTlC","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":true},"staleTime":300} diff --git a/docs/_next/static/6xhnTWazjCi9htjLDl3f1/_buildManifest.js b/docs/_next/static/JablvlklHXp4NGWk4TTlC/_buildManifest.js similarity index 100% rename from docs/_next/static/6xhnTWazjCi9htjLDl3f1/_buildManifest.js rename to docs/_next/static/JablvlklHXp4NGWk4TTlC/_buildManifest.js diff --git a/docs/_next/static/6xhnTWazjCi9htjLDl3f1/_clientMiddlewareManifest.json b/docs/_next/static/JablvlklHXp4NGWk4TTlC/_clientMiddlewareManifest.json similarity index 100% rename from docs/_next/static/6xhnTWazjCi9htjLDl3f1/_clientMiddlewareManifest.json rename to docs/_next/static/JablvlklHXp4NGWk4TTlC/_clientMiddlewareManifest.json diff --git a/docs/_next/static/6xhnTWazjCi9htjLDl3f1/_ssgManifest.js b/docs/_next/static/JablvlklHXp4NGWk4TTlC/_ssgManifest.js similarity index 100% rename from docs/_next/static/6xhnTWazjCi9htjLDl3f1/_ssgManifest.js rename to docs/_next/static/JablvlklHXp4NGWk4TTlC/_ssgManifest.js diff --git a/docs/_next/static/chunks/037fbc56cebf7caa.js b/docs/_next/static/chunks/037fbc56cebf7caa.js new file mode 100644 index 00000000..1e79aaf9 --- /dev/null +++ b/docs/_next/static/chunks/037fbc56cebf7caa.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75056,e=>{"use strict";var t=e.i(40859),r=e.i(71645),n=e.i(8560),i=e.i(90072);e.s(["ACESFilmicToneMapping",()=>i.ACESFilmicToneMapping,"AddEquation",()=>i.AddEquation,"AddOperation",()=>i.AddOperation,"AdditiveAnimationBlendMode",()=>i.AdditiveAnimationBlendMode,"AdditiveBlending",()=>i.AdditiveBlending,"AgXToneMapping",()=>i.AgXToneMapping,"AlphaFormat",()=>i.AlphaFormat,"AlwaysCompare",()=>i.AlwaysCompare,"AlwaysDepth",()=>i.AlwaysDepth,"AlwaysStencilFunc",()=>i.AlwaysStencilFunc,"AmbientLight",()=>i.AmbientLight,"AnimationAction",()=>i.AnimationAction,"AnimationClip",()=>i.AnimationClip,"AnimationLoader",()=>i.AnimationLoader,"AnimationMixer",()=>i.AnimationMixer,"AnimationObjectGroup",()=>i.AnimationObjectGroup,"AnimationUtils",()=>i.AnimationUtils,"ArcCurve",()=>i.ArcCurve,"ArrayCamera",()=>i.ArrayCamera,"ArrowHelper",()=>i.ArrowHelper,"AttachedBindMode",()=>i.AttachedBindMode,"Audio",()=>i.Audio,"AudioAnalyser",()=>i.AudioAnalyser,"AudioContext",()=>i.AudioContext,"AudioListener",()=>i.AudioListener,"AudioLoader",()=>i.AudioLoader,"AxesHelper",()=>i.AxesHelper,"BackSide",()=>i.BackSide,"BasicDepthPacking",()=>i.BasicDepthPacking,"BasicShadowMap",()=>i.BasicShadowMap,"BatchedMesh",()=>i.BatchedMesh,"Bone",()=>i.Bone,"BooleanKeyframeTrack",()=>i.BooleanKeyframeTrack,"Box2",()=>i.Box2,"Box3",()=>i.Box3,"Box3Helper",()=>i.Box3Helper,"BoxGeometry",()=>i.BoxGeometry,"BoxHelper",()=>i.BoxHelper,"BufferAttribute",()=>i.BufferAttribute,"BufferGeometry",()=>i.BufferGeometry,"BufferGeometryLoader",()=>i.BufferGeometryLoader,"ByteType",()=>i.ByteType,"Cache",()=>i.Cache,"Camera",()=>i.Camera,"CameraHelper",()=>i.CameraHelper,"CanvasTexture",()=>i.CanvasTexture,"CapsuleGeometry",()=>i.CapsuleGeometry,"CatmullRomCurve3",()=>i.CatmullRomCurve3,"CineonToneMapping",()=>i.CineonToneMapping,"CircleGeometry",()=>i.CircleGeometry,"ClampToEdgeWrapping",()=>i.ClampToEdgeWrapping,"Clock",()=>i.Clock,"Color",()=>i.Color,"ColorKeyframeTrack",()=>i.ColorKeyframeTrack,"ColorManagement",()=>i.ColorManagement,"CompressedArrayTexture",()=>i.CompressedArrayTexture,"CompressedCubeTexture",()=>i.CompressedCubeTexture,"CompressedTexture",()=>i.CompressedTexture,"CompressedTextureLoader",()=>i.CompressedTextureLoader,"ConeGeometry",()=>i.ConeGeometry,"ConstantAlphaFactor",()=>i.ConstantAlphaFactor,"ConstantColorFactor",()=>i.ConstantColorFactor,"Controls",()=>i.Controls,"CubeCamera",()=>i.CubeCamera,"CubeDepthTexture",()=>i.CubeDepthTexture,"CubeReflectionMapping",()=>i.CubeReflectionMapping,"CubeRefractionMapping",()=>i.CubeRefractionMapping,"CubeTexture",()=>i.CubeTexture,"CubeTextureLoader",()=>i.CubeTextureLoader,"CubeUVReflectionMapping",()=>i.CubeUVReflectionMapping,"CubicBezierCurve",()=>i.CubicBezierCurve,"CubicBezierCurve3",()=>i.CubicBezierCurve3,"CubicInterpolant",()=>i.CubicInterpolant,"CullFaceBack",()=>i.CullFaceBack,"CullFaceFront",()=>i.CullFaceFront,"CullFaceFrontBack",()=>i.CullFaceFrontBack,"CullFaceNone",()=>i.CullFaceNone,"Curve",()=>i.Curve,"CurvePath",()=>i.CurvePath,"CustomBlending",()=>i.CustomBlending,"CustomToneMapping",()=>i.CustomToneMapping,"CylinderGeometry",()=>i.CylinderGeometry,"Cylindrical",()=>i.Cylindrical,"Data3DTexture",()=>i.Data3DTexture,"DataArrayTexture",()=>i.DataArrayTexture,"DataTexture",()=>i.DataTexture,"DataTextureLoader",()=>i.DataTextureLoader,"DataUtils",()=>i.DataUtils,"DecrementStencilOp",()=>i.DecrementStencilOp,"DecrementWrapStencilOp",()=>i.DecrementWrapStencilOp,"DefaultLoadingManager",()=>i.DefaultLoadingManager,"DepthFormat",()=>i.DepthFormat,"DepthStencilFormat",()=>i.DepthStencilFormat,"DepthTexture",()=>i.DepthTexture,"DetachedBindMode",()=>i.DetachedBindMode,"DirectionalLight",()=>i.DirectionalLight,"DirectionalLightHelper",()=>i.DirectionalLightHelper,"DiscreteInterpolant",()=>i.DiscreteInterpolant,"DodecahedronGeometry",()=>i.DodecahedronGeometry,"DoubleSide",()=>i.DoubleSide,"DstAlphaFactor",()=>i.DstAlphaFactor,"DstColorFactor",()=>i.DstColorFactor,"DynamicCopyUsage",()=>i.DynamicCopyUsage,"DynamicDrawUsage",()=>i.DynamicDrawUsage,"DynamicReadUsage",()=>i.DynamicReadUsage,"EdgesGeometry",()=>i.EdgesGeometry,"EllipseCurve",()=>i.EllipseCurve,"EqualCompare",()=>i.EqualCompare,"EqualDepth",()=>i.EqualDepth,"EqualStencilFunc",()=>i.EqualStencilFunc,"EquirectangularReflectionMapping",()=>i.EquirectangularReflectionMapping,"EquirectangularRefractionMapping",()=>i.EquirectangularRefractionMapping,"Euler",()=>i.Euler,"EventDispatcher",()=>i.EventDispatcher,"ExternalTexture",()=>i.ExternalTexture,"ExtrudeGeometry",()=>i.ExtrudeGeometry,"FileLoader",()=>i.FileLoader,"Float16BufferAttribute",()=>i.Float16BufferAttribute,"Float32BufferAttribute",()=>i.Float32BufferAttribute,"FloatType",()=>i.FloatType,"Fog",()=>i.Fog,"FogExp2",()=>i.FogExp2,"FramebufferTexture",()=>i.FramebufferTexture,"FrontSide",()=>i.FrontSide,"Frustum",()=>i.Frustum,"FrustumArray",()=>i.FrustumArray,"GLBufferAttribute",()=>i.GLBufferAttribute,"GLSL1",()=>i.GLSL1,"GLSL3",()=>i.GLSL3,"GreaterCompare",()=>i.GreaterCompare,"GreaterDepth",()=>i.GreaterDepth,"GreaterEqualCompare",()=>i.GreaterEqualCompare,"GreaterEqualDepth",()=>i.GreaterEqualDepth,"GreaterEqualStencilFunc",()=>i.GreaterEqualStencilFunc,"GreaterStencilFunc",()=>i.GreaterStencilFunc,"GridHelper",()=>i.GridHelper,"Group",()=>i.Group,"HalfFloatType",()=>i.HalfFloatType,"HemisphereLight",()=>i.HemisphereLight,"HemisphereLightHelper",()=>i.HemisphereLightHelper,"IcosahedronGeometry",()=>i.IcosahedronGeometry,"ImageBitmapLoader",()=>i.ImageBitmapLoader,"ImageLoader",()=>i.ImageLoader,"ImageUtils",()=>i.ImageUtils,"IncrementStencilOp",()=>i.IncrementStencilOp,"IncrementWrapStencilOp",()=>i.IncrementWrapStencilOp,"InstancedBufferAttribute",()=>i.InstancedBufferAttribute,"InstancedBufferGeometry",()=>i.InstancedBufferGeometry,"InstancedInterleavedBuffer",()=>i.InstancedInterleavedBuffer,"InstancedMesh",()=>i.InstancedMesh,"Int16BufferAttribute",()=>i.Int16BufferAttribute,"Int32BufferAttribute",()=>i.Int32BufferAttribute,"Int8BufferAttribute",()=>i.Int8BufferAttribute,"IntType",()=>i.IntType,"InterleavedBuffer",()=>i.InterleavedBuffer,"InterleavedBufferAttribute",()=>i.InterleavedBufferAttribute,"Interpolant",()=>i.Interpolant,"InterpolateDiscrete",()=>i.InterpolateDiscrete,"InterpolateLinear",()=>i.InterpolateLinear,"InterpolateSmooth",()=>i.InterpolateSmooth,"InterpolationSamplingMode",()=>i.InterpolationSamplingMode,"InterpolationSamplingType",()=>i.InterpolationSamplingType,"InvertStencilOp",()=>i.InvertStencilOp,"KeepStencilOp",()=>i.KeepStencilOp,"KeyframeTrack",()=>i.KeyframeTrack,"LOD",()=>i.LOD,"LatheGeometry",()=>i.LatheGeometry,"Layers",()=>i.Layers,"LessCompare",()=>i.LessCompare,"LessDepth",()=>i.LessDepth,"LessEqualCompare",()=>i.LessEqualCompare,"LessEqualDepth",()=>i.LessEqualDepth,"LessEqualStencilFunc",()=>i.LessEqualStencilFunc,"LessStencilFunc",()=>i.LessStencilFunc,"Light",()=>i.Light,"LightProbe",()=>i.LightProbe,"Line",()=>i.Line,"Line3",()=>i.Line3,"LineBasicMaterial",()=>i.LineBasicMaterial,"LineCurve",()=>i.LineCurve,"LineCurve3",()=>i.LineCurve3,"LineDashedMaterial",()=>i.LineDashedMaterial,"LineLoop",()=>i.LineLoop,"LineSegments",()=>i.LineSegments,"LinearFilter",()=>i.LinearFilter,"LinearInterpolant",()=>i.LinearInterpolant,"LinearMipMapLinearFilter",()=>i.LinearMipMapLinearFilter,"LinearMipMapNearestFilter",()=>i.LinearMipMapNearestFilter,"LinearMipmapLinearFilter",()=>i.LinearMipmapLinearFilter,"LinearMipmapNearestFilter",()=>i.LinearMipmapNearestFilter,"LinearSRGBColorSpace",()=>i.LinearSRGBColorSpace,"LinearToneMapping",()=>i.LinearToneMapping,"LinearTransfer",()=>i.LinearTransfer,"Loader",()=>i.Loader,"LoaderUtils",()=>i.LoaderUtils,"LoadingManager",()=>i.LoadingManager,"LoopOnce",()=>i.LoopOnce,"LoopPingPong",()=>i.LoopPingPong,"LoopRepeat",()=>i.LoopRepeat,"MOUSE",()=>i.MOUSE,"Material",()=>i.Material,"MaterialLoader",()=>i.MaterialLoader,"MathUtils",()=>i.MathUtils,"Matrix2",()=>i.Matrix2,"Matrix3",()=>i.Matrix3,"Matrix4",()=>i.Matrix4,"MaxEquation",()=>i.MaxEquation,"Mesh",()=>i.Mesh,"MeshBasicMaterial",()=>i.MeshBasicMaterial,"MeshDepthMaterial",()=>i.MeshDepthMaterial,"MeshDistanceMaterial",()=>i.MeshDistanceMaterial,"MeshLambertMaterial",()=>i.MeshLambertMaterial,"MeshMatcapMaterial",()=>i.MeshMatcapMaterial,"MeshNormalMaterial",()=>i.MeshNormalMaterial,"MeshPhongMaterial",()=>i.MeshPhongMaterial,"MeshPhysicalMaterial",()=>i.MeshPhysicalMaterial,"MeshStandardMaterial",()=>i.MeshStandardMaterial,"MeshToonMaterial",()=>i.MeshToonMaterial,"MinEquation",()=>i.MinEquation,"MirroredRepeatWrapping",()=>i.MirroredRepeatWrapping,"MixOperation",()=>i.MixOperation,"MultiplyBlending",()=>i.MultiplyBlending,"MultiplyOperation",()=>i.MultiplyOperation,"NearestFilter",()=>i.NearestFilter,"NearestMipMapLinearFilter",()=>i.NearestMipMapLinearFilter,"NearestMipMapNearestFilter",()=>i.NearestMipMapNearestFilter,"NearestMipmapLinearFilter",()=>i.NearestMipmapLinearFilter,"NearestMipmapNearestFilter",()=>i.NearestMipmapNearestFilter,"NeutralToneMapping",()=>i.NeutralToneMapping,"NeverCompare",()=>i.NeverCompare,"NeverDepth",()=>i.NeverDepth,"NeverStencilFunc",()=>i.NeverStencilFunc,"NoBlending",()=>i.NoBlending,"NoColorSpace",()=>i.NoColorSpace,"NoNormalPacking",()=>i.NoNormalPacking,"NoToneMapping",()=>i.NoToneMapping,"NormalAnimationBlendMode",()=>i.NormalAnimationBlendMode,"NormalBlending",()=>i.NormalBlending,"NormalGAPacking",()=>i.NormalGAPacking,"NormalRGPacking",()=>i.NormalRGPacking,"NotEqualCompare",()=>i.NotEqualCompare,"NotEqualDepth",()=>i.NotEqualDepth,"NotEqualStencilFunc",()=>i.NotEqualStencilFunc,"NumberKeyframeTrack",()=>i.NumberKeyframeTrack,"Object3D",()=>i.Object3D,"ObjectLoader",()=>i.ObjectLoader,"ObjectSpaceNormalMap",()=>i.ObjectSpaceNormalMap,"OctahedronGeometry",()=>i.OctahedronGeometry,"OneFactor",()=>i.OneFactor,"OneMinusConstantAlphaFactor",()=>i.OneMinusConstantAlphaFactor,"OneMinusConstantColorFactor",()=>i.OneMinusConstantColorFactor,"OneMinusDstAlphaFactor",()=>i.OneMinusDstAlphaFactor,"OneMinusDstColorFactor",()=>i.OneMinusDstColorFactor,"OneMinusSrcAlphaFactor",()=>i.OneMinusSrcAlphaFactor,"OneMinusSrcColorFactor",()=>i.OneMinusSrcColorFactor,"OrthographicCamera",()=>i.OrthographicCamera,"PCFShadowMap",()=>i.PCFShadowMap,"PCFSoftShadowMap",()=>i.PCFSoftShadowMap,"PMREMGenerator",()=>n.PMREMGenerator,"Path",()=>i.Path,"PerspectiveCamera",()=>i.PerspectiveCamera,"Plane",()=>i.Plane,"PlaneGeometry",()=>i.PlaneGeometry,"PlaneHelper",()=>i.PlaneHelper,"PointLight",()=>i.PointLight,"PointLightHelper",()=>i.PointLightHelper,"Points",()=>i.Points,"PointsMaterial",()=>i.PointsMaterial,"PolarGridHelper",()=>i.PolarGridHelper,"PolyhedronGeometry",()=>i.PolyhedronGeometry,"PositionalAudio",()=>i.PositionalAudio,"PropertyBinding",()=>i.PropertyBinding,"PropertyMixer",()=>i.PropertyMixer,"QuadraticBezierCurve",()=>i.QuadraticBezierCurve,"QuadraticBezierCurve3",()=>i.QuadraticBezierCurve3,"Quaternion",()=>i.Quaternion,"QuaternionKeyframeTrack",()=>i.QuaternionKeyframeTrack,"QuaternionLinearInterpolant",()=>i.QuaternionLinearInterpolant,"R11_EAC_Format",()=>i.R11_EAC_Format,"RED_GREEN_RGTC2_Format",()=>i.RED_GREEN_RGTC2_Format,"RED_RGTC1_Format",()=>i.RED_RGTC1_Format,"REVISION",()=>i.REVISION,"RG11_EAC_Format",()=>i.RG11_EAC_Format,"RGBADepthPacking",()=>i.RGBADepthPacking,"RGBAFormat",()=>i.RGBAFormat,"RGBAIntegerFormat",()=>i.RGBAIntegerFormat,"RGBA_ASTC_10x10_Format",()=>i.RGBA_ASTC_10x10_Format,"RGBA_ASTC_10x5_Format",()=>i.RGBA_ASTC_10x5_Format,"RGBA_ASTC_10x6_Format",()=>i.RGBA_ASTC_10x6_Format,"RGBA_ASTC_10x8_Format",()=>i.RGBA_ASTC_10x8_Format,"RGBA_ASTC_12x10_Format",()=>i.RGBA_ASTC_12x10_Format,"RGBA_ASTC_12x12_Format",()=>i.RGBA_ASTC_12x12_Format,"RGBA_ASTC_4x4_Format",()=>i.RGBA_ASTC_4x4_Format,"RGBA_ASTC_5x4_Format",()=>i.RGBA_ASTC_5x4_Format,"RGBA_ASTC_5x5_Format",()=>i.RGBA_ASTC_5x5_Format,"RGBA_ASTC_6x5_Format",()=>i.RGBA_ASTC_6x5_Format,"RGBA_ASTC_6x6_Format",()=>i.RGBA_ASTC_6x6_Format,"RGBA_ASTC_8x5_Format",()=>i.RGBA_ASTC_8x5_Format,"RGBA_ASTC_8x6_Format",()=>i.RGBA_ASTC_8x6_Format,"RGBA_ASTC_8x8_Format",()=>i.RGBA_ASTC_8x8_Format,"RGBA_BPTC_Format",()=>i.RGBA_BPTC_Format,"RGBA_ETC2_EAC_Format",()=>i.RGBA_ETC2_EAC_Format,"RGBA_PVRTC_2BPPV1_Format",()=>i.RGBA_PVRTC_2BPPV1_Format,"RGBA_PVRTC_4BPPV1_Format",()=>i.RGBA_PVRTC_4BPPV1_Format,"RGBA_S3TC_DXT1_Format",()=>i.RGBA_S3TC_DXT1_Format,"RGBA_S3TC_DXT3_Format",()=>i.RGBA_S3TC_DXT3_Format,"RGBA_S3TC_DXT5_Format",()=>i.RGBA_S3TC_DXT5_Format,"RGBDepthPacking",()=>i.RGBDepthPacking,"RGBFormat",()=>i.RGBFormat,"RGBIntegerFormat",()=>i.RGBIntegerFormat,"RGB_BPTC_SIGNED_Format",()=>i.RGB_BPTC_SIGNED_Format,"RGB_BPTC_UNSIGNED_Format",()=>i.RGB_BPTC_UNSIGNED_Format,"RGB_ETC1_Format",()=>i.RGB_ETC1_Format,"RGB_ETC2_Format",()=>i.RGB_ETC2_Format,"RGB_PVRTC_2BPPV1_Format",()=>i.RGB_PVRTC_2BPPV1_Format,"RGB_PVRTC_4BPPV1_Format",()=>i.RGB_PVRTC_4BPPV1_Format,"RGB_S3TC_DXT1_Format",()=>i.RGB_S3TC_DXT1_Format,"RGDepthPacking",()=>i.RGDepthPacking,"RGFormat",()=>i.RGFormat,"RGIntegerFormat",()=>i.RGIntegerFormat,"RawShaderMaterial",()=>i.RawShaderMaterial,"Ray",()=>i.Ray,"Raycaster",()=>i.Raycaster,"RectAreaLight",()=>i.RectAreaLight,"RedFormat",()=>i.RedFormat,"RedIntegerFormat",()=>i.RedIntegerFormat,"ReinhardToneMapping",()=>i.ReinhardToneMapping,"RenderTarget",()=>i.RenderTarget,"RenderTarget3D",()=>i.RenderTarget3D,"RepeatWrapping",()=>i.RepeatWrapping,"ReplaceStencilOp",()=>i.ReplaceStencilOp,"ReverseSubtractEquation",()=>i.ReverseSubtractEquation,"RingGeometry",()=>i.RingGeometry,"SIGNED_R11_EAC_Format",()=>i.SIGNED_R11_EAC_Format,"SIGNED_RED_GREEN_RGTC2_Format",()=>i.SIGNED_RED_GREEN_RGTC2_Format,"SIGNED_RED_RGTC1_Format",()=>i.SIGNED_RED_RGTC1_Format,"SIGNED_RG11_EAC_Format",()=>i.SIGNED_RG11_EAC_Format,"SRGBColorSpace",()=>i.SRGBColorSpace,"SRGBTransfer",()=>i.SRGBTransfer,"Scene",()=>i.Scene,"ShaderChunk",()=>n.ShaderChunk,"ShaderLib",()=>n.ShaderLib,"ShaderMaterial",()=>i.ShaderMaterial,"ShadowMaterial",()=>i.ShadowMaterial,"Shape",()=>i.Shape,"ShapeGeometry",()=>i.ShapeGeometry,"ShapePath",()=>i.ShapePath,"ShapeUtils",()=>i.ShapeUtils,"ShortType",()=>i.ShortType,"Skeleton",()=>i.Skeleton,"SkeletonHelper",()=>i.SkeletonHelper,"SkinnedMesh",()=>i.SkinnedMesh,"Source",()=>i.Source,"Sphere",()=>i.Sphere,"SphereGeometry",()=>i.SphereGeometry,"Spherical",()=>i.Spherical,"SphericalHarmonics3",()=>i.SphericalHarmonics3,"SplineCurve",()=>i.SplineCurve,"SpotLight",()=>i.SpotLight,"SpotLightHelper",()=>i.SpotLightHelper,"Sprite",()=>i.Sprite,"SpriteMaterial",()=>i.SpriteMaterial,"SrcAlphaFactor",()=>i.SrcAlphaFactor,"SrcAlphaSaturateFactor",()=>i.SrcAlphaSaturateFactor,"SrcColorFactor",()=>i.SrcColorFactor,"StaticCopyUsage",()=>i.StaticCopyUsage,"StaticDrawUsage",()=>i.StaticDrawUsage,"StaticReadUsage",()=>i.StaticReadUsage,"StereoCamera",()=>i.StereoCamera,"StreamCopyUsage",()=>i.StreamCopyUsage,"StreamDrawUsage",()=>i.StreamDrawUsage,"StreamReadUsage",()=>i.StreamReadUsage,"StringKeyframeTrack",()=>i.StringKeyframeTrack,"SubtractEquation",()=>i.SubtractEquation,"SubtractiveBlending",()=>i.SubtractiveBlending,"TOUCH",()=>i.TOUCH,"TangentSpaceNormalMap",()=>i.TangentSpaceNormalMap,"TetrahedronGeometry",()=>i.TetrahedronGeometry,"Texture",()=>i.Texture,"TextureLoader",()=>i.TextureLoader,"TextureUtils",()=>i.TextureUtils,"Timer",()=>i.Timer,"TimestampQuery",()=>i.TimestampQuery,"TorusGeometry",()=>i.TorusGeometry,"TorusKnotGeometry",()=>i.TorusKnotGeometry,"Triangle",()=>i.Triangle,"TriangleFanDrawMode",()=>i.TriangleFanDrawMode,"TriangleStripDrawMode",()=>i.TriangleStripDrawMode,"TrianglesDrawMode",()=>i.TrianglesDrawMode,"TubeGeometry",()=>i.TubeGeometry,"UVMapping",()=>i.UVMapping,"Uint16BufferAttribute",()=>i.Uint16BufferAttribute,"Uint32BufferAttribute",()=>i.Uint32BufferAttribute,"Uint8BufferAttribute",()=>i.Uint8BufferAttribute,"Uint8ClampedBufferAttribute",()=>i.Uint8ClampedBufferAttribute,"Uniform",()=>i.Uniform,"UniformsGroup",()=>i.UniformsGroup,"UniformsLib",()=>n.UniformsLib,"UniformsUtils",()=>i.UniformsUtils,"UnsignedByteType",()=>i.UnsignedByteType,"UnsignedInt101111Type",()=>i.UnsignedInt101111Type,"UnsignedInt248Type",()=>i.UnsignedInt248Type,"UnsignedInt5999Type",()=>i.UnsignedInt5999Type,"UnsignedIntType",()=>i.UnsignedIntType,"UnsignedShort4444Type",()=>i.UnsignedShort4444Type,"UnsignedShort5551Type",()=>i.UnsignedShort5551Type,"UnsignedShortType",()=>i.UnsignedShortType,"VSMShadowMap",()=>i.VSMShadowMap,"Vector2",()=>i.Vector2,"Vector3",()=>i.Vector3,"Vector4",()=>i.Vector4,"VectorKeyframeTrack",()=>i.VectorKeyframeTrack,"VideoFrameTexture",()=>i.VideoFrameTexture,"VideoTexture",()=>i.VideoTexture,"WebGL3DRenderTarget",()=>i.WebGL3DRenderTarget,"WebGLArrayRenderTarget",()=>i.WebGLArrayRenderTarget,"WebGLCoordinateSystem",()=>i.WebGLCoordinateSystem,"WebGLCubeRenderTarget",()=>i.WebGLCubeRenderTarget,"WebGLRenderTarget",()=>i.WebGLRenderTarget,"WebGLRenderer",()=>n.WebGLRenderer,"WebGLUtils",()=>n.WebGLUtils,"WebGPUCoordinateSystem",()=>i.WebGPUCoordinateSystem,"WebXRController",()=>i.WebXRController,"WireframeGeometry",()=>i.WireframeGeometry,"WrapAroundEnding",()=>i.WrapAroundEnding,"ZeroCurvatureEnding",()=>i.ZeroCurvatureEnding,"ZeroFactor",()=>i.ZeroFactor,"ZeroSlopeEnding",()=>i.ZeroSlopeEnding,"ZeroStencilOp",()=>i.ZeroStencilOp,"createCanvasElement",()=>i.createCanvasElement,"error",()=>i.error,"getConsoleFunction",()=>i.getConsoleFunction,"log",()=>i.log,"setConsoleFunction",()=>i.setConsoleFunction,"warn",()=>i.warn,"warnOnce",()=>i.warnOnce],32009);var o=e.i(32009);function a(e,t){let r;return(...n)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...n),t)}}let l=["x","y","top","bottom","left","right","width","height"];var u=e.i(46791),s=e.i(43476);function c({ref:e,children:n,fallback:i,resize:u,style:c,gl:f,events:d=t.f,eventSource:p,eventPrefix:m,shadows:h,linear:v,flat:g,legacy:y,orthographic:b,frameloop:S,dpr:C,performance:x,raycaster:E,camera:A,scene:w,onPointerMissed:_,onCreated:T,...M}){r.useMemo(()=>(0,t.e)(o),[]);let R=(0,t.u)(),[O,I]=function({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){var o,u,s;let c=n||("u"(v.current=!0,()=>void(v.current=!1)));let[g,y,b]=(0,r.useMemo)(()=>{let e=()=>{let e,t;if(!p.current.element)return;let{left:r,top:n,width:o,height:a,bottom:u,right:s,x:c,y:f}=p.current.element.getBoundingClientRect(),m={left:r,top:n,width:o,height:a,bottom:u,right:s,x:c,y:f};p.current.element instanceof HTMLElement&&i&&(m.height=p.current.element.offsetHeight,m.width=p.current.element.offsetWidth),Object.freeze(m),v.current&&(e=p.current.lastBounds,t=m,!l.every(r=>e[r]===t[r]))&&d(p.current.lastBounds=m)};return[e,h?a(e,h):e,m?a(e,m):e]},[d,i,m,h]);function S(){p.current.scrollContainers&&(p.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",b,!0)),p.current.scrollContainers=null),p.current.resizeObserver&&(p.current.resizeObserver.disconnect(),p.current.resizeObserver=null),p.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",p.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",p.current.orientationHandler))}function C(){p.current.element&&(p.current.resizeObserver=new c(b),p.current.resizeObserver.observe(p.current.element),t&&p.current.scrollContainers&&p.current.scrollContainers.forEach(e=>e.addEventListener("scroll",b,{capture:!0,passive:!0})),p.current.orientationHandler=()=>{b()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",p.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",p.current.orientationHandler))}return o=b,u=!!t,(0,r.useEffect)(()=>{if(u)return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)},[o,u]),s=y,(0,r.useEffect)(()=>(window.addEventListener("resize",s),()=>void window.removeEventListener("resize",s)),[s]),(0,r.useEffect)(()=>{S(),C()},[t,b,y]),(0,r.useEffect)(()=>S,[]),[e=>{e&&e!==p.current.element&&(S(),p.current.element=e,p.current.scrollContainers=function e(t){let r=[];if(!t||t===document.body)return r;let{overflow:n,overflowX:i,overflowY:o}=window.getComputedStyle(t);return[n,i,o].some(e=>"auto"===e||"scroll"===e)&&r.push(t),[...r,...e(t.parentElement)]}(e),C())},f,g]}({scroll:!0,debounce:{scroll:50,resize:0},...u}),F=r.useRef(null),L=r.useRef(null);r.useImperativeHandle(e,()=>F.current);let P=(0,t.a)(_),[D,B]=r.useState(!1),[G,k]=r.useState(!1);if(D)throw D;if(G)throw G;let j=r.useRef(null);(0,t.b)(()=>{let e=F.current;I.width>0&&I.height>0&&e&&(j.current||(j.current=(0,t.c)(e)),async function(){await j.current.configure({gl:f,scene:w,events:d,shadows:h,linear:v,flat:g,legacy:y,orthographic:b,frameloop:S,dpr:C,performance:x,raycaster:E,camera:A,size:I,onPointerMissed:(...e)=>null==P.current?void 0:P.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(p?(0,t.i)(p)?p.current:p:L.current),m&&e.setEvents({compute:(e,t)=>{let r=e[m+"X"],n=e[m+"Y"];t.pointer.set(r/t.size.width*2-1,-(2*(n/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==T||T(e)}}),j.current.render((0,s.jsx)(R,{children:(0,s.jsx)(t.E,{set:k,children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(t.B,{set:B}),children:null!=n?n:null})})}))}())}),r.useEffect(()=>{let e=F.current;if(e)return()=>(0,t.d)(e)},[]);let N=p?"none":"auto";return(0,s.jsx)("div",{ref:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:N,...c},...M,children:(0,s.jsx)("div",{ref:O,style:{width:"100%",height:"100%"},children:(0,s.jsx)("canvas",{ref:F,style:{display:"block"},children:i})})})}function f(e){return(0,s.jsx)(u.FiberProvider,{children:(0,s.jsx)(c,{...e})})}e.i(89499),e.s(["Canvas",()=>f],75056)},32424,7368,e=>{"use strict";var t=e.i(12979);function r(){return async e=>{let r;try{r=(0,t.getUrlForPath)(e)}catch(t){return console.warn(`Script not in manifest: ${e} (${t})`),null}try{let t=await fetch(r);if(!t.ok)return console.error(`Script fetch failed: ${e} (${t.status})`),null;return await t.text()}catch(t){return console.error(`Script fetch error: ${e}`),console.error(t),null}}}e.s(["createScriptLoader",()=>r],32424),e.s(["ignoreScripts",0,["scripts/admin.cs","scripts/ai.cs","scripts/aiBotProfiles.cs","scripts/aiBountyGame.cs","scripts/aiChat.cs","scripts/aiCnH.cs","scripts/aiCTF.cs","scripts/aiDeathMatch.cs","scripts/aiDebug.cs","scripts/aiDefaultTasks.cs","scripts/aiDnD.cs","scripts/aiHumanTasks.cs","scripts/aiHunters.cs","scripts/aiInventory.cs","scripts/aiObjectiveBuilder.cs","scripts/aiObjectives.cs","scripts/aiRabbit.cs","scripts/aiSiege.cs","scripts/aiTDM.cs","scripts/aiTeamHunters.cs","scripts/deathMessages.cs","scripts/graphBuild.cs","scripts/navGraph.cs","scripts/serverTasks.cs","scripts/spdialog.cs"]],7368)},17751,e=>{"use strict";var t=e.i(19273),r=e.i(86491),n=e.i(40143),i=e.i(15823),o=class extends i.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,n,i){let o=n.queryKey,a=n.queryHash??(0,t.hashQueryKeyByOptions)(o,n),l=this.get(a);return l||(l=new r.Query({client:e,queryKey:o,queryHash:a,options:e.defaultQueryOptions(n),state:i,defaultOptions:e.getQueryDefaults(o)}),this.add(l)),l}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchQuery)(r,e))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(r=>(0,t.matchQuery)(e,r)):r}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},a=e.i(88587),l=e.i(36553),u=class extends a.Removable{#t;#r;#n;#i;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#r=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#r.includes(e)||(this.#r.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#r=this.#r.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#r.length||("pending"===this.state.status?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#o({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=(0,l.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#o({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#o({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let n="pending"===this.state.status,i=!this.#i.canStart();try{if(n)t();else{this.#o({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#o({type:"pending",context:t,variables:e,isPaused:i})}let o=await this.#i.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,r),await this.options.onSuccess?.(o,e,this.state.context,r),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(o,null,e,this.state.context,r),this.#o({type:"success",data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#o({type:"error",error:t}),t}finally{this.#n.runNext(this)}}#o(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),n.notifyManager.batch(()=>{this.#r.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}},s=i,c=class extends s.Subscribable{constructor(e={}){super(),this.config=e,this.#a=new Set,this.#l=new Map,this.#u=0}#a;#l;#u;build(e,t,r){let n=new u({client:e,mutationCache:this,mutationId:++this.#u,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#a.add(e);let t=f(e);if("string"==typeof t){let r=this.#l.get(t);r?r.push(e):this.#l.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#a.delete(e)){let t=f(e);if("string"==typeof t){let r=this.#l.get(t);if(r)if(r.length>1){let t=r.indexOf(e);-1!==t&&r.splice(t,1)}else r[0]===e&&this.#l.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=f(e);if("string"!=typeof t)return!0;{let r=this.#l.get(t),n=r?.find(e=>"pending"===e.state.status);return!n||n===e}}runNext(e){let t=f(e);if("string"!=typeof t)return Promise.resolve();{let r=this.#l.get(t)?.find(t=>t!==e&&t.state.isPaused);return r?.continue()??Promise.resolve()}}clear(){n.notifyManager.batch(()=>{this.#a.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#a.clear(),this.#l.clear()})}getAll(){return Array.from(this.#a)}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchMutation)(r,e))}findAll(e={}){return this.getAll().filter(r=>(0,t.matchMutation)(e,r))}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return n.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(t.noop))))}};function f(e){return e.options.scope?.id}var d=e.i(75555),p=e.i(14448);function m(e){return{onFetch:(r,n)=>{let i=r.options,o=r.fetchOptions?.meta?.fetchMore?.direction,a=r.state.data?.pages||[],l=r.state.data?.pageParams||[],u={pages:[],pageParams:[]},s=0,c=async()=>{let n=!1,c=(0,t.ensureQueryFn)(r.options,r.fetchOptions),f=async(e,i,o)=>{let a;if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);let l=(a={client:r.client,queryKey:r.queryKey,pageParam:i,direction:o?"backward":"forward",meta:r.options.meta},(0,t.addConsumeAwareSignal)(a,()=>r.signal,()=>n=!0),a),u=await c(l),{maxPages:s}=r.options,f=o?t.addToStart:t.addToEnd;return{pages:f(e.pages,u,s),pageParams:f(e.pageParams,i,s)}};if(o&&a.length){let e="backward"===o,t={pages:a,pageParams:l},r=(e?function(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}:h)(i,t);u=await f(t,r,e)}else{let t=e??a.length;do{let e=0===s?l[0]??i.initialPageParam:h(i,u);if(s>0&&null==e)break;u=await f(u,e),s++}while(sr.options.persister?.(c,{client:r.client,queryKey:r.queryKey,meta:r.options.meta,signal:r.signal},n):r.fetchFn=c}}}function h(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}var v=class{#s;#n;#c;#f;#d;#p;#m;#h;constructor(e={}){this.#s=e.queryCache||new o,this.#n=e.mutationCache||new c,this.#c=e.defaultOptions||{},this.#f=new Map,this.#d=new Map,this.#p=0}mount(){this.#p++,1===this.#p&&(this.#m=d.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#s.onFocus())}),this.#h=p.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#s.onOnline())}))}unmount(){this.#p--,0===this.#p&&(this.#m?.(),this.#m=void 0,this.#h?.(),this.#h=void 0)}isFetching(e){return this.#s.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#n.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#s.get(t.queryHash)?.state.data}ensureQueryData(e){let r=this.defaultQueryOptions(e),n=this.#s.build(this,r),i=n.state.data;return void 0===i?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(i))}getQueriesData(e){return this.#s.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,r,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#s.get(i.queryHash),a=o?.state.data,l=(0,t.functionalUpdate)(r,a);if(void 0!==l)return this.#s.build(this,i).setData(l,{...n,manual:!0})}setQueriesData(e,t,r){return n.notifyManager.batch(()=>this.#s.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#s.get(t.queryHash)?.state}removeQueries(e){let t=this.#s;n.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let r=this.#s;return n.notifyManager.batch(()=>(r.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,r={}){let i={revert:!0,...r};return Promise.all(n.notifyManager.batch(()=>this.#s.findAll(e).map(e=>e.cancel(i)))).then(t.noop).catch(t.noop)}invalidateQueries(e,t={}){return n.notifyManager.batch(()=>(this.#s.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,r={}){let i={...r,cancelRefetch:r.cancelRefetch??!0};return Promise.all(n.notifyManager.batch(()=>this.#s.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let r=e.fetch(void 0,i);return i.throwOnError||(r=r.catch(t.noop)),"paused"===e.state.fetchStatus?Promise.resolve():r}))).then(t.noop)}fetchQuery(e){let r=this.defaultQueryOptions(e);void 0===r.retry&&(r.retry=!1);let n=this.#s.build(this,r);return n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(t.noop).catch(t.noop)}fetchInfiniteQuery(e){return e.behavior=m(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(t.noop).catch(t.noop)}ensureInfiniteQueryData(e){return e.behavior=m(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return p.onlineManager.isOnline()?this.#n.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#s}getMutationCache(){return this.#n}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,r){this.#f.set((0,t.hashKey)(e),{queryKey:e,defaultOptions:r})}getQueryDefaults(e){let r=[...this.#f.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,r){this.#d.set((0,t.hashKey)(e),{mutationKey:e,defaultOptions:r})}getMutationDefaults(e){let r=[...this.#d.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let r={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return r.queryHash||(r.queryHash=(0,t.hashQueryKeyByOptions)(r.queryKey,r)),void 0===r.refetchOnReconnect&&(r.refetchOnReconnect="always"!==r.networkMode),void 0===r.throwOnError&&(r.throwOnError=!!r.suspense),!r.networkMode&&r.persister&&(r.networkMode="offlineFirst"),r.queryFn===t.skipToken&&(r.enabled=!1),r}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#s.clear(),this.#n.clear()}};e.s(["QueryClient",()=>v],17751)},38360,(e,t,r)=>{var n={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},i=Object.keys(n).join("|"),o=RegExp(i,"g"),a=RegExp(i,"");function l(e){return n[e]}var u=function(e){return e.replace(o,l)};t.exports=u,t.exports.has=function(e){return!!e.match(a)},t.exports.remove=u},11889,56373,86447,1559,18364,78440,59129,25998,70238,e=>{"use strict";e.i(47167);var t,r="u">typeof window&&!!(null==(t=window.document)?void 0:t.createElement);function n(e){return e?"self"in e?e.document:e.ownerDocument||document:document}function i(e){return e?"self"in e?e.self:n(e).defaultView||window:self}function o(e,t=!1){var r;let{activeElement:i}=n(e);if(!(null==i?void 0:i.nodeName))return null;if(l(i)&&(null==(r=i.contentDocument)?void 0:r.body))return o(i.contentDocument.body,t);if(t){let e=i.getAttribute("aria-activedescendant");if(e){let t=n(i).getElementById(e);if(t)return t}}return i}function a(e,t){return e===t||e.contains(t)}function l(e){return"IFRAME"===e.tagName}function u(e){let t=e.tagName.toLowerCase();return"button"===t||"input"===t&&!!e.type&&-1!==s.indexOf(e.type)}var s=["button","color","file","image","reset","submit"];function c(e){return"function"==typeof e.checkVisibility?e.checkVisibility():e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0}function f(e){try{let t=e instanceof HTMLInputElement&&null!==e.selectionStart,r="TEXTAREA"===e.tagName;return t||r||!1}catch(e){return!1}}function d(e){return e.isContentEditable||f(e)}function p(e){let t=0,r=0;if(f(e))t=e.selectionStart||0,r=e.selectionEnd||0;else if(e.isContentEditable){let i=n(e).getSelection();if((null==i?void 0:i.rangeCount)&&i.anchorNode&&a(e,i.anchorNode)&&i.focusNode&&a(e,i.focusNode)){let n=i.getRangeAt(0),o=n.cloneRange();o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),t=o.toString().length,o.setEnd(n.endContainer,n.endOffset),r=o.toString().length}}return{start:t,end:r}}function m(e,t){let r=null==e?void 0:e.getAttribute("role");return r&&-1!==["dialog","menu","listbox","tree","grid"].indexOf(r)?r:t}function h(e){if(!e)return null;let t=e=>"auto"===e||"scroll"===e;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:r}=getComputedStyle(e);if(t(r))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:r}=getComputedStyle(e);if(t(r))return e}return h(e.parentElement)||document.scrollingElement||document.body}function v(e,...t){/text|search|password|tel|url/i.test(e.type)&&e.setSelectionRange(...t)}function g(e,t){return t&&e.item(t)||null}var y=Symbol("FOCUS_SILENTLY");function b(e,t,r){if(!t||t===r)return!1;let n=e.item(t.id);return!!n&&(!r||n.element!==r)}function S(){}function C(e,t){return"function"==typeof Object.hasOwn?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function x(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}function E(e){return e}function A(e,t){if(!e){if("string"!=typeof t)throw Error("Invariant failed");throw Error(t)}}function w(e,...t){let r="function"==typeof e?e(...t):e;return null!=r&&!r}function _(e){return e.disabled||!0===e["aria-disabled"]||"true"===e["aria-disabled"]}function T(e){let t={};for(let r in e)void 0!==e[r]&&(t[r]=e[r]);return t}function M(...e){for(let t of e)if(void 0!==t)return t}var R=e.i(71645);function O(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function I(){return r&&!!navigator.maxTouchPoints}function F(){return!!r&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}function L(){return r&&F()&&/apple/i.test(navigator.vendor)}function P(e){return!!(e.currentTarget&&!a(e.currentTarget,e.target))}function D(e){return e.target===e.currentTarget}function B(e,t){let r=new FocusEvent("blur",t),n=e.dispatchEvent(r),i={...t,bubbles:!0};return e.dispatchEvent(new FocusEvent("focusout",i)),n}function G(e,t){let r=new MouseEvent("click",t);return e.dispatchEvent(r)}function k(e,t){let r=t||e.currentTarget,n=e.relatedTarget;return!n||!a(r,n)}function j(e,t,r,n){let i=(e=>{if(n){let t=setTimeout(e,n);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,o,!0),r()}),o=()=>{i(),r()};return e.addEventListener(t,o,{once:!0,capture:!0}),i}function N(e,t,r,n=window){let i=[];try{for(let o of(n.document.addEventListener(e,t,r),Array.from(n.frames)))i.push(N(e,t,r,o))}catch(e){}return()=>{try{n.document.removeEventListener(e,t,r)}catch(e){}for(let e of i)e()}}var U={...R},q=U.useId;U.useDeferredValue;var V=U.useInsertionEffect,H=r?R.useLayoutEffect:R.useEffect;function W(e){let t=(0,R.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return V?V(()=>{t.current=e}):t.current=e,(0,R.useCallback)((...e)=>{var r;return null==(r=t.current)?void 0:r.call(t,...e)},[])}function K(...e){return(0,R.useMemo)(()=>{if(e.some(Boolean))return t=>{for(let r of e)O(r,t)}},e)}function z(e){if(q){let t=q();return e||t}let[t,r]=(0,R.useState)(e);return H(()=>{if(e||t)return;let n=Math.random().toString(36).slice(2,8);r(`id-${n}`)},[e,t]),e||t}function Q(e,t){let r=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(r.current)return e();r.current=!0},t),(0,R.useEffect)(()=>()=>{r.current=!1},[])}function $(){return(0,R.useReducer)(()=>[],[])}function X(e){return W("function"==typeof e?e:()=>e)}function Y(e,t,r=[]){let n=(0,R.useCallback)(r=>(e.wrapElement&&(r=e.wrapElement(r)),t(r)),[...r,e.wrapElement]);return{...e,wrapElement:n}}function Z(e=!1,t){let[r,n]=(0,R.useState)(null);return{portalRef:K(n,t),portalNode:r,domReady:!e||r}}var J=!1,ee=!1,et=0,er=0;function en(e){let t,r;t=e.movementX||e.screenX-et,r=e.movementY||e.screenY-er,et=e.screenX,er=e.screenY,(t||r||0)&&(ee=!0)}function ei(){ee=!1}var eo=e.i(43476);function ea(e){let t=R.forwardRef((t,r)=>e({...t,ref:r}));return t.displayName=e.displayName||e.name,t}function el(e,t){return R.memo(e,t)}function eu(e,t){let r,{wrapElement:n,render:i,...o}=t,a=K(t.ref,i&&(0,R.isValidElement)(i)&&("ref"in i.props||"ref"in i)?({...i.props}).ref||i.ref:null);if(R.isValidElement(i)){let e={...i.props,ref:a};r=R.cloneElement(i,function(e,t){let r={...e};for(let n in t){if(!C(t,n))continue;if("className"===n){let n="className";r[n]=e[n]?`${e[n]} ${t[n]}`:t[n];continue}if("style"===n){let n="style";r[n]=e[n]?{...e[n],...t[n]}:t[n];continue}let i=t[n];if("function"==typeof i&&n.startsWith("on")){let t=e[n];if("function"==typeof t){r[n]=(...e)=>{i(...e),t(...e)};continue}}r[n]=i}return r}(o,e))}else r=i?i(o):(0,eo.jsx)(e,{...o});return n?n(r):r}function es(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function ec(e=[],t=[]){let r=R.createContext(void 0),n=R.createContext(void 0),i=()=>R.useContext(r),o=t=>e.reduceRight((e,r)=>(0,eo.jsx)(r,{...t,children:e}),(0,eo.jsx)(r.Provider,{...t}));return{context:r,scopedContext:n,useContext:i,useScopedContext:(e=!1)=>{let t=R.useContext(n),r=i();return e?t:t||r},useProviderContext:()=>{let e=R.useContext(n),t=i();if(!e||e!==t)return t},ContextProvider:o,ScopedContextProvider:e=>(0,eo.jsx)(o,{...e,children:t.reduceRight((t,r)=>(0,eo.jsx)(r,{...e,children:t}),(0,eo.jsx)(n.Provider,{...e}))})}}var ef=ec(),ed=ef.useContext;ef.useScopedContext,ef.useProviderContext;var ep=ec([ef.ContextProvider],[ef.ScopedContextProvider]),em=ep.useContext;ep.useScopedContext;var eh=ep.useProviderContext,ev=ep.ContextProvider,eg=ep.ScopedContextProvider,ey=(0,R.createContext)(void 0),eb=(0,R.createContext)(void 0),eS=(0,R.createContext)(!0),eC="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function ex(e){return!(!e.matches(eC)||!c(e)||e.closest("[inert]"))}function eE(e){if(!ex(e)||0>Number.parseInt(e.getAttribute("tabindex")||"0",10))return!1;if(!("form"in e)||!e.form||e.checked||"radio"!==e.type)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!("length"in t))return!0;let r=o(e);return!r||r===e||!("form"in r)||r.form!==e.form||r.name!==e.name}function eA(e,t){let r=Array.from(e.querySelectorAll(eC));t&&r.unshift(e);let n=r.filter(ex);return n.forEach((e,t)=>{var r;if(!l(e))return;let i=null==(r=e.contentDocument)?void 0:r.body;i&&n.splice(t,1,...eA(i))}),n}function ew(e,t,r){let n=Array.from(e.querySelectorAll(eC)),i=n.filter(eE);return(t&&eE(e)&&i.unshift(e),i.forEach((e,t)=>{var n;if(!l(e))return;let o=null==(n=e.contentDocument)?void 0:n.body;if(!o)return;let a=ew(o,!1,r);i.splice(t,1,...a)}),!i.length&&r)?n:i}function e_(e,t){var r;let n,i,a,l;return r=document.body,n=o(r),a=(i=eA(r,!1)).indexOf(n),(l=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?l[0]:null)||null}function eT(e,t){var r;let n,i,a,l;return r=document.body,n=o(r),a=(i=eA(r,!1).reverse()).indexOf(n),(l=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?l[0]:null)||null}function eM(e){let t=o(e);if(!t)return!1;if(t===e)return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&r===e.id}function eR(e){let t=o(e);if(!t)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&"id"in e&&(r===e.id||!!e.querySelector(`#${CSS.escape(r)}`))}function eO(e){!eR(e)&&ex(e)&&e.focus()}var eI=L(),eF=["text","search","url","tel","email","password","number","date","month","week","time","datetime","datetime-local"],eL=Symbol("safariFocusAncestor");function eP(e){return"input"===e.tagName.toLowerCase()&&!!e.type&&("radio"===e.type||"checkbox"===e.type)}function eD(e,t){return W(r=>{null==e||e(r),!r.defaultPrevented&&t&&(r.stopPropagation(),r.preventDefault())})}var eB=!1,eG=!0;function ek(e){let t=e.target;t&&"hasAttribute"in t&&!t.hasAttribute("data-focus-visible")&&(eG=!1)}function ej(e){e.metaKey||e.ctrlKey||e.altKey||(eG=!0)}var eN=es(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:r,onFocusVisible:n,...i}){var o,a,l,s,c;let f=(0,R.useRef)(null);(0,R.useEffect)(()=>{!e||eB||(N("mousedown",ek,!0),N("keydown",ej,!0),eB=!0)},[e]),eI&&(0,R.useEffect)(()=>{if(!e)return;let t=f.current;if(!t||!eP(t))return;let r="labels"in t?t.labels:null;if(!r)return;let n=()=>queueMicrotask(()=>t.focus());for(let e of r)e.addEventListener("mouseup",n);return()=>{for(let e of r)e.removeEventListener("mouseup",n)}},[e]);let d=e&&_(i),p=!!d&&!t,[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{e&&p&&m&&h(!1)},[e,p,m]),(0,R.useEffect)(()=>{if(!e||!m)return;let t=f.current;if(!t||"u"{ex(t)||h(!1)});return r.observe(t),()=>r.disconnect()},[e,m]);let v=eD(i.onKeyPressCapture,d),g=eD(i.onMouseDownCapture,d),y=eD(i.onClickCapture,d),b=i.onMouseDown,S=W(t=>{if(null==b||b(t),t.defaultPrevented||!e)return;let r=t.currentTarget;if(!eI||P(t)||!u(r)&&!eP(r))return;let n=!1,i=()=>{n=!0};r.addEventListener("focusin",i,{capture:!0,once:!0});let o=function(e){for(;e&&!ex(e);)e=e.closest(eC);return e||null}(r.parentElement);o&&(o[eL]=!0),j(r,"mouseup",()=>{r.removeEventListener("focusin",i,!0),o&&(o[eL]=!1),n||eO(r)})}),C=(t,r)=>{if(r&&(t.currentTarget=r),!e)return;let i=t.currentTarget;i&&eM(i)&&(null==n||n(t),t.defaultPrevented||(i.dataset.focusVisible="true",h(!0)))},x=i.onKeyDownCapture,E=W(t=>{if(null==x||x(t),t.defaultPrevented||!e||m||t.metaKey||t.altKey||t.ctrlKey||!D(t))return;let r=t.currentTarget;j(r,"focusout",()=>C(t,r))}),A=i.onFocusCapture,w=W(t=>{if(null==A||A(t),t.defaultPrevented||!e)return;if(!D(t))return void h(!1);let r=t.currentTarget;eG||function(e){let{tagName:t,readOnly:r,type:n}=e;return"TEXTAREA"===t&&!r||"SELECT"===t&&!r||("INPUT"!==t||r?!!e.isContentEditable||"combobox"===e.getAttribute("role")&&!!e.dataset.name:eF.includes(n))}(t.target)?j(t.target,"focusout",()=>C(t,r)):h(!1)}),M=i.onBlur,O=W(t=>{null==M||M(t),!e||k(t)&&(t.currentTarget.removeAttribute("data-focus-visible"),h(!1))}),I=(0,R.useContext)(eS),F=W(t=>{e&&r&&t&&I&&queueMicrotask(()=>{eM(t)||ex(t)&&t.focus()})}),L=function(e,t){let r=e=>{if("string"==typeof e)return e},[n,i]=(0,R.useState)(()=>r(void 0));return H(()=>{let t=e&&"current"in e?e.current:e;i((null==t?void 0:t.tagName.toLowerCase())||r(void 0))},[e,void 0]),n}(f),B=e&&(!L||"button"===L||"summary"===L||"input"===L||"select"===L||"textarea"===L||"a"===L),G=e&&(!L||"button"===L||"input"===L||"select"===L||"textarea"===L),U=i.style,q=(0,R.useMemo)(()=>p?{pointerEvents:"none",...U}:U,[p,U]);return i={"data-focus-visible":e&&m||void 0,"data-autofocus":r||void 0,"aria-disabled":d||void 0,...i,ref:K(f,F,i.ref),style:q,tabIndex:(o=e,a=p,l=B,s=G,c=i.tabIndex,o?a?l&&!s?-1:void 0:l?c:c||0:c),disabled:!!G&&!!p||void 0,contentEditable:d?void 0:i.contentEditable,onKeyPressCapture:v,onClickCapture:y,onMouseDownCapture:g,onMouseDown:S,onKeyDownCapture:E,onFocusCapture:w,onBlur:O},T(i)});function eU(e){let t=[];for(let r of e)t.push(...r);return t}function eq(e){return e.slice().reverse()}function eV(e,t,r){return W(n=>{var i;let o,a;if(null==t||t(n),n.defaultPrevented||n.isPropagationStopped()||!D(n)||"Shift"===n.key||"Control"===n.key||"Alt"===n.key||"Meta"===n.key||(!(o=n.target)||f(o))&&1===n.key.length&&!n.ctrlKey&&!n.metaKey)return;let l=e.getState(),u=null==(i=g(e,l.activeId))?void 0:i.element;if(!u)return;let{view:s,...c}=n;u!==(null==r?void 0:r.current)&&u.focus(),a=new KeyboardEvent(n.type,c),u.dispatchEvent(a)||n.preventDefault(),n.currentTarget.contains(u)&&n.stopPropagation()})}ea(function(e){return eu("div",eN(e))});var eH=es(function({store:e,composite:t=!0,focusOnMove:r=t,moveOnKeyPress:n=!0,...i}){let a=eh();A(e=e||a,!1);let l=(0,R.useRef)(null),u=(0,R.useRef)(null),s=function(e){let[t,r]=(0,R.useState)(!1),n=(0,R.useCallback)(()=>r(!0),[]),i=e.useState(t=>g(e,t.activeId));return(0,R.useEffect)(()=>{let e=null==i?void 0:i.element;!t||e&&(r(!1),e.focus({preventScroll:!0}))},[i,t]),n}(e),c=e.useState("moves"),[,d]=function(e){let[t,r]=(0,R.useState)(null);return H(()=>{if(null==t||!e)return;let r=null;return e(e=>(r=e,t)),()=>{e(r)}},[t,e]),[t,r]}(t?e.setBaseElement:null);(0,R.useEffect)(()=>{var n;if(!e||!c||!t||!r)return;let{activeId:i}=e.getState(),o=null==(n=g(e,i))?void 0:n.element;o&&("scrollIntoView"in o?(o.focus({preventScroll:!0}),o.scrollIntoView({block:"nearest",inline:"nearest",...void 0})):o.focus())},[e,c,t,r]),H(()=>{if(!e||!c||!t)return;let{baseElement:r,activeId:n}=e.getState();if(null!==n||!r)return;let i=u.current;u.current=null,i&&B(i,{relatedTarget:r}),eM(r)||r.focus()},[e,c,t]);let p=e.useState("activeId"),m=e.useState("virtualFocus");H(()=>{var r;if(!e||!t||!m)return;let n=u.current;if(u.current=null,!n)return;let i=(null==(r=g(e,p))?void 0:r.element)||o(n);i!==n&&B(n,{relatedTarget:i})},[e,p,m,t]);let h=eV(e,i.onKeyDownCapture,u),v=eV(e,i.onKeyUpCapture,u),S=i.onFocusCapture,C=W(t=>{var r;let n;if(null==S||S(t),t.defaultPrevented||!e)return;let{virtualFocus:i}=e.getState();if(!i)return;let o=t.relatedTarget,a=(n=(r=t.currentTarget)[y],delete r[y],n);D(t)&&a&&(t.stopPropagation(),u.current=o)}),x=i.onFocus,E=W(r=>{if(null==x||x(r),r.defaultPrevented||!t||!e)return;let{relatedTarget:n}=r,{virtualFocus:i}=e.getState();i?D(r)&&!b(e,n)&&queueMicrotask(s):D(r)&&e.setActiveId(null)}),w=i.onBlurCapture,_=W(t=>{var r;if(null==w||w(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:i}=e.getState();if(!n)return;let o=null==(r=g(e,i))?void 0:r.element,a=t.relatedTarget,l=b(e,a),s=u.current;u.current=null,D(t)&&l?(a===o?s&&s!==a&&B(s,t):o?B(o,t):s&&B(s,t),t.stopPropagation()):!b(e,t.target)&&o&&B(o,t)}),T=i.onKeyDown,M=X(n),O=W(t=>{var r;if(null==T||T(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!D(t))return;let{orientation:n,renderedItems:i,activeId:o}=e.getState(),a=g(e,o);if(null==(r=null==a?void 0:a.element)?void 0:r.isConnected)return;let l="horizontal"!==n,u="vertical"!==n,s=i.some(e=>!!e.rowId);if(("ArrowLeft"===t.key||"ArrowRight"===t.key||"Home"===t.key||"End"===t.key)&&f(t.currentTarget))return;let c={ArrowUp:(s||l)&&(()=>{if(s){let e=eU(eq(function(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}(i))).find(e=>!e.disabled);return null==e?void 0:e.id}return null==e?void 0:e.last()}),ArrowRight:(s||u)&&e.first,ArrowDown:(s||l)&&e.first,ArrowLeft:(s||u)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(c){let r=c();if(void 0!==r){if(!M(t))return;t.preventDefault(),e.move(r)}}});return i=Y(i,t=>(0,eo.jsx)(ev,{value:e,children:t}),[e]),i={"aria-activedescendant":e.useState(r=>{var n;if(e&&t&&r.virtualFocus)return null==(n=g(e,r.activeId))?void 0:n.id}),...i,ref:K(l,d,i.ref),onKeyDownCapture:h,onKeyUpCapture:v,onFocusCapture:C,onFocus:E,onBlurCapture:_,onKeyDown:O},i=eN({focusable:e.useState(e=>t&&(e.virtualFocus||null===e.activeId)),...i})});ea(function(e){return eu("div",eH(e))});var eW=ec();eW.useContext,eW.useScopedContext;var eK=eW.useProviderContext,ez=ec([eW.ContextProvider],[eW.ScopedContextProvider]);ez.useContext,ez.useScopedContext;var eQ=ez.useProviderContext,e$=ez.ContextProvider,eX=ez.ScopedContextProvider,eY=(0,R.createContext)(void 0),eZ=(0,R.createContext)(void 0),eJ=ec([e$],[eX]);eJ.useContext,eJ.useScopedContext;var e0=eJ.useProviderContext,e1=eJ.ContextProvider,e2=eJ.ScopedContextProvider,e3=es(function({store:e,...t}){let r=e0();return e=e||r,t={...t,ref:K(null==e?void 0:e.setAnchorElement,t.ref)}});ea(function(e){return eu("div",e3(e))});var e5=(0,R.createContext)(void 0),e4=ec([e1,ev],[e2,eg]),e8=e4.useContext,e6=e4.useScopedContext,e9=e4.useProviderContext,e7=e4.ContextProvider,te=e4.ScopedContextProvider,tt=(0,R.createContext)(void 0),tr=(0,R.createContext)(!1);function tn(e,t){let r=e.__unstableInternals;return A(r,"Invalid store"),r[t]}function ti(e,...t){let r=e,n=r,i=Symbol(),o=S,a=new Set,l=new Set,u=new Set,s=new Set,c=new Set,f=new WeakMap,d=new WeakMap,p=(e,t,r=s)=>(r.add(t),d.set(t,e),()=>{var e;null==(e=f.get(t))||e(),f.delete(t),d.delete(t),r.delete(t)}),m=(e,o,a=!1)=>{var u,p;if(!C(r,e))return;let m=(p=r[e],"function"==typeof o?o("function"==typeof p?p():p):o);if(m===r[e])return;if(!a)for(let r of t)null==(u=null==r?void 0:r.setState)||u.call(r,e,m);let h=r;r={...r,[e]:m};let v=Symbol();i=v,l.add(e);let g=(t,n,i)=>{var o;let a=d.get(t);(!a||a.some(t=>i?i.has(t):t===e))&&(null==(o=f.get(t))||o(),f.set(t,t(r,n)))};for(let e of s)g(e,h);queueMicrotask(()=>{if(i!==v)return;let e=r;for(let e of c)g(e,n,l);n=e,l.clear()})},h={getState:()=>r,setState:m,__unstableInternals:{setup:e=>(u.add(e),()=>u.delete(e)),init:()=>{let e=a.size,n=Symbol();a.add(n);let i=()=>{a.delete(n),a.size||o()};if(e)return i;let l=Object.keys(r).map(e=>x(...t.map(t=>{var r;let n=null==(r=null==t?void 0:t.getState)?void 0:r.call(t);if(n&&C(n,e))return tu(t,[e],t=>{m(e,t[e],!0)})}))),s=[];for(let e of u)s.push(e());return o=x(...l,...s,...t.map(ta)),i},subscribe:(e,t)=>p(e,t),sync:(e,t)=>(f.set(t,t(r,r)),p(e,t)),batch:(e,t)=>(f.set(t,t(r,n)),p(e,t,c)),pick:e=>ti(function(e,t){let r={};for(let n of t)C(e,n)&&(r[n]=e[n]);return r}(r,e),h),omit:e=>ti(function(e,t){let r={...e};for(let e of t)C(r,e)&&delete r[e];return r}(r,e),h)}};return h}function to(e,...t){if(e)return tn(e,"setup")(...t)}function ta(e,...t){if(e)return tn(e,"init")(...t)}function tl(e,...t){if(e)return tn(e,"subscribe")(...t)}function tu(e,...t){if(e)return tn(e,"sync")(...t)}function ts(e,...t){if(e)return tn(e,"batch")(...t)}function tc(e,...t){if(e)return tn(e,"omit")(...t)}function tf(...e){var t;let r={};for(let n of e){let e=null==(t=null==n?void 0:n.getState)?void 0:t.call(n);e&&Object.assign(r,e)}let n=ti(r,...e);return Object.assign({},...e,n)}function td(e,t){}function tp(e,t,r){if(!r)return!1;let n=e.find(e=>!e.disabled&&e.value);return(null==n?void 0:n.value)===t}function tm(e,t){return!!t&&null!=e&&(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase()))}var th=es(function({store:e,focusable:t=!0,autoSelect:r=!1,getAutoSelectId:n,setValueOnChange:i,showMinLength:o=0,showOnChange:a,showOnMouseDown:l,showOnClick:u=l,showOnKeyDown:s,showOnKeyPress:c=s,blurActiveItemOnClick:f,setValueOnClick:d=!0,moveOnKeyPress:g=!0,autoComplete:y="list",...b}){var C;let x,E=e9();A(e=e||E,!1);let _=(0,R.useRef)(null),[T,M]=$(),O=(0,R.useRef)(!1),I=(0,R.useRef)(!1),F=e.useState(e=>e.virtualFocus&&r),L="inline"===y||"both"===y,[P,D]=(0,R.useState)(L);C=[L],x=(0,R.useRef)(!1),H(()=>{if(x.current)return(()=>{L&&D(!0)})();x.current=!0},C),H(()=>()=>{x.current=!1},[]);let B=e.useState("value"),G=(0,R.useRef)(void 0);(0,R.useEffect)(()=>tu(e,["selectedValue","activeId"],(e,t)=>{G.current=t.selectedValue}),[]);let N=e.useState(e=>{var t;if(L&&P){if(e.activeValue&&Array.isArray(e.selectedValue)&&(e.selectedValue.includes(e.activeValue)||(null==(t=G.current)?void 0:t.includes(e.activeValue))))return;return e.activeValue}}),U=e.useState("renderedItems"),q=e.useState("open"),V=e.useState("contentElement"),Y=(0,R.useMemo)(()=>{if(!L||!P)return B;if(tp(U,N,F)){if(tm(B,N)){let e=(null==N?void 0:N.slice(B.length))||"";return B+e}return B}return N||B},[L,P,U,N,F,B]);(0,R.useEffect)(()=>{let e=_.current;if(!e)return;let t=()=>D(!0);return e.addEventListener("combobox-item-move",t),()=>{e.removeEventListener("combobox-item-move",t)}},[]),(0,R.useEffect)(()=>{if(!L||!P||!N||!tp(U,N,F)||!tm(B,N))return;let e=S;return queueMicrotask(()=>{let t=_.current;if(!t)return;let{start:r,end:n}=p(t),i=B.length,o=N.length;v(t,i,o),e=()=>{if(!eM(t))return;let{start:e,end:a}=p(t);e!==i||a===o&&v(t,r,n)}}),()=>e()},[T,L,P,N,U,F,B]);let Z=(0,R.useRef)(null),J=W(n),ee=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!q||!V)return;let t=h(V);if(!t)return;Z.current=t;let r=()=>{O.current=!1},n=()=>{if(!e||!O.current)return;let{activeId:t}=e.getState();null===t||t!==ee.current&&(O.current=!1)},i={passive:!0,capture:!0};return t.addEventListener("wheel",r,i),t.addEventListener("touchmove",r,i),t.addEventListener("scroll",n,i),()=>{t.removeEventListener("wheel",r,!0),t.removeEventListener("touchmove",r,!0),t.removeEventListener("scroll",n,!0)}},[q,V,e]),H(()=>{!B||I.current||(O.current=!0)},[B]),H(()=>{"always"!==F&&q||(O.current=q)},[F,q]);let et=e.useState("resetValueOnSelect");Q(()=>{var t,r;let n=O.current;if(!e||!q||!n&&!et)return;let{baseElement:i,contentElement:o,activeId:a}=e.getState();if(!i||eM(i)){if(null==o?void 0:o.hasAttribute("data-placing")){let e=new MutationObserver(M);return e.observe(o,{attributeFilter:["data-placing"]}),()=>e.disconnect()}if(F&&n){let r,n=J(U),i=void 0!==n?n:null!=(t=null==(r=U.find(e=>{var t;return!e.disabled&&(null==(t=e.element)?void 0:t.getAttribute("role"))!=="tab"}))?void 0:r.id)?t:e.first();ee.current=i,e.move(null!=i?i:null)}else{let t=null==(r=e.item(a||e.first()))?void 0:r.element;t&&"scrollIntoView"in t&&t.scrollIntoView({block:"nearest",inline:"nearest"})}}},[e,q,T,B,F,et,J,U]),(0,R.useEffect)(()=>{if(!L)return;let t=_.current;if(!t)return;let r=[t,V].filter(e=>!!e),n=t=>{r.every(e=>k(t,e))&&(null==e||e.setValue(Y))};for(let e of r)e.addEventListener("focusout",n);return()=>{for(let e of r)e.removeEventListener("focusout",n)}},[L,V,e,Y]);let er=e=>e.currentTarget.value.length>=o,en=b.onChange,ei=X(null!=a?a:er),eo=X(null!=i?i:!e.tag),ea=W(t=>{if(null==en||en(t),t.defaultPrevented||!e)return;let r=t.currentTarget,{value:n,selectionStart:i,selectionEnd:o}=r,a=t.nativeEvent;if(O.current=!0,"input"===a.type&&(a.isComposing&&(O.current=!1,I.current=!0),L)){let e="insertText"===a.inputType||"insertCompositionText"===a.inputType,t=i===n.length;D(e&&t)}if(eo(t)){let t=n===e.getState().value;e.setValue(n),queueMicrotask(()=>{v(r,i,o)}),L&&F&&t&&M()}ei(t)&&e.show(),F&&O.current||e.setActiveId(null)}),el=b.onCompositionEnd,eu=W(e=>{O.current=!0,I.current=!1,null==el||el(e),e.defaultPrevented||F&&M()}),es=b.onMouseDown,ec=X(null!=f?f:()=>!!(null==e?void 0:e.getState().includesBaseElement)),ef=X(d),ed=X(null!=u?u:er),ep=W(t=>{null==es||es(t),t.defaultPrevented||t.button||t.ctrlKey||e&&(ec(t)&&e.setActiveId(null),ef(t)&&e.setValue(Y),ed(t)&&j(t.currentTarget,"mouseup",e.show))}),em=b.onKeyDown,eh=X(null!=c?c:er),ev=W(t=>{if(null==em||em(t),t.repeat||(O.current=!1),t.defaultPrevented||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||!e)return;let{open:r}=e.getState();!r&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&eh(t)&&(t.preventDefault(),e.show())}),eg=b.onBlur,ey=W(e=>{if(O.current=!1,null==eg||eg(e),e.defaultPrevented)return}),eb=z(b.id),eS=e.useState(e=>null===e.activeId);return b={id:eb,role:"combobox","aria-autocomplete":"inline"===y||"list"===y||"both"===y||"none"===y?y:void 0,"aria-haspopup":m(V,"listbox"),"aria-expanded":q,"aria-controls":null==V?void 0:V.id,"data-active-item":eS||void 0,value:Y,...b,ref:K(_,b.ref),onChange:ea,onCompositionEnd:eu,onMouseDown:ep,onKeyDown:ev,onBlur:ey},b=eH({store:e,focusable:t,...b,moveOnKeyPress:e=>!w(g,e)&&(L&&D(!0),!0)}),{autoComplete:"off",...b=e3({store:e,...b})}}),tv=ea(function(e){return eu("input",th(e))});function tg(e){let t=e.relatedTarget;return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE?t:null}e.s(["Combobox",()=>tv],11889);var ty=Symbol("composite-hover"),tb=es(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:r=!!t,...n}){let i=em();A(e=e||i,!1);let o=((0,R.useEffect)(()=>{J||(N("mousemove",en,!0),N("mousedown",ei,!0),N("mouseup",ei,!0),N("keydown",ei,!0),N("scroll",ei,!0),J=!0)},[]),W(()=>ee)),l=n.onMouseMove,u=X(t),s=W(t=>{if((null==l||l(t),!t.defaultPrevented&&o())&&u(t)){if(!eR(t.currentTarget)){let t=null==e?void 0:e.getState().baseElement;t&&!eM(t)&&t.focus()}null==e||e.setActiveId(t.currentTarget.id)}}),c=n.onMouseLeave,f=X(r),d=W(t=>{var r;let n;null==c||c(t),!t.defaultPrevented&&o()&&((n=tg(t))&&a(t.currentTarget,n)||function(e){let t=tg(e);if(!t)return!1;do{if(C(t,ty)&&t[ty])return!0;t=t.parentElement}while(t)return!1}(t)||!u(t)||f(t)&&(null==e||e.setActiveId(null),null==(r=null==e?void 0:e.getState().baseElement)||r.focus()))}),p=(0,R.useCallback)(e=>{e&&(e[ty]=!0)},[]);return T(n={...n,ref:K(p,n.ref),onMouseMove:s,onMouseLeave:d})});el(ea(function(e){return eu("div",tb(e))}));var tS=es(function({store:e,shouldRegisterItem:t=!0,getItem:r=E,element:n,...i}){let o=ed();e=e||o;let a=z(i.id),l=(0,R.useRef)(n);return(0,R.useEffect)(()=>{let n=l.current;if(!a||!n||!t)return;let i=r({id:a,element:n});return null==e?void 0:e.renderItem(i)},[a,t,r,e]),T(i={...i,ref:K(l,i.ref)})});function tC(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return"Enter"===e.key?u(t)||"SUMMARY"===t.tagName||"A"===t.tagName:" "===e.key&&(u(t)||"SUMMARY"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName)}ea(function(e){return eu("div",tS(e))});var tx=Symbol("command"),tE=es(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let i,o,a=(0,R.useRef)(null),[l,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{a.current&&s(u(a.current))},[]);let[c,d]=(0,R.useState)(!1),p=(0,R.useRef)(!1),m=_(n),[h,v]=(i=n.onLoadedMetadataCapture,o=(0,R.useMemo)(()=>Object.assign(()=>{},{...i,[tx]:!0}),[i,tx,!0]),[null==i?void 0:i[tx],{onLoadedMetadataCapture:o}]),g=n.onKeyDown,y=W(n=>{null==g||g(n);let i=n.currentTarget;if(n.defaultPrevented||h||m||!D(n)||f(i)||i.isContentEditable)return;let o=e&&"Enter"===n.key,a=t&&" "===n.key,l="Enter"===n.key&&!e,u=" "===n.key&&!t;if(l||u)return void n.preventDefault();if(o||a){let e=tC(n);if(o){if(!e){n.preventDefault();let{view:e,...t}=n,o=()=>G(i,t);r&&/firefox\//i.test(navigator.userAgent)?j(i,"keyup",o):queueMicrotask(o)}}else a&&(p.current=!0,e||(n.preventDefault(),d(!0)))}}),b=n.onKeyUp,S=W(e=>{if(null==b||b(e),e.defaultPrevented||h||m||e.metaKey)return;let r=t&&" "===e.key;if(p.current&&r&&(p.current=!1,!tC(e))){e.preventDefault(),d(!1);let t=e.currentTarget,{view:r,...n}=e;queueMicrotask(()=>G(t,n))}});return eN(n={"data-active":c||void 0,type:l?"button":void 0,...v,...n,ref:K(a,n.ref),onKeyDown:y,onKeyUp:S})});ea(function(e){return eu("button",tE(e))});var{useSyncExternalStore:tA}=e.i(2239).default,tw=()=>()=>{};function t_(e,t=E){let r=R.useCallback(t=>e?tl(e,null,t):tw(),[e]),n=()=>{let r="string"==typeof t?t:null,n="function"==typeof t?t:null,i=null==e?void 0:e.getState();return n?n(i):i&&r&&C(i,r)?i[r]:void 0};return tA(r,n,n)}function tT(e,t){let r=R.useRef({}),n=R.useCallback(t=>e?tl(e,null,t):tw(),[e]),i=()=>{let n=null==e?void 0:e.getState(),i=!1,o=r.current;for(let e in t){let r=t[e];if("function"==typeof r){let t=r(n);t!==o[e]&&(o[e]=t,i=!0)}if("string"==typeof r){if(!n||!C(n,r))continue;let t=n[r];t!==o[e]&&(o[e]=t,i=!0)}}return i&&(r.current={...o}),r.current};return tA(n,i,i)}function tM(e,t,r,n){var i;let o,a=C(t,r)?t[r]:void 0,l=(i={value:a,setValue:n?t[n]:void 0},o=(0,R.useRef)(i),H(()=>{o.current=i}),o);H(()=>tu(e,[r],(e,t)=>{let{value:n,setValue:i}=l.current;i&&e[r]!==t[r]&&e[r]!==n&&i(e[r])}),[e,r]),H(()=>{if(void 0!==a)return e.setState(r,a),ts(e,[r],()=>{void 0!==a&&e.setState(r,a)})})}function tR(e,t){let[r,n]=R.useState(()=>e(t));H(()=>ta(r),[r]);let i=R.useCallback(e=>t_(r,e),[r]);return[R.useMemo(()=>({...r,useState:i}),[r,i]),W(()=>{n(r=>e({...t,...r.getState()}))})]}function tO(e,t,r,n=!1){var i;let o,a;if(!t||!r)return;let{renderedItems:l}=t.getState(),u=h(e);if(!u)return;let s=function(e,t=!1){let r=e.clientHeight,{top:n}=e.getBoundingClientRect(),i=1.5*Math.max(.875*r,r-40),o=t?r-i+n:i+n;return"HTML"===e.tagName?o+e.scrollTop:o}(u,n);for(let e=0;e=0){void 0!==a&&at||(e&&(null==g?void 0:g.baseElement)&&g.baseElement===e.baseElement?g.id:void 0),baseElement:e=>(null==e?void 0:e.baseElement)||void 0,isActiveItem:e=>!!e&&e.activeId===h,ariaSetSize:e=>null!=l?l:e&&(null==g?void 0:g.ariaSetSize)&&g.baseElement===e.baseElement?g.ariaSetSize:void 0,ariaPosInSet(e){if(null!=s)return s;if(!e||!(null==g?void 0:g.ariaPosInSet)||g.baseElement!==e.baseElement)return;let t=e.renderedItems.filter(e=>e.rowId===C);return g.ariaPosInSet+t.findIndex(e=>e.id===h)},isTabbable(t){if(!(null==t?void 0:t.renderedItems.length))return!0;if(t.virtualFocus)return!1;if(o)return!0;if(null===t.activeId)return!1;let r=null==e?void 0:e.item(t.activeId);return null!=r&&!!r.disabled||null==r||!r.element||t.activeId===h}}),O=(0,R.useCallback)(e=>{var t;let r={...e,id:h||e.id,rowId:C,disabled:!!S,children:null==(t=e.element)?void 0:t.textContent};return a?a(r):r},[h,C,S,a]),I=c.onFocus,F=(0,R.useRef)(!1),B=W(t=>{var r,i;if(null==I||I(t),t.defaultPrevented||P(t)||!h||!e||(r=e,!D(t)&&b(r,t.target)))return;let{virtualFocus:o,baseElement:a}=e.getState();e.setActiveId(h),d(t.currentTarget)&&function(e,t=!1){if(f(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let r=n(e).getSelection();null==r||r.selectAllChildren(e),t&&(null==r||r.collapseToEnd())}}(t.currentTarget),!o||!D(t)||!d(i=t.currentTarget)&&("INPUT"!==i.tagName||u(i))&&(null==a?void 0:a.isConnected)&&((L()&&t.currentTarget.hasAttribute("data-autofocus")&&t.currentTarget.scrollIntoView({block:"nearest",inline:"nearest"}),F.current=!0,t.relatedTarget===a||b(e,t.relatedTarget))?(a[y]=!0,a.focus({preventScroll:!0})):a.focus())}),G=c.onBlurCapture,k=W(t=>{if(null==G||G(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState();(null==r?void 0:r.virtualFocus)&&F.current&&(F.current=!1,t.preventDefault(),t.stopPropagation())}),j=c.onKeyDown,N=X(r),U=X(i),q=W(t=>{if(null==j||j(t),t.defaultPrevented||!D(t)||!e)return;let{currentTarget:r}=t,i=e.getState(),o=e.item(h),a=!!(null==o?void 0:o.rowId),l="horizontal"!==i.orientation,u="vertical"!==i.orientation,s=()=>!(!a&&!u&&i.baseElement&&f(i.baseElement)),c={ArrowUp:(a||l)&&e.up,ArrowRight:(a||u)&&e.next,ArrowDown:(a||l)&&e.down,ArrowLeft:(a||u)&&e.previous,Home:()=>{if(s())return!a||t.ctrlKey?null==e?void 0:e.first():null==e?void 0:e.previous(-1)},End:()=>{if(s())return!a||t.ctrlKey?null==e?void 0:e.last():null==e?void 0:e.next(-1)},PageUp:()=>tO(r,e,null==e?void 0:e.up,!0),PageDown:()=>tO(r,e,null==e?void 0:e.down)}[t.key];if(c){if(d(r)){let e=p(r),i=u&&"ArrowLeft"===t.key,o=u&&"ArrowRight"===t.key,a=l&&"ArrowUp"===t.key,s=l&&"ArrowDown"===t.key;if(o||s){let{length:t}=function(e){if(f(e))return e.value;if(e.isContentEditable){let t=n(e).createRange();return t.selectNodeContents(e),t.toString()}return""}(r);if(e.end!==t)return}else if((i||a)&&0!==e.start)return}let i=c();if(N(t)||void 0!==i){if(!U(t))return;t.preventDefault(),e.move(i)}}}),V=(0,R.useMemo)(()=>({id:h,baseElement:x}),[h,x]);return c={id:h,"data-active-item":E||void 0,...c=Y(c,e=>(0,eo.jsx)(ey.Provider,{value:V,children:e}),[V]),ref:K(v,c.ref),tabIndex:M?c.tabIndex:-1,onFocus:B,onBlurCapture:k,onKeyDown:q},c=tE(c),T({...c=tS({store:e,...c,getItem:O,shouldRegisterItem:!!h&&c.shouldRegisterItem}),"aria-setsize":A,"aria-posinset":w})});el(ea(function(e){return eu("button",tI(e))}));var tF=es(function({store:e,value:t,hideOnClick:r,setValueOnClick:n,selectValueOnClick:i=!0,resetValueOnSelect:o,focusOnHover:a=!1,moveOnKeyPress:l=!0,getItem:u,...s}){var c,d;let p=e6();A(e=e||p,!1);let{resetValueOnSelectState:m,multiSelectable:h,selected:v}=tT(e,{resetValueOnSelectState:"resetValueOnSelect",multiSelectable:e=>Array.isArray(e.selectedValue),selected:e=>(function(e,t){if(null!=t)return null!=e&&(Array.isArray(e)?e.includes(t):e===t)})(e.selectedValue,t)}),g=(0,R.useCallback)(e=>{let r={...e,value:t};return u?u(r):r},[t,u]);n=null!=n?n:!h,r=null!=r?r:null!=t&&!h;let y=s.onClick,b=X(n),S=X(i),C=X(null!=(c=null!=o?o:m)?c:h),x=X(r),E=W(r=>{null==y||y(r),r.defaultPrevented||function(e){let t=e.currentTarget;if(!t)return!1;let r=t.tagName.toLowerCase();return!!e.altKey&&("a"===r||"button"===r&&"submit"===t.type||"input"===r&&"submit"===t.type)}(r)||!function(e){let t=e.currentTarget;if(!t)return!1;let r=F();if(r&&!e.metaKey||!r&&!e.ctrlKey)return!1;let n=t.tagName.toLowerCase();return"a"===n||"button"===n&&"submit"===t.type||"input"===n&&"submit"===t.type}(r)&&(null!=t&&(S(r)&&(C(r)&&(null==e||e.resetValue()),null==e||e.setSelectedValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t)),b(r)&&(null==e||e.setValue(t))),x(r)&&(null==e||e.hide()))}),w=s.onKeyDown,_=W(t=>{if(null==w||w(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState().baseElement;!r||eM(r)||(1===t.key.length||"Backspace"===t.key||"Delete"===t.key)&&(queueMicrotask(()=>r.focus()),f(r)&&(null==e||e.setValue(r.value)))});h&&null!=v&&(s={"aria-selected":v,...s}),s=Y(s,e=>(0,eo.jsx)(tt.Provider,{value:t,children:(0,eo.jsx)(tr.Provider,{value:null!=v&&v,children:e})}),[t,v]),s={role:null!=(d=({menu:"menuitem",listbox:"option",tree:"treeitem"})[(0,R.useContext)(e5)])?d:"option",children:t,...s,onClick:E,onKeyDown:_};let T=X(l);return s=tI({store:e,...s,getItem:g,moveOnKeyPress:t=>{if(!T(t))return!1;let r=new Event("combobox-item-move"),n=null==e?void 0:e.getState().baseElement;return null==n||n.dispatchEvent(r),!0}}),s=tb({store:e,focusOnHover:a,...s})}),tL=el(ea(function(e){return eu("div",tF(e))}));e.s(["ComboboxItem",()=>tL],56373);var tP=e.i(74080);function tD(e,t){let r=setTimeout(t,e);return()=>clearTimeout(r)}function tB(...e){return e.join(", ").split(", ").reduce((e,t)=>{let r=t.endsWith("ms")?1:1e3,n=Number.parseFloat(t||"0s")*r;return n>e?n:e},0)}function tG(e,t,r){return!r&&!1!==t&&(!e||!!t)}var tk=es(function({store:e,alwaysVisible:t,...r}){let n=eK();A(e=e||n,!1);let i=(0,R.useRef)(null),o=z(r.id),[a,l]=(0,R.useState)(null),u=e.useState("open"),s=e.useState("mounted"),c=e.useState("animated"),f=e.useState("contentElement"),d=t_(e.disclosure,"contentElement");H(()=>{i.current&&(null==e||e.setContentElement(i.current))},[e]),H(()=>{let t;return null==e||e.setState("animated",e=>(t=e,!0)),()=>{void 0!==t&&(null==e||e.setState("animated",t))}},[e]),H(()=>{if(c){var e;let t;return(null==f?void 0:f.isConnected)?(e=()=>{l(u?"enter":s?"leave":null)},t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)}),()=>cancelAnimationFrame(t)):void l(null)}},[c,f,u,s]),H(()=>{if(!e||!c||!a||!f)return;let t=()=>null==e?void 0:e.setState("animating",!1),r=()=>(0,tP.flushSync)(t);if("leave"===a&&u||"enter"===a&&!u)return;if("number"==typeof c)return tD(c,r);let{transitionDuration:n,animationDuration:i,transitionDelay:o,animationDelay:l}=getComputedStyle(f),{transitionDuration:s="0",animationDuration:p="0",transitionDelay:m="0",animationDelay:h="0"}=d?getComputedStyle(d):{},v=tB(o,l,m,h)+tB(n,i,s,p);if(!v){"enter"===a&&e.setState("animated",!1),t();return}return tD(Math.max(v-1e3/60,0),r)},[e,c,f,d,u,a]);let p=tG(s,(r=Y(r,t=>(0,eo.jsx)(eX,{value:e,children:t}),[e])).hidden,t),m=r.style,h=(0,R.useMemo)(()=>p?{...m,display:"none"}:m,[p,m]);return T(r={id:o,"data-open":u||void 0,"data-enter":"enter"===a||void 0,"data-leave":"leave"===a||void 0,hidden:p,...r,ref:K(o?e.setContentElement:null,i,r.ref),style:h})}),tj=ea(function(e){return eu("div",tk(e))});ea(function({unmountOnHide:e,...t}){let r=eK();return!1===t_(t.store||r,t=>!e||(null==t?void 0:t.mounted))?null:(0,eo.jsx)(tj,{...t})});var tN=es(function({store:e,alwaysVisible:t,...r}){let n=e6(!0),i=e8(),o=!!(e=e||i)&&e===n;A(e,!1);let a=(0,R.useRef)(null),l=z(r.id),u=e.useState("mounted"),s=tG(u,r.hidden,t),c=s?{...r.style,display:"none"}:r.style,f=e.useState(e=>Array.isArray(e.selectedValue)),d=function(e,t,r){let n=function(e){let[t]=(0,R.useState)(e);return t}(r),[i,o]=(0,R.useState)(n);return(0,R.useEffect)(()=>{let r=e&&"current"in e?e.current:e;if(!r)return;let i=()=>{let e=r.getAttribute(t);o(null==e?n:e)},a=new MutationObserver(i);return a.observe(r,{attributeFilter:[t]}),i(),()=>a.disconnect()},[e,t,n]),i}(a,"role",r.role),p="listbox"===d||"tree"===d||"grid"===d,[m,h]=(0,R.useState)(!1),v=e.useState("contentElement");H(()=>{if(!u)return;let e=a.current;if(!e||v!==e)return;let t=()=>{h(!!e.querySelector("[role='listbox']"))},r=new MutationObserver(t);return r.observe(e,{subtree:!0,childList:!0,attributeFilter:["role"]}),t(),()=>r.disconnect()},[u,v]),m||(r={role:"listbox","aria-multiselectable":p&&f||void 0,...r}),r=Y(r,t=>(0,eo.jsx)(te,{value:e,children:(0,eo.jsx)(e5.Provider,{value:d,children:t})}),[e,d]);let g=!l||n&&o?null:e.setContentElement;return T(r={id:l,hidden:s,...r,ref:K(g,a,r.ref),style:c})}),tU=ea(function(e){return eu("div",tN(e))});e.s(["ComboboxList",()=>tU,"useComboboxList",()=>tN],86447);var tq=(0,R.createContext)(null),tV=es(function(e){return{...e,style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px",...e.style}}});ea(function(e){return eu("span",tV(e))});var tH=es(function(e){return tV(e={"data-focus-trap":"",tabIndex:0,"aria-hidden":!0,...e,style:{position:"fixed",top:0,left:0,...e.style}})}),tW=ea(function(e){return eu("span",tH(e))});function tK(e){queueMicrotask(()=>{null==e||e.focus()})}var tz=es(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:r,portalRef:i,portal:o=!0,...a}){let l=(0,R.useRef)(null),u=K(l,a.ref),s=(0,R.useContext)(tq),[c,f]=(0,R.useState)(null),[d,p]=(0,R.useState)(null),m=(0,R.useRef)(null),h=(0,R.useRef)(null),v=(0,R.useRef)(null),g=(0,R.useRef)(null);return H(()=>{let e=l.current;if(!e||!o)return void f(null);let t=r?"function"==typeof r?r(e):r:n(e).createElement("div");if(!t)return void f(null);let a=t.isConnected;if(a||(s||n(e).body).appendChild(t),t.id||(t.id=e.id?`portal/${e.id}`:function(e="id"){return`${e?`${e}-`:""}${Math.random().toString(36).slice(2,8)}`}()),f(t),O(i,t),!a)return()=>{t.remove(),O(i,null)}},[o,r,s,i]),H(()=>{if(!o||!e||!t)return;let r=n(t).createElement("span");return r.style.position="fixed",t.insertAdjacentElement("afterend",r),p(r),()=>{r.remove(),p(null)}},[o,e,t]),(0,R.useEffect)(()=>{if(!c||!e)return;let t=0,r=e=>{if(!k(e))return;let r="focusin"===e.type;if(cancelAnimationFrame(t),r){let e=c.querySelectorAll("[data-tabindex]"),t=e=>{let t=e.getAttribute("data-tabindex");e.removeAttribute("data-tabindex"),t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")};for(let r of(c.hasAttribute("data-tabindex")&&t(c),e))t(r);return}t=requestAnimationFrame(()=>{for(let e of ew(c,!0))!function(e){var t;let r=null!=(t=e.getAttribute("tabindex"))?t:"";e.setAttribute("data-tabindex",r),e.setAttribute("tabindex","-1")}(e)})};return c.addEventListener("focusin",r,!0),c.addEventListener("focusout",r,!0),()=>{cancelAnimationFrame(t),c.removeEventListener("focusin",r,!0),c.removeEventListener("focusout",r,!0)}},[c,e]),a={...a=Y(a,t=>{if(t=(0,eo.jsx)(tq.Provider,{value:c||s,children:t}),!o)return t;if(!c)return(0,eo.jsx)("span",{ref:u,id:a.id,style:{position:"fixed"},hidden:!0});t=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tW,{ref:h,"data-focus-trap":a.id,className:"__focus-trap-inner-before",onFocus:e=>{k(e,c)?tK(e_()):tK(m.current)}}),t,e&&c&&(0,eo.jsx)(tW,{ref:v,"data-focus-trap":a.id,className:"__focus-trap-inner-after",onFocus:e=>{k(e,c)?tK(eT()):tK(g.current)}})]}),c&&(t=(0,tP.createPortal)(t,c));let r=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tW,{ref:m,"data-focus-trap":a.id,className:"__focus-trap-outer-before",onFocus:e=>{e.relatedTarget!==g.current&&k(e,c)?tK(h.current):tK(eT())}}),e&&(0,eo.jsx)("span",{"aria-owns":null==c?void 0:c.id,style:{position:"fixed"}}),e&&c&&(0,eo.jsx)(tW,{ref:g,"data-focus-trap":a.id,className:"__focus-trap-outer-after",onFocus:e=>{if(k(e,c))tK(v.current);else{let e=e_();if(e===h.current)return void requestAnimationFrame(()=>{var e;return null==(e=e_())?void 0:e.focus()});tK(e)}}})]});return d&&e&&(r=(0,tP.createPortal)(r,d)),(0,eo.jsxs)(eo.Fragment,{children:[r,t]})},[c,s,o,a.id,e,d]),ref:u}});ea(function(e){return eu("div",tz(e))});var tQ=(0,R.createContext)(0);function t$({level:e,children:t}){let r=(0,R.useContext)(tQ),n=Math.max(Math.min(e||r+1,6),1);return(0,eo.jsx)(tQ.Provider,{value:n,children:t})}var tX=es(function({autoFocusOnShow:e=!0,...t}){return Y(t,t=>(0,eo.jsx)(eS.Provider,{value:e,children:t}),[e])});ea(function(e){return eu("div",tX(e))});var tY=new WeakMap;function tZ(e,t,r){tY.has(e)||tY.set(e,new Map);let n=tY.get(e),i=n.get(t);if(!i)return n.set(t,r()),()=>{var e;null==(e=n.get(t))||e(),n.delete(t)};let o=r(),a=()=>{o(),i(),n.delete(t)};return n.set(t,a),()=>{n.get(t)===a&&(o(),n.set(t,i))}}function tJ(e,t,r){return tZ(e,t,()=>{let n=e.getAttribute(t);return e.setAttribute(t,r),()=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)}})}function t0(e,t,r){return tZ(e,t,()=>{let n=t in e,i=e[t];return e[t]=r,()=>{n?e[t]=i:delete e[t]}})}function t1(e,t){return e?tZ(e,"style",()=>{let r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}):()=>{}}var t2=["SCRIPT","STYLE"];function t3(e){return`__ariakit-dialog-snapshot-${e}`}function t5(e,t,r,i){for(let o of t){if(!(null==o?void 0:o.isConnected))continue;let l=t.some(e=>!!e&&e!==o&&e.contains(o)),u=n(o),s=o;for(;o.parentElement&&o!==u.body;){if(null==i||i(o.parentElement,s),!l)for(let i of o.parentElement.children)(function(e,t,r){return!t2.includes(t.tagName)&&!!function(e,t){let r=n(t),i=t3(e);if(!r.body[i])return!0;for(;;){if(t===r.body)return!1;if(t[i])return!0;if(!t.parentElement)return!1;t=t.parentElement}}(e,t)&&!r.some(e=>e&&a(t,e))})(e,i,t)&&r(i,s);o=o.parentElement}}}function t4(e,...t){if(!e)return!1;let r=e.getAttribute("data-backdrop");return null!=r&&(""===r||"true"===r||!t.length||t.some(e=>r===e))}function t8(e="",t=!1){return`__ariakit-dialog-${t?"ancestor":"outside"}${e?`-${e}`:""}`}function t6(e,t=""){return x(t0(e,t8("",!0),!0),t0(e,t8(t,!0),!0))}function t9(e,t){if(e[t8(t,!0)])return!0;let r=t8(t);for(;;){if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}}function t7(e,t){let r=[],n=t.map(e=>null==e?void 0:e.id);return t5(e,t,t=>{t4(t,...n)||r.unshift(function(e,t=""){return x(t0(e,t8(),!0),t0(e,t8(t),!0))}(t,e))},(t,n)=>{n.hasAttribute("data-dialog")&&n.id!==e||r.unshift(t6(t,e))}),()=>{for(let e of r)e()}}function re({store:e,type:t,listener:r,capture:i,domReady:o}){let l=W(r),u=t_(e,"open"),s=(0,R.useRef)(!1);H(()=>{if(!u||!o)return;let{contentElement:t}=e.getState();if(!t)return;let r=()=>{s.current=!0};return t.addEventListener("focusin",r,!0),()=>t.removeEventListener("focusin",r,!0)},[e,u,o]),(0,R.useEffect)(()=>{if(u)return N(t,t=>{let{contentElement:r,disclosureElement:i}=e.getState(),o=t.target;!r||!o||!(!("HTML"===o.tagName||a(n(o).body,o))||a(r,o)||function(e,t){if(!e)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");if(r){let t=n(e).getElementById(r);if(t)return a(e,t)}return!1}(i,o)||o.hasAttribute("data-focus-trap")||function(e,t){if(!("clientY"in e))return!1;let r=t.getBoundingClientRect();return 0!==r.width&&0!==r.height&&r.top<=e.clientY&&e.clientY<=r.top+r.height&&r.left<=e.clientX&&e.clientX<=r.left+r.width}(t,r))&&(!s.current||t9(o,r.id))&&(o&&o[eL]||l(t))},i)},[u,i])}function rt(e,t){return"function"==typeof e?e(t):!!e}var rr=(0,R.createContext)({});function rn(){return"inert"in HTMLElement.prototype}function ri(e,t){if(!("style"in e))return S;if(rn())return t0(e,"inert",!0);let r=ew(e,!0).map(e=>{if(null==t?void 0:t.some(t=>t&&a(t,e)))return S;let r=tZ(e,"focus",()=>(e.focus=S,()=>{delete e.focus}));return x(tJ(e,"tabindex","-1"),r)});return x(...r,tJ(e,"aria-hidden","true"),t1(e,{pointerEvents:"none",userSelect:"none",cursor:"default"}))}function ro(e={}){let t=tf(e.store,tc(e.disclosure,["contentElement","disclosureElement"]));td(e,t);let r=null==t?void 0:t.getState(),n=M(e.open,null==r?void 0:r.open,e.defaultOpen,!1),i=M(e.animated,null==r?void 0:r.animated,!1),o=ti({open:n,animated:i,animating:!!i&&n,mounted:n,contentElement:M(null==r?void 0:r.contentElement,null),disclosureElement:M(null==r?void 0:r.disclosureElement,null)},t);return to(o,()=>tu(o,["animated","animating"],e=>{e.animated||o.setState("animating",!1)})),to(o,()=>tl(o,["open"],()=>{o.getState().animated&&o.setState("animating",!0)})),to(o,()=>tu(o,["open","animating"],e=>{o.setState("mounted",e.open||e.animating)})),{...o,disclosure:e.disclosure,setOpen:e=>o.setState("open",e),show:()=>o.setState("open",!0),hide:()=>o.setState("open",!1),toggle:()=>o.setState("open",e=>!e),stopAnimation:()=>o.setState("animating",!1),setContentElement:e=>o.setState("contentElement",e),setDisclosureElement:e=>o.setState("disclosureElement",e)}}function ra(e,t,r){return Q(t,[r.store,r.disclosure]),tM(e,r,"open","setOpen"),tM(e,r,"mounted","setMounted"),tM(e,r,"animated"),Object.assign(e,{disclosure:r.disclosure})}es(function(e){return e});var rl=ea(function(e){return eu("div",e)});function ru({store:e,backdrop:t,alwaysVisible:r,hidden:n}){let i=(0,R.useRef)(null),o=function(e={}){let[t,r]=tR(ro,e);return ra(t,r,e)}({disclosure:e}),a=t_(e,"contentElement");(0,R.useEffect)(()=>{let e=i.current;!e||a&&(e.style.zIndex=getComputedStyle(a).zIndex)},[a]),H(()=>{let e=null==a?void 0:a.id;if(!e)return;let t=i.current;if(t)return t6(t,e)},[a]);let l=tk({ref:i,store:o,role:"presentation","data-backdrop":(null==a?void 0:a.id)||"",alwaysVisible:r,hidden:null!=n?n:void 0,style:{position:"fixed",top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,R.isValidElement)(t))return(0,eo.jsx)(rl,{...l,render:t});let u="boolean"!=typeof t?t:"div";return(0,eo.jsx)(rl,{...l,render:(0,eo.jsx)(u,{})})}function rs(e={}){return ro(e)}Object.assign(rl,["a","button","details","dialog","div","form","h1","h2","h3","h4","h5","h6","header","img","input","label","li","nav","ol","p","section","select","span","summary","textarea","ul","svg"].reduce((e,t)=>(e[t]=ea(function(e){return eu(t,e)}),e),{}));var rc=L();function rf(e,t=!1){if(!e)return null;let r="current"in e?e.current:e;return r?t?ex(r)?r:null:r:null}var rd=es(function({store:e,open:t,onClose:l,focusable:s=!0,modal:f=!0,portal:d=!!f,backdrop:p=!!f,hideOnEscape:m=!0,hideOnInteractOutside:h=!0,getPersistentElements:v,preventBodyScroll:g=!!f,autoFocusOnShow:y=!0,autoFocusOnHide:b=!0,initialFocus:S,finalFocus:C,unmountOnHide:E,unstable_treeSnapshotKey:A,...w}){var _;let T,M,O,L=eQ(),P=(0,R.useRef)(null),D=function(e={}){let[t,r]=tR(rs,e);return ra(t,r,e)}({store:e||L,open:t,setOpen(e){if(e)return;let t=P.current;if(!t)return;let r=new Event("close",{bubbles:!1,cancelable:!0});l&&t.addEventListener("close",l,{once:!0}),t.dispatchEvent(r),r.defaultPrevented&&D.setOpen(!0)}}),{portalRef:B,domReady:G}=Z(d,w.portalRef),k=w.preserveTabOrder,U=t_(D,e=>k&&!f&&e.mounted),q=z(w.id),V=t_(D,"open"),Q=t_(D,"mounted"),J=t_(D,"contentElement"),ee=tG(Q,w.hidden,w.alwaysVisible);T=function({attribute:e,contentId:t,contentElement:r,enabled:i}){let[o,a]=$(),l=(0,R.useCallback)(()=>{if(!i||!r)return!1;let{body:o}=n(r),a=o.getAttribute(e);return!a||a===t},[o,i,r,e,t]);return(0,R.useEffect)(()=>{if(!i||!t||!r)return;let{body:o}=n(r);if(l())return o.setAttribute(e,t),()=>o.removeAttribute(e);let u=new MutationObserver(()=>(0,tP.flushSync)(a));return u.observe(o,{attributeFilter:[e]}),()=>u.disconnect()},[o,i,t,r,l,e]),l}({attribute:"data-dialog-prevent-body-scroll",contentElement:J,contentId:q,enabled:g&&!ee}),(0,R.useEffect)(()=>{var e,t;if(!T()||!J)return;let o=n(J),a=i(J),{documentElement:l,body:u}=o,s=l.style.getPropertyValue("--scrollbar-width"),c=s?Number.parseInt(s,10):a.innerWidth-l.clientWidth,f=Math.round(l.getBoundingClientRect().left)+l.scrollLeft?"paddingLeft":"paddingRight",d=F()&&!(r&&navigator.platform.startsWith("Mac")&&!I());return x((e="--scrollbar-width",t=`${c}px`,l?tZ(l,e,()=>{let r=l.style.getPropertyValue(e);return l.style.setProperty(e,t),()=>{r?l.style.setProperty(e,r):l.style.removeProperty(e)}}):()=>{}),d?(()=>{var e,t;let{scrollX:r,scrollY:n,visualViewport:i}=a,o=null!=(e=null==i?void 0:i.offsetLeft)?e:0,l=null!=(t=null==i?void 0:i.offsetTop)?t:0,s=t1(u,{position:"fixed",overflow:"hidden",top:`${-(n-Math.floor(l))}px`,left:`${-(r-Math.floor(o))}px`,right:"0",[f]:`${c}px`});return()=>{s(),a.scrollTo({left:r,top:n,behavior:"instant"})}})():t1(u,{overflow:"hidden",[f]:`${c}px`}))},[T,J]),_=t_(D,"open"),M=(0,R.useRef)(null),(0,R.useEffect)(()=>{if(!_){M.current=null;return}return N("mousedown",e=>{M.current=e.target},!0)},[_]),re({...O={store:D,domReady:G,capture:!0},type:"click",listener:e=>{let{contentElement:t}=D.getState(),r=M.current;r&&c(r)&&t9(r,null==t?void 0:t.id)&&rt(h,e)&&D.hide()}}),re({...O,type:"focusin",listener:e=>{let{contentElement:t}=D.getState();!t||e.target===n(t)||rt(h,e)&&D.hide()}}),re({...O,type:"contextmenu",listener:e=>{rt(h,e)&&D.hide()}});let{wrapElement:et,nestedDialogs:er}=function(e){let t=(0,R.useContext)(rr),[r,n]=(0,R.useState)([]),i=(0,R.useCallback)(e=>{var r;return n(t=>[...t,e]),x(null==(r=t.add)?void 0:r.call(t,e),()=>{n(t=>t.filter(t=>t!==e))})},[t]);H(()=>tu(e,["open","contentElement"],r=>{var n;if(r.open&&r.contentElement)return null==(n=t.add)?void 0:n.call(t,e)}),[e,t]);let o=(0,R.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,R.useCallback)(e=>(0,eo.jsx)(rr.Provider,{value:o,children:e}),[o]),nestedDialogs:r}}(D);w=Y(w,et,[et]),H(()=>{if(!V)return;let e=P.current,t=o(e,!0);!t||"BODY"===t.tagName||e&&a(e,t)||D.setDisclosureElement(t)},[D,V]),rc&&(0,R.useEffect)(()=>{if(!Q)return;let{disclosureElement:e}=D.getState();if(!e||!u(e))return;let t=()=>{let t=!1,r=()=>{t=!0};e.addEventListener("focusin",r,{capture:!0,once:!0}),j(e,"mouseup",()=>{e.removeEventListener("focusin",r,!0),t||eO(e)})};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},[D,Q]),(0,R.useEffect)(()=>{if(!Q||!G)return;let e=P.current;if(!e)return;let t=i(e),r=t.visualViewport||t,n=()=>{var r,n;let i=null!=(n=null==(r=t.visualViewport)?void 0:r.height)?n:t.innerHeight;e.style.setProperty("--dialog-viewport-height",`${i}px`)};return n(),r.addEventListener("resize",n),()=>{r.removeEventListener("resize",n)}},[Q,G]),(0,R.useEffect)(()=>{if(!f||!Q||!G)return;let e=P.current;if(e&&!e.querySelector("[data-dialog-dismiss]")){var t;let r;return t=D.hide,(r=n(e).createElement("button")).type="button",r.tabIndex=-1,r.textContent="Dismiss popup",Object.assign(r.style,{border:"0px",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0px",position:"absolute",whiteSpace:"nowrap",width:"1px"}),r.addEventListener("click",t),e.prepend(r),()=>{r.removeEventListener("click",t),r.remove()}}},[D,f,Q,G]),H(()=>{if(!rn()||V||!Q||!G)return;let e=P.current;if(e)return ri(e)},[V,Q,G]);let en=V&&G;H(()=>{if(q&&en)return function(e,t){let{body:r}=n(t[0]),i=[];return t5(e,t,t=>{i.push(t0(t,t3(e),!0))}),x(t0(r,t3(e),!0),()=>{for(let e of i)e()})}(q,[P.current])},[q,en,A]);let ei=W(v);H(()=>{if(!q||!en)return;let{disclosureElement:e}=D.getState(),t=[P.current,...ei()||[],...er.map(e=>e.getState().contentElement)];if(f){let e,r;return x(t7(q,t),(e=[],r=t.map(e=>null==e?void 0:e.id),t5(q,t,n=>{t4(n,...r)||!function(e,...t){if(!e)return!1;let r=e.getAttribute("data-focus-trap");return null!=r&&(!t.length||""!==r&&t.some(e=>r===e))}(n,...r)&&e.unshift(ri(n,t))},r=>{!r.hasAttribute("role")||t.some(e=>e&&a(e,r))||e.unshift(tJ(r,"role","none"))}),()=>{for(let t of e)t()}))}return t7(q,[e,...t])},[q,D,en,ei,er,f,A]);let ea=!!y,el=X(y),[eu,es]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!V||!ea||!G||!(null==J?void 0:J.isConnected))return;let e=rf(S,!0)||J.querySelector("[data-autofocus=true],[autofocus]")||function(e,t,r){let[n]=ew(e,t,r);return n||null}(J,!0,d&&U)||J,t=ex(e);el(t?e:null)&&(es(!0),queueMicrotask(()=>{e.focus(),!rc||t&&e.scrollIntoView({block:"nearest",inline:"nearest"})}))},[V,ea,G,J,S,d,U,el]);let ec=!!b,ef=X(b),[ed,ep]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(V)return ep(!0),()=>ep(!1)},[V]);let em=(0,R.useCallback)((e,t=!0)=>{let r,{disclosureElement:i}=D.getState();if(!(!(r=o())||e&&a(e,r))&&ex(r))return;let l=rf(C)||i;if(null==l?void 0:l.id){let e=n(l),t=`[aria-activedescendant="${l.id}"]`,r=e.querySelector(t);r&&(l=r)}if(l&&!ex(l)){let e=l.closest("[data-dialog]");if(null==e?void 0:e.id){let t=n(e),r=`[aria-controls~="${e.id}"]`,i=t.querySelector(r);i&&(l=i)}}let u=l&&ex(l);!u&&t?requestAnimationFrame(()=>em(e,!1)):!ef(u?l:null)||u&&(null==l||l.focus({preventScroll:!0}))},[D,C,ef]),eh=(0,R.useRef)(!1);H(()=>{if(V||!ed||!ec)return;let e=P.current;eh.current=!0,em(e)},[V,ed,G,ec,em]),(0,R.useEffect)(()=>{if(!ed||!ec)return;let e=P.current;return()=>{if(eh.current){eh.current=!1;return}em(e)}},[ed,ec,em]);let ev=X(m);(0,R.useEffect)(()=>{if(G&&Q)return N("keydown",e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=P.current;if(!t||t9(t))return;let r=e.target;if(!r)return;let{disclosureElement:n}=D.getState();!("BODY"===r.tagName||a(t,r)||!n||a(n,r))||ev(e)&&D.hide()},!0)},[D,G,Q,ev]);let eg=(w=Y(w,e=>(0,eo.jsx)(t$,{level:f?1:void 0,children:e}),[f])).hidden,ey=w.alwaysVisible;w=Y(w,e=>p?(0,eo.jsxs)(eo.Fragment,{children:[(0,eo.jsx)(ru,{store:D,backdrop:p,hidden:eg,alwaysVisible:ey}),e]}):e,[D,p,eg,ey]);let[eb,eS]=(0,R.useState)(),[eC,eE]=(0,R.useState)();return w=tX({...w={id:q,"data-dialog":"",role:"dialog",tabIndex:s?-1:void 0,"aria-labelledby":eb,"aria-describedby":eC,...w=Y(w,e=>(0,eo.jsx)(eX,{value:D,children:(0,eo.jsx)(eY.Provider,{value:eS,children:(0,eo.jsx)(eZ.Provider,{value:eE,children:e})})}),[D]),ref:K(P,w.ref)},autoFocusOnShow:eu}),w=tz({portal:d,...w=eN({...w=tk({store:D,...w}),focusable:s}),portalRef:B,preserveTabOrder:U})});function rp(e,t=eQ){return ea(function(r){let n=t();return t_(r.store||n,e=>!r.unmountOnHide||(null==e?void 0:e.mounted)||!!r.open)?(0,eo.jsx)(e,{...r}):null})}rp(ea(function(e){return eu("div",rd(e))}),eQ);let rm=Math.min,rh=Math.max,rv=Math.round,rg=Math.floor,ry=e=>({x:e,y:e}),rb={left:"right",right:"left",bottom:"top",top:"bottom"},rS={start:"end",end:"start"};function rC(e,t){return"function"==typeof e?e(t):e}function rx(e){return e.split("-")[0]}function rE(e){return e.split("-")[1]}function rA(e){return"x"===e?"y":"x"}function rw(e){return"y"===e?"height":"width"}let r_=new Set(["top","bottom"]);function rT(e){return r_.has(rx(e))?"y":"x"}function rM(e){return e.replace(/start|end/g,e=>rS[e])}let rR=["left","right"],rO=["right","left"],rI=["top","bottom"],rF=["bottom","top"];function rL(e){return e.replace(/left|right|bottom|top/g,e=>rb[e])}function rP(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function rD(e){let{x:t,y:r,width:n,height:i}=e;return{width:n,height:i,top:r,left:t,right:t+n,bottom:r+i,x:t,y:r}}function rB(e,t,r){let n,{reference:i,floating:o}=e,a=rT(t),l=rA(rT(t)),u=rw(l),s=rx(t),c="y"===a,f=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,p=i[u]/2-o[u]/2;switch(s){case"top":n={x:f,y:i.y-o.height};break;case"bottom":n={x:f,y:i.y+i.height};break;case"right":n={x:i.x+i.width,y:d};break;case"left":n={x:i.x-o.width,y:d};break;default:n={x:i.x,y:i.y}}switch(rE(t)){case"start":n[l]-=p*(r&&c?-1:1);break;case"end":n[l]+=p*(r&&c?-1:1)}return n}async function rG(e,t){var r;void 0===t&&(t={});let{x:n,y:i,platform:o,rects:a,elements:l,strategy:u}=e,{boundary:s="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=rC(t,e),m=rP(p),h=l[d?"floating"===f?"reference":"floating":f],v=rD(await o.getClippingRect({element:null==(r=await (null==o.isElement?void 0:o.isElement(h)))||r?h:h.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:s,rootBoundary:c,strategy:u})),g="floating"===f?{x:n,y:i,width:a.floating.width,height:a.floating.height}:a.reference,y=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),b=await (null==o.isElement?void 0:o.isElement(y))&&await (null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},S=rD(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:g,offsetParent:y,strategy:u}):g);return{top:(v.top-S.top+m.top)/b.y,bottom:(S.bottom-v.bottom+m.bottom)/b.y,left:(v.left-S.left+m.left)/b.x,right:(S.right-v.right+m.right)/b.x}}let rk=async(e,t,r)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:a}=r,l=o.filter(Boolean),u=await (null==a.isRTL?void 0:a.isRTL(t)),s=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:f}=rB(s,n,u),d=n,p={},m=0;for(let r=0;rtypeof window}function rq(e){return rW(e)?(e.nodeName||"").toLowerCase():"#document"}function rV(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function rH(e){var t;return null==(t=(rW(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function rW(e){return!!rU()&&(e instanceof Node||e instanceof rV(e).Node)}function rK(e){return!!rU()&&(e instanceof Element||e instanceof rV(e).Element)}function rz(e){return!!rU()&&(e instanceof HTMLElement||e instanceof rV(e).HTMLElement)}function rQ(e){return!(!rU()||"u"{try{return e.matches(t)}catch(e){return!1}})}let r0=["transform","translate","scale","rotate","perspective"],r1=["transform","translate","scale","rotate","perspective","filter"],r2=["paint","layout","strict","content"];function r3(e){let t=r5(),r=rK(e)?r6(e):e;return r0.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||r1.some(e=>(r.willChange||"").includes(e))||r2.some(e=>(r.contain||"").includes(e))}function r5(){return!("u"rK(e)&&"body"!==rq(e)),i=null,o="fixed"===r6(e).position,a=o?r7(e):e;for(;rK(a)&&!r8(a);){let t=r6(a),r=r3(a);r||"fixed"!==t.position||(i=null),(o?!r&&!i:!r&&"static"===t.position&&!!i&&nc.has(i.position)||rX(a)&&!r&&function e(t,r){let n=r7(t);return!(n===r||!rK(n)||r8(n))&&("fixed"===r6(n).position||e(n,r))}(e,a))?n=n.filter(e=>e!==a):i=t,a=r7(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=o[0],l=o.reduce((e,r)=>{let n=nf(t,r,i);return e.top=rh(n.top,e.top),e.right=rm(n.right,e.right),e.bottom=rm(n.bottom,e.bottom),e.left=rh(n.left,e.left),e},nf(t,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:nm,getElementRects:nh,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:r}=nr(e);return{width:t,height:r}},getScale:ni,isElement:rK,isRTL:function(e){return"rtl"===r6(e).direction}};function ng(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ny(e=0,t=0,r=0,n=0){if("function"==typeof DOMRect)return new DOMRect(e,t,r,n);let i={x:e,y:t,width:r,height:n,top:t,right:e+r,bottom:t+n,left:e};return{...i,toJSON:()=>i}}function nb(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function nS(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}var nC=es(function({store:e,modal:t=!1,portal:r=!!t,preserveTabOrder:n=!0,autoFocusOnShow:i=!0,wrapperProps:o,fixed:a=!1,flip:l=!0,shift:u=0,slide:s=!0,overlap:c=!1,sameWidth:f=!1,fitViewport:d=!1,gutter:p,arrowPadding:m=4,overflowPadding:h=8,getAnchorRect:v,updatePosition:g,...y}){let b=e0();A(e=e||b,!1);let S=e.useState("arrowElement"),C=e.useState("anchorElement"),x=e.useState("disclosureElement"),E=e.useState("popoverElement"),w=e.useState("contentElement"),_=e.useState("placement"),T=e.useState("mounted"),M=e.useState("rendered"),O=(0,R.useRef)(null),[I,F]=(0,R.useState)(!1),{portalRef:L,domReady:P}=Z(r,y.portalRef),D=W(v),B=W(g),G=!!g;H(()=>{if(!(null==E?void 0:E.isConnected))return;E.style.setProperty("--popover-overflow-padding",`${h}px`);let t={contextElement:C||void 0,getBoundingClientRect:()=>{let e=null==D?void 0:D(C);return e||!C?function(e){if(!e)return ny();let{x:t,y:r,width:n,height:i}=e;return ny(t,r,n,i)}(e):C.getBoundingClientRect()}},r=async()=>{var r,n,i,o,v;let g,y,b;if(!T)return;S||(O.current=O.current||document.createElement("div"));let C=S||O.current,x=[(r={gutter:p,shift:u},void 0===(n=({placement:e})=>{var t;let n=((null==C?void 0:C.clientHeight)||0)/2,i="number"==typeof r.gutter?r.gutter+n:null!=(t=r.gutter)?t:n;return{crossAxis:e.split("-")[1]?void 0:r.shift,mainAxis:i,alignmentAxis:r.shift}})&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:a,middlewareData:l}=e,u=await rN(e,n);return a===(null==(t=l.offset)?void 0:t.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:a}}}}),function(e){var t;if(!1===e.flip)return;let r="string"==typeof e.flip?e.flip.split(" "):void 0;return A(!r||r.every(nb),!1),{name:"flip",options:t={padding:e.overflowPadding,fallbackPlacements:r},async fn(e){var r,n,i,o,a,l,u,s;let c,f,d,{placement:p,middlewareData:m,rects:h,initialPlacement:v,platform:g,elements:y}=e,{mainAxis:b=!0,crossAxis:S=!0,fallbackPlacements:C,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:A=!0,...w}=rC(t,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let _=rx(p),T=rT(v),M=rx(v)===v,R=await (null==g.isRTL?void 0:g.isRTL(y.floating)),O=C||(M||!A?[rL(v)]:(c=rL(v),[rM(v),c,rM(c)])),I="none"!==E;!C&&I&&O.push(...(f=rE(v),d=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?rO:rR;return t?rR:rO;case"left":case"right":return t?rI:rF;default:return[]}}(rx(v),"start"===E,R),f&&(d=d.map(e=>e+"-"+f),A&&(d=d.concat(d.map(rM)))),d));let F=[v,...O],L=await g.detectOverflow(e,w),P=[],D=(null==(n=m.flip)?void 0:n.overflows)||[];if(b&&P.push(L[_]),S){let e,t,r,n,i=(l=p,u=h,void 0===(s=R)&&(s=!1),e=rE(l),r=rw(t=rA(rT(l))),n="x"===t?e===(s?"end":"start")?"right":"left":"start"===e?"bottom":"top",u.reference[r]>u.floating[r]&&(n=rL(n)),[n,rL(n)]);P.push(L[i[0]],L[i[1]])}if(D=[...D,{placement:p,overflows:P}],!P.every(e=>e<=0)){let e=((null==(i=m.flip)?void 0:i.index)||0)+1,t=F[e];if(t&&("alignment"!==S||T===rT(t)||D.every(e=>rT(e.placement)!==T||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let r=null==(o=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:o.placement;if(!r)switch(x){case"bestFit":{let e=null==(a=D.filter(e=>{if(I){let t=rT(e.placement);return t===T||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:a[0];e&&(r=e);break}case"initialPlacement":r=v}if(p!==r)return{reset:{placement:r}}}return{}}}}({flip:l,overflowPadding:h}),function(e){if(e.slide||e.overlap){var t,r;return{name:"shift",options:r={mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:(void 0===t&&(t={}),{options:t,fn(e){let{x:r,y:n,placement:i,rects:o,middlewareData:a}=e,{offset:l=0,mainAxis:u=!0,crossAxis:s=!0}=rC(t,e),c={x:r,y:n},f=rT(i),d=rA(f),p=c[d],m=c[f],h=rC(l,e),v="number"==typeof h?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(u){let e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+v.mainAxis,r=o.reference[d]+o.reference[e]-v.mainAxis;pr&&(p=r)}if(s){var g,y;let e="y"===d?"width":"height",t=rj.has(rx(i)),r=o.reference[f]-o.floating[e]+(t&&(null==(g=a.offset)?void 0:g[f])||0)+(t?0:v.crossAxis),n=o.reference[f]+o.reference[e]+(t?0:(null==(y=a.offset)?void 0:y[f])||0)-(t?v.crossAxis:0);mn&&(m=n)}return{[d]:p,[f]:m}}})},async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...s}=rC(r,e),c={x:t,y:n},f=await o.detectOverflow(e,s),d=rT(rx(i)),p=rA(d),m=c[p],h=c[d];if(a){let e="y"===p?"top":"left",t="y"===p?"bottom":"right",r=m+f[e],n=m-f[t];m=rh(r,rm(m,n))}if(l){let e="y"===d?"top":"left",t="y"===d?"bottom":"right",r=h+f[e],n=h-f[t];h=rh(r,rm(h,n))}let v=u.fn({...e,[p]:m,[d]:h});return{...v,data:{x:v.x-t,y:v.y-n,enabled:{[p]:a,[d]:l}}}}}}}({slide:s,shift:u,overlap:c,overflowPadding:h}),function(e,t){if(e){let r;return{name:"arrow",options:r={element:e,padding:t.arrowPadding},async fn(e){let{x:t,y:n,placement:i,rects:o,platform:a,elements:l,middlewareData:u}=e,{element:s,padding:c=0}=rC(r,e)||{};if(null==s)return{};let f=rP(c),d={x:t,y:n},p=rA(rT(i)),m=rw(p),h=await a.getDimensions(s),v="y"===p,g=v?"clientHeight":"clientWidth",y=o.reference[m]+o.reference[p]-d[p]-o.floating[m],b=d[p]-o.reference[p],S=await (null==a.getOffsetParent?void 0:a.getOffsetParent(s)),C=S?S[g]:0;C&&await (null==a.isElement?void 0:a.isElement(S))||(C=l.floating[g]||o.floating[m]);let x=C/2-h[m]/2-1,E=rm(f[v?"top":"left"],x),A=rm(f[v?"bottom":"right"],x),w=C-h[m]-A,_=C/2-h[m]/2+(y/2-b/2),T=rh(E,rm(_,w)),M=!u.arrow&&null!=rE(i)&&_!==T&&o.reference[m]/2-(_{},...f}=rC(o,e),d=await u.detectOverflow(e,f),p=rx(a),m=rE(a),h="y"===rT(a),{width:v,height:g}=l.floating;"top"===p||"bottom"===p?(n=p,i=m===(await (null==u.isRTL?void 0:u.isRTL(s.floating))?"start":"end")?"left":"right"):(i=p,n="end"===m?"top":"bottom");let y=g-d.top-d.bottom,b=v-d.left-d.right,S=rm(g-d[n],y),C=rm(v-d[i],b),x=!e.middlewareData.shift,E=S,A=C;if(null!=(t=e.middlewareData.shift)&&t.enabled.x&&(A=b),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(E=y),x&&!m){let e=rh(d.left,0),t=rh(d.right,0),r=rh(d.top,0),n=rh(d.bottom,0);h?A=v-2*(0!==e||0!==t?e+t:rh(d.left,d.right)):E=g-2*(0!==r||0!==n?r+n:rh(d.top,d.bottom))}await c({...e,availableWidth:A,availableHeight:E});let w=await u.getDimensions(s.floating);return v!==w.width||g!==w.height?{reset:{rects:!0}}:{}}}],w=await (v={placement:_,strategy:a?"fixed":"absolute",middleware:x},g=new Map,b={...(y={platform:nv,...v}).platform,_c:g},rk(t,E,{...y,platform:b}));null==e||e.setState("currentPlacement",w.placement),F(!0);let M=nS(w.x),R=nS(w.y);if(Object.assign(E.style,{top:"0",left:"0",transform:`translate3d(${M}px,${R}px,0)`}),C&&w.middlewareData.arrow){let{x:e,y:t}=w.middlewareData.arrow,r=w.placement.split("-")[0],n=C.clientWidth/2,i=C.clientHeight/2,o=null!=e?e+n:-n,a=null!=t?t+i:-i;E.style.setProperty("--popover-transform-origin",{top:`${o}px calc(100% + ${i}px)`,bottom:`${o}px ${-i}px`,left:`calc(100% + ${n}px) ${a}px`,right:`${-n}px ${a}px`}[r]),Object.assign(C.style,{left:null!=e?`${e}px`:"",top:null!=t?`${t}px`:"",[r]:"100%"})}},n=function(e,t,r,n){let i;void 0===n&&(n={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:s=!1}=n,c=nn(e),f=o||a?[...c?ne(c):[],...ne(t)]:[];f.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),a&&e.addEventListener("resize",r)});let d=c&&u?function(e,t){let r,n=null,i=rH(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return!function a(l,u){void 0===l&&(l=!1),void 0===u&&(u=1),o();let s=e.getBoundingClientRect(),{left:c,top:f,width:d,height:p}=s;if(l||t(),!d||!p)return;let m={rootMargin:-rg(f)+"px "+-rg(i.clientWidth-(c+d))+"px "+-rg(i.clientHeight-(f+p))+"px "+-rg(c)+"px",threshold:rh(0,rm(1,u))||1},h=!0;function v(t){let n=t[0].intersectionRatio;if(n!==u){if(!h)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||ng(s,e.getBoundingClientRect())||a(),h=!1}try{n=new IntersectionObserver(v,{...m,root:i.ownerDocument})}catch(e){n=new IntersectionObserver(v,m)}n.observe(e)}(!0),o}(c,r):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),r()}),c&&!s&&m.observe(c),m.observe(t));let h=s?nl(e):null;return s&&function t(){let n=nl(e);h&&!ng(h,n)&&r(),h=n,i=requestAnimationFrame(t)}(),r(),()=>{var e;f.forEach(e=>{o&&e.removeEventListener("scroll",r),a&&e.removeEventListener("resize",r)}),null==d||d(),null==(e=m)||e.disconnect(),m=null,s&&cancelAnimationFrame(i)}}(t,E,async()=>{G?(await B({updatePosition:r}),F(!0)):await r()},{elementResize:"function"==typeof ResizeObserver});return()=>{F(!1),n()}},[e,M,E,S,C,E,_,T,P,a,l,u,s,c,f,d,p,m,h,D,G,B]),H(()=>{if(!T||!P||!(null==E?void 0:E.isConnected)||!(null==w?void 0:w.isConnected))return;let e=()=>{E.style.zIndex=getComputedStyle(w).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[T,P,E,w]);let k=a?"fixed":"absolute";return y=Y(y,t=>(0,eo.jsx)("div",{...o,style:{position:k,top:0,left:0,width:"max-content",...null==o?void 0:o.style},ref:null==e?void 0:e.setPopoverElement,children:t}),[e,k,o]),y={"data-placing":!I||void 0,...y=Y(y,t=>(0,eo.jsx)(e2,{value:e,children:t}),[e]),style:{position:"relative",...y.style}},y=rd({store:e,modal:t,portal:r,preserveTabOrder:n,preserveTabOrderAnchor:x||C,autoFocusOnShow:I&&i,...y,portalRef:L})});rp(ea(function(e){return eu("div",nC(e))}),e0);var nx=es(function({store:e,modal:t,tabIndex:r,alwaysVisible:i,autoFocusOnHide:o=!0,hideOnInteractOutside:a=!0,...l}){let u=e9();A(e=e||u,!1);let s=e.useState("baseElement"),c=(0,R.useRef)(!1),f=t_(e.tag,e=>null==e?void 0:e.renderedItems.length);return l=tN({store:e,alwaysVisible:i,...l}),l=nC({store:e,modal:t,alwaysVisible:i,backdrop:!1,autoFocusOnShow:!1,finalFocus:s,preserveTabOrderAnchor:null,unstable_treeSnapshotKey:f,...l,getPersistentElements(){var r;let i=(null==(r=l.getPersistentElements)?void 0:r.call(l))||[];if(!t||!e)return i;let{contentElement:o,baseElement:a}=e.getState();if(!a)return i;let u=n(a),s=[];if((null==o?void 0:o.id)&&s.push(`[aria-controls~="${o.id}"]`),(null==a?void 0:a.id)&&s.push(`[aria-controls~="${a.id}"]`),!s.length)return[...i,a];let c=s.join(",");return[...i,...u.querySelectorAll(c)]},autoFocusOnHide:e=>!w(o,e)&&(!c.current||(c.current=!1,!1)),hideOnInteractOutside(t){var r,n;let i=null==e?void 0:e.getState(),o=null==(r=null==i?void 0:i.contentElement)?void 0:r.id,l=null==(n=null==i?void 0:i.baseElement)?void 0:n.id;if(function(e,...t){if(!e)return!1;if("id"in e){let r=t.filter(Boolean).map(e=>`[aria-controls~="${e}"]`).join(", ");return!!r&&e.matches(r)}return!1}(t.target,o,l))return!1;let u="function"==typeof a?a(t):a;return u&&(c.current="click"===t.type),u}})}),nE=rp(ea(function(e){return eu("div",nx(e))}),e9);e.s(["ComboboxPopover",()=>nE],1559),(0,R.createContext)(null),(0,R.createContext)(null);var nA=ec([ev],[eg]),nw=nA.useContext;nA.useScopedContext,nA.useProviderContext,nA.ContextProvider,nA.ScopedContextProvider;var n_={id:null};function nT(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function nM(e,t){return e.filter(e=>e.rowId===t)}function nR(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}function nO(e){let t=0;for(let{length:r}of e)r>t&&(t=r);return t}var nI=L()&&I();function nF({tag:e,...t}={}){let r=tf(t.store,function(e,...t){if(e)return tn(e,"pick")(...t)}(e,["value","rtl"]));td(t,r);let i=null==e?void 0:e.getState(),o=null==r?void 0:r.getState(),a=M(t.activeId,null==o?void 0:o.activeId,t.defaultActiveId,null),l=function(e={}){var t;let r=null==(t=e.store)?void 0:t.getState(),i=function(e={}){var t,r;td(e,e.store);let i=null==(t=e.store)?void 0:t.getState(),o=M(e.items,null==i?void 0:i.items,e.defaultItems,[]),a=new Map(o.map(e=>[e.id,e])),l={items:o,renderedItems:M(null==i?void 0:i.renderedItems,[])},u=null==(r=e.store)?void 0:r.__unstablePrivateStore,s=ti({items:o,renderedItems:l.renderedItems},u),c=ti(l,e.store),f=e=>{var t;let r,n,i=(t=e=>e.element,r=e.map((e,t)=>[t,e]),n=!1,(r.sort(([e,r],[i,o])=>{var a;let l=t(r),u=t(o);return l!==u&&l&&u?(a=l,u.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)?(e>i&&(n=!0),-1):(et):e);s.setState("renderedItems",i),c.setState("renderedItems",i)};to(c,()=>ta(s)),to(s,()=>ts(s,["items"],e=>{c.setState("items",e.items)})),to(s,()=>ts(s,["renderedItems"],e=>{let t=!0,r=requestAnimationFrame(()=>{let{renderedItems:t}=c.getState();e.renderedItems!==t&&f(e.renderedItems)});if("function"!=typeof IntersectionObserver)return()=>cancelAnimationFrame(r);let i=new IntersectionObserver(()=>{if(t){t=!1;return}cancelAnimationFrame(r),r=requestAnimationFrame(()=>f(e.renderedItems))},{root:function(e){var t;let r=e.find(e=>!!e.element),i=[...e].reverse().find(e=>!!e.element),o=null==(t=null==r?void 0:r.element)?void 0:t.parentElement;for(;o&&(null==i?void 0:i.element);){let e=o;if(i&&e.contains(i.element))return o;o=o.parentElement}return n(o).body}(e.renderedItems)});for(let t of e.renderedItems)t.element&&i.observe(t.element);return()=>{cancelAnimationFrame(r),i.disconnect()}}));let d=(e,t,r=!1)=>{let n;return t(t=>{let r=t.findIndex(({id:t})=>t===e.id),i=t.slice();if(-1!==r){let o={...n=t[r],...e};i[r]=o,a.set(e.id,o)}else i.push(e),a.set(e.id,e);return i}),()=>{t(t=>{if(!n)return r&&a.delete(e.id),t.filter(({id:t})=>t!==e.id);let i=t.findIndex(({id:t})=>t===e.id);if(-1===i)return t;let o=t.slice();return o[i]=n,a.set(e.id,n),o})}},p=e=>d(e,e=>s.setState("items",e),!0);return{...c,registerItem:p,renderItem:e=>x(p(e),d(e,e=>s.setState("renderedItems",e))),item:e=>{if(!e)return null;let t=a.get(e);if(!t){let{items:r}=s.getState();(t=r.find(t=>t.id===e))&&a.set(e,t)}return t||null},__unstablePrivateStore:s}}(e),o=M(e.activeId,null==r?void 0:r.activeId,e.defaultActiveId),a=ti({...i.getState(),id:M(e.id,null==r?void 0:r.id,`id-${Math.random().toString(36).slice(2,8)}`),activeId:o,baseElement:M(null==r?void 0:r.baseElement,null),includesBaseElement:M(e.includesBaseElement,null==r?void 0:r.includesBaseElement,null===o),moves:M(null==r?void 0:r.moves,0),orientation:M(e.orientation,null==r?void 0:r.orientation,"both"),rtl:M(e.rtl,null==r?void 0:r.rtl,!1),virtualFocus:M(e.virtualFocus,null==r?void 0:r.virtualFocus,!1),focusLoop:M(e.focusLoop,null==r?void 0:r.focusLoop,!1),focusWrap:M(e.focusWrap,null==r?void 0:r.focusWrap,!1),focusShift:M(e.focusShift,null==r?void 0:r.focusShift,!1)},i,e.store);to(a,()=>tu(a,["renderedItems","activeId"],e=>{a.setState("activeId",t=>{var r;return void 0!==t?t:null==(r=nT(e.renderedItems))?void 0:r.id})}));let l=(e="next",t={})=>{var r,n;let i=a.getState(),{skip:o=0,activeId:l=i.activeId,focusShift:u=i.focusShift,focusLoop:s=i.focusLoop,focusWrap:c=i.focusWrap,includesBaseElement:f=i.includesBaseElement,renderedItems:d=i.renderedItems,rtl:p=i.rtl}=t,m="up"===e||"down"===e,h="next"===e||"down"===e,v=m?eU(function(e,t,r){let n=nO(e);for(let i of e)for(let e=0;ee.id===l);if(!g)return null==(n=nT(v))?void 0:n.id;let y=v.some(e=>e.rowId),b=v.indexOf(g),S=v.slice(b+1),C=nM(S,g.rowId);if(o){let e=C.filter(e=>l?!e.disabled&&e.id!==l:!e.disabled),t=e.slice(o)[0]||e[e.length-1];return null==t?void 0:t.id}let x=s&&(m?"horizontal"!==s:"vertical"!==s),E=y&&c&&(m?"horizontal"!==c:"vertical"!==c),A=h?(!y||m)&&x&&f:!!m&&f;if(x){let e=nT(function(e,t,r=!1){let n=e.findIndex(e=>e.id===t);return[...e.slice(n+1),...r?[n_]:[],...e.slice(0,n)]}(E&&!A?v:nM(v,g.rowId),l,A),l);return null==e?void 0:e.id}if(E){let e=nT(A?C:S,l);return A?(null==e?void 0:e.id)||null:null==e?void 0:e.id}let w=nT(C,l);return!w&&A?null:null==w?void 0:w.id};return{...i,...a,setBaseElement:e=>a.setState("baseElement",e),setActiveId:e=>a.setState("activeId",e),move:e=>{void 0!==e&&(a.setState("activeId",e),a.setState("moves",e=>e+1))},first:()=>{var e;return null==(e=nT(a.getState().renderedItems))?void 0:e.id},last:()=>{var e;return null==(e=nT(eq(a.getState().renderedItems)))?void 0:e.id},next:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("next",e)),previous:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("previous",e)),down:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("down",e)),up:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("up",e))}}({...t,activeId:a,includesBaseElement:M(t.includesBaseElement,null==o?void 0:o.includesBaseElement,!0),orientation:M(t.orientation,null==o?void 0:o.orientation,"vertical"),focusLoop:M(t.focusLoop,null==o?void 0:o.focusLoop,!0),focusWrap:M(t.focusWrap,null==o?void 0:o.focusWrap,!0),virtualFocus:M(t.virtualFocus,null==o?void 0:o.virtualFocus,!0)}),u=function({popover:e,...t}={}){let r=tf(t.store,tc(e,["arrowElement","anchorElement","contentElement","popoverElement","disclosureElement"]));td(t,r);let n=null==r?void 0:r.getState(),i=rs({...t,store:r}),o=M(t.placement,null==n?void 0:n.placement,"bottom"),a=ti({...i.getState(),placement:o,currentPlacement:o,anchorElement:M(null==n?void 0:n.anchorElement,null),popoverElement:M(null==n?void 0:n.popoverElement,null),arrowElement:M(null==n?void 0:n.arrowElement,null),rendered:Symbol("rendered")},i,r);return{...i,...a,setAnchorElement:e=>a.setState("anchorElement",e),setPopoverElement:e=>a.setState("popoverElement",e),setArrowElement:e=>a.setState("arrowElement",e),render:()=>a.setState("rendered",Symbol("rendered"))}}({...t,placement:M(t.placement,null==o?void 0:o.placement,"bottom-start")}),s=M(t.value,null==o?void 0:o.value,t.defaultValue,""),c=M(t.selectedValue,null==o?void 0:o.selectedValue,null==i?void 0:i.values,t.defaultSelectedValue,""),f=Array.isArray(c),d={...l.getState(),...u.getState(),value:s,selectedValue:c,resetValueOnSelect:M(t.resetValueOnSelect,null==o?void 0:o.resetValueOnSelect,f),resetValueOnHide:M(t.resetValueOnHide,null==o?void 0:o.resetValueOnHide,f&&!e),activeValue:null==o?void 0:o.activeValue},p=ti(d,l,u,r);return nI&&to(p,()=>tu(p,["virtualFocus"],()=>{p.setState("virtualFocus",!1)})),to(p,()=>{if(e)return x(tu(p,["selectedValue"],t=>{Array.isArray(t.selectedValue)&&e.setValues(t.selectedValue)}),tu(e,["values"],e=>{p.setState("selectedValue",e.values)}))}),to(p,()=>tu(p,["resetValueOnHide","mounted"],e=>{!e.resetValueOnHide||e.mounted||p.setState("value",s)})),to(p,()=>tu(p,["open"],e=>{e.open||(p.setState("activeId",a),p.setState("moves",0))})),to(p,()=>tu(p,["moves","activeId"],(e,t)=>{e.moves===t.moves&&p.setState("activeValue",void 0)})),to(p,()=>ts(p,["moves","renderedItems"],(e,t)=>{if(e.moves===t.moves)return;let{activeId:r}=p.getState(),n=l.item(r);p.setState("activeValue",null==n?void 0:n.value)})),{...u,...l,...p,tag:e,setValue:e=>p.setState("value",e),resetValue:()=>p.setState("value",d.value),setSelectedValue:e=>p.setState("selectedValue",e)}}function nL(e={}){var t,r,n,i,o,a,l,u;let s;t=e,s=nw();let[c,f]=tR(nF,e={id:z((r=t={...t,tag:void 0!==t.tag?t.tag:s}).id),...r});return Q(f,[(n=e).tag]),tM(c,n,"value","setValue"),tM(c,n,"selectedValue","setSelectedValue"),tM(c,n,"resetValueOnHide"),tM(c,n,"resetValueOnSelect"),Object.assign((a=c,Q(l=f,[(u=n).popover]),tM(a,u,"placement"),i=ra(a,l,u),o=i,Q(f,[n.store]),tM(o,n,"items","setItems"),tM(i=o,n,"activeId","setActiveId"),tM(i,n,"includesBaseElement"),tM(i,n,"virtualFocus"),tM(i,n,"orientation"),tM(i,n,"rtl"),tM(i,n,"focusLoop"),tM(i,n,"focusWrap"),tM(i,n,"focusShift"),i),{tag:n.tag})}function nP(e={}){let t=nL(e);return(0,eo.jsx)(e7,{value:t,children:e.children})}e.s(["useComboboxStore",()=>nL],18364),e.s(["ComboboxProvider",()=>nP],78440);var nD=(0,R.createContext)(void 0),nB=es(function(e){let[t,r]=(0,R.useState)();return T(e={role:"group","aria-labelledby":t,...e=Y(e,e=>(0,eo.jsx)(nD.Provider,{value:r,children:e}),[])})});ea(function(e){return eu("div",nB(e))});var nG=es(function({store:e,...t}){return nB(t)});ea(function(e){return eu("div",nG(e))});var nk=es(function({store:e,...t}){let r=e6();return A(e=e||r,!1),"grid"===m(e.useState("contentElement"))&&(t={role:"rowgroup",...t}),t=nG({store:e,...t})}),nj=ea(function(e){return eu("div",nk(e))});e.s(["ComboboxGroup",()=>nj],59129);var nN=es(function(e){let t=(0,R.useContext)(nD),r=z(e.id);return H(()=>(null==t||t(r),()=>null==t?void 0:t(void 0)),[t,r]),T(e={id:r,"aria-hidden":!0,...e})});ea(function(e){return eu("div",nN(e))});var nU=es(function({store:e,...t}){return nN(t)});ea(function(e){return eu("div",nU(e))});var nq=es(function(e){return nU(e)}),nV=ea(function(e){return eu("div",nq(e))});e.s(["ComboboxGroupLabel",()=>nV],25998);var nH=e.i(38360);let nW={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},nK=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function nz(e,t,r={}){let{keys:n,threshold:i=nW.MATCHES,baseSort:o=nK,sorter:a=e=>e.sort((e,t)=>(function(e,t,r){let{rank:n,keyIndex:i}=e,{rank:o,keyIndex:a}=t;return n!==o?n>o?-1:1:i===a?r(e,t):i{let l=nQ(i,s,c),u=t,{minRanking:f,maxRanking:d,threshold:p}=o;return l=nW.MATCHES?l=f:l>d&&(l=d),l>e&&(e=l,r=a,n=p,u=i),{rankedValue:u,rank:e,keyIndex:r,keyThreshold:n}},{rankedValue:l,rank:nW.NO_MATCH,keyIndex:-1,keyThreshold:c.threshold}):{rankedValue:l,rank:nQ(l,s,c),keyIndex:-1,keyThreshold:c.threshold}),{rank:d,keyThreshold:p=i}=f;return d>=p&&e.push({...f,item:o,index:a}),e},[])).map(({item:e})=>e)}function nQ(e,t,r){if(e=n$(e,r),(t=n$(t,r)).length>e.length)return nW.NO_MATCH;if(e===t)return nW.CASE_SENSITIVE_EQUAL;let n=function*(e,t){let r=-1;for(;(r=e.indexOf(t,r+1))>-1;)yield r;return -1}(e=e.toLowerCase(),t=t.toLowerCase()),i=n.next(),o=i.value;if(e.length===t.length&&0===o)return nW.EQUAL;if(0===o)return nW.STARTS_WITH;let a=i;for(;!a.done;){if(a.value>0&&" "===e[a.value-1])return nW.WORD_STARTS_WITH;a=n.next()}return o>0?nW.CONTAINS:1===t.length?nW.NO_MATCH:(function(e){let t="",r=" ";for(let n=0;n-1))return nW.NO_MATCH;return r=o-l,n=i/t.length,nW.MATCHES+1/r*n}(e,t)}function n$(e,{keepDiacritics:t}){return e=`${e}`,t||(e=(0,nH.default)(e)),e}nz.rankings=nW;let nX={maxRanking:1/0,minRanking:-1/0};e.s(["matchSorter",()=>nz],70238)},29402,(e,t,r)=>{var n,i,o,a,l="__lodash_hash_undefined__",u=1/0,s="[object Arguments]",c="[object Array]",f="[object Boolean]",d="[object Date]",p="[object Error]",m="[object Function]",h="[object Map]",v="[object Number]",g="[object Object]",y="[object Promise]",b="[object RegExp]",S="[object Set]",C="[object String]",x="[object Symbol]",E="[object WeakMap]",A="[object ArrayBuffer]",w="[object DataView]",_=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,T=/^\w*$/,M=/^\./,R=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,I=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[s]=L[c]=L[A]=L[f]=L[w]=L[d]=L[p]=L[m]=L[h]=L[v]=L[g]=L[b]=L[S]=L[C]=L[E]=!1;var P=e.g&&e.g.Object===Object&&e.g,D="object"==typeof self&&self&&self.Object===Object&&self,B=P||D||Function("return this")(),G=r&&!r.nodeType&&r,k=G&&t&&!t.nodeType&&t,j=k&&k.exports===G&&P.process,N=function(){try{return j&&j.binding("util")}catch(e){}}(),U=N&&N.isTypedArray;function q(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},ex.prototype.set=function(e,t){var r=this.__data__,n=e_(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},eE.prototype.clear=function(){this.__data__={hash:new eC,map:new(eu||ex),string:new eC}},eE.prototype.delete=function(e){return eP(this,e).delete(e)},eE.prototype.get=function(e){return eP(this,e).get(e)},eE.prototype.has=function(e){return eP(this,e).has(e)},eE.prototype.set=function(e,t){return eP(this,e).set(e,t),this},eA.prototype.add=eA.prototype.push=function(e){return this.__data__.set(e,l),this},eA.prototype.has=function(e){return this.__data__.has(e)},ew.prototype.clear=function(){this.__data__=new ex},ew.prototype.delete=function(e){return this.__data__.delete(e)},ew.prototype.get=function(e){return this.__data__.get(e)},ew.prototype.has=function(e){return this.__data__.has(e)},ew.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ex){var n=r.__data__;if(!eu||n.length<199)return n.push([e,t]),this;r=this.__data__=new eE(n)}return r.set(e,t),this};var eT=(n=function(e,t){return e&&eM(e,t,e0)},function(e,t){if(null==e)return e;if(!ez(e))return n(e,t);for(var r=e.length,i=-1,o=Object(e);++il))return!1;var s=o.get(e);if(s&&o.get(t))return s==t;var c=-1,f=!0,d=1&i?new eA:void 0;for(o.set(e,t),o.set(t,e);++c-1&&e%1==0&&e-1&&e%1==0&&e<=0x1fffffffffffff}function eX(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eY(e){return!!e&&"object"==typeof e}function eZ(e){return"symbol"==typeof e||eY(e)&&ee.call(e)==x}var eJ=U?V(U):function(e){return eY(e)&&e$(e.length)&&!!L[ee.call(e)]};function e0(e){return ez(e)?function(e,t){var r=eK(e)||eW(e)?function(e,t){for(var r=-1,n=Array(e);++rt||o&&a&&u&&!l&&!s||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!s&&e=l)return u;return u*("desc"==r[n]?-1:1)}}return e.index-t.index}(e,t,r)});u--;)l[u]=l[u].value;return l}(e,t,r))}},97442,e=>{e.v({Group:"MissionSelect-module__N_AIjG__Group",GroupLabel:"MissionSelect-module__N_AIjG__GroupLabel",Input:"MissionSelect-module__N_AIjG__Input",InputWrapper:"MissionSelect-module__N_AIjG__InputWrapper",Item:"MissionSelect-module__N_AIjG__Item",ItemHeader:"MissionSelect-module__N_AIjG__ItemHeader",ItemMissionName:"MissionSelect-module__N_AIjG__ItemMissionName",ItemName:"MissionSelect-module__N_AIjG__ItemName",ItemType:"MissionSelect-module__N_AIjG__ItemType",ItemTypes:"MissionSelect-module__N_AIjG__ItemTypes",List:"MissionSelect-module__N_AIjG__List",NoResults:"MissionSelect-module__N_AIjG__NoResults",Popover:"MissionSelect-module__N_AIjG__Popover",SelectedName:"MissionSelect-module__N_AIjG__SelectedName",SelectedValue:"MissionSelect-module__N_AIjG__SelectedValue",Shortcut:"MissionSelect-module__N_AIjG__Shortcut"})},81405,(e,t,r)=>{var n;e.e,(n=function(){function e(e){return i.appendChild(e.dom),e}function t(e){for(var t=0;ta+1e3&&(u.update(1e3*l/(e-a),100),a=e,l=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:i,setMode:t}}).Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),l=80*a,u=48*a,s=3*a,c=2*a,f=3*a,d=15*a,p=74*a,m=30*a,h=document.createElement("canvas");h.width=l,h.height=u,h.style.cssText="width:80px;height:48px";var v=h.getContext("2d");return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,l,u),v.fillStyle=t,v.fillText(e,s,c),v.fillRect(f,d,p,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(f,d,p,m),{dom:h,update:function(u,g){n=Math.min(n,u),i=Math.max(i,u),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,l,d),v.fillStyle=t,v.fillText(o(u)+" "+e+" ("+o(n)+"-"+o(i)+")",s,c),v.drawImage(h,f+a,d,p-a,m,f,d,p-a,m),v.fillRect(f+p-a,d,a,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(f+p-a,d,a,o((1-u/g)*m))}}},t.exports=n},55141,e=>{e.v({AxisLabel:"DebugElements-module__Cmeo9W__AxisLabel",StatsPanel:"DebugElements-module__Cmeo9W__StatsPanel"})},86855,e=>{"use strict";var t=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(40859),i=i,o=i,a=e.i(81405);function l(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}function u({showPanel:e=0,className:t,parent:r}){let u=function(e,t=[],r){let[i,o]=n.useState();return n.useLayoutEffect(()=>{let t=e();return o(t),l(void 0,t),()=>l(void 0,null)},t),i}(()=>new a.default,[]);return n.useEffect(()=>{if(u){let n=r&&r.current||document.body;u.showPanel(e),null==n||n.appendChild(u.dom);let a=(null!=t?t:"").split(" ").filter(e=>e);a.length&&u.dom.classList.add(...a);let l=(0,i.j)(()=>u.begin()),s=(0,o.k)(()=>u.end());return()=>{a.length&&u.dom.classList.remove(...a),null==n||n.removeChild(u.dom),l(),s()}}},[r,u,t,e]),null}var s=e.i(60099),c=e.i(79123),f=e.i(55141);function d(){let e,i,o=(0,r.c)(3),{debugMode:a}=(0,c.useDebug)(),l=(0,n.useRef)(null);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=l.current;e&&e.setColors("rgb(153, 255, 0)","rgb(0, 153, 255)","rgb(255, 153, 0)")},o[0]=e):e=o[0],(0,n.useEffect)(e),o[1]!==a?(i=a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{className:f.default.StatsPanel}),(0,t.jsx)("axesHelper",{ref:l,args:[70],renderOrder:999,children:(0,t.jsx)("lineBasicMaterial",{depthTest:!1,depthWrite:!1,fog:!1,vertexColors:!0})}),(0,t.jsx)(s.Html,{position:[80,0,0],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"y",children:"Y"})}),(0,t.jsx)(s.Html,{position:[0,80,0],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"z",children:"Z"})}),(0,t.jsx)(s.Html,{position:[0,0,80],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"x",children:"X"})})]}):null,o[1]=a,o[2]=i):i=o[2],i}e.s(["DebugElements",()=>d],86855)},38847,e=>{"use strict";var t=e.i(80902),r=e.i(22289),n=e.i(71645);function i(e,t,n){try{return e(t)}catch(e){return(0,r.l)("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":""),t,e,n),null}}function o(e){function t(t){if(void 0===t)return null;let r="";if(Array.isArray(t)){if(void 0===t[0])return null;r=t[0]}return"string"==typeof t&&(r=t),i(e.parse,r)}return{type:"single",eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide:r=>t(r)??e}},withOptions(e){return{...this,...e}}}}let a=o({parse:e=>e,serialize:String});o({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),o({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),o({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(1&t.length?"0":"")+t}}),o({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});let l=o({parse:e=>"true"===e.toLowerCase(),serialize:String});function u(e,t){return e.valueOf()===t.valueOf()}o({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:u}),o({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:u}),o({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:u});let s=(0,t.r)(),c={};function f(e,r,n,o,a,l){let u=!1,s=Object.entries(e).reduce((e,[s,c])=>{var f;let d=r?.[s]??s,p=o[d],m="multi"===c.type?[]:null,h=void 0===p?("multi"===c.type?n?.getAll(d):n?.get(d))??m:p;return a&&l&&((f=a[d]??m)===h||null!==f&&null!==h&&"string"!=typeof f&&"string"!=typeof h&&f.length===h.length&&f.every((e,t)=>e===h[t]))?e[s]=l[s]??null:(u=!0,e[s]=((0,t.i)(h)?null:i(c.parse,h,d))??null,a&&(a[d]=h)),e},{});if(!u){let t=Object.keys(e),r=Object.keys(l??{});u=t.length!==r.length||t.some(e=>!r.includes(e))}return{state:s,hasChanged:u}}function d(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,e[r]??t[r]??null]))}function p(e,i={}){let{parse:o,type:a,serialize:l,eq:u,defaultValue:m,...h}=i,[{[e]:v},g]=function(e,i={}){let o=(0,n.useId)(),a=(0,r.i)(),l=(0,r.a)(),{history:u="replace",scroll:p=a?.scroll??!1,shallow:m=a?.shallow??!0,throttleMs:h=t.s.timeMs,limitUrlUpdates:v=a?.limitUrlUpdates,clearOnDefault:g=a?.clearOnDefault??!0,startTransition:y,urlKeys:b=c}=i,S=Object.keys(e).join(","),C=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(e=>[e,b[e]??e])),[S,JSON.stringify(b)]),x=(0,r.r)(Object.values(C)),E=x.searchParams,A=(0,n.useRef)({}),w=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(t=>[t,e[t].defaultValue??null])),[Object.values(e).map(({defaultValue:e})=>e).join(",")]),_=t.t.useQueuedQueries(Object.values(C)),[T,M]=(0,n.useState)(()=>f(e,b,E??new URLSearchParams,_).state),R=(0,n.useRef)(T);if((0,r.c)("[nuq+ %s `%s`] render - state: %O, iSP: %s",o,S,T,E),Object.keys(A.current).join("&")!==Object.values(C).join("&")){let{state:t,hasChanged:n}=f(e,b,E,_,A.current,R.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,S,{state:t,initialSearchParams:E,queuedQueries:_,queryRef:A.current,stateRef:R.current}),R.current=t,M(t)),A.current=Object.fromEntries(Object.entries(C).map(([t,r])=>[r,e[t]?.type==="multi"?E?.getAll(r):E?.get(r)??null]))}(0,n.useEffect)(()=>{let{state:t,hasChanged:n}=f(e,b,E,_,A.current,R.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,S,{state:t,initialSearchParams:E,queuedQueries:_,queryRef:A.current,stateRef:R.current}),R.current=t,M(t))},[Object.values(C).map(e=>`${e}=${E?.getAll(e)}`).join("&"),JSON.stringify(_)]),(0,n.useEffect)(()=>{let t=Object.keys(e).reduce((t,n)=>(t[n]=({state:t,query:i})=>{M(a=>{let{defaultValue:l}=e[n],u=C[n],s=t??l??null;return Object.is(a[n]??l??null,s)?((0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",o,S,u,t,l,R.current),a):(R.current={...R.current,[n]:s},A.current[u]=i,(0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",o,S,u,t,l,R.current),R.current)})},t),{});for(let n of Object.keys(e)){let e=C[n];(0,r.c)("[nuq+ %s `%s`] Subscribing to sync for `%s`",o,e,S),s.on(e,t[n])}return()=>{for(let n of Object.keys(e)){let e=C[n];(0,r.c)("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",o,e,S),s.off(e,t[n])}}},[S,C]);let O=(0,n.useCallback)((n,i={})=>{let a,c=Object.fromEntries(Object.keys(e).map(e=>[e,null])),f="function"==typeof n?n(d(R.current,w))??c:n??c;(0,r.c)("[nuq+ %s `%s`] setState: %O",o,S,f);let b=0,E=!1,A=[];for(let[n,o]of Object.entries(f)){let c=e[n],f=C[n];if(!c||void 0===o)continue;(i.clearOnDefault??c.clearOnDefault??g)&&null!==o&&void 0!==c.defaultValue&&(c.eq??((e,t)=>e===t))(o,c.defaultValue)&&(o=null);let d=null===o?null:(c.serialize??String)(o);s.emit(f,{state:o,query:d});let S={key:f,query:d,options:{history:i.history??c.history??u,shallow:i.shallow??c.shallow??m,scroll:i.scroll??c.scroll??p,startTransition:i.startTransition??c.startTransition??y}};if(i?.limitUrlUpdates?.method==="debounce"||v?.method==="debounce"||c.limitUrlUpdates?.method==="debounce"){!0===S.options.shallow&&console.warn((0,r.s)(422));let e=i?.limitUrlUpdates?.timeMs??v?.timeMs??c.limitUrlUpdates?.timeMs??t.s.timeMs,n=t.t.push(S,e,x,l);bt(e),E?t.n.flush(x,l):t.n.getPendingPromise(x));return a??_},[S,u,m,p,h,v?.method,v?.timeMs,y,C,x.updateUrl,x.getSearchParamsSnapshot,x.rateLimitFactor,l,w]);return[(0,n.useMemo)(()=>d(T,w),[T,w]),O]}({[e]:{parse:o??(e=>e),type:a,serialize:l,eq:u,defaultValue:m}},h);return[v,(0,n.useCallback)((t,r={})=>g(r=>({[e]:"function"==typeof t?t(r[e]):t}),r),[e,g])]}e.s(["createParser",()=>o,"parseAsBoolean",()=>l,"parseAsString",()=>a,"useQueryState",()=>p],38847)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/07f1e4bb8e7d8066.js b/docs/_next/static/chunks/07f1e4bb8e7d8066.js deleted file mode 100644 index bf893e01..00000000 --- a/docs/_next/static/chunks/07f1e4bb8e7d8066.js +++ /dev/null @@ -1 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66027,t=>{"use strict";var e=t.i(69230),r=t.i(69637);function c(t,c){return(0,r.useBaseQuery)(t,e.QueryObserver,c)}t.s(["useQuery",()=>c])},11152,40141,t=>{"use strict";var e=t.i(71645),r={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},c=e.default.createContext&&e.default.createContext(r),n=["attr","size","title"];function o(){return(o=Object.assign.bind()).apply(this,arguments)}function i(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);e&&(c=c.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,c)}return r}function l(t){for(var e=1;ee.default.createElement(u,o({attr:l({},t.attr)},r),function t(r){return r&&r.map((r,c)=>e.default.createElement(r.tag,l({key:c},r.attr),t(r.child)))}(t.child))}function u(t){var i=r=>{var c,{attr:i,size:a,title:u}=t,s=function(t,e){if(null==t)return{};var r,c,n=function(t,e){if(null==t)return{};var r={};for(var c in t)if(Object.prototype.hasOwnProperty.call(t,c)){if(e.indexOf(c)>=0)continue;r[c]=t[c]}return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(c=0;c=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(t,n),f=a||r.size||"1em";return r.className&&(c=r.className),t.className&&(c=(c?c+" ":"")+t.className),e.default.createElement("svg",o({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,i,s,{className:c,style:l(l({color:t.color||r.color},r.style),t.style),height:f,width:f,xmlns:"http://www.w3.org/2000/svg"}),u&&e.default.createElement("title",null,u),t.children)};return void 0!==c?e.default.createElement(c.Consumer,null,t=>i(t)):i(r)}function s(t){return a({tag:"svg",attr:{viewBox:"0 0 288 512"},child:[{tag:"path",attr:{d:"M112 316.94v156.69l22.02 33.02c4.75 7.12 15.22 7.12 19.97 0L176 473.63V316.94c-10.39 1.92-21.06 3.06-32 3.06s-21.61-1.14-32-3.06zM144 0C64.47 0 0 64.47 0 144s64.47 144 144 144 144-64.47 144-144S223.53 0 144 0zm0 76c-37.5 0-68 30.5-68 68 0 6.62-5.38 12-12 12s-12-5.38-12-12c0-50.73 41.28-92 92-92 6.62 0 12 5.38 12 12s-5.38 12-12 12z"},child:[]}]})(t)}function f(t){return a({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zM461.64 256l45.64-45.64c6.3-6.3 6.3-16.52 0-22.82l-22.82-22.82c-6.3-6.3-16.52-6.3-22.82 0L416 210.36l-45.64-45.64c-6.3-6.3-16.52-6.3-22.82 0l-22.82 22.82c-6.3 6.3-6.3 16.52 0 22.82L370.36 256l-45.63 45.63c-6.3 6.3-6.3 16.52 0 22.82l22.82 22.82c6.3 6.3 16.52 6.3 22.82 0L416 301.64l45.64 45.64c6.3 6.3 16.52 6.3 22.82 0l22.82-22.82c6.3-6.3 6.3-16.52 0-22.82L461.64 256z"},child:[]}]})(t)}function p(t){return a({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"},child:[]}]})(t)}t.s(["GenIcon",()=>a],40141),t.s(["FaMapPin",()=>s,"FaVolumeMute",()=>f,"FaVolumeUp",()=>p],11152)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/0be79f7f5e0597a7.css b/docs/_next/static/chunks/0be79f7f5e0597a7.css deleted file mode 100644 index 9103a7c8..00000000 --- a/docs/_next/static/chunks/0be79f7f5e0597a7.css +++ /dev/null @@ -1,2 +0,0 @@ -.GuiMarkup-module__CLgNnq__GuiMarkup{white-space:pre-wrap;font-size:14px;line-height:1.5}.GuiMarkup-module__CLgNnq__GuiMarkup a{color:inherit;text-decoration:underline}.GuiMarkup-module__CLgNnq__Bullet{margin-left:.5em;margin-right:.5em} -.MapInfoDialog-module__m0lXla__Dialog{color:#bccec3;-webkit-user-select:text;user-select:text;-webkit-touch-callout:default;background:#142526cc;border:1px solid #41838b99;border-radius:4px;outline:none;grid-template-rows:1fr auto;grid-template-columns:100%;width:800px;max-width:calc(100dvw - 40px);height:600px;max-height:calc(100dvh - 40px);font-size:14px;line-height:1.5;display:grid;position:relative;overflow:hidden;box-shadow:0 0 50px #0006,inset 0 0 60px #01070d99}.MapInfoDialog-module__m0lXla__Overlay{z-index:10;background:#000000b3;justify-content:center;align-items:center;padding:20px;display:flex;position:fixed;inset:0}.MapInfoDialog-module__m0lXla__Body{grid-template-rows:100%;grid-template-columns:1fr auto;min-height:0;display:grid;overflow:hidden}.MapInfoDialog-module__m0lXla__Left{padding:24px 28px;overflow-y:auto}.MapInfoDialog-module__m0lXla__PreviewImage{border-left:1px solid #00bedc40;height:100%;display:block}.MapInfoDialog-module__m0lXla__PreviewImageFloating{float:right;clear:right;width:auto;max-width:30%;max-height:260px;margin:0 0 16px 20px;display:block}.MapInfoDialog-module__m0lXla__Title{color:#7dffff;text-shadow:0 1px 6px #0006;margin:0;font-size:26px;font-weight:500}.MapInfoDialog-module__m0lXla__MapMeta{flex-wrap:wrap;gap:8px 16px;margin-bottom:4px;font-size:15px;font-weight:400;display:flex}.MapInfoDialog-module__m0lXla__MapPlanet{color:#dbcaa8b3}.MapInfoDialog-module__m0lXla__MapQuote{border-left:2px solid #00bedc59;margin:16px 0;padding:0 0 0 14px;font-style:italic}.MapInfoDialog-module__m0lXla__MapQuote p{white-space:pre-line;margin:0 0 4px}.MapInfoDialog-module__m0lXla__MapQuote cite{color:#ffffff73;font-size:12px;font-style:normal;display:block}.MapInfoDialog-module__m0lXla__MapBlurb{margin:0 0 16px;font-size:13px}.MapInfoDialog-module__m0lXla__Section{margin-top:20px}.MapInfoDialog-module__m0lXla__SectionTitle{color:#7dffff;letter-spacing:.04em;text-transform:uppercase;text-shadow:0 0 16px #00d2f040;margin:0 0 8px;font-size:16px;font-weight:500}.MapInfoDialog-module__m0lXla__MusicTrack{color:#cad0ac80;align-items:center;gap:6px;margin-top:16px;font-size:14px;font-style:italic;display:flex}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true]{color:#f7fdd8b3}.MapInfoDialog-module__m0lXla__MusicButton{cursor:pointer;color:#557663;opacity:.5;background:0 0;border:0;border-radius:20px;flex-shrink:0;place-content:center;width:32px;height:32px;padding:0;font-size:20px;font-style:normal;line-height:1;display:grid}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true] .MapInfoDialog-module__m0lXla__MusicButton{color:#6dffaa;opacity:1}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true] .MapInfoDialog-module__m0lXla__MusicButton:hover{opacity:.7}.MapInfoDialog-module__m0lXla__Footer{background:#021415b3;border-top:1px solid #00bedc40;flex-shrink:0;align-items:center;gap:16px;padding:10px 12px;display:flex}.MapInfoDialog-module__m0lXla__CloseButton{color:#9aefe1e6;text-shadow:0 -1px #00000080;cursor:pointer;background:linear-gradient(#29ac9cb3,#005041b3);border:1px solid #29615499;border-top-color:#65b9b080;border-radius:3px;padding:4px 18px;font-size:14px;font-weight:500;box-shadow:inset 0 1px #78dcc333,inset 0 -1px #0000004d,0 2px 4px #0006}.MapInfoDialog-module__m0lXla__CloseButton:active{transform:translateY(1px)}.MapInfoDialog-module__m0lXla__Hint{color:#c9dcd84d;margin-left:auto;font-size:12px}.MapInfoDialog-module__m0lXla__MusicTrackName{text-transform:capitalize}@media (max-width:719px){.MapInfoDialog-module__m0lXla__Body{display:block;overflow:auto}.MapInfoDialog-module__m0lXla__Hint{display:none}.MapInfoDialog-module__m0lXla__Left{width:100%;height:auto;margin:0;padding:16px 20px;overflow:auto}.MapInfoDialog-module__m0lXla__PreviewImage{width:auto;height:auto;margin:16px auto}.MapInfoDialog-module__m0lXla__CloseButton{width:220px;height:36px;margin:0 auto}} diff --git a/docs/_next/static/chunks/0c29da8d7ee18a67.js b/docs/_next/static/chunks/0c29da8d7ee18a67.js new file mode 100644 index 00000000..ba05abd0 --- /dev/null +++ b/docs/_next/static/chunks/0c29da8d7ee18a67.js @@ -0,0 +1,89 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,21500,e=>{"use strict";var t=e.i(43476),i=e.i(932),r=e.i(32865),a=e.i(71645),o=e.i(71753),n=e.i(78140),l=e.i(90072),s=e.i(85557),c=e.i(12979),u=e.i(15080),d=e.i(75567);let m=Math.PI/180,p=Math.PI/18e4;function f(e,t,i){let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:i}function h(e,t,i){let r=e[t];return"boolean"==typeof r?r:"number"==typeof r?0!==r:i}function g(e,t){let i,r=e.particles;if(Array.isArray(r)){for(let e of r)if("number"==typeof e&&(i=t(e)))break}return i?{ejectionPeriodMS:f(e,"ejectionPeriodMS",100),periodVarianceMS:f(e,"periodVarianceMS",0),ejectionVelocity:.01*f(e,"ejectionVelocity",200),velocityVariance:.01*f(e,"velocityVariance",100),ejectionOffset:.01*f(e,"ejectionOffset",0),thetaMin:f(e,"thetaMin",0),thetaMax:f(e,"thetaMax",90),phiReferenceVel:f(e,"phiReferenceVel",0),phiVariance:f(e,"phiVariance",360),overrideAdvances:h(e,"overrideAdvances",!1),orientParticles:h(e,"orientParticles",!1),orientOnVelocity:h(e,"orientOnVelocity",!0),lifetimeMS:f(e,"lifetimeMS",0)<<5,lifetimeVarianceMS:f(e,"lifetimeVarianceMS",0)<<5,particles:function(e){let t=e.keys,i=[];if(Array.isArray(t)&&t.length>0)for(let e=0;e0&&t[0]&&(r=t[0])}return{dragCoefficient:5*f(e,"dragCoefficient",0),windCoefficient:f(e,"windCoefficient",1),gravityCoefficient:10*f(e,"gravityCoefficient",0),inheritedVelFactor:f(e,"inheritedVelFactor",0),constantAcceleration:f(e,"constantAcceleration",0),lifetimeMS:f(e,"lifetimeMS",31)<<5,lifetimeVarianceMS:f(e,"lifetimeVarianceMS",0)<<5,spinSpeed:f(e,"spinSpeed",0),spinRandomMin:f(e,"spinRandomMin",1e3)+-1e3,spinRandomMax:f(e,"spinRandomMax",1e3)+-1e3,useInvAlpha:h(e,"useInvAlpha",!1),keys:i,textureName:r}}(i)}:null}function y(e,t){return e+(2*Math.random()-1)*t}function S(e,t,i,r,a,o,n){let l=Math.cos(n),s=Math.sin(n),c=e*r+t*a+i*o;return[e*l+(a*i-o*t)*s+r*c*(1-l),t*l+(o*e-r*i)*s+a*c*(1-l),i*l+(r*t-a*e)*s+o*c*(1-l)]}class b{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,i){this.data=e,this.maxParticles=t;let r=i??e.lifetimeMS;!i&&e.lifetimeVarianceMS>0&&(r+=Math.round(y(0,e.lifetimeVarianceMS))),this.emitterLifetime=r}emitBurst(e,t,i=[0,0,1]){for(let r=0;r0;){if(this.nextParticleTime>0){let e=Math.min(r,this.nextParticleTime);this.nextParticleTime-=e,r-=e,this.internalClock+=e;continue}if(this.particles.length0)){let e=this.particles[this.particles.length-1];e.currentAge+=r,e.currentAge>=e.totalLifetime&&this.particles.pop()}let t=this.data.ejectionPeriodMS;this.data.periodVarianceMS>0&&(t+=Math.round(y(0,this.data.periodVarianceMS))),this.nextParticleTime=Math.max(1,t)}}update(e){this.emitterAge+=e,this.emitterLifetime>0&&this.emitterAge>this.emitterLifetime&&(this.emitterDead=!0);let t=e/1e3,i=this.data.particles;for(let r=this.particles.length-1;r>=0;r--){let a=this.particles[r];if(a.currentAge+=e,a.currentAge>=a.totalLifetime){this.particles[r]=this.particles[this.particles.length-1],this.particles.pop();continue}let o=i.dragCoefficient,n=i.gravityCoefficient,l=a.acc[0]-a.vel[0]*o,s=a.acc[1]-a.vel[1]*o,c=a.acc[2]-a.vel[2]*o+-9.81*n;a.vel[0]+=l*t,a.vel[1]+=s*t,a.vel[2]+=c*t,a.pos[0]+=a.vel[0]*t,a.pos[1]+=a.vel[1]*t,a.pos[2]+=a.vel[2]*t;let u=a.currentAge/a.totalLifetime,d=function(e,t){for(let i=1;i=t){let r=e[i-1],a=e[i],o=a.time-r.time,n=o>0?(t-r.time)/o:0;return{r:r.r+(a.r-r.r)*n,g:r.g+(a.g-r.g)*n,b:r.b+(a.b-r.b)*n,a:r.a+(a.a-r.a)*n,size:r.size+(a.size-r.size)*n}}let i=e[e.length-1];return{r:i.r,g:i.g,b:i.b,a:i.a,size:i.size}}(i.keys,u);a.r=d.r,a.g=d.g,a.b=d.b,a.a=d.a,a.size=d.size,a.currentSpin=a.spinSpeed*a.currentAge*p}}isDead(){return this.emitterDead&&0===this.particles.length}kill(){this.emitterDead=!0}addParticle(e,t){var i,r,a,o;let n,l,s,c,u=this.data,d=u.particles,p=t[0],f=t[1],h=t[2],g=(i=p,r=f,.9>Math.abs(a=h)?(n=r,l=-i,s=0):(n=-a,l=0,s=i),(c=Math.sqrt(n*n+l*l+s*s))<1e-8?[1,0,0]:[n/c,l/c,s/c]),b=(u.thetaMin+Math.random()*(u.thetaMax-u.thetaMin))*m,v=(this.internalClock/1e3*u.phiReferenceVel+Math.random()*u.phiVariance)*m;[p,f,h]=S(p,f,h,g[0],g[1],g[2],b),[p,f,h]=S(p,f,h,t[0],t[1],t[2],v);let M=Math.sqrt(p*p+f*f+h*h);M>1e-8&&(p/=M,f/=M,h/=M);let x=y(u.ejectionVelocity,u.velocityVariance),w=[e[0]+p*u.ejectionOffset,e[1]+f*u.ejectionOffset,e[2]+h*u.ejectionOffset],A=[p*x,f*x,h*x],T=d.constantAcceleration,P=[A[0]*T,A[1]*T,A[2]*T],k=d.lifetimeMS;d.lifetimeVarianceMS>0&&(k+=Math.round(y(0,d.lifetimeVarianceMS))),k=Math.max(1,k);let C=d.spinSpeed+((o=d.spinRandomMin)+Math.random()*(d.spinRandomMax-o)),I=d.keys[0];this.particles.push({pos:w,vel:A,acc:P,orientDir:[p,f,h],currentAge:0,totalLifetime:k,dataIndex:0,spinSpeed:C,currentSpin:0,r:I.r,g:I.g,b:I.b,a:I.a,size:I.size})}}let v=` +// 'position' is auto-declared by Three.js for ShaderMaterial. +attribute vec4 particleColor; +attribute float particleSize; +attribute float particleSpin; +attribute vec2 quadCorner; // (-0.5,-0.5) to (0.5,0.5) +attribute vec3 orientDir; + +uniform bool uOrientParticles; +// cameraPosition is a built-in Three.js uniform. + +varying vec2 vUv; +varying vec4 vColor; + +void main() { + vUv = quadCorner + 0.5; // [0,1] range + vColor = particleColor; + + if (uOrientParticles) { + if (length(orientDir) < 0.0001) { + // V12: don't render oriented particles with zero velocity. + gl_Position = vec4(0.0, 0.0, 0.0, 0.0); + return; + } + // V12 oriented particle: quad aligned along direction, facing camera. + vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz; + vec3 dir = normalize(orientDir); + vec3 dirFromCam = worldPos - cameraPosition; + vec3 crossDir = normalize(cross(dirFromCam, dir)); + + // V12 maps U along dir (velocity) — match by using quadCorner.x for dir. + vec3 offset = dir * quadCorner.x + crossDir * quadCorner.y; + worldPos += offset * particleSize; + + gl_Position = projectionMatrix * viewMatrix * vec4(worldPos, 1.0); + } else { + // Standard camera-facing billboard. + vec3 viewPos = (modelViewMatrix * vec4(position, 1.0)).xyz; + + // Apply spin rotation to quad corner. + float c = cos(particleSpin); + float s = sin(particleSpin); + vec2 rotated = vec2( + c * quadCorner.x - s * quadCorner.y, + s * quadCorner.x + c * quadCorner.y + ); + + // Offset in view space (camera-facing billboard). + viewPos.xy += rotated * particleSize; + + gl_Position = projectionMatrix * vec4(viewPos, 1.0); + } +} +`,M=` +uniform sampler2D particleTexture; +uniform bool hasTexture; +uniform float debugOpacity; + +varying vec2 vUv; +varying vec4 vColor; + +void main() { + if (hasTexture) { + vec4 texColor = texture2D(particleTexture, vUv); + gl_FragColor = texColor * vColor; + } else { + gl_FragColor = vColor; + } + gl_FragColor.a *= debugOpacity; +} +`;var x=e.i(79123),w=e.i(51434),A=e.i(29055);e.i(13876);var T=e.i(58647);let P=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),k=new Map,C=new Set,I=new l.DataTexture(new Uint8Array([255,255,255,255]),1,1,l.RGBAFormat,l.UnsignedByteType);function B(e){if(!e)return I;let t=k.get(e);if(t)return t;try{let t=(0,c.textureToUrl)(e),i=(0,d.loadTexture)(t,e=>{(0,s.setupEffectTexture)(e),C.add(e)});return(0,s.setupEffectTexture)(i),k.set(e,i),i}catch{return I}}I.needsUpdate=!0;let D=new l.SphereGeometry(1,6,6),E=new l.MeshBasicMaterial({color:0xff0000,wireframe:!0}),R=new l.BoxGeometry(.3,.3,.3),V=new l.MeshBasicMaterial({color:65280,wireframe:!0}),F=new l.SphereGeometry(1,12,8),N=` + attribute vec4 vertexColor; + attribute vec2 texCoord; + varying vec4 vColor; + varying vec2 vUV; + void main() { + vColor = vertexColor; + vUV = texCoord; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + } +`,_=` + uniform sampler2D uTexture; + varying vec4 vColor; + varying vec2 vUV; + void main() { + vec4 tex = texture2D(uTexture, vUV); + gl_FragColor = vec4(vColor.rgb * tex.rgb, vColor.a * tex.a); + } +`;function O(e){let t=(e+1)*2,i=new Float32Array(3*t),r=new Float32Array(2*t),a=new Float32Array(4*t),o=new Uint16Array(6*e);for(let t=0;t{let i=Y.current,r=k.current;if(!i||!r)return;let a=T.engineStore.getState().playback,o="playing"===a.status,n=o?t*a.rate:0,s=1e3*n,u=P.getDataBlockData.bind(P);for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position||X.current.has(e.id))continue;X.current.add(e.id);let t=function(e,t){let i=t(e);if(!i)return null;let r=[],a=[],o=i.particleEmitter;if("number"==typeof o){let e=t(o);if(e){let a=g(e,t);if(a){let e=i.particleDensity??10;r.push({data:a,density:e})}}}let n=i.emitters;if(Array.isArray(n))for(let e of n){if("number"!=typeof e)continue;let i=t(e);if(!i)continue;let r=g(i,t);r&&a.push(r)}return 0===r.length&&0===a.length?null:{burstEmitters:r,streamingEmitters:a,lifetimeMS:32*(i.lifetimeMS??31)}}(e.explosionDataBlockId,u);if(!t)continue;let r=[...e.position];for(let e of t.burstEmitters){let t=new b(e.data,256);t.emitBurst(r,e.density);let a=B(e.data.particles.textureName),o=U(256),n=q(a,e.data.particles.useInvAlpha,e.data.orientParticles),s=new l.Mesh(o,n);s.frustumCulled=!1,i.add(s),Q.current.push({emitter:t,mesh:s,geometry:o,material:n,targetTexture:a,origin:r,isBurst:!0,hasBurst:!0})}for(let e of t.streamingEmitters){let a=new b(e,256,t.lifetimeMS),o=B(e.particles.textureName),n=U(256),s=q(o,e.particles.useInvAlpha,e.orientParticles),c=new l.Mesh(n,s);c.frustumCulled=!1,i.add(c),Q.current.push({emitter:a,mesh:c,geometry:n,material:s,targetTexture:o,origin:r,isBurst:!1,hasBurst:!1})}let a=u(e.explosionDataBlockId);if(I){let o=a?function(e){let t=e.sizes;if(Array.isArray(t)&&t.length>0){let e=0;for(let i of t)e=Math.max(e,i.x,i.y,i.z);if(e>0)return e/1e3}let i=e.particleRadius;return"number"==typeof i&&i>0?i:5}(a):5,n=function(e){if(!e)return 0xff00ff;let t=e.toLowerCase();return t.includes("disc")?4491519:t.includes("grenade")?0xff8800:t.includes("mortar")?0xff4400:t.includes("plasma")?4521796:t.includes("laser")?0xff2222:t.includes("blaster")?0xffff00:t.includes("missile")?0xff6600:t.includes("bomb")?0xff0000:t.includes("mine")?0xff8844:t.includes("concussion")?0xffaa00:t.includes("shocklance")?8930559:t.includes("chaingun")||t.includes("bullet")?0xcccccc:0xff00ff}(e.dataBlock),s=new l.MeshBasicMaterial({color:n,wireframe:!0,transparent:!0,opacity:1,depthWrite:!1}),c=new l.Mesh(F,s);c.frustumCulled=!1,c.scale.setScalar(o),c.position.set(r[1],r[2],r[0]),i.add(c);let{sprite:u,material:d}=function(e,t){let i=document.createElement("canvas"),r=i.getContext("2d");r.font="bold 32px monospace",i.width=Math.ceil(r.measureText(e).width)+16,i.height=48,r.font="bold 32px monospace",r.fillStyle=`#${t.toString(16).padStart(6,"0")}`,r.textBaseline="middle",r.fillText(e,8,i.height/2);let a=new l.CanvasTexture(i),o=new l.SpriteMaterial({map:a,transparent:!0,depthTest:!1,depthWrite:!1}),n=new l.Sprite(o),s=i.width/i.height;return n.scale.set(2*s,2,1),{sprite:n,material:o}}(`${e.id}: ${e.dataBlock??`expId:${e.explosionDataBlockId}`}`,n);u.position.set(r[1],r[2]+o+2,r[0]),u.frustumCulled=!1,i.add(u),et.current.push({entityId:e.id,mesh:c,material:s,label:u,labelMaterial:d,creationTime:(0,T.effectNow)(),lifetimeMS:Math.max(t.lifetimeMS,3e3),targetRadius:o})}let o=a?.shockwave;if("number"==typeof o){let t=function(e,t){let i=t(e);if(!i)return null;let r=i.colors??[],a=i.times??[0,.5,1,1];return{width:i.width??1,numSegments:Math.max(i.numSegments??16,4),velocity:i.velocity??0,height:i.height??0,verticalCurve:i.verticalCurve??0,acceleration:i.acceleration??0,texWrap:i.texWrap??1,lifetimeMS:i.lifetimeMS??500,is2D:!!i.is2D,renderSquare:!!i.renderSquare,renderBottom:!!i.renderBottom,mapToTerrain:!!i.mapToTerrain,colors:r,times:a,textureName:i.textureName??"",mapToTexture:i.mapToTexture??""}}(o,u);if(t){let a=B(t.textureName),o=O(t.numSegments),n=new l.ShaderMaterial({vertexShader:N,fragmentShader:_,uniforms:{uTexture:{value:a}},transparent:!0,depthWrite:!1,blending:l.AdditiveBlending,side:l.DoubleSide}),s=new l.Mesh(o,n);s.frustumCulled=!1,s.position.set(r[1],r[2],r[0]),i.add(s);let c=null,u=null;t.renderBottom&&(u=O(t.numSegments),(c=new l.Mesh(u,n)).frustumCulled=!1,c.position.set(r[1],r[2],r[0]),c.scale.y=-1,i.add(c));let d=Math.abs(t.velocity)>1e-10?t.velocity:0;ei.current.push({entityId:e.id,mesh:s,bottomMesh:c,geometry:o,bottomGeometry:u,material:n,creationTime:(0,T.effectNow)(),lifetimeMS:t.lifetimeMS,data:t,radius:0,velocity:d})}}}let d=new Set;for(let e of r.entities){if(d.add(e.id),!e.maintainEmitterId||J.current.has(e.id))continue;J.current.add(e.id);let t=u(e.maintainEmitterId);if(!t)continue;let r=g(t,u);if(!r)continue;let a=e.position?[...e.position]:[0,0,0],o=new b(r,256),n=B(r.particles.textureName),s=U(256),c=q(n,r.particles.useInvAlpha,r.orientParticles),m=new l.Mesh(s,c);m.frustumCulled=!1,i.add(m),Q.current.push({emitter:o,mesh:m,geometry:s,material:c,targetTexture:n,origin:a,isBurst:!1,hasBurst:!1,followEntityId:e.id})}for(let e of Q.current)e.followEntityId&&!d.has(e.followEntityId)&&e.emitter.kill();for(let e of J.current)d.has(e)||J.current.delete(e);let m=Q.current;for(let e=m.length-1;e>=0;e--){let t=m[e];if(t.shaderChecked||(!function(e,t,i){let r=e.properties.get(t).currentProgram;if(!r)return;let a=r.program,o=e.getContext();o.getProgramParameter(a,o.LINK_STATUS)||console.error(`[ParticleFX] Shader LINK ERROR (${i}):`,o.getProgramInfoLog(a))}(K,t.material,t.isBurst?"burst":"stream"),t.shaderChecked=!0),t.followEntityId){let e=r.entities.find(e=>e.id===t.followEntityId);e?.position&&(t.origin[0]=e.position[0],t.origin[1]=e.position[1],t.origin[2]=e.position[2]),e?.direction&&(t.emitAxis=e.direction)}if(t.isBurst||t.emitter.emitPeriodic(t.origin,s,t.emitAxis),t.emitter.update(s),C.has(t.targetTexture)&&t.material.uniforms.particleTexture.value!==t.targetTexture&&(t.material.uniforms.particleTexture.value=t.targetTexture),t.material.uniforms.debugOpacity.value=I?.2:1,!function(e){let t=e.emitter.particles,i=e.geometry,r=i.getAttribute("position"),a=i.getAttribute("particleColor"),o=i.getAttribute("particleSize"),n=i.getAttribute("particleSpin"),l=i.getAttribute("orientDir"),s=r.array,c=a.array,u=o.array,d=n.array,m=l.array,p=Math.min(t.length,256),f=e.emitter.data.orientOnVelocity;for(let e=0;e=0;e--){let t=p[e],r=Math.min((f-t.creationTime)/t.lifetimeMS,1),a=Math.min(r/.1,1);t.mesh.scale.setScalar(t.targetRadius*a),t.material.opacity=1-r,t.labelMaterial.opacity=1-r,r>=1&&(i.remove(t.mesh),i.remove(t.label),t.material.dispose(),t.labelMaterial.dispose(),p.splice(e,1))}let h=ei.current;for(let t=h.length-1;t>=0;t--){let r=h[t],a=Math.min((f-r.creationTime)/r.lifetimeMS,1);r.velocity=r.velocity+r.data.acceleration*n,r.radius=r.radius+r.velocity*n;let o=function(e,t){let{colors:i,times:r}=e;if(0===i.length)return[1,1,1,1];let a=0;for(let e=0;e=r[e]&&(a=e);let o=Math.min(a+1,i.length-1),n=r[a]??0,l=(r[o]??1)-n,s=l>0?Math.min((t-n)/l,1):0,c=i[a]??i[0],u=i[o]??i[0];return[c.r+(u.r-c.r)*s,c.g+(u.g-c.g)*s,c.b+(u.b-c.b)*s,c.a+(u.a-c.a)*s]}(r.data,a);z(r.geometry,r.data,r.radius,o,r.data.is2D),r.bottomGeometry&&z(r.bottomGeometry,r.data,r.radius,o,r.data.is2D),r.data.is2D&&r.mesh.lookAt(e.camera.position),a>=1&&(i.remove(r.mesh),r.bottomMesh&&i.remove(r.bottomMesh),r.geometry.dispose(),r.bottomGeometry?.dispose(),r.material.dispose(),h.splice(t,1))}if(o&&j&&H&&$&&Y.current){for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position)continue;let t=`snd:${e.id}`;if(ee.current.has(t))continue;ee.current.add(t);let i=u(e.explosionDataBlockId);if(!i)continue;let r=i.soundProfile;if("number"!=typeof r)continue;let a=(0,A.resolveAudioProfile)(r,u);if(!a)continue;let o=new l.Vector3(e.position[1],e.position[2],e.position[0]);(0,A.playOneShotSound)(a,$,H,o,Y.current)}let e=Z.current;for(let t of r.entities){if("Projectile"!==t.type||!t.dataBlockId||!t.position)continue;if(e.has(t.id)){e.get(t.id).position.set(t.position[1],t.position[2],t.position[0]);continue}if(e.size>=20)continue;let i=u(t.dataBlockId);if(!i)continue;let r=i.sound;if("number"!=typeof r)continue;let o=(0,A.resolveAudioProfile)(r,u);if(o&&o.isLooping&&o.is3D)try{let i=(0,c.audioToUrl)(o.filename),r=(0,A.getSoundGeneration)();(0,A.getCachedAudioBuffer)(i,H,i=>{if(r!==(0,A.getSoundGeneration)()||!d.has(t.id)||e.has(t.id))return;let n=Y.current;if(!n)return;let s=new l.PositionalAudio($);s.setBuffer(i),s.setDistanceModel("inverse"),s.setRefDistance(o.refDist),s.setMaxDistance(o.maxDist),s.setRolloffFactor(1),s.setVolume(o.volume),s.setPlaybackRate(a.rate),s.setLoop(!0),s.position.set(t.position[1],t.position[2],t.position[0]),n.add(s),(0,A.trackSound)(s),s.play(),e.set(t.id,s)})}catch{}}for(let[t,i]of e)if(!d.has(t)){(0,A.untrackSound)(i);try{i.stop()}catch{}try{i.disconnect()}catch{}Y.current?.remove(i),e.delete(t)}for(let e of r.audioEvents){let t=`${e.timeSec}:${e.profileId}:${e.position?.x??""}`;if(ee.current.has(t))continue;ee.current.add(t);let i=(0,A.resolveAudioProfile)(e.profileId,u);if(!i)continue;let r=e.position?new l.Vector3(e.position.y,e.position.z,e.position.x):void 0;(0,A.playOneShotSound)(i,$,H,r,Y.current)}}if(X.current.size>500){let e=new Set(r.entities.map(G));for(let t of X.current)e.has(t)||X.current.delete(t)}if(ee.current.size>500){let e=new Set(r.entities.map(L));for(let t of ee.current)t.startsWith("snd:")&&e.has(t.slice(4))||ee.current.delete(t)}},M[7]=j,M[8]=$,M[9]=H,M[10]=I,M[11]=K,M[12]=P,M[13]=k,M[14]=h):h=M[14],(0,o.useFrame)(h),M[15]===Symbol.for("react.memo_cache_sentinel")?(S=()=>()=>{let e=Y.current;for(let t of Q.current){if(e&&(e.remove(t.mesh),t.debugOriginMesh&&e.remove(t.debugOriginMesh),t.debugParticleMeshes))for(let i of t.debugParticleMeshes)e.remove(i);t.geometry.dispose(),t.material.dispose()}for(let t of(Q.current=[],et.current))e&&(e.remove(t.mesh),e.remove(t.label)),t.material.dispose(),t.labelMaterial.dispose();for(let t of(et.current=[],ei.current))e&&(e.remove(t.mesh),t.bottomMesh&&e.remove(t.bottomMesh)),t.geometry.dispose(),t.bottomGeometry?.dispose(),t.material.dispose();for(let[,t]of(ei.current=[],X.current.clear(),J.current.clear(),Z.current)){(0,A.untrackSound)(t);try{t.stop()}catch{}try{t.disconnect()}catch{}e&&e.remove(t)}Z.current.clear(),ee.current.clear()},y=[],M[15]=y,M[16]=S):(y=M[15],S=M[16]),(0,a.useEffect)(S,y),M[17]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("group",{ref:Y}),M[17]=v):v=M[17],v}function L(e){return e.id}function G(e){return e.id}function W(e){return e.gl}var H=e.i(9721),$=e.i(92224),K=e.i(93784);function Y(e,t){return{id:e.id,className:e.className??e.type,ghostIndex:e.ghostIndex,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,spawnTime:t,position:e.position,rotation:e.rotation,velocity:e.velocity,keyframes:[{time:t??0,position:e.position??[0,0,0],rotation:e.rotation??[0,0,0,1]}]}}var Q=e.i(77964);let X=new WeakMap;function J(e){let t=X.get(e);return t||(t=new Map(e.entities.map(e=>[e.id,e])),X.set(e,t)),t}let Z=new l.Vector3,ee=new l.Quaternion,et=new l.Quaternion,ei=new l.Quaternion(0,1,0,0),er=new l.Vector3,ea=new l.Vector3,eo=new l.Vector3;function en(e){let r,u,d,m,p,f,h,g,y,S=(0,i.c)(19),{recording:b}=e,v=(0,T.useEngineStoreApi)(),M=(0,a.useRef)(0),x=(0,a.useRef)(null),w=(0,a.useRef)(null);S[0]===Symbol.for("react.memo_cache_sentinel")?(r=new l.Vector3(0,s.DEFAULT_EYE_HEIGHT,0),S[0]=r):r=S[0];let P=(0,a.useRef)(r),k=(0,a.useRef)(b.streamingPlayback??null),C=(0,a.useRef)(null);S[1]===Symbol.for("react.memo_cache_sentinel")?(u=new Map,S[1]=u):u=S[1];let I=(0,a.useRef)(u),B=(0,a.useRef)(null),[D,E]=(0,a.useState)(null);S[2]===Symbol.for("react.memo_cache_sentinel")?(d=e=>{if(e===B.current)return;B.current=e;let t=I.current,i=new Map,r=!1;for(let o of e.entities){let n=t.get(o.id);if(n&&n.className===(o.className??o.type)&&n.ghostIndex===o.ghostIndex&&n.dataBlockId===o.dataBlockId&&n.shapeHint===o.shapeHint&&n.shapeName===o.dataBlock&&("Player"===n.renderType||n.weaponShape===o.weaponShape)){var a=n;switch(a.renderType){case"Player":a.threads=o.threads,a.weaponShape=o.weaponShape,a.weaponImageState=o.weaponImageState,a.weaponImageStates=o.weaponImageStates,a.playerName=o.playerName,a.iffColor=o.iffColor,a.headPitch=o.headPitch,a.headYaw=o.headYaw,a.targetRenderFlags=o.targetRenderFlags;break;case"Shape":a.threads=o.threads,a.targetRenderFlags=o.targetRenderFlags,a.iffColor=o.iffColor}}else n=function(e,t){if(e.sceneData){let i={id:e.id,className:e.className??e.type,ghostIndex:e.ghostIndex,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,spawnTime:t};switch(e.sceneData.className){case"TerrainBlock":return{...i,renderType:"TerrainBlock",terrainData:e.sceneData};case"InteriorInstance":return{...i,renderType:"InteriorInstance",interiorData:e.sceneData};case"Sky":return{...i,renderType:"Sky",skyData:e.sceneData};case"Sun":return{...i,renderType:"Sun",sunData:e.sceneData};case"WaterBlock":return{...i,renderType:"WaterBlock",waterData:e.sceneData};case"MissionArea":return{...i,renderType:"MissionArea",missionAreaData:e.sceneData};case"TSStatic":return{...Y(e,t),renderType:"Shape",shapeName:e.sceneData.shapeName,shapeType:"TSStatic",dataBlock:e.dataBlock}}}return e.visual?.kind==="tracer"?{...Y(e,t),renderType:"Tracer",visual:e.visual,dataBlock:e.dataBlock,direction:e.direction}:e.visual?.kind==="sprite"?{...Y(e,t),renderType:"Sprite",visual:e.visual}:"Player"===e.type?{...Y(e,t),renderType:"Player",shapeName:e.dataBlock,dataBlock:e.dataBlock,weaponShape:e.weaponShape,playerName:e.playerName,iffColor:e.iffColor,threads:e.threads,weaponImageState:e.weaponImageState,weaponImageStates:e.weaponImageStates,headPitch:e.headPitch,headYaw:e.headYaw,targetRenderFlags:e.targetRenderFlags}:"Explosion"===e.type?{...Y(e,t),renderType:"Explosion",shapeName:e.dataBlock,dataBlock:e.dataBlock,explosionDataBlockId:e.explosionDataBlockId,faceViewer:e.faceViewer}:"ForceFieldBare"===e.className?{...Y(e,t),renderType:"ForceFieldBare"}:"AudioEmitter"===e.className?{...Y(e,t),renderType:"AudioEmitter",audioFileName:e.audioFileName,audioVolume:e.audioVolume,audioIs3D:e.audioIs3D,audioIsLooping:e.audioIsLooping??!0,audioMinDistance:e.audioMinDistance,audioMaxDistance:e.audioMaxDistance,audioMinLoopGap:e.audioMinLoopGap,audioMaxLoopGap:e.audioMaxLoopGap}:"WayPoint"===e.className?{...Y(e,t),renderType:"WayPoint",label:e.label}:"Camera"===e.className?{...Y(e,t),renderType:"Camera"}:{...Y(e,t),renderType:"Shape",shapeName:e.dataBlock,shapeType:"Turret"===e.className?"Turret":"Item"===e.className?"Item":"StaticShape",dataBlock:e.dataBlock,weaponShape:e.weaponShape,threads:e.threads,targetRenderFlags:e.targetRenderFlags,iffColor:e.iffColor}}(o,e.timeSec),r=!0;if(i.set(o.id,n),(0,Q.isSceneEntity)(n)||"None"===n.renderType)continue;let l=n.keyframes;0===l.length&&l.push({time:e.timeSec,position:o.position??[0,0,0],rotation:o.rotation??[0,0,0,1]});let s=l[0];s.time=e.timeSec,o.position&&(s.position=o.position),o.rotation&&(s.rotation=o.rotation),s.velocity=o.velocity,s.health=o.health,s.energy=o.energy,s.actionAnim=o.actionAnim,s.actionAtEnd=o.actionAtEnd,s.damageState=o.damageState}for(let[a,o]of t)if(!i.has(a)){if("Explosion"===o.renderType&&o.shapeName&&null!=o.spawnTime&&e.timeSec-o.spawnTime<5){i.set(a,o);continue}r=!0}i.size!==t.size&&(r=!0),I.current=i,r&&$.gameEntityStore.getState().setAllStreamEntities(Array.from(i.values()));let o=null;if(e.camera?.mode==="first-person"&&e.camera.controlEntityId){let t=i.get(e.camera.controlEntityId),r=t?t.shapeName:void 0;r&&(o=r)}E(e=>e===o?e:o)},S[2]=d):d=S[2];let R=d;return S[3]!==v||S[4]!==b.streamingPlayback?(m=()=>{(0,A.stopAllTrackedSounds)(),k.current=b.streamingPlayback??null,I.current=new Map,B.current=null,C.current=null,(0,K.resetStreamPlayback)(),M.current=0,x.current=null,w.current=null;let e=k.current;if(K.streamPlaybackStore.setState({playback:e}),$.gameEntityStore.getState().beginStreaming(),!e)return void v.getState().setPlaybackStreamSnapshot(null);for(let t of(e.reset(),e.getEffectShapes()))n.useGLTF.preload((0,c.shapeToUrl)(t));let t=e.getSnapshot();return K.streamPlaybackStore.setState({time:t.timeSec}),M.current=t.timeSec,x.current=t,w.current=t,R(t),v.getState().setPlaybackStreamSnapshot(t),C.current=t,()=>{(0,A.stopAllTrackedSounds)(),$.gameEntityStore.getState().endStreaming(),(0,K.resetStreamPlayback)(),v.getState().setPlaybackStreamSnapshot(null)}},S[3]=v,S[4]=b.streamingPlayback,S[5]=m):m=S[5],S[6]!==v||S[7]!==b?(p=[b,v,R],S[6]=v,S[7]=b,S[8]=p):p=S[8],(0,a.useEffect)(m,p),S[9]!==v||S[10]!==b.source?(f=(e,t)=>{let i=k.current;if(!i)return;let r=v.getState(),a=r.playback,o="playing"===a.status,n=a.timeMs/1e3,l=!o&&Math.abs(n-M.current)>5e-4,c=o&&Math.abs(n-K.streamPlaybackStore.getState().time)>.05,u=l||c;u&&(M.current=n),o&&((0,T.advanceEffectClock)(t,a.rate),M.current=M.current+t*a.rate);let d=Math.max(1,Math.ceil(1e3*t*Math.max(a.rate,.01)/32)+2),m=M.current+s.STREAM_TICK_SEC,p=i.stepToTime(m,o&&!u?d:1/0),f=w.current;!f||p.timeSec1.5*s.STREAM_TICK_SEC?(x.current=p,w.current=p):p.timeSec!==f.timeSec&&(x.current=f,w.current=p);let h=w.current??p,g=x.current??h,y=h.timeSec-s.STREAM_TICK_SEC,S=Math.max(0,Math.min(1,(M.current-y)/s.STREAM_TICK_SEC));K.streamPlaybackStore.setState({time:M.current}),p.exhausted&&o&&(M.current=Math.min(M.current,p.timeSec)),R(h),K.streamPlaybackStore.getState().entities=I.current,h!==C.current&&(C.current=h,r.setPlaybackStreamSnapshot(h));let A=h.camera,B=A&&g.camera&&g.camera.mode===A.mode&&g.camera.controlEntityId===A.controlEntityId&&g.camera.orbitTargetId===A.orbitTargetId?g.camera:null,D=K.streamPlaybackStore.getState().freeFlyCamera,E="live"===b.source;if(A&&!D){if(B){let t=B.position[0],i=B.position[1],r=B.position[2],a=A.position[0],o=A.position[1],n=A.position[2];e.camera.position.set(i+(o-i)*S,r+(n-r)*S,t+(a-t)*S),E||(ee.set(...B.rotation),et.set(...A.rotation),ee.slerp(et,S),e.camera.quaternion.copy(ee))}else e.camera.position.set(A.position[1],A.position[2],A.position[0]),E||e.camera.quaternion.set(...A.rotation);if(!E&&Number.isFinite(A.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,i=B&&Number.isFinite(B.fov)?B.fov+(A.fov-B.fov)*S:A.fov,r=(0,s.torqueHorizontalFovToThreeVerticalFov)(i,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let V=J(h),F=J(g),N=I.current,_=K.streamPlaybackStore.getState().root;if(_)for(let t of _.children){let i=N.get(t.name);if(i&&(0,Q.isSceneEntity)(i))continue;let r=V.get(t.name);if(!r){let e=i&&"keyframes"in i?i.keyframes:void 0;if(e?.[0]?.position){let i=e[0];t.visible=!0,t.position.set(i.position[1],i.position[2],i.position[0]);continue}}if(!r?.position){t.visible=!1;continue}t.visible=!0;let a=F.get(t.name);if(a?.position){let e=a.position[0],i=a.position[1],o=a.position[2],n=r.position[0],l=r.position[1],s=r.position[2],c=e+(n-e)*S,u=i+(l-i)*S,d=o+(s-o)*S;t.position.set(u,d,c)}else t.position.set(r.position[1],r.position[2],r.position[0]);r.faceViewer?t.quaternion.copy(e.camera.quaternion).multiply(ei):r.visual?.kind==="tracer"?t.quaternion.identity():r.rotation&&(a?.rotation?(ee.set(...a.rotation),et.set(...r.rotation),ee.slerp(et,S),t.quaternion.copy(ee)):t.quaternion.set(...r.rotation))}let O=A?.mode;if(!D&&!E&&"third-person"===O&&_&&A?.orbitTargetId){let t=_.children.find(e=>e.name===A.orbitTargetId);if(t){let i=V.get(A.orbitTargetId);ea.copy(t.position),i?.type==="Player"&&(ea.y=ea.y+1);let r=!1;if("number"==typeof A.yaw&&"number"==typeof A.pitch){let e=Math.sin(A.pitch),t=Math.cos(A.pitch),i=Math.sin(A.yaw),a=Math.cos(A.yaw);er.set(-t,-i*e,-a*e),r=er.lengthSq()>1e-8}if(r||(er.copy(e.camera.position).sub(ea),r=er.lengthSq()>1e-8),r){er.normalize();let t=Math.max(.1,A.orbitDistance??4);eo.copy(ea).addScaledVector(er,t),e.camera.position.copy(eo),e.camera.lookAt(ea)}}}if(!D&&"first-person"===O&&_&&A?.controlEntityId){let t=_.children.find(e=>e.name===A.controlEntityId);t?(Z.copy(P.current).applyQuaternion(t.quaternion),e.camera.position.add(Z)):e.camera.position.y=e.camera.position.y+P.current.y}o&&p.exhausted&&r.setPlaybackStatus("paused");let z=1e3*M.current;Math.abs(z-a.timeMs)>.5&&r.setPlaybackTime(z)},S[9]=v,S[10]=b.source,S[11]=f):f=S[11],(0,o.useFrame)(f),S[12]!==b.streamingPlayback?(h=(0,t.jsx)(j,{playback:b.streamingPlayback,snapshotRef:w}),S[12]=b.streamingPlayback,S[13]=h):h=S[13],S[14]!==D?(g=D&&(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(H.PlayerEyeOffset,{shapeName:D,eyeOffsetRef:P})}),S[14]=D,S[15]=g):g=S[15],S[16]!==h||S[17]!==g?(y=(0,t.jsxs)(t.Fragment,{children:[h,g]}),S[16]=h,S[17]=g,S[18]=y):y=S[18],y}function el(){let e,a=(0,i.c)(2),o=(0,r.useRecording)();return o?(a[0]!==o?(e=(0,t.jsx)(en,{recording:o}),a[0]=o,a[1]=e):e=a[1],e):null}e.s(["DemoPlayback",()=>el],21500)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/12261e943ff623d2.js b/docs/_next/static/chunks/12261e943ff623d2.js new file mode 100644 index 00000000..cce59bb8 --- /dev/null +++ b/docs/_next/static/chunks/12261e943ff623d2.js @@ -0,0 +1,397 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66936,(e,t,n)=>{"use strict";function i(e,t){var n=e.length;for(e.push(t);0>>1,r=e[i];if(0>>1;is(l,n))us(c,l)?(e[i]=c,e[u]=n,i=u):(e[i]=l,e[o]=n,i=o);else if(us(c,n))e[i]=c,e[u]=n,i=u;else break}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(n.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var o,l=performance;n.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();n.unstable_now=function(){return u.now()-c}}var h=[],d=[],p=1,f=null,m=3,g=!1,v=!1,_=!1,y=!1,x="function"==typeof setTimeout?setTimeout:null,b="function"==typeof clearTimeout?clearTimeout:null,S="u">typeof setImmediate?setImmediate:null;function M(e){for(var t=r(d);null!==t;){if(null===t.callback)a(d);else if(t.startTime<=e)a(d),t.sortIndex=t.expirationTime,i(h,t);else break;t=r(d)}}function T(e){if(_=!1,M(e),!v)if(null!==r(h))v=!0,w||(w=!0,o());else{var t=r(d);null!==t&&N(T,t.startTime-e)}}var w=!1,E=-1,A=5,C=-1;function R(){return!!y||!(n.unstable_now()-Ce&&R());){var s=f.callback;if("function"==typeof s){f.callback=null,m=f.priorityLevel;var l=s(f.expirationTime<=e);if(e=n.unstable_now(),"function"==typeof l){f.callback=l,M(e),t=!0;break t}f===r(h)&&a(h),M(e)}else a(h);f=r(h)}if(null!==f)t=!0;else{var u=r(d);null!==u&&N(T,u.startTime-e),t=!1}}break e}finally{f=null,m=i,g=!1}}}finally{t?o():w=!1}}}if("function"==typeof S)o=function(){S(P)};else if("u">typeof MessageChannel){var I=new MessageChannel,L=I.port2;I.port1.onmessage=P,o=function(){L.postMessage(null)}}else o=function(){x(P,0)};function N(e,t){E=x(function(){e(n.unstable_now())},t)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(e){e.callback=null},n.unstable_forceFrameRate=function(e){0>e||125s?(e.sortIndex=a,i(d,e),null===r(h)&&e===r(d)&&(_?(b(E),E=-1):_=!0,N(T,a-s))):(e.sortIndex=l,i(h,e),v||g||(v=!0,w||(w=!0,o()))),e},n.unstable_shouldYield=R,n.unstable_wrapCallback=function(e){var t=m;return function(){var n=m;m=t;try{return e.apply(this,arguments)}finally{m=n}}}},89499,(e,t,n)=>{"use strict";t.exports=e.r(66936)},40859,90072,8560,46791,e=>{"use strict";let t,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g,v,_;var y,x,b,S,M,T,w=e.i(47167),E=e.i(71645);let A={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},C={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},R="attached",P="detached",I="srgb",L="srgb-linear",N="linear",U="srgb",D="300 es",O={COMPUTE:"compute",RENDER:"render"},F={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},z={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function B(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}let k={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function V(e,t){return new k[e](t)}function H(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function G(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function W(){let e=G("canvas");return e.style.display="block",e}let j={},X=null;function q(e){X=e}function Y(){return X}function Z(...e){let t="THREE."+e.shift();X?X("log",t,...e):console.log(t,...e)}function J(...e){let t="THREE."+e.shift();X?X("warn",t,...e):console.warn(t,...e)}function K(...e){let t="THREE."+e.shift();X?X("error",t,...e):console.error(t,...e)}function $(...e){let t=e.join(" ");t in j||(j[t]=!0,J(...e))}function Q(e,t,n){return new Promise(function(i,r){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}},n)})}class ee{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n&&void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners;if(void 0===n)return;let i=n[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(void 0===t)return;let n=t[e.type];if(void 0!==n){e.target=this;let t=n.slice(0);for(let n=0,i=t.length;n>8&255]+et[e>>16&255]+et[e>>24&255]+"-"+et[255&t]+et[t>>8&255]+"-"+et[t>>16&15|64]+et[t>>24&255]+"-"+et[63&n|128]+et[n>>8&255]+"-"+et[n>>16&255]+et[n>>24&255]+et[255&i]+et[i>>8&255]+et[i>>16&255]+et[i>>24&255]).toLowerCase()}function es(e,t,n){return Math.max(t,Math.min(n,e))}function eo(e,t){return(e%t+t)%t}function el(e,t,n){return(1-n)*e+n*t}function eu(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/0xffffffff;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/0x7fffffff,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function ec(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(0xffffffff*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(0x7fffffff*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}let eh={DEG2RAD:ei,RAD2DEG:er,generateUUID:ea,clamp:es,euclideanModulo:eo,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:el,damp:function(e,t,n,i){return el(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(eo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(en=e);let t=en+=0x6d2b79f5;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/0x100000000},degToRad:function(e){return e*ei},radToDeg:function(e){return e*er},isPowerOfTwo:function(e){return(e&e-1)==0&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),u=a((t+i)/2),c=s((t+i)/2),h=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*h,l*d,o*u);break;case"YZY":e.set(l*d,o*c,l*h,o*u);break;case"ZXZ":e.set(l*h,l*d,o*c,o*u);break;case"XZX":e.set(o*c,l*f,l*p,o*u);break;case"YXY":e.set(l*p,o*c,l*f,o*u);break;case"ZYZ":e.set(l*f,l*p,o*c,o*u);break;default:J("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:ec,denormalize:eu};class ed{constructor(e=0,t=0){ed.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:Math.acos(es(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ep{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,s){let o=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],h=r[a+0],d=r[a+1],p=r[a+2],f=r[a+3];if(s<=0){e[t+0]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c;return}if(s>=1){e[t+0]=h,e[t+1]=d,e[t+2]=p,e[t+3]=f;return}if(c!==f||o!==h||l!==d||u!==p){let e=o*h+l*d+u*p+c*f;e<0&&(h=-h,d=-d,p=-p,f=-f,e=-e);let t=1-s;if(e<.9995){let n=Math.acos(e),i=Math.sin(n);o=o*(t=Math.sin(t*n)/i)+h*(s=Math.sin(s*n)/i),l=l*t+d*s,u=u*t+p*s,c=c*t+f*s}else{let e=1/Math.sqrt((o=o*t+h*s)*o+(l=l*t+d*s)*l+(u=u*t+p*s)*u+(c=c*t+f*s)*c);o*=e,l*=e,u*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],u=n[i+3],c=r[a],h=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+u*c+o*d-l*h,e[t+1]=o*p+u*h+l*c-s*d,e[t+2]=l*p+u*d+s*h-o*c,e[t+3]=u*p-s*c-o*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),u=s(i/2),c=s(r/2),h=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"YXZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"ZXY":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"ZYX":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"YZX":this._x=h*u*c+l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c-h*d*p;break;case"XZY":this._x=h*u*c-l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c+h*d*p;break;default:J("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],u=t[6],c=t[10],h=n+s+c;if(h>0){let e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(u-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(u-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+u)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=n,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(es(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,u=t._w;return this._x=n*u+a*s+i*l-r*o,this._y=i*u+a*o+r*s-n*l,this._z=r*u+a*l+n*o-i*s,this._w=a*u-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,r=e._z,a=e._w,s=this.dot(e);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-t;if(s<.9995){let e=Math.acos(s),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ef{constructor(e=0,t=0,n=0){ef.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(eg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),u=2*(s*t-r*i),c=2*(r*n-a*t);return this.x=t+o*l+a*c-s*u,this.y=n+o*u+s*l-r*c,this.z=i+o*c+r*u-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this.z=es(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this.z=es(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return em.copy(this).projectOnVector(e),this.sub(em)}reflect(e){return this.sub(em.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:Math.acos(es(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let em=new ef,eg=new ep;class ev{constructor(e,t,n,i,r,a,s,o,l){ev.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){let u=this.elements;return u[0]=e,u[1]=i,u[2]=s,u[3]=t,u[4]=r,u[5]=o,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],u=n[4],c=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],y=i[7],x=i[2],b=i[5],S=i[8];return r[0]=a*f+s*v+o*x,r[3]=a*m+s*_+o*b,r[6]=a*g+s*y+o*S,r[1]=l*f+u*v+c*x,r[4]=l*m+u*_+c*b,r[7]=l*g+u*y+c*S,r[2]=h*f+d*v+p*x,r[5]=h*m+d*_+p*b,r[8]=h*g+d*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*a*u-t*s*l-n*r*u+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=u*a-s*l,h=s*o-u*r,d=l*r-a*o,p=t*c+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-u*n)*f,e[2]=(s*n-i*a)*f,e[3]=h*f,e[4]=(u*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(e_.makeScale(e,t)),this}rotate(e){return this.premultiply(e_.makeRotation(-e)),this}translate(e,t){return this.premultiply(e_.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let e_=new ev,ey=new ev().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ex=new ev().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),eb=(d=[.64,.33,.3,.6,.15,.06],p=[.2126,.7152,.0722],f=[.3127,.329],(h={enabled:!0,workingColorSpace:L,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n&&(this.spaces[t].transfer===U&&(e.r=eS(e.r),e.g=eS(e.g),e.b=eS(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===U&&(e.r=eM(e.r),e.g=eM(e.g),e.b=eM(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return""===e?N:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,t){return $("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),h.workingToColorSpace(e,t)},toWorkingColorSpace:function(e,t){return $("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),h.colorSpaceToWorking(e,t)}}).define({[L]:{primaries:d,whitePoint:f,transfer:N,toXYZ:ey,fromXYZ:ex,luminanceCoefficients:p,workingColorSpaceConfig:{unpackColorSpace:I},outputColorSpaceConfig:{drawingBufferColorSpace:I}},[I]:{primaries:d,whitePoint:f,transfer:U,toXYZ:ey,fromXYZ:ex,luminanceCoefficients:p,outputColorSpaceConfig:{drawingBufferColorSpace:I}}}),h);function eS(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function eM(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class eT{static getDataURL(e,n="image/png"){let i;if(/^data:/i.test(e.src)||"u"typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap){let t=G("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;etypeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"u">typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;ttypeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap?eT.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(J("Texture: Unable to serialize Texture."),{})}let eC=0,eR=new ef;class eP extends ee{constructor(e=eP.DEFAULT_IMAGE,t=eP.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=1009,l=eP.DEFAULT_ANISOTROPY,u=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:eC++}),this.uuid=ea(),this.name="",this.source=new eE(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new ed(0,0),this.repeat=new ed(1,1),this.center=new ed(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ev,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!e&&!!e.depth&&e.depth>1,this.pmremVersion=0}get width(){return this.source.getSize(eR).x}get height(){return this.source.getSize(eR).y}get depth(){return this.source.getSize(eR).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(void 0===n){J(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){J(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}eP.DEFAULT_IMAGE=null,eP.DEFAULT_MAPPING=300,eP.DEFAULT_ANISOTROPY=1;class eI{constructor(e=0,t=0,n=0,i=1){eI.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-d)&&.01>Math.abs(h-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+d)&&.1>Math.abs(h+p)&&.1>Math.abs(s+c+f-3))return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+u)/4,v=(l+d)/4,_=(h+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(i=g/(n=Math.sqrt(e)),r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(n=g/(i=Math.sqrt(a)),r=_/i):m<.01?(n=.707106781,i=.707106781,r=0):(n=v/(r=Math.sqrt(m)),i=_/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-h)*(p-h)+(l-d)*(l-d)+(u-o)*(u-o));return .001>Math.abs(m)&&(m=1),this.x=(p-h)/m,this.y=(l-d)/m,this.z=(u-o)/m,this.w=Math.acos((s+c+f-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this.z=es(this.z,e.z,t.z),this.w=es(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this.z=es(this.z,e,t),this.w=es(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class eL extends ee{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new eI(0,0,e,t),this.scissorTest=!1,this.viewport=new eI(0,0,e,t);const i=new eP({width:e,height:t,depth:n.depth});this.textures=[];const r=n.count;for(let e=0;e1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ek),ek.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eY),eZ.subVectors(this.max,eY),eH.subVectors(e.a,eY),eG.subVectors(e.b,eY),eW.subVectors(e.c,eY),ej.subVectors(eG,eH),eX.subVectors(eW,eG),eq.subVectors(eH,eW);let t=[0,-ej.z,ej.y,0,-eX.z,eX.y,0,-eq.z,eq.y,ej.z,0,-ej.x,eX.z,0,-eX.x,eq.z,0,-eq.x,-ej.y,ej.x,0,-eX.y,eX.x,0,-eq.y,eq.x,0];return!!e$(t,eH,eG,eW,eZ)&&!!e$(t=[1,0,0,0,1,0,0,0,1],eH,eG,eW,eZ)&&(eJ.crossVectors(ej,eX),e$(t=[eJ.x,eJ.y,eJ.z],eH,eG,eW,eZ))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ek).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(ek).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(eB[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),eB[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),eB[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),eB[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),eB[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),eB[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),eB[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),eB[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(eB)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}let eB=[new ef,new ef,new ef,new ef,new ef,new ef,new ef,new ef],ek=new ef,eV=new ez,eH=new ef,eG=new ef,eW=new ef,ej=new ef,eX=new ef,eq=new ef,eY=new ef,eZ=new ef,eJ=new ef,eK=new ef;function e$(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){eK.fromArray(e,a);let s=r.x*Math.abs(eK.x)+r.y*Math.abs(eK.y)+r.z*Math.abs(eK.z),o=t.dot(eK),l=n.dot(eK),u=i.dot(eK);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>s)return!1}return!0}let eQ=new ez,e0=new ef,e1=new ef;class e2{constructor(e=new ef,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;void 0!==t?n.copy(t):eQ.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;e0.subVectors(e,this.center);let t=e0.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(e0,n/e),this.radius+=n}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(e1.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(e0.copy(e.center).add(e1)),this.expandByPoint(e0.copy(e.center).sub(e1)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let e3=new ef,e4=new ef,e5=new ef,e6=new ef,e8=new ef,e9=new ef,e7=new ef;class te{constructor(e=new ef,t=new ef(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,e3)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=e3.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(e3.copy(this.origin).addScaledVector(this.direction,t),e3.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){let r,a,s,o;e4.copy(e).add(t).multiplyScalar(.5),e5.copy(t).sub(e).normalize(),e6.copy(this.origin).sub(e4);let l=.5*e.distanceTo(t),u=-this.direction.dot(e5),c=e6.dot(this.direction),h=-e6.dot(e5),d=e6.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(r=u*h-c,a=u*c-h,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+u*a+2*c)+a*(u*r+a+2*h)+d}else s=-(r=Math.max(0,-(u*(a=l)+c)))*r+a*(a+2*h)+d;else s=-(r=Math.max(0,-(u*(a=-l)+c)))*r+a*(a+2*h)+d;else a<=-o?(a=(r=Math.max(0,-(-u*l+c)))>0?-l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d):a<=o?(r=0,s=(a=Math.min(Math.max(-l,-h),l))*(a+2*h)+d):(a=(r=Math.max(0,-(u*l+c)))>0?l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d);else a=u>0?-l:l,s=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(e4).addScaledVector(e5,a),s}intersectSphere(e,t){e3.subVectors(e.center,this.origin);let n=e3.dot(this.direction),i=e3.dot(e3)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return!!(0===t||e.normal.dot(this.direction)*t<0)}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return(l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-h.z)*c,o=(e.max.z-h.z)*c):(s=(e.max.z-h.z)*c,o=(e.min.z-h.z)*c),n>o||s>i||((s>n||n!=n)&&(n=s),(o=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,e3)}intersectTriangle(e,t,n,i,r){let a;e8.subVectors(t,e),e9.subVectors(n,e),e7.crossVectors(e8,e9);let s=this.direction.dot(e7);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}e6.subVectors(this.origin,e);let o=a*this.direction.dot(e9.crossVectors(e6,e9));if(o<0)return null;let l=a*this.direction.dot(e8.cross(e6));if(l<0||o+l>s)return null;let u=-a*e6.dot(e7);return u<0?null:this.at(u/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class tt{constructor(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){tt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new tt().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return 0===this.determinant()?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1)):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2)),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinant())return this.identity();let t=this.elements,n=e.elements,i=1/tn.setFromMatrixColumn(e,0).length(),r=1/tn.setFromMatrixColumn(e,1).length(),a=1/tn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*u,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*u,t[9]=-s*u,t[2]=-l*u,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=-c,t[8]=l*u,t[1]=e*c+r,t[5]=a*u,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*u,t[10]=r*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(tr,e,ta)}lookAt(e,t,n){let i=this.elements;return tl.subVectors(e,t),0===tl.lengthSq()&&(tl.z=1),tl.normalize(),ts.crossVectors(n,tl),0===ts.lengthSq()&&(1===Math.abs(n.z)?tl.x+=1e-4:tl.z+=1e-4,tl.normalize(),ts.crossVectors(n,tl)),ts.normalize(),to.crossVectors(tl,ts),i[0]=ts.x,i[4]=to.x,i[8]=tl.x,i[1]=ts.y,i[5]=to.y,i[9]=tl.y,i[2]=ts.z,i[6]=to.z,i[10]=tl.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],y=n[11],x=n[15],b=i[0],S=i[4],M=i[8],T=i[12],w=i[1],E=i[5],A=i[9],C=i[13],R=i[2],P=i[6],I=i[10],L=i[14],N=i[3],U=i[7],D=i[11],O=i[15];return r[0]=a*b+s*w+o*R+l*N,r[4]=a*S+s*E+o*P+l*U,r[8]=a*M+s*A+o*I+l*D,r[12]=a*T+s*C+o*L+l*O,r[1]=u*b+c*w+h*R+d*N,r[5]=u*S+c*E+h*P+d*U,r[9]=u*M+c*A+h*I+d*D,r[13]=u*T+c*C+h*L+d*O,r[2]=p*b+f*w+m*R+g*N,r[6]=p*S+f*E+m*P+g*U,r[10]=p*M+f*A+m*I+g*D,r[14]=p*T+f*C+m*L+g*O,r[3]=v*b+_*w+y*R+x*N,r[7]=v*S+_*E+y*P+x*U,r[11]=v*M+_*A+y*I+x*D,r[15]=v*T+_*C+y*L+x*O,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],u=e[2],c=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15],v=o*d-l*h,_=s*d-l*c,y=s*h-o*c,x=a*d-l*u,b=a*h-o*u,S=a*c-s*u;return t*(f*v-m*_+g*y)-n*(p*v-m*x+g*b)+i*(p*_-f*x+g*S)-r*(p*y-f*b+m*S)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*h*l+f*o*d-s*m*d-c*o*g+s*h*g,_=p*h*l-u*m*l-p*o*d+a*m*d+u*o*g-a*h*g,y=u*f*l-p*c*l+p*s*d-a*f*d-u*s*g+a*c*g,x=p*c*o-u*f*o-p*s*h+a*f*h+u*s*m-a*c*m,b=t*v+n*_+i*y+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/b;return e[0]=v*S,e[1]=(f*h*r-c*m*r-f*i*d+n*m*d+c*i*g-n*h*g)*S,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*S,e[3]=(c*o*r-s*h*r-c*i*l+n*h*l+s*i*d-n*o*d)*S,e[4]=_*S,e[5]=(u*m*r-p*h*r+p*i*d-t*m*d-u*i*g+t*h*g)*S,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*S,e[7]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*S,e[8]=y*S,e[9]=(p*c*r-u*f*r-p*n*d+t*f*d+u*n*g-t*c*g)*S,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*S,e[11]=(u*s*r-a*c*r-u*n*l+t*c*l+a*n*d-t*s*d)*S,e[12]=x*S,e[13]=(u*f*i-p*c*i+p*n*h-t*f*h-u*n*m+t*c*m)*S,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*S,e[15]=(a*c*i-u*s*i+u*n*o-t*c*o-a*n*h+t*s*h)*S,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,u=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,u*s+n,u*o-i*a,0,l*o-i*s,u*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,u=a+a,c=s+s,h=r*l,d=r*u,p=r*c,f=a*u,m=a*c,g=s*c,v=o*l,_=o*u,y=o*c,x=n.x,b=n.y,S=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+y)*x,i[2]=(p-_)*x,i[3]=0,i[4]=(d-y)*b,i[5]=(1-(h+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(p+_)*S,i[9]=(m-v)*S,i[10]=(1-(h+f))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;if(e.x=i[12],e.y=i[13],e.z=i[14],0===this.determinant())return n.set(1,1,1),t.identity(),this;let r=tn.set(i[0],i[1],i[2]).length(),a=tn.set(i[4],i[5],i[6]).length(),s=tn.set(i[8],i[9],i[10]).length();0>this.determinant()&&(r=-r),ti.copy(this);let o=1/r,l=1/a,u=1/s;return ti.elements[0]*=o,ti.elements[1]*=o,ti.elements[2]*=o,ti.elements[4]*=l,ti.elements[5]*=l,ti.elements[6]*=l,ti.elements[8]*=u,ti.elements[9]*=u,ti.elements[10]*=u,t.setFromRotationMatrix(ti),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=r/(a-r),u=a*r/(a-r);else if(2e3===s)l=-(a+r)/(a-r),u=-2*a*r/(a-r);else if(2001===s)l=-a/(a-r),u=-a*r/(a-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return c[0]=2*r/(t-e),c[4]=0,c[8]=(t+e)/(t-e),c[12]=0,c[1]=0,c[5]=2*r/(n-i),c[9]=(n+i)/(n-i),c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=1/(a-r),u=a/(a-r);else if(2e3===s)l=-2/(a-r),u=-(a+r)/(a-r);else if(2001===s)l=-1/(a-r),u=-r/(a-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return c[0]=2/(t-e),c[4]=0,c[8]=0,c[12]=-(t+e)/(t-e),c[1]=0,c[5]=2/(n-i),c[9]=0,c[13]=-(n+i)/(n-i),c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}let tn=new ef,ti=new tt,tr=new ef(0,0,0),ta=new ef(1,1,1),ts=new ef,to=new ef,tl=new ef,tu=new tt,tc=new ep;class th{constructor(e=0,t=0,n=0,i=th.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],u=i[9],c=i[2],h=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(es(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-es(u,-1,1)),.9999999>Math.abs(u)?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(es(h,-1,1)),.9999999>Math.abs(h)?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-es(c,-1,1)),.9999999>Math.abs(c)?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(es(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-es(a,-1,1)),.9999999>Math.abs(a)?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-u,d),this._y=0);break;default:J("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tc.setFromEuler(this),this.setFromQuaternion(tc,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}th.DEFAULT_ORDER="XYZ";class td{constructor(){this.mask=1}set(e){this.mask=1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){tR.subVectors(i,t),tP.subVectors(n,t),tI.subVectors(e,t);let a=tR.dot(tR),s=tR.dot(tP),o=tR.dot(tI),l=tP.dot(tP),u=tP.dot(tI),c=a*l-s*s;if(0===c)return r.set(0,0,0),null;let h=1/c,d=(l*o-s*u)*h,p=(a*u-s*o)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,tL)&&tL.x>=0&&tL.y>=0&&tL.x+tL.y<=1}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,tL)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,tL.x),o.addScaledVector(a,tL.y),o.addScaledVector(s,tL.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return tB.setScalar(0),tk.setScalar(0),tV.setScalar(0),tB.fromBufferAttribute(e,t),tk.fromBufferAttribute(e,n),tV.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(tB,r.x),a.addScaledVector(tk,r.y),a.addScaledVector(tV,r.z),a}static isFrontFacing(e,t,n,i){return tR.subVectors(n,t),tP.subVectors(e,t),0>tR.cross(tP).dot(i)}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return tR.subVectors(this.c,this.b),tP.subVectors(this.a,this.b),.5*tR.cross(tP).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tH.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tH.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return tH.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tH.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tH.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;tN.subVectors(a,r),tU.subVectors(s,r),tO.subVectors(e,r);let o=tN.dot(tO),l=tU.dot(tO);if(o<=0&&l<=0)return t.copy(r);tF.subVectors(e,a);let u=tN.dot(tF),c=tU.dot(tF);if(u>=0&&c<=u)return t.copy(a);let h=o*c-u*l;if(h<=0&&o>=0&&u<=0)return n=o/(o-u),t.copy(r).addScaledVector(tN,n);tz.subVectors(e,s);let d=tN.dot(tz),p=tU.dot(tz);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(tU,i);let m=u*p-d*c;if(m<=0&&c-u>=0&&d-p>=0)return tD.subVectors(s,a),i=(c-u)/(c-u+(d-p)),t.copy(a).addScaledVector(tD,i);let g=1/(m+f+h);return n=f*g,i=h*g,t.copy(r).addScaledVector(tN,n).addScaledVector(tU,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let tG={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},tW={h:0,s:0,l:0},tj={h:0,s:0,l:0};function tX(e,t,n){return(n<0&&(n+=1),n>1&&(n-=1),n<1/6)?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*6*(2/3-n):e}class tq{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){return void 0===t&&void 0===n?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,t,n),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=I){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,eb.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=eb.workingColorSpace){return this.r=e,this.g=t,this.b=n,eb.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=eb.workingColorSpace){if(e=eo(e,1),t=es(t,0,1),n=es(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=tX(r,i,e+1/3),this.g=tX(r,i,e),this.b=tX(r,i,e-1/3)}return eb.colorSpaceToWorking(this,i),this}setStyle(e,t=I){let n;function i(t){void 0!==t&&1>parseFloat(t)&&J("Color: Alpha component of "+e+" will be ignored.")}if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:J("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(i,16),t);J("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=I){let n=tG[e.toLowerCase()];return void 0!==n?this.setHex(n,t):J("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=eS(e.r),this.g=eS(e.g),this.b=eS(e.b),this}copyLinearToSRGB(e){return this.r=eM(e.r),this.g=eM(e.g),this.b=eM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=I){return eb.workingToColorSpace(tY.copy(this),e),65536*Math.round(es(255*tY.r,0,255))+256*Math.round(es(255*tY.g,0,255))+Math.round(es(255*tY.b,0,255))}getHexString(e=I){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=eb.workingColorSpace){let n,i;eb.workingToColorSpace(tY.copy(this),t);let r=tY.r,a=tY.g,s=tY.b,o=Math.max(r,a,s),l=Math.min(r,a,s),u=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=u<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+6*(a0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){J(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){J(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(n.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(n.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(null!==t){let e=t.length;n=Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class tK extends tJ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tq(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}let t$=function(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;(8388608&t)==0;)t<<=1,n-=8388608;t&=-8388609,n+=0x38800000,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=0x38000000+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=0x47800000,s[32]=0x80000000;for(let e=33;e<63;++e)s[e]=0x80000000+(e-32<<23);s[63]=0xc7800000;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}();function tQ(e){Math.abs(e)>65504&&J("DataUtils.toHalfFloat(): Value out of range."),e=es(e,-65504,65504),t$.floatView[0]=e;let t=t$.uint32View[0],n=t>>23&511;return t$.baseTable[n]+((8388607&t)>>t$.shiftTable[n])}function t0(e){let t=e>>10;return t$.uint32View[0]=t$.mantissaTable[t$.offsetTable[t]+(1023&e)]+t$.exponentTable[t],t$.floatView[0]}class t1{static toHalfFloat(e){return tQ(e)}static fromHalfFloat(e){return t0(e)}}let t2=new ef,t3=new ed,t4=0;class t5{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:t4++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;it.count&&J("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ez);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ef(-1/0,-1/0,-1/0),new ef(Infinity,Infinity,Infinity));return}if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let i=n[t];e.data.attributes[t]=i.toJSON(e.data)}let i={},r=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere=s.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;null!==n&&this.setIndex(n.clone());let i=e.attributes;for(let e in i){let n=i[e];this.setAttribute(e,n.clone(t))}let r=e.morphAttributes;for(let e in r){let n=[],i=r[e];for(let e=0,r=i.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)||(np.copy(r).invert(),nf.copy(e.ray).applyMatrix4(np),(null===n.boundingBox||!1!==nf.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,nf)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,c=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=h.length;rn.far?null:{distance:l,point:nM.clone(),object:e}}(e,t,n,i,nv,n_,ny,nS);if(c){let e=new ef;tH.getBarycoord(nS,nv,n_,ny,e),r&&(c.uv=tH.getInterpolatedAttribute(r,o,l,u,e,new ed)),a&&(c.uv1=tH.getInterpolatedAttribute(a,o,l,u,e,new ed)),s&&(c.normal=tH.getInterpolatedAttribute(s,o,l,u,e,new ef),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let t={a:o,b:l,c:u,normal:new ef,materialIndex:0};tH.getNormal(nv,n_,ny,t.normal),c.face=t,c.barycoord=e}return c}class nE extends nd{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r);const o=[],l=[],u=[],c=[];let h=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let _=a/m,y=p/g,x=a/2,b=p/2,S=f/2,M=m+1,T=g+1,w=0,E=0,A=new ef;for(let a=0;a0?1:-1,u.push(A.x,A.y,A.z),c.push(o/m),c.push(1-a/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class nL extends tC{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tt,this.projectionMatrix=new tt,this.projectionMatrixInverse=new tt,this.coordinateSystem=2e3,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}let nN=new ef,nU=new ed,nD=new ed;class nO extends nL{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*er*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*ei*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*er*Math.atan(Math.tan(.5*ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){nN.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(nN.x,nN.y).multiplyScalar(-e/nN.z),nN.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(nN.x,nN.y).multiplyScalar(-e/nN.z)}getViewSize(e,t){return this.getViewBounds(e,nU,nD),t.subVectors(nD,nU)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*ei*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class nF extends tC{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new nO(-90,1,e,t);i.layers=this.layers,this.add(i);const r=new nO(-90,1,e,t);r.layers=this.layers,this.add(r);const a=new nO(-90,1,e,t);a.layers=this.layers,this.add(a);const s=new nO(-90,1,e,t);s.layers=this.layers,this.add(s);const o=new nO(-90,1,e,t);o.layers=this.layers,this.add(o);const l=new nO(-90,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let e of t)this.remove(e);if(2e3===e)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===e)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,s,o,l,u]=this.children,c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(c,h,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class nz extends eP{constructor(e=[],t=301,n,i,r,a,s,o,l,u){super(e,t,n,i,r,a,s,o,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class nB extends eN{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1};this.texture=new nz([n,n,n,n,n,n]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new nE(5,5,5),r=new nI({name:"CubemapFromEquirect",uniforms:nA(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;let a=new nT(i,r),s=t.minFilter;return 1008===t.minFilter&&(t.minFilter=1006),new nF(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}class nk extends tC{constructor(){super(),this.isGroup=!0,this.type="Group"}}let nV={type:"move"};class nH{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nk,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nk,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ef,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ef),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nk,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ef,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ef),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null,s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){for(let i of(a=!0,e.hand.values())){let e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}let i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position);l.inputState.pinching&&s>.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1);null!==s&&(null===(i=t.getPose(e.targetRaySpace,n))&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(nV)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new nk;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class nG{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new tq(e),this.density=t}clone(){return new nG(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class nW{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new tq(e),this.near=t,this.far=n}clone(){return new nW(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class nj extends tC{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new th,this.environmentIntensity=1,this.environmentRotation=new th,this.overrideMaterial=null,"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class nX{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=ea()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:nJ.clone(),uv:tH.getInterpolation(nJ,n2,n3,n4,n5,n6,n8,new ed),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function n7(e,t,n,i,r,a){nQ.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(n0.x=a*nQ.x-r*nQ.y,n0.y=r*nQ.x+a*nQ.y):n0.copy(nQ),e.copy(t),e.x+=n0.x,e.y+=n0.y,e.applyMatrix4(n1)}let ie=new ef,it=new ef;class ii extends tC{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){ie.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(ie);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){let n,i;ie.setFromMatrixPosition(e.matrixWorld),it.setFromMatrixPosition(this.matrixWorld);let r=ie.distanceTo(it)/e.zoom;for(n=1,t[0].object.visible=!0,i=t.length;n=e)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||iI.getNormalMatrix(e),i=this.coplanarPoint(iR).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let iN=new e2,iU=new ed(.5,.5),iD=new ef;class iO{constructor(e=new iL,t=new iL,n=new iL,i=new iL,r=new iL,a=new iL){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){let i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,d-u,g-p,x-v).normalize(),i[1].setComponents(l+a,d+u,g+p,x+v).normalize(),i[2].setComponents(l+s,d+c,g+f,x+_).normalize(),i[3].setComponents(l-s,d-c,g-f,x-_).normalize(),n)i[4].setComponents(o,h,m,y).normalize(),i[5].setComponents(l-o,d-h,g-m,x-y).normalize();else if(i[4].setComponents(l-o,d-h,g-m,x-y).normalize(),2e3===t)i[5].setComponents(l+o,d+h,g+m,x+y).normalize();else if(2001===t)i[5].setComponents(o,h,m,y).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),iN.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),iN.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iN)}intersectsSprite(e){return iN.center.set(0,0,0),iN.radius=.7071067811865476+iU.distanceTo(e.center),iN.applyMatrix4(e.matrixWorld),this.intersectsSphere(iN)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,iD.y=i.normal.y>0?e.max.y:e.min.y,iD.z=i.normal.z>0?e.max.z:e.min.z,0>i.distanceToPoint(iD))return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(0>t[n].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}let iF=new tt,iz=new iO;class iB{constructor(){this.coordinateSystem=2e3}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let n=0;n=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let s=r[this.index];a.push(s),this.index++,s.start=e,s.count=t,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}},iQ=new nT,i0=[];function i1(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let i=0;i65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new t5(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ez);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw Error("THREE.BatchedMesh: Maximum item count reached.");let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ik),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let i=this._matricesTexture;iG.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;let r=this._colorsTexture;return r&&(iW.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){let i;this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=-1===t?e.getAttribute("position").count:t;let s=e.getIndex();if(null!==s&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=-1===n?s.count:n),-1!==r.indexStart&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ik),a[i=this._availableGeometryIds.shift()]=r):(i=this._geometryCount,this._geometryCount++,a.push(r)),this.setGeometryAt(i,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,i}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=t.getIndex(),s=this._geometryInfo[e];if(i&&a.count>s.reservedIndexCount||t.attributes.position.count>s.reservedVertexCount)throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let o=s.vertexStart,l=s.reservedVertexCount;for(let e in s.vertexCount=t.getAttribute("position").count,n.attributes){let i=t.getAttribute(e),r=n.getAttribute(e);!function(e,t,n=0){let i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let r=e.count;for(let a=0;a=t.length||!1===t[e].active)return this;let n=this._instanceInfo;for(let t=0,i=n.length;tt).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),r=this.geometry;for(let a=0,s=n.length;a=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingBox){let e=new ez,t=n.index,r=n.attributes.position;for(let n=i.start,a=i.start+i.count;n=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingSphere){let t=new e2;this.getBoundingBoxAt(e,iq),iq.getCenter(t.center);let r=n.index,a=n.attributes.position,s=0;for(let e=i.start,n=i.start+i.count;ee.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let i=this.geometry;i.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new nd,this._initializeGeometry(i));let r=this.geometry;for(let e in i.index&&i1(i.index.array,r.index.array),i.attributes)i1(i.attributes[e].array,r.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;iQ.material=this.material,iQ.geometry.index=a.index,iQ.geometry.attributes=a.attributes,null===iQ.geometry.boundingBox&&(iQ.geometry.boundingBox=new ez),null===iQ.geometry.boundingSphere&&(iQ.geometry.boundingSphere=new e2);for(let a=0,s=n.length;a({...e,boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=i.getIndex(),s=null===a?1:a.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,c=this._geometryInfo,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,f=n.isArrayCamera?iX:ij;h&&!n.isArrayCamera&&(iG.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ij.setFromProjectionMatrix(iG,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){iG.copy(this.matrixWorld).invert(),iZ.setFromMatrixPosition(n.matrixWorld).applyMatrix4(iG),iJ.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(iG);for(let e=0,t=o.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei)return;i7.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(i7);if(!(lt.far))return{distance:l,point:re.clone().applyMatrix4(e.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:e}}let ri=new ef,rr=new ef;class ra extends rt{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}class rf extends eP{constructor(e,t,n,i,r=1006,a=1006,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const u=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class rm extends rf{constructor(e,t,n,i,r,a,s,o){super({},e,t,n,i,r,a,s,o),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class rg extends eP{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class rv extends eP{constructor(e,t,n,i,r,a,s,o,l,u,c,h){super(null,a,s,o,l,u,i,r,c,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class r_ extends rv{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ry extends rv{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class rx extends eP{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rb extends eP{constructor(e,t,n=1014,i,r,a,s=1003,o=1003,l,u=1026,c=1){if(1026!==u&&1027!==u)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:c},i,r,a,s,o,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new eE(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class rS extends rb{constructor(e,t=1014,n=301,i,r,a=1003,s=1003,o,l=1026){const u={width:e,height:e,depth:1};super(e,e,t,n,i,r,a,s,o,l),this.image=[u,u,u,u,u,u],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class rM extends eP{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rT extends nd{constructor(e=1,t=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:r},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i));const a=[],s=[],o=[],l=[],u=t/2,c=Math.PI/2*e,h=t,d=2*c+h,p=2*n+(r=Math.max(1,Math.floor(r))),f=i+1,m=new ef,g=new ef;for(let v=0;v<=p;v++){let _=0,y=0,x=0,b=0;if(v<=n){const t=v/n,i=t*Math.PI/2;y=-u-e*Math.cos(i),x=e*Math.sin(i),b=-e*Math.cos(i),_=t*c}else if(v<=n+r){const i=(v-n)/r;y=-u+i*t,x=e,b=0,_=c+i*h}else{const t=(v-n-r)/n,i=t*Math.PI/2;y=u+e*Math.sin(i),x=e*Math.cos(i),b=e*Math.sin(i),_=c+h+t*c}const S=Math.max(0,Math.min(1,_/d));let M=0;0===v?M=.5/i:v===p&&(M=-.5/i);for(let e=0;e<=i;e++){const t=e/i,n=t*Math.PI*2,r=Math.sin(n),a=Math.cos(n);g.x=-x*a,g.y=y,g.z=x*r,s.push(g.x,g.y,g.z),m.set(-x*a,b,x*r),m.normalize(),o.push(m.x,m.y,m.z),l.push(t+M,S)}if(v>0){const e=(v-1)*f;for(let t=0;t0||0!==i)&&(u.push(a,s,l),_+=3),(t>0||i!==r-1)&&(u.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_})(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new nr(c,3)),this.setAttribute("normal",new nr(h,3)),this.setAttribute("uv",new nr(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rE(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rA extends rE{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new rA(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rC extends nd{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e){r.push(e.x,e.y,e.z)}function o(t,n){let i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function l(e,t,n,i){i<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}(function(e){let n=new ef,i=new ef,r=new ef;for(let a=0;a.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new nr(r,3)),this.setAttribute("normal",new nr(r.slice(),3)),this.setAttribute("uv",new nr(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rC(e.vertices,e.indices,e.radius,e.detail)}}class rR extends rC{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rR(e.radius,e.detail)}}let rP=new ef,rI=new ef,rL=new ef,rN=new tH;class rU extends nd{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=Math.cos(ei*t),i=e.getIndex(),r=e.getAttribute("position"),a=i?i.count:r.count,s=[0,0,0],o=["a","b","c"],l=[,,,],u={},c=[];for(let e=0;e0)o=r-1;else{o=r;break}if(i[r=o]===n)return r/(a-1);let u=i[r],c=i[r+1];return(r+(n-u)/(c-u))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new ed:new ef);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new ef,i=[],r=[],a=[],s=new ef,o=new tt;for(let t=0;t<=e;t++){let n=t/e;i[t]=this.getTangentAt(n,new ef)}r[0]=new ef,a[0]=new ef;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),c=Math.abs(i[0].y),h=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(es(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(es(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class rO extends rD{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t=new ed){let n=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)n;)i-=n;i0?0:(Math.floor(Math.abs(o)/a)+1)*a:0===l&&o===a-1&&(o=a-2,l=1),this.closed||o>0?n=r[(o-1)%a]:(rB.subVectors(r[0],r[1]).add(r[0]),n=rB);let u=r[o%a],c=r[(o+1)%a];if(this.closed||o+2n.length-2?n.length-1:r+1],u=n[r>n.length-3?n.length-1:r+2];return t.set(rW(a,s.x,o.x,l.x,u.x),rW(a,s.y,o.y,l.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class r3 extends r2{constructor(e){super(e),this.uuid=ea(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n0)for(let r=t;r=t;r-=i)a=ao(r/i|0,e[r],e[r+1],a);return a&&at(a,a.next)&&(al(a),a=a.next),a}function r5(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(at(n,n.next)||0===ae(n.prev,n,n.next))){if(al(n),(n=t=n.prev)===n.next)break;i=!0}else n=n.next;while(i||n!==t)return t}function r6(e,t){let n=e.x-t.x;return 0===n&&0==(n=e.y-t.y)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function r8(e,t,n,i,r){return(e=((e=((e=((e=((e=(e-n)*r|0)|e<<8)&0xff00ff)|e<<4)&0xf0f0f0f)|e<<2)&0x33333333)|e<<1)&0x55555555)|(t=((t=((t=((t=((t=(t-i)*r|0)|t<<8)&0xff00ff)|t<<4)&0xf0f0f0f)|t<<2)&0x33333333)|t<<1)&0x55555555)<<1}function r9(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function r7(e,t,n,i,r,a,s,o){return(e!==s||t!==o)&&r9(e,t,n,i,r,a,s,o)}function ae(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function at(e,t){return e.x===t.x&&e.y===t.y}function an(e,t,n,i){let r=ar(ae(e,t,n)),a=ar(ae(e,t,i)),s=ar(ae(n,i,e)),o=ar(ae(n,i,t));return!!(r!==a&&s!==o||0===r&&ai(e,n,t)||0===a&&ai(e,i,t)||0===s&&ai(n,e,i)||0===o&&ai(n,t,i))}function ai(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ar(e){return e>0?1:e<0?-1:0}function aa(e,t){return 0>ae(e.prev,e,e.next)?ae(e,t,e.next)>=0&&ae(e,e.prev,t)>=0:0>ae(e,t,e.prev)||0>ae(e,e.next,t)}function as(e,t){let n=au(e.i,e.x,e.y),i=au(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function ao(e,t,n,i){let r=au(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function al(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function au(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ac{static triangulate(e,t,n=2){return function(e,t,n=2){let i,r,a,s=t&&t.length,o=s?t[0]*n:e.length,l=r4(e,0,o,n,!0),u=[];if(!l||l.next===l.prev)return u;if(s&&(l=function(e,t,n,i){let r=[];for(let n=0,a=t.length;n=i.next.y&&i.next.y!==i.y){let e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,n=i.x=i.x&&i.x>=l&&r!==i.x&&r9(an.x||i.x===n.x&&(h=n,d=i,0>ae(h.prev,h,d.prev)&&0>ae(d.next,h,h.next))))&&(n=i,c=t)}i=i.next}while(i!==o)return n}(e,t);if(!n)return t;let i=as(n,e);return r5(i,i.next),r5(n,n.next)}(r[e],n);return n}(e,t,l,n)),e.length>80*n){i=e[0],r=e[1];let t=i,s=r;for(let a=n;at&&(t=n),o>s&&(s=o)}a=0!==(a=Math.max(t-i,s-r))?32767/a:0}return function e(t,n,i,r,a,s,o){if(!t)return;!o&&s&&function(e,t,n,i){let r=e;do 0===r.z&&(r.z=r8(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e)r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let i,r=e;e=null;let a=null;for(t=0;r;){t++;let s=r,o=0;for(let e=0;e0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=s}a.nextZ=null,n*=2}while(t>1)}(r)}(t,r,a,s);let l=t;for(;t.prev!==t.next;){let u=t.prev,c=t.next;if(s?function(e,t,n,i){let r=e.prev,a=e.next;if(ae(r,e,a)>=0)return!1;let s=r.x,o=e.x,l=a.x,u=r.y,c=e.y,h=a.y,d=Math.min(s,o,l),p=Math.min(u,c,h),f=Math.max(s,o,l),m=Math.max(u,c,h),g=r8(d,p,t,n,i),v=r8(f,m,t,n,i),_=e.prevZ,y=e.nextZ;for(;_&&_.z>=g&&y&&y.z<=v;){if(_.x>=d&&_.x<=f&&_.y>=p&&_.y<=m&&_!==r&&_!==a&&r7(s,u,o,c,l,h,_.x,_.y)&&ae(_.prev,_,_.next)>=0||(_=_.prevZ,y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&r7(s,u,o,c,l,h,y.x,y.y)&&ae(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;_&&_.z>=g;){if(_.x>=d&&_.x<=f&&_.y>=p&&_.y<=m&&_!==r&&_!==a&&r7(s,u,o,c,l,h,_.x,_.y)&&ae(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;y&&y.z<=v;){if(y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&r7(s,u,o,c,l,h,y.x,y.y)&&ae(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}(t,r,a,s):function(e){let t=e.prev,n=e.next;if(ae(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,s=t.y,o=e.y,l=n.y,u=Math.min(i,r,a),c=Math.min(s,o,l),h=Math.max(i,r,a),d=Math.max(s,o,l),p=n.next;for(;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=c&&p.y<=d&&r7(i,s,r,o,a,l,p.x,p.y)&&ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}(t)){n.push(u.i,t.i,c.i),al(t),t=c.next,l=c.next;continue}if((t=c)===l){o?1===o?e(t=function(e,t){let n=e;do{let i=n.prev,r=n.next.next;!at(i,r)&&an(i,n,n.next,r)&&aa(i,r)&&aa(r,i)&&(t.push(i.i,n.i,r.i),al(n),al(n.next),n=e=r),n=n.next}while(n!==e)return r5(n)}(r5(t),n),n,i,r,a,s,2):2===o&&function(t,n,i,r,a,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){var l,u;if(o.i!==t.i&&(l=o,u=t,l.next.i!==u.i&&l.prev.i!==u.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&an(n,n.next,e,t))return!0;n=n.next}while(n!==e)return!1}(l,u)&&(aa(l,u)&&aa(u,l)&&function(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e)return i}(l,u)&&(ae(l.prev,l,u.prev)||ae(l,u.prev,u))||at(l,u)&&ae(l.prev,l,l.next)>0&&ae(u.prev,u,u.next)>0))){let l=as(o,t);o=r5(o,o.next),l=r5(l,l.next),e(o,n,i,r,a,s,0),e(l,n,i,r,a,s,0);return}t=t.next}o=o.next}while(o!==t)}(t,n,i,r,a,s):e(r5(t),n,i,r,a,s,1);break}}}(l,u,n,i,r,a,0),u}(e,t,n)}}class ah{static area(e){let t=e.length,n=0;for(let i=t-1,r=0;rah.area(e)}static triangulateShape(e,t){let n=[],i=[],r=[];ad(e),ap(n,e);let a=e.length;t.forEach(ad);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function ap(e,t){for(let n=0;nNumber.EPSILON){let h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),p=t.x-o/h,f=t.y+s/h,m=((n.x-u/d-p)*u-(n.y+l/d-f)*l)/(s*u-o*l),g=(i=p+s*m-e.x)*i+(r=f+o*m-e.y)*r;if(g<=2)return new ed(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(u)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new ed(i/a,r/a)}let L=[];for(let e=0,t=C.length,n=t-1,i=e+1;e=0;e--){let t=e/_,n=m*Math.cos(t*Math.PI/2),i=g*Math.sin(t*Math.PI/2)+v;for(let e=0,t=C.length;e=0;){let a=r,s=r-1;s<0&&(s=e.length-1);for(let e=0,r=d+2*_;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class aU extends tJ{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new tq(0xffffff),this.specular=new tq(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aD extends tJ{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new tq(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class aO extends tJ{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class aF extends tJ{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new tq(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class az extends tJ{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class aB extends tJ{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class ak extends tJ{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new tq(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aV extends i3{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function aH(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function aG(e){let t=e.length,n=Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort(function(t,n){return e[t]-e[n]}),n}function aW(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function aj(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do void 0!==(s=a[i])&&(t.push(a.time),n.push(...s)),a=e[r++];while(void 0!==a)else if(void 0!==s.toArray)do void 0!==(s=a[i])&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++];while(void 0!==a)else do void 0!==(s=a[i])&&(t.push(a.time),n.push(s)),a=e[r++];while(void 0!==a)}class aX{static convertArray(e,t){return aH(e,t)}static isTypedArray(e){return H(e)}static getKeyframeOrder(e){return aG(e)}static sortedArray(e,t,n){return aW(e,t,n)}static flattenJSON(e,t,n,i){aj(e,t,n,i)}static subclip(e,t,n,i,r=30){return function(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(o=a.tracks[e].times[0]);for(let e=0;e=r.times[d]){let e=d*u+l,t=e+u-l;i=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=l,n=u-l;e.evaluate(a),i=e.resultBuffer.slice(t,n)}"quaternion"===s&&new ep().fromArray(i).normalize().conjugate().toArray(i);let p=o.times.length;for(let e=0;e=r)){let s=t[1];e=(r=t[--n-1]))break i}a=n,n=0;break r}break n}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);let e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(K("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(K("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){let i=n[t];if("number"==typeof i&&isNaN(i)){K("KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){K("KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&H(i))for(let t=0,n=i.length;t!==n;++t){let n=i[t];if(isNaN(n)){K("KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=2302===this.getInterpolation(),r=e.length-1,a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=new this.constructor(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}aK.prototype.ValueTypeName="",aK.prototype.TimeBufferType=Float32Array,aK.prototype.ValueBufferType=Float32Array,aK.prototype.DefaultInterpolation=2301;class a$ extends aK{constructor(e,t,n){super(e,t,n)}}a$.prototype.ValueTypeName="bool",a$.prototype.ValueBufferType=Array,a$.prototype.DefaultInterpolation=2300,a$.prototype.InterpolantFactoryMethodLinear=void 0,a$.prototype.InterpolantFactoryMethodSmooth=void 0;class aQ extends aK{constructor(e,t,n,i){super(e,t,n,i)}}aQ.prototype.ValueTypeName="color";class a0 extends aK{constructor(e,t,n,i){super(e,t,n,i)}}a0.prototype.ValueTypeName="number";class a1 extends aq{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let e=l+s;l!==e;l+=4)ep.slerpFlat(r,0,a,l-s,a,l,o);return r}}class a2 extends aK{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new a1(this.times,this.values,this.getValueSize(),e)}}a2.prototype.ValueTypeName="quaternion",a2.prototype.InterpolantFactoryMethodSmooth=void 0;class a3 extends aK{constructor(e,t,n){super(e,t,n)}}a3.prototype.ValueTypeName="string",a3.prototype.ValueBufferType=Array,a3.prototype.DefaultInterpolation=2300,a3.prototype.InterpolantFactoryMethodLinear=void 0,a3.prototype.InterpolantFactoryMethodSmooth=void 0;class a4 extends aK{constructor(e,t,n,i){super(e,t,n,i)}}a4.prototype.ValueTypeName="vector";class a5{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ea(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push((function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return a0;case"vector":case"vector2":case"vector3":case"vector4":return a4;case"color":return aQ;case"quaternion":return a2;case"bool":case"boolean":return a$;case"string":return a3}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let t=[],n=[];aj(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)})(n[e]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,i=n.length;e!==i;++e)t.push(aK.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let e=0;e1){let e=a[1],t=i[e];t||(i[e]=t=[]),t.push(n)}}let a=[];for(let e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(J("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return K("AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];aj(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)},0),r;if(void 0!==se[e])return void se[e].push({onLoad:t,onProgress:n,onError:i});se[e]=[],se[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),s=this.mimeType,o=this.responseType;fetch(a).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&J("FileLoader: HTTP Status 0 received."),"u"{if(i)e.close();else{let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o+=r.byteLength,total:a});for(let e=0,t=n.length;e{e.error(t)})}()}}))}throw new st(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>new DOMParser().parseFromString(e,s));case"json":return e.json();default:if(""===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=new TextDecoder(t&&t[1]?t[1].toLowerCase():void 0);return e.arrayBuffer().then(e=>n.decode(e))}}}).then(t=>{a6.add(`file:${e}`,t);let n=se[e];delete se[e];for(let e=0,i=n.length;e{let n=se[e];if(void 0===n)throw this.manager.itemError(e),t;delete se[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class si extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):K(t),r.manager.itemError(e)}},n,i)}parse(e){let t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let t in e.uniforms){let r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=new tq().setHex(r.value);break;case"v2":i.uniforms[t].value=new ed().fromArray(r.value);break;case"v3":i.uniforms[t].value=new ef().fromArray(r.value);break;case"v4":i.uniforms[t].value=new eI().fromArray(r.value);break;case"m3":i.uniforms[t].value=new ev().fromArray(r.value);break;case"m4":i.uniforms[t].value=new tt().fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=new ed().fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=new ed().fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return sA.createMaterialFromType(e)}static createMaterialFromType(e){return new({ShadowMaterial:aP,SpriteMaterial:nZ,RawShaderMaterial:aI,ShaderMaterial:nI,PointsMaterial:ro,MeshPhysicalMaterial:aN,MeshStandardMaterial:aL,MeshPhongMaterial:aU,MeshToonMaterial:aD,MeshNormalMaterial:aO,MeshLambertMaterial:aF,MeshDepthMaterial:az,MeshDistanceMaterial:aB,MeshBasicMaterial:tK,MeshMatcapMaterial:ak,LineDashedMaterial:aV,LineBasicMaterial:i3,Material:tJ})[e]}}class sC{static extractUrlBase(e){let t=e.lastIndexOf("/");return -1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e))?e:t+e}}class sR extends nd{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class sP extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):K(t),r.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(e,i){if(void 0!==t[i])return t[i];let r=e.interleavedBuffers[i],a=function(e,t){if(void 0!==n[t])return n[t];let i=new Uint32Array(e.arrayBuffers[t]).buffer;return n[t]=i,i}(e,r.buffer),s=new nX(V(r.type,a),r.stride);return s.uuid=r.uuid,t[i]=s,s}let r=e.isInstancedBufferGeometry?new sR:new nd,a=e.data.index;if(void 0!==a){let e=V(a.type,a.array);r.setIndex(new t5(e,1))}let s=e.data.attributes;for(let t in s){let n,a=s[t];if(a.isInterleavedBufferAttribute)n=new nY(i(e.data,a.data),a.itemSize,a.offset,a.normalized);else{let e=V(a.type,a.array);n=new(a.isInstancedBufferAttribute?ix:t5)(e,a.itemSize,a.normalized)}void 0!==a.name&&(n.name=a.name),void 0!==a.usage&&n.setUsage(a.usage),r.setAttribute(t,n)}let o=e.data.morphAttributes;if(o)for(let t in o){let n=o[t],a=[];for(let t=0,r=n.length;t0){(n=new ss(new a8(t))).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){(t=new ss(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t{let t=null,n=null;return void 0!==e.boundingBox&&(t=new ez().fromJSON(e.boundingBox)),void 0!==e.boundingSphere&&(n=new e2().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),void 0!==e.colorsTexture&&(a._colorsTexture=c(e.colorsTexture.uuid)),void 0!==e.boundingSphere&&(a.boundingSphere=new e2().fromJSON(e.boundingSphere)),void 0!==e.boundingBox&&(a.boundingBox=new ez().fromJSON(e.boundingBox));break;case"LOD":a=new ii;break;case"Line":a=new rt(l(e.geometry),u(e.material));break;case"LineLoop":a=new rs(l(e.geometry),u(e.material));break;case"LineSegments":a=new ra(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new rd(l(e.geometry),u(e.material));break;case"Sprite":a=new n9(u(e.material));break;case"Group":a=new nk;break;case"Bone":a=new im;break;default:a=new tC}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(a.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children){let s=e.children;for(let e=0;e{if(!0!==sD.has(a))return t&&t(n),r.manager.itemEnd(e),n;i&&i(sD.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)}):(setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a);let s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,s.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,s).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(n){return a6.add(`image-bitmap:${e}`,n),t&&t(n),r.manager.itemEnd(e),n}).catch(function(t){i&&i(t),sD.set(o,t),a6.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});a6.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class sF{static getContext(){return void 0===i&&(i=new(window.AudioContext||window.webkitAudioContext)),i}static setContext(e){i=e}}class sz extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(this.manager);function s(t){i?i(t):K(t),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{let n=e.slice(0);sF.getContext().decodeAudioData(n,function(e){t(e)}).catch(s)}catch(e){s(e)}},n,i)}}let sB=new tt,sk=new tt,sV=new tt;class sH{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new nO,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new nO,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){let n,i;t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,sV.copy(e.projectionMatrix);let r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(ei*t.fov*.5)/t.zoom;sk.elements[12]=-r,sB.elements[12]=r,n=-s*t.aspect+a,i=s*t.aspect+a,sV.elements[0]=2*t.near/(i-n),sV.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy(sV),n=-s*t.aspect-a,i=s*t.aspect-a,sV.elements[0]=2*t.near/(i-n),sV.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy(sV)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(sk),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(sB)}}class sG extends nO{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class sW{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}let sj=new ef,sX=new ep,sq=new ef,sY=new ef,sZ=new ef;class sJ extends tC{constructor(){super(),this.type="AudioListener",this.context=sF.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new sW}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(sj,sX,sq),sY.set(0,0,-1).applyQuaternion(sX),sZ.set(0,1,0).applyQuaternion(sX),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(sj.x,e),t.positionY.linearRampToValueAtTime(sj.y,e),t.positionZ.linearRampToValueAtTime(sj.z,e),t.forwardX.linearRampToValueAtTime(sY.x,e),t.forwardY.linearRampToValueAtTime(sY.y,e),t.forwardZ.linearRampToValueAtTime(sY.z,e),t.upX.linearRampToValueAtTime(sZ.x,e),t.upY.linearRampToValueAtTime(sZ.y,e),t.upZ.linearRampToValueAtTime(sZ.z,e)}else t.setPosition(sj.x,sj.y,sj.z),t.setOrientation(sY.x,sY.y,sY.z,sZ.x,sZ.y,sZ.z)}}class sK extends tC{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void J("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void J("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){return!1===this.hasPlaybackControl?void J("Audio: this Audio has no playback control."):(!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this)}stop(e=0){return!1===this.hasPlaybackControl?void J("Audio: this Audio has no playback control."):(this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this)}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n;e!==i;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){ep.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;ep.multiplyQuaternionsFlat(e,a,e,t,e,n),ep.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}}let s5="\\[\\]\\.:\\/",s6=RegExp("["+s5+"]","g"),s8="[^"+s5+"]",s9="[^"+s5.replace("\\.","")+"]",s7=RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",s8)+/(WCOD+)?/.source.replace("WCOD",s9)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",s8)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",s8)+"$"),oe=["material","materials","bones","map"];class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ot.Composite(e,t,n):new ot(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(s6,"")}static parseTrackName(e){let t=s7.exec(e);if(null===t)throw Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==oe.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i=r){let a=r++,u=e[a];t[u.uuid]=l,e[l]=u,t[o]=a,e[a]=s;for(let e=0;e!==i;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s],l=o.uuid,u=t[l];if(void 0!==u)if(delete t[l],u0&&(t[s.uuid]=u),e[u]=s,e.pop();for(let e=0;e!==i;++e){let t=n[e];t[u]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,u=this.nCachedObjects_,c=Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let n=u,i=o.length;n!==i;++n){let i=o[n];c[n]=new ot(i,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class oi{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,s=Array(a),o={endingStart:2400,endingEnd:2400};for(let e=0;e!==a;++e){const t=r[e].createInterpolant(null);s[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),!0===n){let n=this._clip.duration,i=e._clip.duration;e.warp(1,i/n,t),this.warp(n/i,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=2202===n;if(0===e)return -1===r?i:a&&(1&r)==1?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));s:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break s}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&(1&r)==1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(e?i.endingStart=this.zeroSlopeAtStart?2401:2400:i.endingStart=2402,t?i.endingEnd=this.zeroSlopeAtEnd?2401:2400:i.endingEnd=2402)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}}let or=new Float32Array(1);class oa extends ee{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,u=l[o];void 0===u&&(u={},l[o]=u);for(let e=0;e!==r;++e){let r=i[e],l=r.name,c=u[l];if(void 0!==c)++c.referenceCount,a[e]=c;else{if(void 0!==(c=a[e])){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,l));continue}let i=t&&t._propertyBindings[e].binding.parsedPath;c=new s4(ot.create(n,l,i),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,l),a[e]=c}s[e].resultBuffer=c.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let s=0;s!==n;++s)t[s]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)s[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ob).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}let oM=new ef,oT=new ef,ow=new ef,oE=new ef,oA=new ef,oC=new ef,oR=new ef;class oP{constructor(e=new ef,t=new ef){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){oM.subVectors(e,this.start),oT.subVectors(this.end,this.start);let n=oT.dot(oT),i=oT.dot(oM)/n;return t&&(i=es(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=oC,n=oR){let i,r,a=1e-8*1e-8,s=this.start,o=e.start,l=this.end,u=e.end;ow.subVectors(l,s),oE.subVectors(u,o),oA.subVectors(s,o);let c=ow.dot(ow),h=oE.dot(oE),d=oE.dot(oA);if(c<=a&&h<=a)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(c<=a)i=0,r=es(r=d/h,0,1);else{let e=ow.dot(oA);if(h<=a)r=0,i=es(-e/c,0,1);else{let t=ow.dot(oE),n=c*h-t*t;i=0!==n?es((t*d-e*h)/n,0,1):0,(r=(t*i+d)/h)<0?(r=0,i=es(-e/c,0,1)):r>1&&(r=1,i=es((t-e)/c,0,1))}}return t.copy(s).add(ow.multiplyScalar(i)),n.copy(o).add(oE.multiplyScalar(r)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}let oI=new ef;class oL extends tC{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new nd,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){const n=e/32*Math.PI*2,r=t/32*Math.PI*2;i.push(Math.cos(n),Math.sin(n),1,Math.cos(r),Math.sin(r),1)}n.setAttribute("position",new nr(i,3));const r=new i3({fog:!1,toneMapped:!1});this.cone=new ra(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),oI.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(oI),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}let oN=new ef,oU=new tt,oD=new tt;class oO extends ra{constructor(e){const t=function e(t){let n=[];!0===t.isBone&&n.push(t);for(let i=0;i1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{o2.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(o2,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class o4 extends ra{constructor(e=1){const t=new nd;t.setAttribute("position",new nr([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],3)),t.setAttribute("color",new nr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,new i3({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new tq,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class o5{constructor(){this.type="ShapePath",this.color=new tq,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new r2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){let t,n,i,r,a,s=ah.isClockWise,o=this.subPaths;if(0===o.length)return[];let l=[];if(1===o.length)return n=o[0],(i=new r3).curves=n.curves,l.push(i),l;let u=!s(o[0].getPoints());u=e?!u:u;let c=[],h=[],d=[],p=0;h[0]=void 0,d[p]=[];for(let i=0,a=o.length;i1){let e=!1,t=0;for(let e=0,t=h.length;eNumber.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.ys.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i})(a.p,h[i].p)&&(n!==i&&t++,s?(s=!1,c[i].push(a)):e=!0);s&&c[n].push(a)}}t>0&&!1===e&&(d=c)}for(let e=0,t=h.length;et?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}static cover(e,t){let n;return(n=e.image&&e.image.width?e.image.width/e.image.height:1)>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}static fill(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}static getByteLength(e,t,n,i){return o8(e,t,n,i)}}function o7(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0===t||null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function le(e){let t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){let e=t.get(n);(!e||e.versiontypeof Float16Array&&r instanceof Float16Array)i=e.HALF_FLOAT;else if(r instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)i=e.SHORT;else if(r instanceof Uint32Array)i=e.UNSIGNED_INT;else if(r instanceof Int32Array)i=e.INT;else if(r instanceof Int8Array)i=e.BYTE;else if(r instanceof Uint8Array)i=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)i=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);return{buffer:o,type:i,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:s}}(n,i));else if(r.versione.start-t.start);let t=0;for(let e=1;etypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}})),"u">typeof window&&(window.__THREE__?J("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182"),e.s(["ACESFilmicToneMapping",()=>4,"AddEquation",()=>100,"AddOperation",()=>2,"AdditiveAnimationBlendMode",()=>2501,"AdditiveBlending",()=>2,"AgXToneMapping",()=>6,"AlphaFormat",()=>1021,"AlwaysCompare",()=>519,"AlwaysDepth",()=>1,"AlwaysStencilFunc",()=>519,"AmbientLight",()=>sM,"AnimationAction",()=>oi,"AnimationClip",()=>a5,"AnimationLoader",()=>si,"AnimationMixer",()=>oa,"AnimationObjectGroup",()=>on,"AnimationUtils",()=>aX,"ArcCurve",()=>rF,"ArrayCamera",()=>sG,"ArrowHelper",()=>o3,"AttachedBindMode",()=>R,"Audio",()=>sK,"AudioAnalyser",()=>s3,"AudioContext",()=>sF,"AudioListener",()=>sJ,"AudioLoader",()=>sz,"AxesHelper",()=>o4,"BackSide",()=>1,"BasicDepthPacking",()=>3200,"BasicShadowMap",()=>0,"BatchedMesh",()=>i2,"Bone",()=>im,"BooleanKeyframeTrack",()=>a$,"Box2",()=>oS,"Box3",()=>ez,"Box3Helper",()=>o0,"BoxGeometry",()=>nE,"BoxHelper",()=>oQ,"BufferAttribute",()=>t5,"BufferGeometry",()=>nd,"BufferGeometryLoader",()=>sP,"ByteType",()=>1010,"Cache",()=>a6,"Camera",()=>nL,"CameraHelper",()=>oJ,"CanvasTexture",()=>rx,"CapsuleGeometry",()=>rT,"CatmullRomCurve3",()=>rG,"CineonToneMapping",()=>3,"CircleGeometry",()=>rw,"ClampToEdgeWrapping",()=>1001,"Clock",()=>sW,"Color",()=>tq,"ColorKeyframeTrack",()=>aQ,"ColorManagement",()=>eb,"CompressedArrayTexture",()=>r_,"CompressedCubeTexture",()=>ry,"CompressedTexture",()=>rv,"CompressedTextureLoader",()=>sr,"ConeGeometry",()=>rA,"ConstantAlphaFactor",()=>213,"ConstantColorFactor",()=>211,"Controls",()=>o6,"CubeCamera",()=>nF,"CubeDepthTexture",()=>rS,"CubeReflectionMapping",()=>301,"CubeRefractionMapping",()=>302,"CubeTexture",()=>nz,"CubeTextureLoader",()=>so,"CubeUVReflectionMapping",()=>306,"CubicBezierCurve",()=>rq,"CubicBezierCurve3",()=>rY,"CubicInterpolant",()=>aY,"CullFaceBack",()=>1,"CullFaceFront",()=>2,"CullFaceFrontBack",()=>3,"CullFaceNone",()=>0,"Curve",()=>rD,"CurvePath",()=>r1,"CustomBlending",()=>5,"CustomToneMapping",()=>5,"CylinderGeometry",()=>rE,"Cylindrical",()=>oy,"Data3DTexture",()=>eO,"DataArrayTexture",()=>eU,"DataTexture",()=>ig,"DataTextureLoader",()=>sl,"DataUtils",()=>t1,"DecrementStencilOp",()=>7683,"DecrementWrapStencilOp",()=>34056,"DefaultLoadingManager",()=>a9,"DepthFormat",()=>1026,"DepthStencilFormat",()=>1027,"DepthTexture",()=>rb,"DetachedBindMode",()=>P,"DirectionalLight",()=>sS,"DirectionalLightHelper",()=>oq,"DiscreteInterpolant",()=>aJ,"DodecahedronGeometry",()=>rR,"DoubleSide",()=>2,"DstAlphaFactor",()=>206,"DstColorFactor",()=>208,"DynamicCopyUsage",()=>35050,"DynamicDrawUsage",()=>35048,"DynamicReadUsage",()=>35049,"EdgesGeometry",()=>rU,"EllipseCurve",()=>rO,"EqualCompare",()=>514,"EqualDepth",()=>4,"EqualStencilFunc",()=>514,"EquirectangularReflectionMapping",()=>303,"EquirectangularRefractionMapping",()=>304,"Euler",()=>th,"EventDispatcher",()=>ee,"ExternalTexture",()=>rM,"ExtrudeGeometry",()=>af,"FileLoader",()=>sn,"Float16BufferAttribute",()=>ni,"Float32BufferAttribute",()=>nr,"FloatType",()=>1015,"Fog",()=>nW,"FogExp2",()=>nG,"FramebufferTexture",()=>rg,"FrontSide",()=>0,"Frustum",()=>iO,"FrustumArray",()=>iB,"GLBufferAttribute",()=>oh,"GLSL1",()=>"100","GLSL3",()=>D,"GreaterCompare",()=>516,"GreaterDepth",()=>6,"GreaterEqualCompare",()=>518,"GreaterEqualDepth",()=>5,"GreaterEqualStencilFunc",()=>518,"GreaterStencilFunc",()=>516,"GridHelper",()=>oH,"Group",()=>nk,"HalfFloatType",()=>1016,"HemisphereLight",()=>sh,"HemisphereLightHelper",()=>oV,"IcosahedronGeometry",()=>ag,"ImageBitmapLoader",()=>sO,"ImageLoader",()=>ss,"ImageUtils",()=>eT,"IncrementStencilOp",()=>7682,"IncrementWrapStencilOp",()=>34055,"InstancedBufferAttribute",()=>ix,"InstancedBufferGeometry",()=>sR,"InstancedInterleavedBuffer",()=>oc,"InstancedMesh",()=>iC,"Int16BufferAttribute",()=>t7,"Int32BufferAttribute",()=>nt,"Int8BufferAttribute",()=>t6,"IntType",()=>1013,"InterleavedBuffer",()=>nX,"InterleavedBufferAttribute",()=>nY,"Interpolant",()=>aq,"InterpolateDiscrete",()=>2300,"InterpolateLinear",()=>2301,"InterpolateSmooth",()=>2302,"InterpolationSamplingMode",()=>z,"InterpolationSamplingType",()=>F,"InvertStencilOp",()=>5386,"KeepStencilOp",()=>7680,"KeyframeTrack",()=>aK,"LOD",()=>ii,"LatheGeometry",()=>av,"Layers",()=>td,"LessCompare",()=>513,"LessDepth",()=>2,"LessEqualCompare",()=>515,"LessEqualDepth",()=>3,"LessEqualStencilFunc",()=>515,"LessStencilFunc",()=>513,"Light",()=>sc,"LightProbe",()=>sE,"Line",()=>rt,"Line3",()=>oP,"LineBasicMaterial",()=>i3,"LineCurve",()=>rZ,"LineCurve3",()=>rJ,"LineDashedMaterial",()=>aV,"LineLoop",()=>rs,"LineSegments",()=>ra,"LinearFilter",()=>1006,"LinearInterpolant",()=>aZ,"LinearMipMapLinearFilter",()=>1008,"LinearMipMapNearestFilter",()=>1007,"LinearMipmapLinearFilter",()=>1008,"LinearMipmapNearestFilter",()=>1007,"LinearSRGBColorSpace",()=>L,"LinearToneMapping",()=>1,"LinearTransfer",()=>N,"Loader",()=>a7,"LoaderUtils",()=>sC,"LoadingManager",()=>a8,"LoopOnce",()=>2200,"LoopPingPong",()=>2202,"LoopRepeat",()=>2201,"MOUSE",()=>A,"Material",()=>tJ,"MaterialLoader",()=>sA,"MathUtils",()=>eh,"Matrix2",()=>ox,"Matrix3",()=>ev,"Matrix4",()=>tt,"MaxEquation",()=>104,"Mesh",()=>nT,"MeshBasicMaterial",()=>tK,"MeshDepthMaterial",()=>az,"MeshDistanceMaterial",()=>aB,"MeshLambertMaterial",()=>aF,"MeshMatcapMaterial",()=>ak,"MeshNormalMaterial",()=>aO,"MeshPhongMaterial",()=>aU,"MeshPhysicalMaterial",()=>aN,"MeshStandardMaterial",()=>aL,"MeshToonMaterial",()=>aD,"MinEquation",()=>103,"MirroredRepeatWrapping",()=>1002,"MixOperation",()=>1,"MultiplyBlending",()=>4,"MultiplyOperation",()=>0,"NearestFilter",()=>1003,"NearestMipMapLinearFilter",()=>1005,"NearestMipMapNearestFilter",()=>1004,"NearestMipmapLinearFilter",()=>1005,"NearestMipmapNearestFilter",()=>1004,"NeutralToneMapping",()=>7,"NeverCompare",()=>512,"NeverDepth",()=>0,"NeverStencilFunc",()=>512,"NoBlending",()=>0,"NoColorSpace",()=>"","NoNormalPacking",()=>"","NoToneMapping",()=>0,"NormalAnimationBlendMode",()=>2500,"NormalBlending",()=>1,"NormalGAPacking",()=>"ga","NormalRGPacking",()=>"rg","NotEqualCompare",()=>517,"NotEqualDepth",()=>7,"NotEqualStencilFunc",()=>517,"NumberKeyframeTrack",()=>a0,"Object3D",()=>tC,"ObjectLoader",()=>sI,"ObjectSpaceNormalMap",()=>1,"OctahedronGeometry",()=>a_,"OneFactor",()=>201,"OneMinusConstantAlphaFactor",()=>214,"OneMinusConstantColorFactor",()=>212,"OneMinusDstAlphaFactor",()=>207,"OneMinusDstColorFactor",()=>209,"OneMinusSrcAlphaFactor",()=>205,"OneMinusSrcColorFactor",()=>203,"OrthographicCamera",()=>sx,"PCFShadowMap",()=>1,"PCFSoftShadowMap",()=>2,"Path",()=>r2,"PerspectiveCamera",()=>nO,"Plane",()=>iL,"PlaneGeometry",()=>ay,"PlaneHelper",()=>o1,"PointLight",()=>sy,"PointLightHelper",()=>oF,"Points",()=>rd,"PointsMaterial",()=>ro,"PolarGridHelper",()=>oG,"PolyhedronGeometry",()=>rC,"PositionalAudio",()=>s2,"PropertyBinding",()=>ot,"PropertyMixer",()=>s4,"QuadraticBezierCurve",()=>rK,"QuadraticBezierCurve3",()=>r$,"Quaternion",()=>ep,"QuaternionKeyframeTrack",()=>a2,"QuaternionLinearInterpolant",()=>a1,"R11_EAC_Format",()=>37488,"RAD2DEG",()=>er,"RED_GREEN_RGTC2_Format",()=>36285,"RED_RGTC1_Format",()=>36283,"REVISION",()=>"182","RG11_EAC_Format",()=>37490,"RGBADepthPacking",()=>3201,"RGBAFormat",()=>1023,"RGBAIntegerFormat",()=>1033,"RGBA_ASTC_10x10_Format",()=>37819,"RGBA_ASTC_10x5_Format",()=>37816,"RGBA_ASTC_10x6_Format",()=>37817,"RGBA_ASTC_10x8_Format",()=>37818,"RGBA_ASTC_12x10_Format",()=>37820,"RGBA_ASTC_12x12_Format",()=>37821,"RGBA_ASTC_4x4_Format",()=>37808,"RGBA_ASTC_5x4_Format",()=>37809,"RGBA_ASTC_5x5_Format",()=>37810,"RGBA_ASTC_6x5_Format",()=>37811,"RGBA_ASTC_6x6_Format",()=>37812,"RGBA_ASTC_8x5_Format",()=>37813,"RGBA_ASTC_8x6_Format",()=>37814,"RGBA_ASTC_8x8_Format",()=>37815,"RGBA_BPTC_Format",()=>36492,"RGBA_ETC2_EAC_Format",()=>37496,"RGBA_PVRTC_2BPPV1_Format",()=>35843,"RGBA_PVRTC_4BPPV1_Format",()=>35842,"RGBA_S3TC_DXT1_Format",()=>33777,"RGBA_S3TC_DXT3_Format",()=>33778,"RGBA_S3TC_DXT5_Format",()=>33779,"RGBDepthPacking",()=>3202,"RGBFormat",()=>1022,"RGBIntegerFormat",()=>1032,"RGB_BPTC_SIGNED_Format",()=>36494,"RGB_BPTC_UNSIGNED_Format",()=>36495,"RGB_ETC1_Format",()=>36196,"RGB_ETC2_Format",()=>37492,"RGB_PVRTC_2BPPV1_Format",()=>35841,"RGB_PVRTC_4BPPV1_Format",()=>35840,"RGB_S3TC_DXT1_Format",()=>33776,"RGDepthPacking",()=>3203,"RGFormat",()=>1030,"RGIntegerFormat",()=>1031,"RawShaderMaterial",()=>aI,"Ray",()=>te,"Raycaster",()=>op,"RectAreaLight",()=>sT,"RedFormat",()=>1028,"RedIntegerFormat",()=>1029,"ReinhardToneMapping",()=>2,"RenderTarget",()=>eL,"RenderTarget3D",()=>os,"RepeatWrapping",()=>1e3,"ReplaceStencilOp",()=>7681,"ReverseSubtractEquation",()=>102,"RingGeometry",()=>ax,"SIGNED_R11_EAC_Format",()=>37489,"SIGNED_RED_GREEN_RGTC2_Format",()=>36286,"SIGNED_RED_RGTC1_Format",()=>36284,"SIGNED_RG11_EAC_Format",()=>37491,"SRGBColorSpace",()=>I,"SRGBTransfer",()=>U,"Scene",()=>nj,"ShaderMaterial",()=>nI,"ShadowMaterial",()=>aP,"Shape",()=>r3,"ShapeGeometry",()=>ab,"ShapePath",()=>o5,"ShapeUtils",()=>ah,"ShortType",()=>1011,"Skeleton",()=>iy,"SkeletonHelper",()=>oO,"SkinnedMesh",()=>ip,"Source",()=>eE,"Sphere",()=>e2,"SphereGeometry",()=>aS,"Spherical",()=>o_,"SphericalHarmonics3",()=>sw,"SplineCurve",()=>rQ,"SpotLight",()=>sv,"SpotLightHelper",()=>oL,"Sprite",()=>n9,"SpriteMaterial",()=>nZ,"SrcAlphaFactor",()=>204,"SrcAlphaSaturateFactor",()=>210,"SrcColorFactor",()=>202,"StaticCopyUsage",()=>35046,"StaticDrawUsage",()=>35044,"StaticReadUsage",()=>35045,"StereoCamera",()=>sH,"StreamCopyUsage",()=>35042,"StreamDrawUsage",()=>35040,"StreamReadUsage",()=>35041,"StringKeyframeTrack",()=>a3,"SubtractEquation",()=>101,"SubtractiveBlending",()=>3,"TOUCH",()=>C,"TangentSpaceNormalMap",()=>0,"TetrahedronGeometry",()=>aM,"Texture",()=>eP,"TextureLoader",()=>su,"TextureUtils",()=>o9,"Timer",()=>og,"TimestampQuery",()=>O,"TorusGeometry",()=>aT,"TorusKnotGeometry",()=>aw,"Triangle",()=>tH,"TriangleFanDrawMode",()=>2,"TriangleStripDrawMode",()=>1,"TrianglesDrawMode",()=>0,"TubeGeometry",()=>aE,"UVMapping",()=>300,"Uint16BufferAttribute",()=>ne,"Uint32BufferAttribute",()=>nn,"Uint8BufferAttribute",()=>t8,"Uint8ClampedBufferAttribute",()=>t9,"Uniform",()=>oo,"UniformsGroup",()=>ou,"UniformsUtils",()=>nP,"UnsignedByteType",()=>1009,"UnsignedInt101111Type",()=>35899,"UnsignedInt248Type",()=>1020,"UnsignedInt5999Type",()=>35902,"UnsignedIntType",()=>1014,"UnsignedShort4444Type",()=>1017,"UnsignedShort5551Type",()=>1018,"UnsignedShortType",()=>1012,"VSMShadowMap",()=>3,"Vector2",()=>ed,"Vector3",()=>ef,"Vector4",()=>eI,"VectorKeyframeTrack",()=>a4,"VideoFrameTexture",()=>rm,"VideoTexture",()=>rf,"WebGL3DRenderTarget",()=>eF,"WebGLArrayRenderTarget",()=>eD,"WebGLCoordinateSystem",()=>2e3,"WebGLCubeRenderTarget",()=>nB,"WebGLRenderTarget",()=>eN,"WebGPUCoordinateSystem",()=>2001,"WebXRController",()=>nH,"WireframeGeometry",()=>aA,"WrapAroundEnding",()=>2402,"ZeroCurvatureEnding",()=>2400,"ZeroFactor",()=>200,"ZeroSlopeEnding",()=>2401,"ZeroStencilOp",()=>0,"arrayNeedsUint32",()=>B,"cloneUniforms",()=>nA,"createCanvasElement",()=>W,"createElementNS",()=>G,"error",()=>K,"getByteLength",()=>o8,"getConsoleFunction",()=>Y,"getUnlitUniformColorSpace",()=>nR,"log",()=>Z,"mergeUniforms",()=>nC,"probeAsync",()=>Q,"setConsoleFunction",()=>q,"warn",()=>J,"warnOnce",()=>$],90072);let lt={alphahash_fragment:"#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec3 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n }\n#endif",batching_vertex:"#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n vColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, dp );\n #else\n shadow = step( dp, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},ln={common:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new ev},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ev}},envmap:{envMap:{value:null},envMapRotation:{value:new ev},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ev}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ev}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ev},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ev},normalScale:{value:new ed(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ev},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ev}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ev}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ev}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tq(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0},uvTransform:{value:new ev}},sprite:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},center:{value:new ed(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ev},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0}}},li={basic:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.fog]),vertexShader:lt.meshbasic_vert,fragmentShader:lt.meshbasic_frag},lambert:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,ln.lights,{emissive:{value:new tq(0)}}]),vertexShader:lt.meshlambert_vert,fragmentShader:lt.meshlambert_frag},phong:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,ln.lights,{emissive:{value:new tq(0)},specular:{value:new tq(1118481)},shininess:{value:30}}]),vertexShader:lt.meshphong_vert,fragmentShader:lt.meshphong_frag},standard:{uniforms:nC([ln.common,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.roughnessmap,ln.metalnessmap,ln.fog,ln.lights,{emissive:{value:new tq(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag},toon:{uniforms:nC([ln.common,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.gradientmap,ln.fog,ln.lights,{emissive:{value:new tq(0)}}]),vertexShader:lt.meshtoon_vert,fragmentShader:lt.meshtoon_frag},matcap:{uniforms:nC([ln.common,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,{matcap:{value:null}}]),vertexShader:lt.meshmatcap_vert,fragmentShader:lt.meshmatcap_frag},points:{uniforms:nC([ln.points,ln.fog]),vertexShader:lt.points_vert,fragmentShader:lt.points_frag},dashed:{uniforms:nC([ln.common,ln.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lt.linedashed_vert,fragmentShader:lt.linedashed_frag},depth:{uniforms:nC([ln.common,ln.displacementmap]),vertexShader:lt.depth_vert,fragmentShader:lt.depth_frag},normal:{uniforms:nC([ln.common,ln.bumpmap,ln.normalmap,ln.displacementmap,{opacity:{value:1}}]),vertexShader:lt.meshnormal_vert,fragmentShader:lt.meshnormal_frag},sprite:{uniforms:nC([ln.sprite,ln.fog]),vertexShader:lt.sprite_vert,fragmentShader:lt.sprite_frag},background:{uniforms:{uvTransform:{value:new ev},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:lt.background_vert,fragmentShader:lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ev}},vertexShader:lt.backgroundCube_vert,fragmentShader:lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:lt.cube_vert,fragmentShader:lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lt.equirect_vert,fragmentShader:lt.equirect_frag},distance:{uniforms:nC([ln.common,ln.displacementmap,{referencePosition:{value:new ef},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lt.distance_vert,fragmentShader:lt.distance_frag},shadow:{uniforms:nC([ln.lights,ln.fog,{color:{value:new tq(0)},opacity:{value:1}}]),vertexShader:lt.shadow_vert,fragmentShader:lt.shadow_frag}};li.physical={uniforms:nC([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ev},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ev},clearcoatNormalScale:{value:new ed(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ev},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ev},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ev},sheen:{value:0},sheenColor:{value:new tq(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ev},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ev},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ev},transmissionSamplerSize:{value:new ed},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ev},attenuationDistance:{value:0},attenuationColor:{value:new tq(0)},specularColor:{value:new tq(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ev},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ev},anisotropyVector:{value:new ed},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ev}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag};let lr={r:0,b:0,g:0},la=new th,ls=new tt;function lo(e,t,n,i,r,a,s){let o,l,u=new tq(0),c=+(!0!==a),h=null,d=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;return i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i)),i}function m(t,n){t.getRGB(lr,nR(e)),i.buffers.color.setClear(lr.r,lr.g,lr.b,n,s)}return{getClearColor:function(){return u},setClearColor:function(e,t=1){u.set(e),m(u,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){m(u,c=e)},render:function(t){let n=!1,r=f(t);null===r?m(u,c):r&&r.isColor&&(m(r,1),n=!0);let a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let i=f(n);i&&(i.isCubeTexture||306===i.mapping)?(void 0===l&&((l=new nT(new nE(1,1,1),new nI({name:"BackgroundCubeMaterial",uniforms:nA(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),la.copy(n.backgroundRotation),la.x*=-1,la.y*=-1,la.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(la.y*=-1,la.z*=-1),l.material.uniforms.envMap.value=i,l.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(ls.makeRotationFromEuler(la)),l.material.toneMapped=eb.getTransfer(i.colorSpace)!==U,(h!==i||d!==i.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(void 0===o&&((o=new nT(new ay(2,2),new nI({name:"BackgroundMaterial",uniforms:nA(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=i,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=eb.getTransfer(i.colorSpace)!==U,!0===i.matrixAutoUpdate&&i.updateMatrix(),o.material.uniforms.uvTransform.value.copy(i.matrix),(h!==i||d!==i.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function ll(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=u(null),a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){let t=[],i=[],r=[];for(let e=0;e=0){let n=r[t],i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n||n.attribute!==i||i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,m,l,g))&&function(e,t,n,i){let r={},s=t.attributes,o=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));let i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(M||s)&&(s=!1,function(n,i,r,a){c();let s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(let i in o){let r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){let i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;let u=l.buffer,c=l.type,p=l.bytesPerElement,m=c===e.INT||c===e.UNSIGNED_INT||1013===o.gpuType;if(o.isInterleavedBufferAttribute){let t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp",o=a(s);return o!==s&&(J("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return 1023===t||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){let r=1016===n&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return 1009===n||i.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n||!!r},precision:s,logarithmicDepthBuffer:!0===n.logarithmicDepthBuffer,reversedDepthBuffer:!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function lh(e){let t=this,n=null,i=0,r=!1,a=!1,s=new iL,o=new ev,l={value:null,needsUpdate:!1};function u(e,n,i,r){let a=null!==e?e.length:0,u=null;if(0!==a){if(u=l.value,!0!==r||null===u){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===u||u.length0),t.numPlanes=i,t.numIntersection=0)}}function ld(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=301:304===t&&(e.mapping=302),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping;if(303===a||304===a)if(t.has(r))return n(t.get(r).texture,r.mapping);else{let a=r.image;if(!a||!(a.height>0))return null;{let s=new nB(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}}}return r},dispose:function(){t=new WeakMap}}}let lp=[.125,.215,.35,.446,.526,.582],lf=new sx,lm=new tq,lg=null,lv=0,l_=0,ly=!1,lx=new ef;class lb{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){let{size:a=256,position:s=lx}=r;lg=this._renderer.getRenderTarget(),lv=this._renderer.getActiveCubeFace(),l_=this._renderer.getActiveMipmapLevel(),ly=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=lw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=lT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=lp[s-e+4-1]:0===s&&(o=0),n.push(o);let l=1/(a-2),u=-l,c=1+l,h=[u,u,c,u,c,c,u,u,c,c,u,c],d=new Float32Array(108),p=new Float32Array(72),f=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];d.set(i,18*e),p.set(h,12*e);let r=[e,e,e,e,e,e];f.set(r,6*e)}let m=new nd;m.setAttribute("position",new t5(d,3)),m.setAttribute("uv",new t5(p,2)),m.setAttribute("faceIndex",new t5(f,1)),i.push(new nT(m,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=(r=i,new nI({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:new Float32Array(20)},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:new ef(0,1,0)}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})),this._ggxMaterial=(a=i,new nI({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:lE(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 3.2: Transform view direction to hemisphere configuration + vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); + + // Section 4.1: Orthonormal basis + float lensq = Vh.x * Vh.x + Vh.y * Vh.y; + vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(Vh, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + Vh.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1}))}return i}_compileMaterial(e){let t=new nT(new nd,e);this._renderer.compile(t,lf)}_sceneToCubeUV(e,t,n,i,r){let a=new nO(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,u=l.autoClear,c=l.toneMapping;l.getClearColor(lm),l.toneMapping=0,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new nT(new nE,new tK({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));let h=this._backgroundBox,d=h.material,p=!1,f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(lm),p=!0);for(let t=0;t<6;t++){let n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));let u=this._cubeSize;lM(i,n*u,t>2?u:0,u,u),l.setRenderTarget(i),p&&l.render(h,a),l.render(e,a)}l.toneMapping=c,l.autoClear=u,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=301===e.mapping||302===e.mapping;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=lw()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=lT());let r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=e;let s=this._cubeSize;lM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,lf)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let t=1;th-4?n-h+4:0),f=4*(this._cubeSize-d);o.envMap.value=e.texture,o.roughness.value=c*(0+1.25*l),o.mipInt.value=h-t,lM(r,p,f,3*d,2*d),i.setRenderTarget(r),i.render(s,lf),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,lM(e,p,f,3*d,2*d),i.setRenderTarget(e),i.render(s,lf)}_blur(e,t,n,i,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&K("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[i];u.material=l;let c=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):20;f>20&&J(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);let m=[],g=0;for(let e=0;e<20;++e){let t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),y,3*_,2*_),o.setRenderTarget(t),o.render(u,lf)}}function lS(e,t,n){let i=new eN(e,t,n);return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function lM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function lT(){return new nI({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function lw(){return new nI({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function lE(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function lA(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=303===a||304===a,o=301===a||302===a;if(s||o){let a=t.get(r),l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new lb(e)),(a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a)).texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;{if(void 0!==a)return a.texture;let l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(l)?(null===n&&(n=new lb(e)),(a=s?n.fromEquirectangular(r):n.fromCubemap(r)).texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function lC(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){let t=n(e);return null===t&&$("WebGLRenderer: "+e+" extension not supported."),t}}}function lR(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;for(let e in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];let l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){let n=[],i=e.index,r=e.attributes.position,s=0;if(null!==i){let e=i.array;s=i.version;for(let t=0,i=e.length;tt.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let m=new Float32Array(p*f*4*c),g=new eU(m,p,f,c);g.type=1015,g.needsUpdate=!0;let v=4*d;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),c=new nT(l,u),h=new sx(-1,1,1,-1,0,1),d=null,p=null,f=!1,m=null,g=[],v=!1;this.setSize=function(e,t){s.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&!0===g[0].isRenderPass;let t=s.width,n=s.height;for(let e=0;e0)return e;let r=t*n,a=lV[r];if(void 0===a&&(a=new Float32Array(r),lV[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function lq(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n0&&(this.seq=i.concat(r))}setValue(e,t,n,i){let r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){let a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let r=e[i];r.id in t&&n.push(r)}return n}}function uP(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let uI=0,uL=new ev;function uN(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(!a)return r;{let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){let n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}}let uU={1:"Linear",2:"Reinhard",3:"Cineon",4:"ACESFilmic",6:"AgX",7:"Neutral",5:"Custom"},uD=new ef;function uO(e){return""!==e}function uF(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function uz(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}let uB=/^[ \t]*#include +<([\w\d./]+)>/gm;function uk(e){return e.replace(uB,uH)}let uV=new Map;function uH(e,t){let n=lt[t];if(void 0===n){let e=uV.get(t);if(void 0!==e)n=lt[e],J('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e);else throw Error("Can not resolve #include <"+t+">")}return uk(n)}let uG=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function uW(e){return e.replace(uG,uj)}function uj(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(s+="\n"),(o=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(uO).join("\n")).length>0&&(o+="\n");else{let e,t,i,l,u;s=[uX(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(uO).join("\n"),o=[uX(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+m:"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",_?"#define CUBEUV_TEXEL_WIDTH "+_.texelWidth:"",_?"#define CUBEUV_TEXEL_HEIGHT "+_.texelHeight:"",_?"#define CUBEUV_MAX_MIP "+_.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lt.tonemapping_pars_fragment:"",0!==n.toneMapping?(r="toneMapping",void 0===(e=uU[a=n.toneMapping])?(J("WebGLProgram: Unsupported toneMapping:",a),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",lt.colorspace_pars_fragment,(t=function(e){eb._getMatrix(uL,eb.workingColorSpace,e);let t=`mat3( ${uL.elements.map(e=>e.toFixed(4))} )`;switch(eb.getTransfer(e)){case N:return[t,"LinearTransferOETF"];case U:return[t,"sRGBTransferOETF"];default:return J("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(n.outputColorSpace),`vec4 linearToOutputTexel( vec4 value ) { + return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) ); +}`),(eb.getLuminanceCoefficients(uD),i=uD.x.toFixed(4),l=uD.y.toFixed(4),u=uD.z.toFixed(4),`float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( ${i}, ${l}, ${u} ); + return dot( weights, rgb ); +}`),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(uO).join("\n")}d=uz(d=uF(d=uk(d),n),n),p=uz(p=uF(p=uk(p),n),n),d=uW(d),p=uW(p),!0!==n.isRawShaderMaterial&&(S="#version 300 es\n",s=[y,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+s,o=["#define varying in",n.glslVersion===D?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===D?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+o);let M=S+s+d,T=S+o+p,w=uP(c,c.VERTEX_SHADER,M),E=uP(c,c.FRAGMENT_SHADER,T);function A(t){if(e.debug.checkShaderErrors){let n=c.getProgramInfoLog(b)||"",i=c.getShaderInfoLog(w)||"",r=c.getShaderInfoLog(E)||"",a=n.trim(),l=i.trim(),u=r.trim(),h=!0,d=!0;if(!1===c.getProgramParameter(b,c.LINK_STATUS))if(h=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(c,b,w,E);else{let e=uN(c,w,"vertex"),n=uN(c,E,"fragment");K("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(b,c.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+a+"\n"+e+"\n"+n)}else""!==a?J("WebGLProgram: Program Info Log:",a):(""===l||""===u)&&(d=!1);d&&(t.diagnostics={runnable:h,programLog:a,vertexShader:{log:l,prefix:s},fragmentShader:{log:u,prefix:o}})}c.deleteShader(w),c.deleteShader(E),l=new uR(c,b),u=function(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,Y=a.clearcoat>0,Z=a.dispersion>0,K=a.iridescence>0,$=a.sheen>0,Q=a.transmission>0,ee=q&&!!a.anisotropyMap,et=Y&&!!a.clearcoatMap,en=Y&&!!a.clearcoatNormalMap,ei=Y&&!!a.clearcoatRoughnessMap,er=K&&!!a.iridescenceMap,ea=K&&!!a.iridescenceThicknessMap,es=$&&!!a.sheenColorMap,eo=$&&!!a.sheenRoughnessMap,el=!!a.specularMap,eu=!!a.specularColorMap,ec=!!a.specularIntensityMap,eh=Q&&!!a.transmissionMap,ed=Q&&!!a.thicknessMap,ep=!!a.gradientMap,ef=!!a.alphaMap,em=a.alphaTest>0,eg=!!a.alphaHash,ev=!!a.extensions,e_=0;a.toneMapped&&(null===P||!0===P.isXRRenderTarget)&&(e_=e.toneMapping);let ey={shaderID:E,shaderType:a.type,shaderName:a.name,vertexShader:v,fragmentShader:_,defines:a.defines,customVertexShaderID:y,customFragmentShaderID:x,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:N,instancingColor:N&&null!==g.instanceColor,instancingMorph:N&&null!==g.morphTexture,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:L,alphaToCoverage:!!a.alphaToCoverage,map:O,matcap:F,envMap:z,envMapMode:z&&T.mapping,envMapCubeUVHeight:w,aoMap:B,lightMap:k,bumpMap:V,normalMap:H,displacementMap:G,emissiveMap:W,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:ee,clearcoat:Y,clearcoatMap:et,clearcoatNormalMap:en,clearcoatRoughnessMap:ei,dispersion:Z,iridescence:K,iridescenceMap:er,iridescenceThicknessMap:ea,sheen:$,sheenColorMap:es,sheenRoughnessMap:eo,specularMap:el,specularColorMap:eu,specularIntensityMap:ec,transmission:Q,transmissionMap:eh,thicknessMap:ed,gradientMap:ep,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:ef,alphaTest:em,alphaHash:eg,combine:a.combine,mapUv:O&&m(a.map.channel),aoMapUv:B&&m(a.aoMap.channel),lightMapUv:k&&m(a.lightMap.channel),bumpMapUv:V&&m(a.bumpMap.channel),normalMapUv:H&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:W&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:ee&&m(a.anisotropyMap.channel),clearcoatMapUv:et&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:en&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ei&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:er&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ea&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:es&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:eo&&m(a.sheenRoughnessMap.channel),specularMapUv:el&&m(a.specularMap.channel),specularColorMapUv:eu&&m(a.specularColorMap.channel),specularIntensityMapUv:ec&&m(a.specularIntensityMap.channel),transmissionMapUv:eh&&m(a.transmissionMap.channel),thicknessMapUv:ed&&m(a.thicknessMap.channel),alphaMapUv:ef&&m(a.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(H||q),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!S.attributes.uv&&(O||ef),fog:!!b,useFog:!0===a.fog,fogExp2:!!b&&b.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:C,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:e_,decodeVideoTexture:O&&!0===a.map.isVideoTexture&&eb.getTransfer(a.map.colorSpace)===U,decodeVideoTextureEmissive:W&&!0===a.emissiveMap.isVideoTexture&&eb.getTransfer(a.emissiveMap.colorSpace)===U,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ev&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ev&&!0===a.extensions.multiDraw||D)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ey.vertexUv1s=u.has(1),ey.vertexUv2s=u.has(2),ey.vertexUv3s=u.has(3),u.clear(),ey},getProgramCacheKey:function(t){var n,i,r,a;let s=[];if(t.shaderID?s.push(t.shaderID):(s.push(t.customVertexShaderID),s.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)s.push(e),s.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(n=s,i=t,n.push(i.precision),n.push(i.outputColorSpace),n.push(i.envMapMode),n.push(i.envMapCubeUVHeight),n.push(i.mapUv),n.push(i.alphaMapUv),n.push(i.lightMapUv),n.push(i.aoMapUv),n.push(i.bumpMapUv),n.push(i.normalMapUv),n.push(i.displacementMapUv),n.push(i.emissiveMapUv),n.push(i.metalnessMapUv),n.push(i.roughnessMapUv),n.push(i.anisotropyMapUv),n.push(i.clearcoatMapUv),n.push(i.clearcoatNormalMapUv),n.push(i.clearcoatRoughnessMapUv),n.push(i.iridescenceMapUv),n.push(i.iridescenceThicknessMapUv),n.push(i.sheenColorMapUv),n.push(i.sheenRoughnessMapUv),n.push(i.specularMapUv),n.push(i.specularColorMapUv),n.push(i.specularIntensityMapUv),n.push(i.transmissionMapUv),n.push(i.thicknessMapUv),n.push(i.combine),n.push(i.fogExp2),n.push(i.sizeAttenuation),n.push(i.morphTargetsCount),n.push(i.morphAttributeCount),n.push(i.numDirLights),n.push(i.numPointLights),n.push(i.numSpotLights),n.push(i.numSpotLightMaps),n.push(i.numHemiLights),n.push(i.numRectAreaLights),n.push(i.numDirLightShadows),n.push(i.numPointLightShadows),n.push(i.numSpotLightShadows),n.push(i.numSpotLightShadowsWithMaps),n.push(i.numLightProbes),n.push(i.shadowMapType),n.push(i.toneMapping),n.push(i.numClippingPlanes),n.push(i.numClipIntersection),n.push(i.depthPacking),r=s,a=t,o.disableAll(),a.instancing&&o.enable(0),a.instancingColor&&o.enable(1),a.instancingMorph&&o.enable(2),a.matcap&&o.enable(3),a.envMap&&o.enable(4),a.normalMapObjectSpace&&o.enable(5),a.normalMapTangentSpace&&o.enable(6),a.clearcoat&&o.enable(7),a.iridescence&&o.enable(8),a.alphaTest&&o.enable(9),a.vertexColors&&o.enable(10),a.vertexAlphas&&o.enable(11),a.vertexUv1s&&o.enable(12),a.vertexUv2s&&o.enable(13),a.vertexUv3s&&o.enable(14),a.vertexTangents&&o.enable(15),a.anisotropy&&o.enable(16),a.alphaHash&&o.enable(17),a.batching&&o.enable(18),a.dispersion&&o.enable(19),a.batchingColor&&o.enable(20),a.gradientMap&&o.enable(21),r.push(o.mask),o.disableAll(),a.fog&&o.enable(0),a.useFog&&o.enable(1),a.flatShading&&o.enable(2),a.logarithmicDepthBuffer&&o.enable(3),a.reversedDepthBuffer&&o.enable(4),a.skinning&&o.enable(5),a.morphTargets&&o.enable(6),a.morphNormals&&o.enable(7),a.morphColors&&o.enable(8),a.premultipliedAlpha&&o.enable(9),a.shadowMapEnabled&&o.enable(10),a.doubleSided&&o.enable(11),a.flipSided&&o.enable(12),a.useDepthPacking&&o.enable(13),a.dithering&&o.enable(14),a.transmission&&o.enable(15),a.sheen&&o.enable(16),a.opaque&&o.enable(17),a.pointsUvs&&o.enable(18),a.decodeVideoTexture&&o.enable(19),a.decodeVideoTextureEmissive&&o.enable(20),a.alphaToCoverage&&o.enable(21),r.push(o.mask),s.push(e.outputColorSpace)),s.push(t.customProgramCacheKey),s.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=li[n];t=nP.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i=h.get(n);return void 0!==i?++i.usedTimes:(i=new uK(e,n,t,a),c.push(i),h.set(n,i)),i},releaseProgram:function(e){if(0==--e.usedTimes){let t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),h.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function u2(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function u3(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function u4(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function u5(){let e=[],t=0,n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||u3),i.length>1&&i.sort(t||u4),r.length>1&&r.sort(t||u4)}}}function u6(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new u5,e.set(t,[i])):n>=r.length?(i=new u5,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function u8(){let e={};return{get:function(t){let n;if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":n={direction:new ef,color:new tq};break;case"SpotLight":n={position:new ef,direction:new ef,color:new tq,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ef,color:new tq,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ef,skyColor:new tq,groundColor:new tq};break;case"RectAreaLight":n={color:new tq,position:new ef,halfWidth:new ef,halfHeight:new ef}}return e[t.id]=n,n}}}let u9=0;function u7(e,t){return 2*!!t.castShadow-2*!!e.castShadow+ +!!t.map-!!e.map}function ce(e){let t,n=new u8,i=(t={},{get:function(e){let n;if(void 0!==t[e.id])return t[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ed};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ed,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new ef);let a=new ef,s=new tt,o=new tt;return{setup:function(t){let a=0,s=0,o=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,c=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0;t.sort(u7);for(let e=0,y=t.length;e0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ln.LTC_FLOAT_1,r.rectAreaLTC2=ln.LTC_FLOAT_2):(r.rectAreaLTC1=ln.LTC_HALF_1,r.rectAreaLTC2=ln.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=s,r.ambient[2]=o;let y=r.hash;(y.directionalLength!==l||y.pointLength!==u||y.spotLength!==c||y.rectAreaLength!==h||y.hemiLength!==d||y.numDirectionalShadows!==p||y.numPointShadows!==f||y.numSpotShadows!==m||y.numSpotMaps!==g||y.numLightProbes!==_)&&(r.directional.length=l,r.spot.length=c,r.rectArea.length=h,r.point.length=u,r.hemi.length=d,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=f,r.pointShadowMap.length=f,r.spotShadow.length=m,r.spotShadowMap.length=m,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=f,r.spotLightMatrix.length=m+g-v,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=v,r.numLightProbes=_,y.directionalLength=l,y.pointLength=u,y.spotLength=c,y.rectAreaLength=h,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=_,r.version=u9++)},setupView:function(e,t){let n=0,i=0,l=0,u=0,c=0,h=t.matrixWorldInverse;for(let t=0,d=e.length;t=a.length?(r=new ct(e),a.push(r)):r=a[i],r},dispose:function(){t=new WeakMap}}}let ci=[new ef(1,0,0),new ef(-1,0,0),new ef(0,1,0),new ef(0,-1,0),new ef(0,0,1),new ef(0,0,-1)],cr=[new ef(0,-1,0),new ef(0,-1,0),new ef(0,0,1),new ef(0,0,-1),new ef(0,-1,0),new ef(0,-1,0)],ca=new tt,cs=new ef,co=new ef;function cl(e,t,n){let i=new iO,r=new ed,a=new ed,s=new eI,o=new az,l=new aB,u={},c=n.maxTextureSize,h={0:1,1:0,2:2},d=new nI({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ed},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new nd;f.setAttribute("position",new t5(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new nT(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=a.uuid,t=n.uuid,i=u[e];void 0===i&&(i={},u[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",y)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,3===r?a.side=null!==n.shadowSide?n.shadowSide:n.side:a.side=null!==n.shadowSide?n.shadowSide:h[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function y(e){for(let t in e.target.removeEventListener("dispose",y),u){let n=u[t],i=e.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(n,o,l){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===n.length)return;2===n.type&&(J("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),n.type=1);let u=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),y=e.state;y.setBlending(0),!0===y.buffers.depth.getReversed()?y.buffers.color.setClear(0,0,0,0):y.buffers.color.setClear(1,1,1,1),y.buffers.depth.setTest(!0),y.setScissorTest(!1);let x=v!==this.type;x&&o.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,h=n.length;uc||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/g.x),r.x=a.x*g.x,f.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/g.y),r.y=a.y*g.y,f.mapSize.y=a.y)),null===f.map||!0===x){if(null!==f.map&&(null!==f.map.depthTexture&&(f.map.depthTexture.dispose(),f.map.depthTexture=null),f.map.dispose()),3===this.type){if(h.isPointLight){J("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}f.map=new eN(r.x,r.y,{format:1030,type:1016,minFilter:1006,magFilter:1006,generateMipmaps:!1}),f.map.texture.name=h.name+".shadowMap",f.map.depthTexture=new rb(r.x,r.y,1015),f.map.depthTexture.name=h.name+".shadowMapDepth",f.map.depthTexture.format=1026,f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003}else{h.isPointLight?(f.map=new nB(r.x),f.map.depthTexture=new rS(r.x,1014)):(f.map=new eN(r.x,r.y),f.map.depthTexture=new rb(r.x,r.y,1014)),f.map.depthTexture.name=h.name+".shadowMap",f.map.depthTexture.format=1026;let t=e.state.buffers.depth.getReversed();1===this.type?(f.map.depthTexture.compareFunction=t?518:515,f.map.depthTexture.minFilter=1006,f.map.depthTexture.magFilter=1006):(f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003)}f.camera.updateProjectionMatrix()}let v=f.map.isWebGLCubeRenderTarget?6:1;for(let n=0;n=1:-1!==P.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(P)[1])>=2);let I=null,L={},N=e.getParameter(e.SCISSOR_BOX),U=e.getParameter(e.VIEWPORT),D=new eI().fromArray(N),O=new eI().fromArray(U);function F(t,n,i,r){let a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;stypeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new ed,h=new WeakMap,d=new WeakMap,p=!1;try{p="u">typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return p?new OffscreenCanvas(e,t):G("canvas")}function m(e,t,n){let i=1,r=X(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1)if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof VideoFrame&&e instanceof VideoFrame){let n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===o&&(o=f(n,a));let s=t?f(n,a):o;return s.width=n,s.height=a,s.getContext("2d").drawImage(e,0,0,n,a),J("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}else"data"in e&&J("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+").");return e}function g(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function _(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];J("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){let t=s?N:eb.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===U?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function y(t,n){let i;return t?null===n||1014===n||1020===n?i=e.DEPTH24_STENCIL8:1015===n?i=e.DEPTH32F_STENCIL8:1012===n&&(i=e.DEPTH24_STENCIL8,J("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||1014===n||1020===n?i=e.DEPTH_COMPONENT24:1015===n?i=e.DEPTH_COMPONENT32F:1012===n&&(i=e.DEPTH_COMPONENT16),i}function x(e,t){return!0===g(e)||e.isFramebufferTexture&&1003!==e.minFilter&&1006!==e.minFilter?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(e){let t=e.target;t.removeEventListener("dispose",b),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=d.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&d.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function S(t){let n=t.target;n.removeEventListener("dispose",S),function(t){let n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i0&&l.__version!==t.version){let e=t.image;if(null===e)J("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void D(l,t,r);J("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(l.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,l.__webglTexture,e.TEXTURE0+r)}let E={1e3:e.REPEAT,1001:e.CLAMP_TO_EDGE,1002:e.MIRRORED_REPEAT},A={1003:e.NEAREST,1004:e.NEAREST_MIPMAP_NEAREST,1005:e.NEAREST_MIPMAP_LINEAR,1006:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,1008:e.LINEAR_MIPMAP_LINEAR},C={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function R(n,a){if((1015===a.type&&!1===t.has("OES_texture_float_linear")&&(1006===a.magFilter||1007===a.magFilter||1005===a.magFilter||1008===a.magFilter||1006===a.minFilter||1007===a.minFilter||1005===a.minFilter||1008===a.minFilter)&&J("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,E[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,E[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,E[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,A[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,A[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,C[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic"))&&1003!==a.magFilter&&(1005===a.minFilter||1008===a.minFilter)&&(1015!==a.type||!1!==t.has("OES_texture_float_linear"))&&(a.anisotropy>1||i.get(a).__currentAnisotropy)){let s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}function P(t,n){let i,r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",b));let a=n.source,o=d.get(a);void 0===o&&(o={},d.set(a,o));let l=((i=[]).push(n.wrapS),i.push(n.wrapT),i.push(n.wrapR||0),i.push(n.magFilter),i.push(n.minFilter),i.push(n.anisotropy),i.push(n.internalFormat),i.push(n.format),i.push(n.type),i.push(n.generateMipmaps),i.push(n.premultiplyAlpha),i.push(n.flipY),i.push(n.unpackAlignment),i.push(n.colorSpace),i.join());if(l!==t.__cacheKey){void 0===o[l]&&(o[l]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),o[l].usedTimes++;let i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&M(n)),t.__cacheKey=l,t.__webglTexture=o[l].texture}return r}function I(e,t,n){return Math.floor(Math.floor(e/n)/t)}function D(t,s,o){let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);let u=P(t,s),c=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);let h=i.get(c);if(c.version!==h.__version||!0===u){let t;n.activeTexture(e.TEXTURE0+o);let i=eb.getPrimaries(eb.workingColorSpace),d=""===s.colorSpace?null:eb.getPrimaries(s.colorSpace),p=""===s.colorSpace||i===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let f=m(s.image,!1,r.maxTextureSize);f=j(s,f);let b=a.convert(s.format,s.colorSpace),S=a.convert(s.type),M=_(s.internalFormat,b,S,s.colorSpace,s.isVideoTexture);R(l,s);let T=s.mipmaps,w=!0!==s.isVideoTexture,E=void 0===h.__version||!0===u,A=c.dataReady,C=x(s,f);if(s.isDepthTexture)M=y(1027===s.format,s.type),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,M,f.width,f.height):n.texImage2D(e.TEXTURE_2D,0,M,f.width,f.height,0,b,S,null));else if(s.isDataTexture)if(T.length>0){w&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,T[0].width,T[0].height);for(let i=0,r=T.length;ie.start-t.start);let o=0;for(let e=1;e0){let r=o8(t.width,t.height,s.format,s.type);for(let a of s.layerUpdates){let s=t.data.subarray(a*r/t.data.BYTES_PER_ELEMENT,(a+1)*r/t.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,t.width,t.height,1,b,s)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,t.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,t.data,0,0);else J("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,S,t.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,b,S,t.data)}else{w&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,T[0].width,T[0].height);for(let i=0,r=T.length;i0){let t=o8(f.width,f.height,s.format,s.type);for(let i of s.layerUpdates){let r=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,f.width,f.height,1,b,S,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isData3DTexture)w?(E&&n.texStorage3D(e.TEXTURE_3D,C,M,f.width,f.height,f.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)):n.texImage3D(e.TEXTURE_3D,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isFramebufferTexture){if(E)if(w)n.texStorage2D(e.TEXTURE_2D,C,M,f.width,f.height);else{let t=f.width,i=f.height;for(let r=0;r>=1,i>>=1}}else if(T.length>0){if(w&&E){let t=X(T[0]);n.texStorage2D(e.TEXTURE_2D,C,M,t.width,t.height)}for(let i=0,r=T.length;i>c),i=Math.max(1,r.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,c,p,t,i,r.depth,0,h,d,null):n.texImage2D(u,c,p,t,i,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),W(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,u,m.__webglTexture,0,H(r)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,u,m.__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=y(n.stencilBuffer,a),o=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;W(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,o,e.RENDERBUFFER,t)}else{let t=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)z(r.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?z(r.__webglFramebuffer[0],t,0):z(r.__webglFramebuffer,t,0)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),F(r.__webglDepthbuffer[i],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),F(r.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let k=[],V=[];function H(e){return Math.min(r.maxSamples,e.samples)}function W(e){let n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function j(e,t){let n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==L&&""!==n&&(eb.getTransfer(n)===U?(1023!==i||1009!==r)&&J("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):K("WebGLTextures: Unsupported texture color space:",n)),t}function X(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"u">typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){let e=T;return e>=r.maxTextures&&J("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=w,this.setTexture2DArray=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?D(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))},this.setTexture3D=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?D(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){let o=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;let l=P(t,s),u=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);let c=i.get(u);if(u.version!==c.__version||!0===l){let t;n.activeTexture(e.TEXTURE0+o);let i=eb.getPrimaries(eb.workingColorSpace),h=""===s.colorSpace?null:eb.getPrimaries(s.colorSpace),d=""===s.colorSpace||i===h?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,y=[];for(let e=0;e<6;e++)p||f?y[e]=f?s.image[e].image:s.image[e]:y[e]=m(s.image[e],!0,r.maxCubemapSize),y[e]=j(s,y[e]);let b=y[0],S=a.convert(s.format,s.colorSpace),M=a.convert(s.type),T=_(s.internalFormat,S,M,s.colorSpace),w=!0!==s.isVideoTexture,E=void 0===c.__version||!0===l,A=u.dataReady,C=x(s,b);if(R(e.TEXTURE_CUBE_MAP,s),p){w&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,C,T,b.width,b.height);for(let i=0;i<6;i++){t=y[i].mipmaps;for(let r=0;r0&&C++;let i=X(y[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,C,T,i.width,i.height)}for(let i=0;i<6;i++)if(f){w?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,0,0,y[i].width,y[i].height,S,M,y[i].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,y[i].width,y[i].height,0,S,M,y[i].data);for(let r=0;r1;if(!h&&(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),c){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let t=0;t0&&!1===W(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0){if(!1===W(t)){let r=t.textures,a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),h=r.length>1;if(h)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class cm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){let n=new rM(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){let t=e.cameras[0].viewport,n=new nI({vertexShader:cp,fragmentShader:cf,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nT(new ay(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cg extends ee{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,u=null,c=null,h=null,d=null,p=null;const f="u">typeof XRWebGLBinding,m=new cm,g={},v=t.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new ed;let M=null;const T=new nO;T.viewport=new eI;const w=new nO;w.viewport=new eI;const E=[T,w],A=new sG;let C=null,R=null;function P(e){let t=b.indexOf(e.inputSource);if(-1===t)return;let n=x[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function I(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",L);for(let e=0;e=0&&(b[i]=null,x[i].disconnect(n))}for(let t=0;t=b.length){b.push(n),i=e;break}else if(null===b[e]){b[e]=n,i=e;break}if(-1===i)break}let r=x[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getGripSpace()},this.getHand=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&J("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&J("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return null===c&&f&&(c=new XRWebGLBinding(i,t)),c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(u){if(null!==(i=u)){if(_=e.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",I),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(S),f&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,a=null,s=null;v.depth&&(s=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=v.stencil?1027:1026,a=v.stencil?1020:1014);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=(c=this.getBinding()).createProjectionLayer(o),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),y=new eN(h.textureWidth,h.textureHeight,{format:1023,type:1009,depthTexture:new rb(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:4*!!v.antialias,resolveDepthBuffer:!1===h.ignoreDepthValues,resolveStencilBuffer:!1===h.ignoreDepthValues})}else{let n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),y=new eN(d.framebufferWidth,d.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const N=new ef,U=new ef;function D(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var t,n,r;if(null===i)return;let a=e.near,s=e.far;null!==m.texture&&(m.depthNear>0&&(a=m.depthNear),m.depthFar>0&&(s=m.depthFar)),A.near=w.near=T.near=a,A.far=w.far=T.far=s,(C!==A.near||R!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|e.layers.mask,T.layers.mask=3&A.layers.mask,w.layers.mask=5&A.layers.mask;let o=e.parent,l=A.cameras;D(A,o);for(let e=0;e0&&(e.alphaTest.value=i.alphaTest);let r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,cv.copy(s),cv.x*=-1,cv.y*=-1,cv.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(cv.y*=-1,cv.z*=-1),e.envMapRotation.value.setFromMatrix4(c_.makeRotationFromEuler(cv)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,nR(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){var l,u,c,h,d,p,f,m,g,v,_,y,x,b,S,M,T,w,E,A,C,R,P;let I;r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),l=e,(u=r).gradientMap&&(l.gradientMap.value=u.gradientMap)):r.isMeshPhongMaterial?(i(e,r),c=e,h=r,c.specular.value.copy(h.specular),c.shininess.value=Math.max(h.shininess,1e-4)):r.isMeshStandardMaterial?(i(e,r),d=e,p=r,d.metalness.value=p.metalness,p.metalnessMap&&(d.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,d.metalnessMapTransform)),d.roughness.value=p.roughness,p.roughnessMap&&(d.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,d.roughnessMapTransform)),p.envMap&&(d.envMapIntensity.value=p.envMapIntensity),r.isMeshPhysicalMaterial&&(f=e,m=r,g=o,f.ior.value=m.ior,m.sheen>0&&(f.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),f.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(f.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,f.sheenColorMapTransform)),m.sheenRoughnessMap&&(f.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,f.sheenRoughnessMapTransform))),m.clearcoat>0&&(f.clearcoat.value=m.clearcoat,f.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(f.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,f.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(f.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),1===m.side&&f.clearcoatNormalScale.value.negate())),m.dispersion>0&&(f.dispersion.value=m.dispersion),m.iridescence>0&&(f.iridescence.value=m.iridescence,f.iridescenceIOR.value=m.iridescenceIOR,f.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(f.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,f.iridescenceMapTransform)),m.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),m.transmission>0&&(f.transmission.value=m.transmission,f.transmissionSamplerMap.value=g.texture,f.transmissionSamplerSize.value.set(g.width,g.height),m.transmissionMap&&(f.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,f.transmissionMapTransform)),f.thickness.value=m.thickness,m.thicknessMap&&(f.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=m.attenuationDistance,f.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(f.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(f.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=m.specularIntensity,f.specularColor.value.copy(m.specularColor),m.specularColorMap&&(f.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,f.specularColorMapTransform)),m.specularIntensityMap&&(f.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,f.specularIntensityMapTransform)))):r.isMeshMatcapMaterial?(i(e,r),v=e,(_=r).matcap&&(v.matcap.value=_.matcap)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),y=e,x=r,I=t.get(x).light,y.referencePosition.value.setFromMatrixPosition(I.matrixWorld),y.nearDistance.value=I.shadow.camera.near,y.farDistance.value=I.shadow.camera.far):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(b=e,S=r,b.diffuse.value.copy(S.color),b.opacity.value=S.opacity,S.map&&(b.map.value=S.map,n(S.map,b.mapTransform)),r.isLineDashedMaterial&&(M=e,T=r,M.dashSize.value=T.dashSize,M.totalSize.value=T.dashSize+T.gapSize,M.scale.value=T.scale)):r.isPointsMaterial?(w=e,E=r,A=a,C=s,w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.size.value=E.size*A,w.scale.value=.5*C,E.map&&(w.map.value=E.map,n(E.map,w.uvTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,n(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)):r.isSpriteMaterial?(R=e,P=r,R.diffuse.value.copy(P.color),R.opacity.value=P.opacity,R.rotation.value=P.rotation,P.map&&(R.map.value=P.map,n(P.map,R.mapTransform)),P.alphaMap&&(R.alphaMap.value=P.alphaMap,n(P.alphaMap,R.alphaMapTransform)),P.alphaTest>0&&(R.alphaTest.value=P.alphaTest)):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function cx(e,t,n,i){let r={},a={},s=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e){let t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?J("WebGLRenderer: Texture samplers can not be part of an uniforms group."):J("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){let n=t.target;n.removeEventListener("dispose",u);let i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){let n=t.program;i.uniformBlockBinding(e,n)},update:function(n,c){var h;let d,p,f,m,g=r[n.id];void 0===g&&(function(e){let t=e.uniforms,n=0;for(let e=0,i=t.length;e0&&(n+=16-i),e.__size=n,e.__cache={}}(n),(h=n).__bindingPointIndex=d=function(){for(let e=0;etypeof WebGLRenderingContext&&A instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=A.getContextAttributes().alpha}else t=P;const k=new Set([1033,1031,1029]),V=new Set([1009,1014,1012,1020,1017,1018]),H=new Uint32Array(4),G=new Int32Array(4);let j=null,X=null;const q=[],Y=[];let ee=null;this.domElement=E,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const et=this;let en=!1;this._outputColorSpace=I;let ei=0,er=0,ea=null,es=-1,eo=null;const el=new eI,eu=new eI;let ec=null;const eh=new tq(0);let ed=0,ep=E.width,em=E.height,eg=1,ev=null,e_=null;const ey=new eI(0,0,ep,em),ex=new eI(0,0,ep,em);let eS=!1;const eM=new iO;let eT=!1,ew=!1;const eE=new tt,eA=new ef,eC=new eI,eR={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let eP=!1;function eL(){return null===ea?eg:1}let eU=A;function eD(e,t){return E.getContext(e,t)}try{if("setAttribute"in E&&E.setAttribute("data-engine","three.js r182"),E.addEventListener("webglcontextlost",ez,!1),E.addEventListener("webglcontextrestored",eB,!1),E.addEventListener("webglcontextcreationerror",ek,!1),null===eU){const e="webgl2";if(eU=eD(e,{alpha:!0,depth:C,stencil:R,antialias:N,premultipliedAlpha:U,preserveDrawingBuffer:D,powerPreference:O,failIfMajorPerformanceCaveat:F}),null===eU)if(eD(e))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(e){throw K("WebGLRenderer: "+e.message),e}function eO(){(n=new lC(eU)).init(),M=new cd(eU,n),i=new lc(eU,n,e,M),r=new cc(eU,n),i.reversedDepthBuffer&&z&&r.buffers.depth.setReversed(!0),a=new lI(eU),s=new u2,o=new ch(eU,n,r,s,i,M,a),l=new ld(et),u=new lA(et),c=new le(eU),T=new ll(eU,c),h=new lR(eU,c,a,T),d=new lN(eU,h,c,a),x=new lL(eU,i,o),v=new lh(s),p=new u1(et,l,u,n,i,T,v),f=new cy(et,s),m=new u6,g=new cn(n),y=new lo(et,l,u,r,d,t,U),_=new cl(et,d,i),w=new cx(eU,a,i,r),b=new lu(eU,n,a),S=new lP(eU,n,a),a.programs=p.programs,et.capabilities=i,et.extensions=n,et.properties=s,et.renderLists=m,et.shadowMap=_,et.state=r,et.info=a}eO(),1009!==B&&(ee=new lD(B,E.width,E.height,C,R));const eF=new cg(et,eU);function ez(e){e.preventDefault(),Z("WebGLRenderer: Context Lost."),en=!0}function eB(){Z("WebGLRenderer: Context Restored."),en=!1;let e=a.autoReset,t=_.enabled,n=_.autoUpdate,i=_.needsUpdate,r=_.type;eO(),a.autoReset=e,_.enabled=t,_.autoUpdate=n,_.needsUpdate=i,_.type=r}function ek(e){K("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function eV(e){var t,n;let i,r=e.target;r.removeEventListener("dispose",eV),n=t=r,void 0!==(i=s.get(n).programs)&&(i.forEach(function(e){p.releaseProgram(e)}),n.isShaderMaterial&&p.releaseShaderCache(n)),s.remove(t)}function eH(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,e$(e,t,n),e.side=0,e.needsUpdate=!0,e$(e,t,n),e.side=2):e$(e,t,n)}this.xr=eF,this.getContext=function(){return eU},this.getContextAttributes=function(){return eU.getContextAttributes()},this.forceContextLoss=function(){let e=n.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=n.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return eg},this.setPixelRatio=function(e){void 0!==e&&(eg=e,this.setSize(ep,em,!1))},this.getSize=function(e){return e.set(ep,em)},this.setSize=function(e,t,n=!0){eF.isPresenting?J("WebGLRenderer: Can't change size while VR device is presenting."):(ep=e,em=t,E.width=Math.floor(e*eg),E.height=Math.floor(t*eg),!0===n&&(E.style.width=e+"px",E.style.height=t+"px"),null!==ee&&ee.setSize(E.width,E.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(ep*eg,em*eg).floor()},this.setDrawingBufferSize=function(e,t,n){ep=e,em=t,eg=n,E.width=Math.floor(e*n),E.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(1009===B)return void console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");if(e){for(let t=0;tp.matrixWorld.determinant(),y=function(e,t,n,a,c){var h,d;!0!==t.isScene&&(t=eR),o.resetTextureUnits();let p=t.fog,m=a.isMeshStandardMaterial?t.environment:null,g=null===ea?et.outputColorSpace:!0===ea.isXRRenderTarget?ea.texture.colorSpace:L,_=(a.isMeshStandardMaterial?u:l).get(a.envMap||m),y=!0===a.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,b=!!n.attributes.tangent&&(!!a.normalMap||a.anisotropy>0),S=!!n.morphAttributes.position,M=!!n.morphAttributes.normal,T=!!n.morphAttributes.color,E=0;a.toneMapped&&(null===ea||!0===ea.isXRRenderTarget)&&(E=et.toneMapping);let A=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,C=void 0!==A?A.length:0,R=s.get(a),P=X.state.lights;if(!0===eT&&(!0===ew||e!==eo)){let t=e===eo&&a.id===es;v.setState(a,e,t)}let I=!1;a.version===R.__version?R.needsLights&&R.lightsStateVersion!==P.state.version||R.outputColorSpace!==g||c.isBatchedMesh&&!1===R.batching?I=!0:c.isBatchedMesh||!0!==R.batching?c.isBatchedMesh&&!0===R.batchingColor&&null===c.colorTexture||c.isBatchedMesh&&!1===R.batchingColor&&null!==c.colorTexture||c.isInstancedMesh&&!1===R.instancing?I=!0:c.isInstancedMesh||!0!==R.instancing?c.isSkinnedMesh&&!1===R.skinning?I=!0:c.isSkinnedMesh||!0!==R.skinning?c.isInstancedMesh&&!0===R.instancingColor&&null===c.instanceColor||c.isInstancedMesh&&!1===R.instancingColor&&null!==c.instanceColor||c.isInstancedMesh&&!0===R.instancingMorph&&null===c.morphTexture||c.isInstancedMesh&&!1===R.instancingMorph&&null!==c.morphTexture||R.envMap!==_||!0===a.fog&&R.fog!==p||void 0!==R.numClippingPlanes&&(R.numClippingPlanes!==v.numPlanes||R.numIntersection!==v.numIntersection)||R.vertexAlphas!==y||R.vertexTangents!==b||R.morphTargets!==S||R.morphNormals!==M||R.morphColors!==T||R.toneMapping!==E?I=!0:R.morphTargetsCount!==C&&(I=!0):I=!0:I=!0:I=!0:(I=!0,R.__version=a.version);let N=R.currentProgram;!0===I&&(N=e$(a,t,c));let U=!1,D=!1,O=!1,F=N.getUniforms(),z=R.uniforms;if(r.useProgram(N.program)&&(U=!0,D=!0,O=!0),a.id!==es&&(es=a.id,D=!0),U||eo!==e){r.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),F.setValue(eU,"projectionMatrix",e.projectionMatrix),F.setValue(eU,"viewMatrix",e.matrixWorldInverse);let t=F.map.cameraPosition;void 0!==t&&t.setValue(eU,eA.setFromMatrixPosition(e.matrixWorld)),i.logarithmicDepthBuffer&&F.setValue(eU,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)&&F.setValue(eU,"isOrthographic",!0===e.isOrthographicCamera),eo!==e&&(eo=e,D=!0,O=!0)}if(R.needsLights&&(P.state.directionalShadowMap.length>0&&F.setValue(eU,"directionalShadowMap",P.state.directionalShadowMap,o),P.state.spotShadowMap.length>0&&F.setValue(eU,"spotShadowMap",P.state.spotShadowMap,o),P.state.pointShadowMap.length>0&&F.setValue(eU,"pointShadowMap",P.state.pointShadowMap,o)),c.isSkinnedMesh){F.setOptional(eU,c,"bindMatrix"),F.setOptional(eU,c,"bindMatrixInverse");let e=c.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),F.setValue(eU,"boneTexture",e.boneTexture,o))}c.isBatchedMesh&&(F.setOptional(eU,c,"batchingTexture"),F.setValue(eU,"batchingTexture",c._matricesTexture,o),F.setOptional(eU,c,"batchingIdTexture"),F.setValue(eU,"batchingIdTexture",c._indirectTexture,o),F.setOptional(eU,c,"batchingColorTexture"),null!==c._colorsTexture&&F.setValue(eU,"batchingColorTexture",c._colorsTexture,o));let B=n.morphAttributes;if((void 0!==B.position||void 0!==B.normal||void 0!==B.color)&&x.update(c,n,N),(D||R.receiveShadow!==c.receiveShadow)&&(R.receiveShadow=c.receiveShadow,F.setValue(eU,"receiveShadow",c.receiveShadow)),a.isMeshGouraudMaterial&&null!==a.envMap&&(z.envMap.value=_,z.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1),a.isMeshStandardMaterial&&null===a.envMap&&null!==t.environment&&(z.envMapIntensity.value=t.environmentIntensity),void 0!==z.dfgLUT&&(z.dfgLUT.value=(null===cS&&((cS=new ig(cb,16,16,1030,1016)).name="DFG_LUT",cS.minFilter=1006,cS.magFilter=1006,cS.wrapS=1001,cS.wrapT=1001,cS.generateMipmaps=!1,cS.needsUpdate=!0),cS)),D&&(F.setValue(eU,"toneMappingExposure",et.toneMappingExposure),R.needsLights&&(h=z,d=O,h.ambientLightColor.needsUpdate=d,h.lightProbe.needsUpdate=d,h.directionalLights.needsUpdate=d,h.directionalLightShadows.needsUpdate=d,h.pointLights.needsUpdate=d,h.pointLightShadows.needsUpdate=d,h.spotLights.needsUpdate=d,h.spotLightShadows.needsUpdate=d,h.rectAreaLights.needsUpdate=d,h.hemisphereLights.needsUpdate=d),p&&!0===a.fog&&f.refreshFogUniforms(z,p),f.refreshMaterialUniforms(z,a,eg,em,X.state.transmissionRenderTarget[e.id]),uR.upload(eU,eQ(R),z,o)),a.isShaderMaterial&&!0===a.uniformsNeedUpdate&&(uR.upload(eU,eQ(R),z,o),a.uniformsNeedUpdate=!1),a.isSpriteMaterial&&F.setValue(eU,"center",c.center),F.setValue(eU,"modelViewMatrix",c.modelViewMatrix),F.setValue(eU,"normalMatrix",c.normalMatrix),F.setValue(eU,"modelMatrix",c.matrixWorld),a.isShaderMaterial||a.isRawShaderMaterial){let e=a.uniformsGroups;for(let t=0,n=e.length;t{function i(){(r.forEach(function(e){s.get(e).currentProgram.isReady()&&r.delete(e)}),0===r.size)?t(e):setTimeout(i,10)}null!==n.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let eG=null;function eW(){eX.stop()}function ej(){eX.start()}const eX=new o7;function eq(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)X.pushLight(e),e.castShadow&&X.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||eM.intersectsSprite(e)){i&&eC.setFromMatrixPosition(e.matrixWorld).applyMatrix4(eE);let t=d.update(e),r=e.material;r.visible&&j.push(e,t,r,n,eC.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||eM.intersectsObject(e))){let t=d.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),eC.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),eC.copy(t.boundingSphere.center)),eC.applyMatrix4(e.matrixWorld).applyMatrix4(eE)),Array.isArray(r)){let i=t.groups;for(let a=0,s=i.length;a0&&eJ(a,t,n),s.length>0&&eJ(s,t,n),o.length>0&&eJ(o,t,n),r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),r.setPolygonOffset(!1)}function eZ(e,t,r,a){if(null!==(!0===r.isScene?r.overrideMaterial:null))return;if(void 0===X.state.transmissionRenderTarget[a.id]){let e=n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float");X.state.transmissionRenderTarget[a.id]=new eN(1,1,{generateMipmaps:!0,type:e?1016:1009,minFilter:1008,samples:i.samples,stencilBuffer:R,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:eb.workingColorSpace})}let s=X.state.transmissionRenderTarget[a.id],l=a.viewport||el;s.setSize(l.z*et.transmissionResolutionScale,l.w*et.transmissionResolutionScale);let u=et.getRenderTarget(),c=et.getActiveCubeFace(),h=et.getActiveMipmapLevel();et.setRenderTarget(s),et.getClearColor(eh),(ed=et.getClearAlpha())<1&&et.setClearColor(0xffffff,.5),et.clear(),eP&&y.render(r);let d=et.toneMapping;et.toneMapping=0;let p=a.viewport;if(void 0!==a.viewport&&(a.viewport=void 0),X.setupLightsView(a),!0===eT&&v.setGlobalState(et.clippingPlanes,a),eJ(e,r,a),o.updateMultisampleRenderTarget(s),o.updateRenderTargetMipmap(s),!1===n.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let n=0,i=t.length;ntypeof self&&eX.setContext(self),this.setAnimationLoop=function(e){eG=e,eF.setAnimationLoop(e),null===e?eX.stop():eX.start()},eF.addEventListener("sessionstart",eW),eF.addEventListener("sessionend",ej),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void K("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===en)return;let n=!0===eF.enabled&&!0===eF.isPresenting,i=null!==ee&&(null===ea||n)&&ee.begin(et,ea);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===eF.enabled&&!0===eF.isPresenting&&(null===ee||!1===ee.isCompositing())&&(!0===eF.cameraAutoUpdate&&eF.updateCamera(t),t=eF.getCamera()),!0===e.isScene&&e.onBeforeRender(et,e,t,ea),(X=g.get(e,Y.length)).init(t),Y.push(X),eE.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),eM.setFromProjectionMatrix(eE,2e3,t.reversedDepth),ew=this.localClippingEnabled,eT=v.init(this.clippingPlanes,ew),(j=m.get(e,q.length)).init(),q.push(j),!0===eF.enabled&&!0===eF.isPresenting){let e=et.xr.getDepthSensingMesh();null!==e&&eq(e,t,-1/0,et.sortObjects)}eq(e,t,0,et.sortObjects),j.finish(),!0===et.sortObjects&&j.sort(ev,e_),(eP=!1===eF.enabled||!1===eF.isPresenting||!1===eF.hasDepthSensing())&&y.addToRenderList(j,e),this.info.render.frame++,!0===eT&&v.beginShadows();let r=X.state.shadowsArray;if(_.render(r,e,t),!0===eT&&v.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(i&&ee.hasRenderPass())){let n=j.opaque,i=j.transmissive;if(X.setupLights(),t.isArrayCamera){let r=t.cameras;if(i.length>0)for(let t=0,a=r.length;t0&&eZ(n,i,e,t),eP&&y.render(e),eY(j,e,t)}null!==ea&&0===er&&(o.updateMultisampleRenderTarget(ea),o.updateRenderTargetMipmap(ea)),i&&ee.end(et),!0===e.isScene&&e.onAfterRender(et,e,t),T.resetDefaultState(),es=-1,eo=null,Y.pop(),Y.length>0?(X=Y[Y.length-1],!0===eT&&v.setGlobalState(et.clippingPlanes,X.state.camera)):X=null,q.pop(),j=q.length>0?q[q.length-1]:null},this.getActiveCubeFace=function(){return ei},this.getActiveMipmapLevel=function(){return er},this.getRenderTarget=function(){return ea},this.setRenderTargetTextures=function(e,t,n){let i=s.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),s.get(e.texture).__webglTexture=t,s.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=s.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const e1=eU.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){ea=e,ei=t,er=n;let i=null,a=!1,l=!1;if(e){let u=s.get(e);if(void 0!==u.__useDefaultFramebuffer){r.bindFramebuffer(eU.FRAMEBUFFER,u.__webglFramebuffer),el.copy(e.viewport),eu.copy(e.scissor),ec=e.scissorTest,r.viewport(el),r.scissor(eu),r.setScissorTest(ec),es=-1;return}if(void 0===u.__webglFramebuffer)o.setupRenderTarget(e);else if(u.__hasExternalTextures)o.rebindTextures(e,s.get(e.texture).__webglTexture,s.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(u.__boundDepthTexture!==t){if(null!==t&&s.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");o.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(l=!0);let h=s.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(h[t])?h[t][n]:h[t],a=!0):i=e.samples>0&&!1===o.useMultisampledRTT(e)?s.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,el.copy(e.viewport),eu.copy(e.scissor),ec=e.scissorTest}else el.copy(ey).multiplyScalar(eg).floor(),eu.copy(ex).multiplyScalar(eg).floor(),ec=eS;if(0!==n&&(i=e1),r.bindFramebuffer(eU.FRAMEBUFFER,i)&&r.drawBuffers(e,i),r.viewport(el),r.scissor(eu),r.setScissorTest(ec),a){let i=s.get(e.texture);eU.framebufferTexture2D(eU.FRAMEBUFFER,eU.COLOR_ATTACHMENT0,eU.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(l)for(let i=0;i=0&&t<=e.width-a&&n>=0&&n<=e.height-o&&(e.textures.length>1&&eU.readBuffer(eU.COLOR_ATTACHMENT0+c),eU.readPixels(t,n,a,o,M.convert(s),M.convert(u),l))}finally{let e=null!==ea?s.get(ea).__webglFramebuffer:null;r.bindFramebuffer(eU.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,a,o,l,u,c=0){if(!(e&&e.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=s.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(h=h[u]),h)if(t>=0&&t<=e.width-a&&n>=0&&n<=e.height-o){r.bindFramebuffer(eU.FRAMEBUFFER,h);let u=e.textures[c],d=u.format,p=u.type;if(!i.textureFormatReadable(d))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!i.textureTypeReadable(p))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let f=eU.createBuffer();eU.bindBuffer(eU.PIXEL_PACK_BUFFER,f),eU.bufferData(eU.PIXEL_PACK_BUFFER,l.byteLength,eU.STREAM_READ),e.textures.length>1&&eU.readBuffer(eU.COLOR_ATTACHMENT0+c),eU.readPixels(t,n,a,o,M.convert(d),M.convert(p),0);let m=null!==ea?s.get(ea).__webglFramebuffer:null;r.bindFramebuffer(eU.FRAMEBUFFER,m);let g=eU.fenceSync(eU.SYNC_GPU_COMMANDS_COMPLETE,0);return eU.flush(),await Q(eU,g,4),eU.bindBuffer(eU.PIXEL_PACK_BUFFER,f),eU.getBufferSubData(eU.PIXEL_PACK_BUFFER,0,l),eU.deleteBuffer(f),eU.deleteSync(g),l}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(e,t=null,n=0){let i=Math.pow(2,-n),a=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i),l=null!==t?t.x:0,u=null!==t?t.y:0;o.setTexture2D(e,0),eU.copyTexSubImage2D(eU.TEXTURE_2D,n,0,0,l,u,a,s),r.unbindTexture()};const e2=eU.createFramebuffer(),e3=eU.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,a=0,l=null){let u,c,h,d,p,f,m,g,v,_;null===l&&(0!==a?($("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),l=a,a=0):l=0);let y=e.isCompressedTexture?e.mipmaps[l]:e.image;if(null!==n)u=n.max.x-n.min.x,c=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,d=n.min.x,p=n.min.y,f=n.isBox3?n.min.z:0;else{let t=Math.pow(2,-a);u=Math.floor(y.width*t),c=Math.floor(y.height*t),h=e.isDataArrayTexture?y.depth:e.isData3DTexture?Math.floor(y.depth*t):1,d=0,p=0,f=0}null!==i?(m=i.x,g=i.y,v=i.z):(m=0,g=0,v=0);let x=M.convert(t.format),b=M.convert(t.type);t.isData3DTexture?(o.setTexture3D(t,0),_=eU.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(o.setTexture2DArray(t,0),_=eU.TEXTURE_2D_ARRAY):(o.setTexture2D(t,0),_=eU.TEXTURE_2D),eU.pixelStorei(eU.UNPACK_FLIP_Y_WEBGL,t.flipY),eU.pixelStorei(eU.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),eU.pixelStorei(eU.UNPACK_ALIGNMENT,t.unpackAlignment);let S=eU.getParameter(eU.UNPACK_ROW_LENGTH),T=eU.getParameter(eU.UNPACK_IMAGE_HEIGHT),w=eU.getParameter(eU.UNPACK_SKIP_PIXELS),E=eU.getParameter(eU.UNPACK_SKIP_ROWS),A=eU.getParameter(eU.UNPACK_SKIP_IMAGES);eU.pixelStorei(eU.UNPACK_ROW_LENGTH,y.width),eU.pixelStorei(eU.UNPACK_IMAGE_HEIGHT,y.height),eU.pixelStorei(eU.UNPACK_SKIP_PIXELS,d),eU.pixelStorei(eU.UNPACK_SKIP_ROWS,p),eU.pixelStorei(eU.UNPACK_SKIP_IMAGES,f);let C=e.isDataArrayTexture||e.isData3DTexture,R=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=s.get(e),i=s.get(t),o=s.get(n.__renderTarget),_=s.get(i.__renderTarget);r.bindFramebuffer(eU.READ_FRAMEBUFFER,o.__webglFramebuffer),r.bindFramebuffer(eU.DRAW_FRAMEBUFFER,_.__webglFramebuffer);for(let n=0;ntypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=eb._getDrawingBufferColorSpace(e),t.unpackColorSpace=eb._getUnpackColorSpace()}}e.s(["PMREMGenerator",()=>lb,"ShaderChunk",()=>lt,"ShaderLib",()=>li,"UniformsLib",()=>ln,"WebGLRenderer",()=>cM,"WebGLUtils",()=>cd],8560);var cT=e.i(66748);let cw=[];function cE(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;let i=e.length;if(t.length!==i)return!1;for(let r=0;r0&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(r.remove,i.lifespan)),r.response;if(!n)throw r.promise}let r={keys:t,equal:i.equal,remove:()=>{let e=cw.indexOf(r);-1!==e&&cw.splice(e,1)},promise:("object"==typeof e&&"function"==typeof e.then?e:e(...t)).then(e=>{r.response=e,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(e=>r.error=e)};if(cw.push(r),!n)throw r.promise}var cC=e.i(89499),cR=e.i(43476),cP=E;function cI(e,t,n){if(!e)return;if(!0===n(e))return e;let i=t?e.return:e.child;for(;i;){let e=cI(i,t,n);if(e)return e;i=t?null:i.sibling}}function cL(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(t){return e}}"u">typeof window&&((null==(y=window.document)?void 0:y.createElement)||(null==(x=window.navigator)?void 0:x.product)==="ReactNative")?cP.useLayoutEffect:cP.useEffect;let cN=cL(cP.createContext(null));class cU extends cP.Component{render(){return cP.createElement(cN.Provider,{value:this._reactInternals},this.props.children)}}function cD(){let e=cP.useContext(cN);if(null===e)throw Error("its-fine: useFiber must be called within a !");let t=cP.useId();return cP.useMemo(()=>{for(let n of[e,null==e?void 0:e.alternate]){if(!n)continue;let e=cI(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}let cO=Symbol.for("react.context"),cF=e=>null!==e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===cO;function cz(){let e=function(){let e=cD(),[t]=cP.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;cF(e)&&e!==cN&&!t.has(e)&&t.set(e,cP.use(cL(e))),n=n.return}return t}();return cP.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>i=>cP.createElement(t,null,cP.createElement(n.Provider,{...i,value:e.get(n)})),e=>cP.createElement(cU,{...e})),[e])}function cB(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}e.s(["FiberProvider",()=>cU,"traverseFiber",()=>cI,"useContextBridge",()=>cz,"useFiber",()=>cD],46791),E.act;let ck=e=>e&&e.hasOwnProperty("current"),cV=e=>null!=e&&("string"==typeof e||"number"==typeof e||e.isColor),cH="u">typeof window&&((null==(m=window.document)?void 0:m.createElement)||(null==(g=window.navigator)?void 0:g.product)==="ReactNative")?E.useLayoutEffect:E.useEffect;function cG(e){let t=E.useRef(e);return cH(()=>void(t.current=e),[e]),t}function cW(){let e=cD(),t=cz();return E.useMemo(()=>({children:n})=>{let i=cI(e,!0,e=>e.type===E.StrictMode)?E.StrictMode:E.Fragment;return(0,cR.jsx)(i,{children:(0,cR.jsx)(t,{children:n})})},[e,t])}function cj({set:e}){return cH(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}let cX=((v=class extends E.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}).getDerivedStateFromError=()=>({error:!0}),v);function cq(e){var t;let n="u">typeof window?null!=(t=window.devicePixelRatio)?t:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],n),e[1]):e}function cY(e){var t;return null==(t=e.__r3f)?void 0:t.root.getState()}let cZ={obj:e=>e===Object(e)&&!cZ.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,boo:e=>"boolean"==typeof e,und:e=>void 0===e,nul:e=>null===e,arr:e=>Array.isArray(e),equ(e,t,{arrays:n="shallow",objects:i="reference",strict:r=!0}={}){let a;if(typeof e!=typeof t||!!e!=!!t)return!1;if(cZ.str(e)||cZ.num(e)||cZ.boo(e))return e===t;let s=cZ.obj(e);if(s&&"reference"===i)return e===t;let o=cZ.arr(e);if(o&&"reference"===n)return e===t;if((o||s)&&e===t)return!0;for(a in e)if(!(a in t))return!1;if(s&&"shallow"===n&&"shallow"===i){for(a in r?t:e)if(!cZ.equ(e[a],t[a],{strict:r,objects:"reference"}))return!1}else for(a in r?t:e)if(e[a]!==t[a])return!1;if(cZ.und(a)){if(o&&0===e.length&&0===t.length||s&&0===Object.keys(e).length&&0===Object.keys(t).length)return!0;if(e!==t)return!1}return!0}},cJ=["children","key","ref"];function cK(e,t,n,i){let r=null==e?void 0:e.__r3f;return!r&&(r={root:t,type:n,parent:null,children:[],props:function(e){let t={};for(let n in e)cJ.includes(n)||(t[n]=e[n]);return t}(i),object:e,eventCount:0,handlers:{},isHidden:!1},e&&(e.__r3f=r)),r}function c$(e,t){if(!t.includes("-")||t in e)return{root:e,key:t,target:e[t]};let n=e,i=t.split("-");for(let r of i){if("object"!=typeof n||null===n){if(void 0!==n)return{root:n,key:i.slice(i.indexOf(r)).join("-"),target:void 0};return{root:e,key:t,target:void 0}}t=r,e=n,n=n[t]}return{root:e,key:t,target:n}}let cQ=/-\d+$/;function c0(e,t){if(cZ.str(t.props.attach)){if(cQ.test(t.props.attach)){let n=t.props.attach.replace(cQ,""),{root:i,key:r}=c$(e.object,n);Array.isArray(i[r])||(i[r]=[])}let{root:n,key:i}=c$(e.object,t.props.attach);t.previousAttach=n[i],n[i]=t.object}else cZ.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function c1(e,t){if(cZ.str(t.props.attach)){let{root:n,key:i}=c$(e.object,t.props.attach),r=t.previousAttach;void 0===r?delete n[i]:n[i]=r}else null==t.previousAttach||t.previousAttach(e.object,t.object);delete t.previousAttach}let c2=[...cJ,"args","dispose","attach","object","onUpdate","dispose"],c3=new Map,c4=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],c5=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function c6(e,t){var n,i;let r=e.__r3f,a=r&&cB(r).getState(),s=null==r?void 0:r.eventCount;for(let n in t){let s=t[n];if(c2.includes(n))continue;if(r&&c5.test(n)){"function"==typeof s?r.handlers[n]=s:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(void 0===s)continue;let{root:o,key:l,target:u}=c$(e,n);if(void 0===u&&("object"!=typeof o||null===o))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${l}".`);u instanceof td&&s instanceof td?u.mask=s.mask:u instanceof tq&&cV(s)?u.set(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"function"==typeof u.copy&&null!=s&&s.constructor&&u.constructor===s.constructor?u.copy(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&Array.isArray(s)?"function"==typeof u.fromArray?u.fromArray(s):u.set(...s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"number"==typeof s?"function"==typeof u.setScalar?u.setScalar(s):u.set(s):(o[l]=s,a&&!a.linear&&c4.includes(l)&&null!=(i=o[l])&&i.isTexture&&1023===o[l].format&&1009===o[l].type&&(o[l].colorSpace=I))}if(null!=r&&r.parent&&null!=a&&a.internal&&null!=(n=r.object)&&n.isObject3D&&s!==r.eventCount){let e=r.object,t=a.internal.interaction.indexOf(e);t>-1&&a.internal.interaction.splice(t,1),r.eventCount&&null!==e.raycast&&a.internal.interaction.push(e)}return r&&void 0===r.props.attach&&(r.object.isBufferGeometry?r.props.attach="geometry":r.object.isMaterial&&(r.props.attach="material")),r&&c8(r),e}function c8(e){var t;if(!e.parent)return;null==e.props.onUpdate||e.props.onUpdate(e.object);let n=null==(t=e.root)||null==t.getState?void 0:t.getState();n&&0===n.internal.frames&&n.invalidate()}let c9=e=>null==e?void 0:e.isObject3D;function c7(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function he(e,t,n,i){let r=n.get(t);r&&(n.delete(t),0===n.size&&(e.delete(i),r.target.releasePointerCapture(i)))}let ht=e=>!!(null!=e&&e.render),hn=E.createContext(null);function hi(){let e=E.useContext(hn);if(!e)throw Error("R3F: Hooks can only be used within the Canvas component!");return e}function hr(e=e=>e,t){return hi()(e,t)}function ha(e,t=0){let n=hi(),i=n.getState().internal.subscribe,r=cG(e);return cH(()=>i(r,t,n),[t,i,n]),null}let hs=new WeakMap;function ho(e,t){return function(n,...i){var r;let a;return"function"==typeof n&&(null==n||null==(r=n.prototype)?void 0:r.constructor)===n?(a=hs.get(n))||(a=new n,hs.set(n,a)):a=n,e&&e(a),Promise.all(i.map(e=>new Promise((n,i)=>a.load(e,e=>{var t;let i;c9(null==e?void 0:e.scene)&&Object.assign(e,(t=e.scene,i={nodes:{},materials:{},meshes:{}},t&&t.traverse(e=>{e.name&&(i.nodes[e.name]=e),e.material&&!i.materials[e.material.name]&&(i.materials[e.material.name]=e.material),e.isMesh&&!i.meshes[e.name]&&(i.meshes[e.name]=e)}),i)),n(e)},t,t=>i(Error(`Could not load ${e}: ${null==t?void 0:t.message}`))))))}}function hl(e,t,n,i){let r=Array.isArray(t)?t:[t],a=cA(ho(n,i),[e,...r],!1,{equal:cZ.equ});return Array.isArray(t)?a:a[0]}hl.preload=function(e,t,n){let i,r=Array.isArray(t)?t:[t];cA(ho(n),[e,...r],!0,i)},hl.clear=function(e,t){var n=[e,...Array.isArray(t)?t:[t]];if(void 0===n||0===n.length)cw.splice(0,cw.length);else{let e=cw.find(e=>cE(n,e.keys,e.equal));e&&e.remove()}};var hu={exports:{}},hc={exports:{}};hc.exports;let hh=(T||(T=1,M||(M=1,hc.exports=function(e){function t(e,t,n,i){return new iJ(e,t,n,i)}function n(){}function i(e){var t="https://react.dev/errors/"+e;if(1sT||(e.current=sM[sT],sM[sT]=null,sT--)}function h(e,t){sM[++sT]=e.current,e.current=t}function d(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 0x1000000:case 0x2000000:return 0x3c00000&e;case 0x4000000:return 0x4000000;case 0x8000000:return 0x8000000;case 0x10000000:return 0x10000000;case 0x20000000:return 0x20000000;case 0x40000000:return 0;default:return e}}function p(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=0x7ffffff&i;return 0!==o?0!=(i=o&~a)?r=d(i):0!=(s&=o)?r=d(s):n||0!=(n=o&~e)&&(r=d(n)):0!=(o=i&~a)?r=d(o):0!==s?r=d(s):n||0!=(n=i&~e)&&(r=d(n)),0===r?0:0!==t&&t!==r&&(t&a)==0&&((a=r&-r)>=(n=t&-t)||32===a&&(4194048&n)!=0)?t:r}function f(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)==0}function m(){var e=sI;return(0x3c00000&(sI<<=1))==0&&(sI=4194304),e}function g(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function v(e,t){e.pendingLanes|=t,0x10000000!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function _(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-sE(t);e.entangledLanes|=t,e.entanglements[i]=0x40000000|e.entanglements[i]|261930&n}function y(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-sE(n),r=1<)":-1r||l[i]!==u[r]){var c=` +`+l[i].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=i&&0<=r)break}}}finally{sY=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?T(n):""}function C(e){try{var t="",n=null;do t+=function(e,t){switch(e.tag){case 26:case 27:case 5:return T(e.type);case 16:return T("Lazy");case 13:return e.child!==t&&null!==t?T("Suspense Fallback"):T("Suspense");case 19:return T("SuspenseList");case 0:case 15:return A(e.type,!1);case 11:return A(e.type.render,!1);case 1:return A(e.type,!0);case 31:return T("Activity");default:return""}}(e,n),n=e,e=e.return;while(e)return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}function R(e,t){if("object"==typeof e&&null!==e){var n=sZ.get(e);return void 0!==n?n:(t={value:e,source:t,stack:C(t)},sZ.set(e,t),t)}return{value:e,source:t,stack:C(t)}}function P(e,t){sJ[sK++]=sQ,sJ[sK++]=s$,s$=e,sQ=t}function I(e,t,n){s0[s1++]=s3,s0[s1++]=s4,s0[s1++]=s2,s2=e;var i=s3;e=s4;var r=32-sE(i)-1;i&=~(1<>=s,r-=s,s3=1<<32-sE(t)+r|n<d?(p=h,h=null):p=h.sibling;var v=m(t,h,s[d],o);if(null===v){null===h&&(h=p);break}e&&h&&null===v.alternate&&n(t,h),i=l(v,i,d),null===c?u=v:c.sibling=v,c=v,h=p}if(d===s.length)return r(t,h),ot&&P(t,d),u;if(null===h){for(;dp?(v=d,d=null):v=d.sibling;var y=m(t,d,_.value,u);if(null===y){null===d&&(d=v);break}e&&d&&null===y.alternate&&n(t,d),s=l(y,s,p),null===h?c=y:h.sibling=y,h=y,d=v}if(_.done)return r(t,d),ot&&P(t,p),c;if(null===d){for(;!_.done;p++,_=o.next())null!==(_=f(t,_.value,u))&&(s=l(_,s,p),null===h?c=_:h.sibling=_,h=_);return ot&&P(t,p),c}for(d=a(d);!_.done;p++,_=o.next())null!==(_=g(d,t,p,_.value,u))&&(e&&null!==_.alternate&&d.delete(null===_.key?p:_.key),s=l(_,s,p),null===h?c=_:h.sibling=_,h=_);return e&&d.forEach(function(e){return n(t,e)}),ot&&P(t,p),c}(c,h,d=v.call(d),p)}if("function"==typeof d.then)return t(c,h,eM(d),p);if(d.$$typeof===rd)return t(c,h,ee(c,d),p);ew(c,d)}return"string"==typeof d&&""!==d||"number"==typeof d||"bigint"==typeof d?(d=""+d,null!==h&&6===h.tag?(r(c,h.sibling),(p=s(h,d)).return=c):(r(c,h),(p=i2(d,c.mode,p)).return=c),u(c=p)):r(c,h)}(c,h,d,p);return oR=null,v}catch(e){if(e===oT||e===oE)throw e;var _=t(29,e,null,c.mode);return _.lanes=p,_.return=c,_}finally{}}}function eA(){for(var e=oU,t=oD=oU=0;ta?a:8);var s=rM.T,o={};rM.T=o,t$(e,!1,t,n);try{var l=r(),u=rM.S;if(null!==u&&u(o,l),null!==l&&"object"==typeof l&&"function"==typeof l.then){var c,h,d=(c=[],h={status:"pending",value:null,reason:null,then:function(e){c.push(e)}},l.then(function(){h.status="fulfilled",h.value=i;for(var e=0;e";case lu:return":has("+(id(e)||"")+")";case lc:return'[role="'+e.value+'"]';case ld:return'"'+e.value+'"';case lh:return'[data-testname="'+e.value+'"]';default:throw Error(i(365))}}function ip(e,t){var n=[];e=[e,0];for(var i=0;ilO&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=eK(s))){if(t.flags|=128,a=!0,t.updateQueue=e=e.updateQueue,nD(t,e),nO(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!ot)return nF(t),null}else 2*sO()-r.renderingStartTime>lO&&0x20000000!==n&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=sO(),e.sibling=null,n=oH.current,h(oH,a?1&n|2:1&n),ot&&P(t,r.treeForkCount),e):(nF(t),null);case 22:case 23:return eJ(t),ej(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(0x20000000&n)!=0&&(128&t.flags)==0&&(nF(t),6&t.subtreeFlags&&(t.flags|=8192)):nF(t),null!==(n=t.updateQueue)&&nD(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&c(oM),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),q(oh),nF(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}(t.alternate,t,lT);if(null!==n){lv=n;return}if(null!==(t=t.sibling)){lv=t;return}lv=t=e}while(null!==t)0===lw&&(lw=5)}function iD(e,t){do{var n=function(e,t){switch(N(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return q(oh),O(),(65536&(e=t.flags))!=0&&(128&e)==0?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return z(t),null;case 31:if(null!==t.memoizedState){if(eJ(t),null===t.alternate)throw Error(i(340));G()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(eJ(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));G()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return c(oH),null;case 4:return O(),null;case 10:return q(t.type),null;case 22:case 23:return eJ(t),ej(),null!==e&&c(oM),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return q(oh),null;default:return null}}(e.alternate,e);if(null!==n){n.flags&=32767,lv=n;return}if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling)){lv=e;return}lv=e=n}while(null!==e)lw=6,lv=null}function iO(e,t,n,r,a,s,o,l,u){e.cancelPendingCommit=null;do iV();while(0!==lB)if((6&lm)!=0)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,u=e.hiddenUpdates;for(n=s&~n;0n?32:n;n=rM.T;var a=rq();try{rX(r),rM.T=null,r=lW,lW=null;var s=lk,o=lH;if(lB=0,lV=lk=null,lH=0,(6&lm)!=0)throw Error(i(331));var l=lm;if(lm|=4,il(s.current),it(s,s.current,o,r),lm=l,es(0,!1),sW&&"function"==typeof sW.onPostCommitFiberRoot)try{sW.onPostCommitFiberRoot(sG,s)}catch{}return!0}finally{rX(a),rM.T=n,ik(e,t)}}function iG(e,t,n){t=R(n,t),t=t9(e.stateNode,t,2),null!==(e=eO(e,t,2))&&(v(e,2),ea(e))}function iW(e,t,n){if(3===e.tag)iG(e,e,n);else for(;null!==t;){if(3===t.tag){iG(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===lz||!lz.has(i))){e=R(n,e),null!==(i=eO(t,n=t7(2),2))&&(ne(n,i,t,e),v(i,2),ea(i));break}}t=t.return}}function ij(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new lf;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(lM=!0,r.add(n),e=iX.bind(null,e,t,n),t.then(e,e))}function iX(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,lg===e&&(l_&n)===n&&(4===lw||3===lw&&(0x3c00000&l_)===l_&&300>sO()-lU?(2&lm)==0&&iT(e,0):lC|=n,lP===l_&&(lP=0)),ea(e)}function iq(e,t){0===t&&(t=m()),null!==(e=eP(e,t))&&(v(e,t),ea(e))}function iY(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),iq(e,n)}function iZ(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),iq(e,n)}function iJ(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function iK(e){return!(!(e=e.prototype)||!e.isReactComponent)}function i$(e,n){var i=e.alternate;return null===i?((i=t(e.tag,n,e.key,e.mode)).elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=0x3e00000&e.flags,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i.refCleanup=e.refCleanup,i}function iQ(e,t){e.flags&=0x3e00002;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,e.dependencies=null===(t=n.dependencies)?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function i0(e,n,r,a,s,o){var l=0;if(a=e,"function"==typeof e)iK(e)&&(l=1);else if("string"==typeof e)l=si&&sv?sr(e,r,s5.current)?26:sb(e)?27:5:si?sr(e,r,s5.current)?26:5:sv&&sb(e)?27:5;else o:switch(e){case r_:return(e=t(31,r,n,s)).elementType=r_,e.lanes=o,e;case rl:return i1(r.children,s,o,n);case ru:l=8,s|=24;break;case rc:return(e=t(12,r,n,2|s)).elementType=rc,e.lanes=o,e;case rf:return(e=t(13,r,n,s)).elementType=rf,e.lanes=o,e;case rm:return(e=t(19,r,n,s)).elementType=rm,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case rd:l=10;break o;case rh:l=9;break o;case rp:l=11;break o;case rg:l=14;break o;case rv:l=16,a=null;break o}l=29,r=Error(i(130,null===e?"null":typeof e,"")),a=null}return(n=t(l,r,n,s)).elementType=e,n.type=a,n.lanes=o,n}function i1(e,n,i,r){return(e=t(7,e,r,n)).lanes=i,e}function i2(e,n,i){return(e=t(6,e,null,n)).lanes=i,e}function i3(e){var n=t(18,null,null,0);return n.stateNode=e,n}function i4(e,n,i){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function i5(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=rB,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=g(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=g(0),this.hiddenUpdates=g(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function i6(e,n,i,r,a,s,o,l,u,c,h,d){return e=new i5(e,n,i,o,u,c,h,d,l),n=1,!0===s&&(n|=24),s=t(3,null,null,n),e.current=s,s.stateNode=e,n=en(),n.refCount++,e.pooledCache=n,n.refCount++,s.memoizedState={element:r,isDehydrated:i,cache:n},eN(s),e}function i8(e){var t=e._reactInternals;if(void 0===t)throw"function"==typeof e.render?Error(i(188)):Error(i(268,e=Object.keys(e).join(",")));return null===(e=null!==(e=s(t))?function e(t){var n=t.tag;if(5===n||26===n||27===n||6===n)return t;for(t=t.child;null!==t;){if(null!==(n=e(t)))return n;t=t.sibling}return null}(e):null)?null:rA(e.stateNode)}function i9(e,t,n,i,r,a){r=sw,null===i.context?i.context=r:i.pendingContext=r,(i=eD(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=eO(e,i,t))&&(i_(n,e,t),eF(n,e,t))}function i7(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n>>=0)?32:31-(sA(e)/sC|0)|0},sA=Math.log,sC=Math.LN2,sR=256,sP=262144,sI=4194304,sL=ri.unstable_scheduleCallback,sN=ri.unstable_cancelCallback,sU=ri.unstable_shouldYield,sD=ri.unstable_requestPaint,sO=ri.unstable_now,sF=ri.unstable_ImmediatePriority,sz=ri.unstable_UserBlockingPriority,sB=ri.unstable_NormalPriority,sk=ri.unstable_IdlePriority,sV=ri.log,sH=ri.unstable_setDisableYieldValue,sG=null,sW=null,sj="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},sX="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof w.default&&"function"==typeof w.default.emit)return void w.default.emit("uncaughtException",e);console.error(e)},sq=Object.prototype.hasOwnProperty,sY=!1,sZ=new WeakMap,sJ=[],sK=0,s$=null,sQ=0,s0=[],s1=0,s2=null,s3=1,s4="",s5=u(null),s6=u(null),s8=u(null),s9=u(null),s7=null,oe=null,ot=!1,on=null,oi=!1,or=Error(i(519)),oa=u(null),os=null,oo=null,ol="u">typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ou=ri.unstable_scheduleCallback,oc=ri.unstable_NormalPriority,oh={$$typeof:rd,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},od=null,op=null,of=!1,om=!1,og=!1,ov=0,o_=null,oy=0,ox=0,ob=null,oS=rM.S;rM.S=function(e,t){lD=sO(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===o_){var n=o_=[];oy=0,ox=ed(),ob={status:"pending",value:void 0,then:function(e){n.push(e)}}}oy++,t.then(ep,ep)}(0,t),null!==oS&&oS(e,t)};var oM=u(null),oT=Error(i(460)),ow=Error(i(474)),oE=Error(i(542)),oA={then:function(){}},oC=null,oR=null,oP=0,oI=eE(!0),oL=eE(!1),oN=[],oU=0,oD=0,oO=!1,oF=!1,oz=u(null),oB=u(0),ok=u(null),oV=null,oH=u(0),oG=0,oW=null,oj=null,oX=null,oq=!1,oY=!1,oZ=!1,oJ=0,oK=0,o$=null,oQ=0,o0={readContext:Q,use:tt,useCallback:e$,useContext:e$,useEffect:e$,useImperativeHandle:e$,useLayoutEffect:e$,useInsertionEffect:e$,useMemo:e$,useReducer:e$,useRef:e$,useState:e$,useDebugValue:e$,useDeferredValue:e$,useTransition:e$,useSyncExternalStore:e$,useId:e$,useHostTransitionStatus:e$,useFormState:e$,useActionState:e$,useOptimistic:e$,useMemoCache:e$,useCacheRefresh:e$};o0.useEffectEvent=e$;var o1={readContext:Q,use:tt,useCallback:function(e,t){return e8().memoizedState=[e,void 0===t?null:t],e},useContext:Q,useEffect:tI,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,tR(4194308,4,tO.bind(null,t,e),n)},useLayoutEffect:function(e,t){return tR(4194308,4,e,t)},useInsertionEffect:function(e,t){tR(4,2,e,t)},useMemo:function(e,t){var n=e8();t=void 0===t?null:t;var i=e();return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=e8();if(void 0!==n)var r=n(t);else r=t;return i.memoizedState=i.baseState=r,i.queue=e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},e=e.dispatch=tZ.bind(null,oW,e),[i.memoizedState,e]},useRef:function(e){return e8().memoizedState={current:e}},useState:function(e){var t=(e=tp(e)).queue,n=tJ.bind(null,oW,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:tz,useDeferredValue:function(e,t){return tV(e8(),e,t)},useTransition:function(){var e=tp(!1);return e=tG.bind(null,oW,e.queue,!0,!1),e8().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=oW,a=e8();if(ot){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===lg)throw Error(i(349));(127&l_)!=0||tl(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,tI(tc.bind(null,r,s,e),[e]),r.flags|=2048,tA(9,{destroy:void 0},tu.bind(null,r,s,n,t),null),n},useId:function(){var e=e8(),t=lg.identifierPrefix;if(ot){var n=s4,i=s3;t="_"+t+"R_"+(n=(i&~(1<<32-sE(i)-1)).toString(32)+n),0<(n=oJ++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=oQ++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:tj,useFormState:tS,useActionState:tS,useOptimistic:function(e){var t=e8();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=t$.bind(null,oW,!0,n),n.dispatch=t,[e,t]},useMemoCache:tn,useCacheRefresh:function(){return e8().memoizedState=tY.bind(null,oW)},useEffectEvent:function(e){var t=e8(),n={impl:e};return t.memoizedState=n,function(){if((2&lm)!=0)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},o2={readContext:Q,use:tt,useCallback:tB,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tU,useLayoutEffect:tD,useMemo:tk,useReducer:tr,useRef:tC,useState:function(){return tr(ti)},useDebugValue:tz,useDeferredValue:function(e,t){return tH(e9(),oj.memoizedState,e,t)},useTransition:function(){var e=tr(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tj,useFormState:tM,useActionState:tM,useOptimistic:function(e,t){return tf(e9(),oj,e,t)},useMemoCache:tn,useCacheRefresh:tq};o2.useEffectEvent=tN;var o3={readContext:Q,use:tt,useCallback:tB,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tU,useLayoutEffect:tD,useMemo:tk,useReducer:ts,useRef:tC,useState:function(){return ts(ti)},useDebugValue:tz,useDeferredValue:function(e,t){var n=e9();return null===oj?tV(n,e,t):tH(n,oj.memoizedState,e,t)},useTransition:function(){var e=ts(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tj,useFormState:tE,useActionState:tE,useOptimistic:function(e,t){var n=e9();return null!==oj?tf(n,oj,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:tn,useCacheRefresh:tq};o3.useEffectEvent=tN;var o4={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eD(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(i_(t,e,i),eF(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eD(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(i_(t,e,i),eF(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ig(),i=eD(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=eO(e,i,n))&&(i_(t,e,n),eF(t,e,n))}},o5=Error(i(461)),o6=!1,o8={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},o9=!1,o7=!1,le=!1,lt="function"==typeof WeakSet?WeakSet:Set,ln=null,li=null,lr=!1,la=null,ls=8192,lo={getCacheForType:function(e){var t=Q(oh),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Q(oh).controller.signal}},ll=0,lu=1,lc=2,lh=3,ld=4;if("function"==typeof Symbol&&Symbol.for){var lp=Symbol.for;ll=lp("selector.component"),lu=lp("selector.has_pseudo_class"),lc=lp("selector.role"),lh=lp("selector.test_id"),ld=lp("selector.text")}var lf="function"==typeof WeakMap?WeakMap:Map,lm=0,lg=null,lv=null,l_=0,ly=0,lx=null,lb=!1,lS=!1,lM=!1,lT=0,lw=0,lE=0,lA=0,lC=0,lR=0,lP=0,lI=null,lL=null,lN=!1,lU=0,lD=0,lO=1/0,lF=null,lz=null,lB=0,lk=null,lV=null,lH=0,lG=0,lW=null,lj=null,lX=0,lq=null;return rt.attemptContinuousHydration=function(e){if(13===e.tag||31===e.tag){var t=eP(e,0x4000000);null!==t&&i_(t,e,0x4000000),re(e,0x4000000)}},rt.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag||31===e.tag){var t=ig(),n=eP(e,t=b(t));null!==n&&i_(n,e,t),re(e,t)}},rt.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if((e=e.stateNode).current.memoizedState.isDehydrated){var t=d(e.pendingLanes);if(0!==t){for(e.pendingLanes|=2,e.entangledLanes|=2;t;){var n=1<<31-sE(t);e.entanglements[1]|=n,t&=~n}ea(e),(6&lm)==0&&(lO=sO()+500,es(0,!1))}}break;case 31:case 13:null!==(t=eP(e,2))&&i_(t,e,2),iS(),re(e,2)}},rt.batchedUpdates=function(e,t){return e(t)},rt.createComponentSelector=function(e){return{$$typeof:ll,value:e}},rt.createContainer=function(e,t,n,i,r,a,s,o,l,u){return i6(e,t,!1,null,n,i,a,null,s,o,l,u)},rt.createHasPseudoClassSelector=function(e){return{$$typeof:lu,value:e}},rt.createHydrationContainer=function(e,t,n,i,r,a,s,o,l,u,c,h,d,p){var f;return(e=i6(n,i,!0,e,r,a,o,p,l,u,c,h)).context=sw,n=e.current,(r=eD(i=b(i=ig()))).callback=null!=(f=t)?f:null,eO(n,r,i),t=i,e.current.lanes=t,v(e,t),ea(e),e},rt.createPortal=function(e,t,n){var i=3=c&&s>=d&&a<=h&&o<=p){e.splice(t,1);break}if(r!==c||n.width!==u.width||po){if(!(s!==d||n.height!==u.height||ha)){c>r&&(u.width+=c-r,u.x=r),hs&&(u.height+=d-s,u.y=s),pn&&(n=l)),l ")+` + +No matching component was found for: + `+e.join(" > ")}return null},rt.getPublicRootInstance=function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 27:case 5:return rA(e.child.stateNode);default:return e.child.stateNode}},rt.injectIntoDevTools=function(){var e={bundleType:0,version:rT,rendererPackageName:rw,currentDispatcherRef:rM,reconcilerVersion:"19.2.0"};if(null!==rE&&(e.rendererConfig=rE),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{sG=t.inject(e),sW=t}catch{}e=!!t.checkDCE}}return e},rt.isAlreadyRendering=function(){return(6&lm)!=0},rt.observeVisibleRects=function(e,t,n,r){if(!r7)throw Error(i(363));var a=as(e=im(e,t),n,r).disconnect;return{disconnect:function(){a()}}},rt.shouldError=function(){return null},rt.shouldSuspend=function(){return!1},rt.startHostTransition=function(e,t,r,a){if(5!==e.tag)throw Error(i(476));var s=tW(e).queue;tG(e,s,t,r4,null===r?n:function(){var t=tW(e);return null===t.next&&(t=e.alternate.memoizedState),tK(e,t.next.queue,{},ig()),r(a)})},rt.updateContainer=function(e,t,n,i){var r=t.current,a=ig();return i9(r,a,e,t,n,i),a},rt.updateContainerSync=function(e,t,n,i){return i9(t.current,2,e,t,n,i),2},rt},hc.exports.default=hc.exports,Object.defineProperty(hc.exports,"__esModule",{value:!0})),hu.exports=hc.exports),(b=hu.exports)&&b.__esModule&&Object.prototype.hasOwnProperty.call(b,"default"))?b.default:b,hd={},hp=/^three(?=[A-Z])/,hf=e=>`${e[0].toUpperCase()}${e.slice(1)}`,hm=0;function hg(e){if("function"==typeof e){let t=`${hm++}`;return hd[t]=e,t}Object.assign(hd,e)}function hv(e,t){let n=hf(e),i=hd[n];if("primitive"!==e&&!i)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if("primitive"===e&&!t.object)throw Error("R3F: Primitives without 'object' are invalid!");if(void 0!==t.args&&!Array.isArray(t.args))throw Error("R3F: The args prop must be an array!")}function h_(e){if(e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?c0(e.parent,e):c9(e.object)&&!1!==e.props.visible&&(e.object.visible=!0),e.isHidden=!1,c8(e)}}function hy(e,t,n){let i=t.root.getState();if(e.parent||e.object===i.scene){if(!t.object){var r,a;let e=hd[hf(t.type)];t.object=null!=(r=t.props.object)?r:new e(...null!=(a=t.props.args)?a:[]),t.object.__r3f=t}if(c6(t.object,t.props),t.props.attach)c0(e,t);else if(c9(t.object)&&c9(e.object)){let i=e.object.children.indexOf(null==n?void 0:n.object);if(n&&-1!==i){let n=e.object.children.indexOf(t.object);-1!==n?(e.object.children.splice(n,1),e.object.children.splice(n{try{e.dispose()}catch{}};"u">typeof IS_REACT_ACT_ENVIRONMENT?t():(0,cC.unstable_scheduleCallback)(cC.unstable_IdlePriority,t)}}function hM(e,t,n){if(!t)return;t.parent=null;let i=e.children.indexOf(t);-1!==i&&e.children.splice(i,1),t.props.attach?c1(e,t):c9(t.object)&&c9(e.object)&&(e.object.remove(t.object),function(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,i)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(i)}),n.capturedMap.forEach((e,i)=>{he(n.capturedMap,t,e,i)})}(cB(t),t.object));let r=null!==t.props.dispose&&!1!==n;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];hM(t,n,r)}t.children.length=0,delete t.object.__r3f,r&&"primitive"!==t.type&&"Scene"!==t.object.type&&hS(t.object),void 0===n&&c8(t)}let hT=[],hw=()=>{},hE={},hA=0,hC=(S={isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:function(e,t,n){var i;return hv(e=hf(e)in hd?e:e.replace(hp,""),t),"primitive"===e&&null!=(i=t.object)&&i.__r3f&&delete t.object.__r3f,cK(t.object,n,e,t)},removeChild:hM,appendChild:hx,appendInitialChild:hx,insertBefore:hb,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hx(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hM(n,t)},insertInContainerBefore(e,t,n){let i=e.getState().scene.__r3f;t&&n&&i&&hb(i,t,n)},getRootHostContext:()=>hE,getChildHostContext:()=>hE,commitUpdate(e,t,n,i,r){var a,s,o;hv(t,i);let l=!1;if("primitive"===e.type&&n.object!==i.object||(null==(a=i.args)?void 0:a.length)!==(null==(s=n.args)?void 0:s.length)?l=!0:null!=(o=i.args)&&o.some((e,t)=>{var i;return e!==(null==(i=n.args)?void 0:i[t])})&&(l=!0),l)hT.push([e,{...i},r]);else{let t=function(e,t){let n={};for(let i in t)if(!c2.includes(i)&&!cZ.equ(t[i],e.props[i]))for(let e in n[i]=t[i],t)e.startsWith(`${i}-`)&&(n[e]=t[e]);for(let i in e.props){if(c2.includes(i)||t.hasOwnProperty(i))continue;let{root:r,key:a}=c$(e.object,i);if(r.constructor&&0===r.constructor.length){let e=function(e){let t=c3.get(e.constructor);try{t||(t=new e.constructor,c3.set(e.constructor,t))}catch(e){}return t}(r);cZ.und(e)||(n[a]=e[a])}else n[a]=0}return n}(e,i);Object.keys(t).length&&(Object.assign(e.props,t),c6(e.object,t))}(null===r.sibling||(4&r.flags)==0)&&function(){for(let[e]of hT){let t=e.parent;if(t)for(let n of(e.props.attach?c1(t,e):c9(e.object)&&c9(t.object)&&t.object.remove(e.object),e.children))n.props.attach?c1(e,n):c9(n.object)&&c9(e.object)&&e.object.remove(n.object);e.isHidden&&h_(e),e.object.__r3f&&delete e.object.__r3f,"primitive"!==e.type&&hS(e.object)}for(let[i,r,a]of hT){i.props=r;let s=i.parent;if(s){let r=hd[hf(i.type)];i.object=null!=(e=i.props.object)?e:new r(...null!=(t=i.props.args)?t:[]),i.object.__r3f=i;var e,t,n=i.object;for(let e of[a,a.alternate])if(null!==e)if("function"==typeof e.ref){null==e.refCleanup||e.refCleanup();let t=e.ref(n);"function"==typeof t&&(e.refCleanup=t)}else e.ref&&(e.ref.current=n);for(let e of(c6(i.object,i.props),i.props.attach?c0(s,i):c9(i.object)&&c9(s.object)&&s.object.add(i.object),i.children))e.props.attach?c0(i,e):c9(e.object)&&c9(i.object)&&i.object.add(e.object);c8(i)}}hT.length=0}()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>null==e?void 0:e.object,prepareForCommit:()=>null,preparePortalMount:e=>cK(e.getState().scene,e,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:function(e){if(!e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?c1(e.parent,e):c9(e.object)&&(e.object.visible=!1),e.isHidden=!0,c8(e)}},unhideInstance:h_,createTextInstance:hw,hideTextInstance:hw,unhideTextInstance:hw,scheduleTimeout:"function"==typeof setTimeout?setTimeout:void 0,cancelTimeout:"function"==typeof clearTimeout?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:E.createContext(null),setCurrentUpdatePriority(e){hA=e},getCurrentUpdatePriority:()=>hA,resolveUpdatePriority(){var e;if(0!==hA)return hA;switch("u">typeof window&&(null==(e=window.event)?void 0:e.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return 2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return 8;default:return 32}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:"9.5.0",applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance:(e,t)=>e,cloneMutableTextInstance:e=>e,cloneRootViewTransitionContainer(e){throw Error("Not implemented.")},removeRootViewTransitionClone(e,t){throw Error("Not implemented.")},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null},(_=hh(S)).injectIntoDevTools(),_),hR=new Map,hP={objects:"shallow",strict:!1};function hI(e){var t,n;let i,r,a,s,o,l,u,c=hR.get(e),h=null==c?void 0:c.fiber,d=null==c?void 0:c.store;c&&console.warn("R3F.createRoot should only be called once!");let p="function"==typeof reportError?reportError:console.error,f=d||(t=hX,n=hq,o=(s=(a=(0,cT.createWithEqualityFn)((e,i)=>{let r,a=new ef,s=new ef,o=new ef;function l(e=i().camera,t=s,n=i().size){let{width:r,height:u,top:c,left:h}=n,d=r/u;t.isVector3?o.copy(t):o.set(...t);let p=e.getWorldPosition(a).distanceTo(o);if(e&&e.isOrthographicCamera)return{width:r/e.zoom,height:u/e.zoom,top:c,left:h,factor:1,distance:p,aspect:d};{let t=2*Math.tan(e.fov*Math.PI/180/2)*p,n=r/u*t;return{width:n,height:t,top:c,left:h,factor:r/n,distance:p,aspect:d}}}let u=t=>e(e=>({performance:{...e.performance,current:t}})),c=new ed;return{set:e,get:i,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(e=1)=>t(i(),e),advance:(e,t)=>n(e,t,i()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new sW,pointer:c,mouse:c,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=i();r&&clearTimeout(r),e.performance.current!==e.performance.min&&u(e.performance.min),r=setTimeout(()=>u(i().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:l},setEvents:t=>e(e=>({...e,events:{...e.events,...t}})),setSize:(t,n,r=0,a=0)=>{let o=i().camera,u={width:t,height:n,top:r,left:a};e(e=>({size:u,viewport:{...e.viewport,...l(o,s,u)}}))},setDpr:t=>e(e=>{let n=cq(t);return{viewport:{...e.viewport,dpr:n,initialDpr:e.viewport.initialDpr||n}}}),setFrameloop:(t="always")=>{let n=i().clock;n.stop(),n.elapsedTime=0,"never"!==t&&(n.start(),n.elapsedTime=0),e(()=>({frameloop:t}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:E.createRef(),active:!1,frames:0,priority:0,subscribe:(e,t,n)=>{let r=i().internal;return r.priority=r.priority+ +(t>0),r.subscribers.push({ref:e,priority:t,store:n}),r.subscribers=r.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let n=i().internal;null!=n&&n.subscribers&&(n.priority=n.priority-(t>0),n.subscribers=n.subscribers.filter(t=>t.ref!==e))}}}}})).getState()).size,l=s.viewport.dpr,u=s.camera,a.subscribe(()=>{let{camera:e,size:t,viewport:n,gl:i,set:r}=a.getState();if(t.width!==o.width||t.height!==o.height||n.dpr!==l){o=t,l=n.dpr;!e.manual&&(e&&e.isOrthographicCamera?(e.left=-(t.width/2),e.right=t.width/2,e.top=t.height/2,e.bottom=-(t.height/2)):e.aspect=t.width/t.height,e.updateProjectionMatrix());n.dpr>0&&i.setPixelRatio(n.dpr);let r="u">typeof HTMLCanvasElement&&i.domElement instanceof HTMLCanvasElement;i.setSize(t.width,t.height,r)}e!==u&&(u=e,r(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),a.subscribe(e=>t(e)),a),m=h||hC.createContainer(f,1,null,!1,null,"",p,p,p,null);c||hR.set(e,{fiber:m,store:f});let g=!1,v=null;return{async configure(t={}){var n,a;let s;v=new Promise(e=>s=e);let{gl:o,size:l,scene:u,events:c,onCreated:h,shadows:d=!1,linear:p=!1,flat:m=!1,legacy:_=!1,orthographic:y=!1,frameloop:x="always",dpr:b=[1,2],performance:S,raycaster:M,camera:T,onPointerMissed:w}=t,E=f.getState(),A=E.gl;if(!E.gl){let t={canvas:e,powerPreference:"high-performance",antialias:!0,alpha:!0},n="function"==typeof o?await o(t):o;A=ht(n)?n:new cM({...t,...o}),E.set({gl:A})}let C=E.raycaster;C||E.set({raycaster:C=new op});let{params:R,...P}=M||{};if(cZ.equ(P,C,hP)||c6(C,{...P}),cZ.equ(R,C.params,hP)||c6(C,{params:{...C.params,...R}}),!E.camera||E.camera===r&&!cZ.equ(r,T,hP)){r=T;let e=null==T?void 0:T.isCamera,t=e?T:y?new sx(0,0,0,0,.1,1e3):new nO(75,0,.1,1e3);!e&&(t.position.z=5,T&&(c6(t,T),!t.manual&&("aspect"in T||"left"in T||"right"in T||"bottom"in T||"top"in T)&&(t.manual=!0,t.updateProjectionMatrix())),E.camera||null!=T&&T.rotation||t.lookAt(0,0,0)),E.set({camera:t}),C.camera=t}if(!E.scene){let e;null!=u&&u.isScene?cK(e=u,f,"",{}):(cK(e=new nj,f,"",{}),u&&c6(e,u)),E.set({scene:e})}c&&!E.events.handlers&&E.set({events:c(f)});let N=function(e,t){if(!t&&"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:i,left:r}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:r}}return!t&&"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...t}}(e,l);if(cZ.equ(N,E.size,hP)||E.setSize(N.width,N.height,N.top,N.left),b&&E.viewport.dpr!==cq(b)&&E.setDpr(b),E.frameloop!==x&&E.setFrameloop(x),E.onPointerMissed||E.set({onPointerMissed:w}),S&&!cZ.equ(S,E.performance,hP)&&E.set(e=>({performance:{...e.performance,...S}})),!E.xr){let e=(e,t)=>{let n=f.getState();"never"!==n.frameloop&&hq(e,!0,n,t)},t=()=>{let t=f.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||hX(t)},i={connect(){let e=f.getState().gl;e.xr.addEventListener("sessionstart",t),e.xr.addEventListener("sessionend",t)},disconnect(){let e=f.getState().gl;e.xr.removeEventListener("sessionstart",t),e.xr.removeEventListener("sessionend",t)}};"function"==typeof(null==(n=A.xr)?void 0:n.addEventListener)&&i.connect(),E.set({xr:i})}if(A.shadowMap){let e=A.shadowMap.enabled,t=A.shadowMap.type;A.shadowMap.enabled=!!d,cZ.boo(d)?A.shadowMap.type=2:cZ.str(d)?A.shadowMap.type=null!=(a=({basic:0,percentage:1,soft:2,variance:3})[d])?a:2:cZ.obj(d)&&Object.assign(A.shadowMap,d),(e!==A.shadowMap.enabled||t!==A.shadowMap.type)&&(A.shadowMap.needsUpdate=!0)}return eb.enabled=!_,g||(A.outputColorSpace=p?L:I,A.toneMapping=4*!m),E.legacy!==_&&E.set(()=>({legacy:_})),E.linear!==p&&E.set(()=>({linear:p})),E.flat!==m&&E.set(()=>({flat:m})),!o||cZ.fun(o)||ht(o)||cZ.equ(o,A,hP)||c6(A,o),i=h,g=!0,s(),this},render(t){return g||v||this.configure(),v.then(()=>{hC.updateContainer((0,cR.jsx)(hL,{store:f,children:t,onCreated:i,rootElement:e}),m,null,()=>void 0)}),f},unmount(){hN(e)}}}function hL({store:e,children:t,onCreated:n,rootElement:i}){return cH(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||null==t.events.connect||t.events.connect(i)},[]),(0,cR.jsx)(hn.Provider,{value:e,children:t})}function hN(e,t){let n=hR.get(e),i=null==n?void 0:n.fiber;if(i){let r=null==n?void 0:n.store.getState();r&&(r.internal.active=!1),hC.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{null==r.events.disconnect||r.events.disconnect(),null==(n=r.gl)||null==(i=n.renderLists)||null==i.dispose||i.dispose(),null==(a=r.gl)||null==a.forceContextLoss||a.forceContextLoss(),null!=(s=r.gl)&&s.xr&&r.xr.disconnect();var n,i,a,s,o=r.scene;for(let e in"Scene"!==o.type&&(null==o.dispose||o.dispose()),o){let t=o[e];(null==t?void 0:t.type)!=="Scene"&&(null==t||null==t.dispose||t.dispose())}hR.delete(e),t&&t(e)}catch(e){}},500)})}}function hU(e,t){let n={callback:e};return t.add(n),()=>void t.delete(n)}let hD=new Set,hO=new Set,hF=new Set,hz=e=>hU(e,hD),hB=e=>hU(e,hO);function hk(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function hV(e,t){switch(e){case"before":return hk(hD,t);case"after":return hk(hO,t);case"tail":return hk(hF,t)}}function hH(e,t,n){let i=t.clock.getDelta();"never"===t.frameloop&&"number"==typeof e&&(i=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),s=t.internal.subscribers;for(let e=0;e0)&&!(null!=(t=c.gl.xr)&&t.isPresenting)&&(l+=hH(e,c))}if(hW=!1,hV("after",e),0===l)return hV("tail",e),hG=!1,cancelAnimationFrame(u)}function hX(e,t=1){var n;if(!e)return hR.forEach(e=>hX(e.store.getState(),t));(null==(n=e.gl.xr)||!n.isPresenting)&&e.internal.active&&"never"!==e.frameloop&&(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):hW?e.internal.frames=2:e.internal.frames=1,hG||(hG=!0,requestAnimationFrame(hj)))}function hq(e,t=!0,n,i){if(t&&hV("before",e),n)hH(e,n,i);else for(let t of hR.values())hH(e,t.store.getState());t&&hV("after",e)}let hY={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function hZ(e){let{handlePointer:t}=function(e){function t(e){return e.filter(e=>["Move","Over","Enter","Out","Leave"].some(t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))}function n(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let i=e.eventObject.__r3f;if(n.hovered.delete(c7(e)),null!=i&&i.eventCount){let n=i.handlers,r={...e,intersections:t};null==n.onPointerOut||n.onPointerOut(r),null==n.onPointerLeave||n.onPointerLeave(r)}}}function i(e,t){for(let n=0;nn([]);case"onLostPointerCapture":return t=>{let{internal:i}=e.getState();"pointerId"in t&&i.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{i.capturedMap.has(t.pointerId)&&(i.capturedMap.delete(t.pointerId),n([]))})}}return function(a){let{onPointerMissed:s,internal:o}=e.getState();o.lastEvent.current=a;let l="onPointerMove"===r,u="onClick"===r||"onContextMenu"===r||"onDoubleClick"===r,c=function(t,n){let i=e.getState(),r=new Set,a=[],s=n?n(i.internal.interaction):i.internal.interaction;for(let e=0;e{let n=cY(e.object),i=cY(t.object);return n&&i&&i.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=c7(e);return!r.has(t)&&(r.add(t),!0)});for(let e of(i.events.filter&&(o=i.events.filter(o,i)),o)){let t=e.object;for(;t;){var l;null!=(l=t.__r3f)&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if("pointerId"in t&&i.internal.capturedMap.has(t.pointerId))for(let e of i.internal.capturedMap.get(t.pointerId).values())r.has(c7(e.intersection))||a.push(e.intersection);return a}(a,l?t:void 0),h=u?function(t){let{internal:n}=e.getState(),i=t.offsetX-n.initialClick[0],r=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(i*i+r*r))}(a):0;"onPointerDown"===r&&(o.initialClick=[a.offsetX,a.offsetY],o.initialHits=c.map(e=>e.eventObject)),u&&!c.length&&h<=2&&(i(a,o.interaction),s&&s(a)),l&&n(c),!function(e,t,i,r){if(e.length){let a={stopped:!1};for(let s of e){let o=cY(s.object);if(o||s.object.traverseAncestors(e=>{let t=cY(e);if(t)return o=t,!1}),o){let{raycaster:l,pointer:u,camera:c,internal:h}=o,d=new ef(u.x,u.y,0).unproject(c),p=e=>{var t,n;return null!=(t=null==(n=h.capturedMap.get(e))?void 0:n.has(s.eventObject))&&t},f=e=>{let n={intersection:s,target:t.target};h.capturedMap.has(e)?h.capturedMap.get(e).set(s.eventObject,n):h.capturedMap.set(e,new Map([[s.eventObject,n]])),t.target.setPointerCapture(e)},m=e=>{let t=h.capturedMap.get(e);t&&he(h.capturedMap,s.eventObject,t,e)},g={};for(let e in t){let n=t[e];"function"!=typeof n&&(g[e]=n)}let v={...s,...g,pointer:u,intersections:e,stopped:a.stopped,delta:i,unprojectedPoint:d,ray:l.ray,camera:c,stopPropagation(){let i="pointerId"in t&&h.capturedMap.get(t.pointerId);(!i||i.has(s.eventObject))&&(v.stopped=a.stopped=!0,h.hovered.size&&Array.from(h.hovered.values()).find(e=>e.eventObject===s.eventObject)&&n([...e.slice(0,e.indexOf(s)),s]))},target:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},currentTarget:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},nativeEvent:t};if(r(v),!0===a.stopped)break}}}}(c,a,h,function(e){let t=e.eventObject,n=t.__r3f;if(!(null!=n&&n.eventCount))return;let s=n.handlers;if(l){if(s.onPointerOver||s.onPointerEnter||s.onPointerOut||s.onPointerLeave){let t=c7(e),n=o.hovered.get(t);n?n.stopped&&e.stopPropagation():(o.hovered.set(t,e),null==s.onPointerOver||s.onPointerOver(e),null==s.onPointerEnter||s.onPointerEnter(e))}null==s.onPointerMove||s.onPointerMove(e)}else{let n=s[r];n?(!u||o.initialHits.includes(t))&&(i(a,o.interaction.filter(e=>!o.initialHits.includes(e))),n(e)):u&&o.initialHits.includes(t)&&i(a,o.interaction.filter(e=>!o.initialHits.includes(e)))}})}}}}(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(2*(e.offsetY/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(hY).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:i}=e.getState();null!=(t=i.lastEvent)&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{let{set:n,events:i}=e.getState();if(null==i.disconnect||i.disconnect(),n(e=>({events:{...e.events,connected:t}})),i.handlers)for(let e in i.handlers){let n=i.handlers[e],[r,a]=hY[e];t.addEventListener(r,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[i]=hY[e];n.connected.removeEventListener(i,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}e.s(["B",()=>cj,"C",()=>hr,"D",()=>ha,"E",()=>cX,"G",()=>hl,"a",()=>cG,"b",()=>cH,"c",()=>hI,"d",()=>hN,"e",()=>hg,"f",()=>hZ,"i",()=>ck,"j",()=>hz,"k",()=>hB,"u",()=>cW],40859)},15080,e=>{"use strict";var t=e.i(40859);e.s(["useThree",()=>t.C])},71753,e=>{"use strict";var t=e.i(40859);e.s(["useFrame",()=>t.D])},79123,e=>{"use strict";var t=e.i(43476),n=e.i(71645);let i=(0,n.createContext)(null),r=(0,n.createContext)(null),a=(0,n.createContext)(null);function s(){return(0,n.useContext)(i)}function o(){return(0,n.useContext)(r)}function l(){return(0,n.useContext)(a)}function u({children:e,fogEnabledOverride:s,onClearFogEnabledOverride:o}){let[l,u]=(0,n.useState)(!0),[c,h]=(0,n.useState)(!1),[d,p]=(0,n.useState)(1),[f,m]=(0,n.useState)(90),[g,v]=(0,n.useState)(!1),[_,y]=(0,n.useState)(!0),[x,b]=(0,n.useState)(!1),[S,M]=(0,n.useState)("moveLookStick"),T=(0,n.useCallback)(e=>{u(e),o()},[o]),w=(0,n.useMemo)(()=>({fogEnabled:s??l,setFogEnabled:T,highQualityFog:c,setHighQualityFog:h,fov:f,setFov:m,audioEnabled:g,setAudioEnabled:v,animationEnabled:_,setAnimationEnabled:y}),[l,s,T,c,f,g,_]),E=(0,n.useMemo)(()=>({debugMode:x,setDebugMode:b}),[x,b]),A=(0,n.useMemo)(()=>({speedMultiplier:d,setSpeedMultiplier:p,touchMode:S,setTouchMode:M}),[d,p,S,M]);(0,n.useLayoutEffect)(()=>{let e={};try{e=JSON.parse(localStorage.getItem("settings"))||{}}catch(e){}null!=e.debugMode&&b(e.debugMode),null!=e.audioEnabled&&v(e.audioEnabled),null!=e.animationEnabled&&y(e.animationEnabled),null!=e.fogEnabled&&u(e.fogEnabled),null!=e.highQualityFog&&h(e.highQualityFog),null!=e.speedMultiplier&&p(e.speedMultiplier),null!=e.fov&&m(e.fov),null!=e.touchMode&&M(e.touchMode)},[]);let C=(0,n.useRef)(null);return(0,n.useEffect)(()=>(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{try{localStorage.setItem("settings",JSON.stringify({fogEnabled:l,highQualityFog:c,speedMultiplier:d,fov:f,audioEnabled:g,animationEnabled:_,debugMode:x,touchMode:S}))}catch(e){}},500),()=>{C.current&&clearTimeout(C.current)}),[l,c,d,f,g,_,x,S]),(0,t.jsx)(i.Provider,{value:w,children:(0,t.jsx)(r.Provider,{value:E,children:(0,t.jsx)(a.Provider,{value:A,children:e})})})}e.s(["SettingsProvider",()=>u,"useControls",()=>l,"useDebug",()=>o,"useSettings",()=>s])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/3e57999e46d7efb4.css b/docs/_next/static/chunks/12ed5d454f7c6ac3.css similarity index 78% rename from docs/_next/static/chunks/3e57999e46d7efb4.css rename to docs/_next/static/chunks/12ed5d454f7c6ac3.css index c2e968be..daec829c 100644 --- a/docs/_next/static/chunks/3e57999e46d7efb4.css +++ b/docs/_next/static/chunks/12ed5d454f7c6ac3.css @@ -1,13 +1,13 @@ -.FloatingLabel-module__8y09Ka__Label{color:#fff;white-space:nowrap;text-align:center;background:#00000080;border-radius:1px;padding:1px 3px;font-size:11px} -.DebugElements-module__Cmeo9W__StatsPanel{bottom:0;right:0;top:auto!important;left:auto!important}.DebugElements-module__Cmeo9W__AxisLabel{pointer-events:none;font-size:12px}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=x]{color:#f90}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=y]{color:#9f0}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=z]{color:#09f} .KeyboardOverlay-module__HsRBsa__Root{pointer-events:none;z-index:1;align-items:flex-end;gap:10px;display:flex;position:fixed;bottom:16px;left:50%;transform:translate(-50%)}.KeyboardOverlay-module__HsRBsa__Column{flex-direction:column;justify-content:center;gap:4px;display:flex}.KeyboardOverlay-module__HsRBsa__Row{justify-content:stretch;gap:4px;display:flex}.KeyboardOverlay-module__HsRBsa__Spacer{width:32px}.KeyboardOverlay-module__HsRBsa__Key{color:#ffffff80;white-space:nowrap;background:#0006;border:1px solid #fff3;border-radius:4px;flex:1 0 0;justify-content:center;align-items:center;min-width:32px;height:32px;padding:0 8px;font-size:11px;font-weight:600;display:flex}.KeyboardOverlay-module__HsRBsa__Key[data-pressed=true]{color:#fff;background:#34bbab99;border-color:#23fddc80}.KeyboardOverlay-module__HsRBsa__Arrow{margin-right:3px} +.TouchControls-module__AkxfgW__Joystick{z-index:1;width:140px;height:140px;position:fixed;bottom:20px;left:50%;transform:translate(-50%)}.TouchControls-module__AkxfgW__Left{left:20px;transform:none;}.TouchControls-module__AkxfgW__Right{left:auto;right:20px;transform:none;} .MissionSelect-module__N_AIjG__InputWrapper{align-items:center;display:flex;position:relative}.MissionSelect-module__N_AIjG__Shortcut{color:#fff9;pointer-events:none;background:#ffffff26;border-radius:3px;padding:1px 4px;font-family:system-ui,sans-serif;font-size:11px;position:absolute;right:7px}.MissionSelect-module__N_AIjG__Input[aria-expanded=true]~.MissionSelect-module__N_AIjG__Shortcut{display:none}.MissionSelect-module__N_AIjG__Input{color:#fff;-webkit-user-select:text;user-select:text;background:#0009;border:1px solid #ffffff4d;border-radius:3px;outline:none;width:280px;padding:6px 36px 6px 8px;font-size:14px}.MissionSelect-module__N_AIjG__Input[aria-expanded=true]{padding-right:8px}.MissionSelect-module__N_AIjG__Input:focus{border-color:#fff9}.MissionSelect-module__N_AIjG__Input::placeholder{color:#0000}.MissionSelect-module__N_AIjG__SelectedValue{pointer-events:none;align-items:center;gap:6px;display:flex;position:absolute;left:8px;right:36px;overflow:hidden}.MissionSelect-module__N_AIjG__Input[aria-expanded=true]~.MissionSelect-module__N_AIjG__SelectedValue{display:none}.MissionSelect-module__N_AIjG__SelectedName{color:#fff;white-space:nowrap;text-overflow:ellipsis;flex-shrink:1;min-width:0;font-size:14px;font-weight:600;overflow:hidden}.MissionSelect-module__N_AIjG__SelectedValue>.MissionSelect-module__N_AIjG__ItemType{flex-shrink:0}.MissionSelect-module__N_AIjG__Popover{z-index:100;min-width:320px;max-height:var(--popover-available-height,90vh);overscroll-behavior:contain;background:#141414f2;border:1px solid #ffffff80;border-radius:3px;overflow-y:auto;box-shadow:0 8px 24px #0009}.MissionSelect-module__N_AIjG__List{padding:4px 0}.MissionSelect-module__N_AIjG__List:has(>.MissionSelect-module__N_AIjG__Group:first-child){padding-top:0}.MissionSelect-module__N_AIjG__Group{padding-bottom:4px}.MissionSelect-module__N_AIjG__GroupLabel{color:#c6caca;z-index:1;background:#3a4548f2;border-bottom:1px solid #ffffff4d;padding:6px 8px 6px 12px;font-size:13px;font-weight:600;position:sticky;top:0}.MissionSelect-module__N_AIjG__Group:not(:last-child){border-bottom:1px solid #ffffff4d}.MissionSelect-module__N_AIjG__Item{cursor:pointer;border-radius:4px;outline:none;flex-direction:column;gap:1px;margin:4px 4px 0;padding:6px 8px;scroll-margin-top:32px;display:flex}.MissionSelect-module__N_AIjG__List>.MissionSelect-module__N_AIjG__Item:first-child{margin-top:0}.MissionSelect-module__N_AIjG__Item[data-active-item]{background:#ffffff26}.MissionSelect-module__N_AIjG__Item[aria-selected=true]{background:#6496ff4d}.MissionSelect-module__N_AIjG__ItemHeader{align-items:center;gap:6px;display:flex}.MissionSelect-module__N_AIjG__ItemName{color:#fff;font-size:14px;font-weight:600}.MissionSelect-module__N_AIjG__ItemTypes{gap:3px;display:flex}.MissionSelect-module__N_AIjG__ItemType{color:#fff;background:#ff9d0066;border-radius:3px;padding:2px 5px;font-size:10px;font-weight:600}.MissionSelect-module__N_AIjG__ItemType:hover{background:#ff9d00b3}.MissionSelect-module__N_AIjG__ItemMissionName{color:#ffffff80;font-size:12px}.MissionSelect-module__N_AIjG__NoResults{color:#ffffff80;text-align:center;padding:12px 8px;font-size:13px} -.InspectorControls-module__gNRB6W__Controls{color:#fff;z-index:2;background:#00000080;border-radius:0 0 4px;justify-content:center;align-items:center;gap:20px;padding:8px 12px 8px 8px;font-size:13px;display:flex;position:fixed;top:0;left:0}.InspectorControls-module__gNRB6W__Dropdown,.InspectorControls-module__gNRB6W__Group{justify-content:center;align-items:center;gap:20px;display:flex}.InspectorControls-module__gNRB6W__CheckboxField,.InspectorControls-module__gNRB6W__LabelledButton,.InspectorControls-module__gNRB6W__Field{align-items:center;gap:6px;display:flex}.InspectorControls-module__gNRB6W__IconButton{color:#fff;cursor:pointer;background:#03529399;border:1px solid #c8c8c84d;border-color:#ffffff4d #c8c8c84d #c8c8c84d #ffffff4d;border-radius:4px;justify-content:center;align-items:center;width:28px;height:28px;margin:0 0 0 -12px;padding:0;font-size:15px;transition:background .2s,border-color .2s;display:flex;position:relative;transform:translate(0);box-shadow:0 1px 2px #0006}.InspectorControls-module__gNRB6W__IconButton svg{pointer-events:none}@media (hover:hover){.InspectorControls-module__gNRB6W__IconButton:hover{background:#0062b3cc;border-color:#fff6}}.InspectorControls-module__gNRB6W__IconButton:active,.InspectorControls-module__gNRB6W__IconButton[aria-expanded=true]{background:#0062b3b3;border-color:#ffffff4d;transform:translateY(1px)}.InspectorControls-module__gNRB6W__IconButton[data-active=true]{background:#0075d5e6;border-color:#fff6}.InspectorControls-module__gNRB6W__ButtonLabel{font-size:12px}.InspectorControls-module__gNRB6W__Toggle{margin:0;}.InspectorControls-module__gNRB6W__MapInfoButton{}@media (max-width:1279px){.InspectorControls-module__gNRB6W__Dropdown[data-open=false]{display:none}.InspectorControls-module__gNRB6W__Dropdown{background:#000c;border:1px solid #fff3;border-radius:4px;flex-direction:column;align-items:center;gap:12px;max-height:calc(100dvh - 56px);padding:12px;display:flex;position:absolute;top:calc(100% + 2px);left:2px;right:2px;overflow:auto;box-shadow:0 0 12px #0006}.InspectorControls-module__gNRB6W__Group{flex-wrap:wrap;gap:12px 20px}.InspectorControls-module__gNRB6W__LabelledButton{width:auto;padding:0 10px}}@media (max-width:639px){.InspectorControls-module__gNRB6W__Controls{border-radius:0;right:0}.InspectorControls-module__gNRB6W__MissionSelectWrapper{flex:1 1 0;min-width:0}.InspectorControls-module__gNRB6W__MissionSelectWrapper input{width:100%}.InspectorControls-module__gNRB6W__Toggle{flex:none}}@media (min-width:1280px){.InspectorControls-module__gNRB6W__Toggle,.InspectorControls-module__gNRB6W__LabelledButton .InspectorControls-module__gNRB6W__ButtonLabel,.InspectorControls-module__gNRB6W__MapInfoButton{display:none}} +.InspectorControls-module__gNRB6W__Controls{color:#fff;z-index:2;background:#00000080;border-radius:0 0 4px;justify-content:center;align-items:center;gap:20px;padding:8px 12px 8px 8px;font-size:13px;display:flex;position:fixed;top:0;left:0}.InspectorControls-module__gNRB6W__Dropdown,.InspectorControls-module__gNRB6W__Group{justify-content:center;align-items:center;gap:20px;display:flex}.InspectorControls-module__gNRB6W__CheckboxField,.InspectorControls-module__gNRB6W__LabelledButton,.InspectorControls-module__gNRB6W__Field{align-items:center;gap:6px;display:flex}.InspectorControls-module__gNRB6W__IconButton{color:#fff;cursor:pointer;background:#03529399;border:1px solid #c8c8c84d;border-color:#ffffff4d #c8c8c84d #c8c8c84d #ffffff4d;border-radius:4px;justify-content:center;align-items:center;min-width:28px;height:28px;margin:0 0 0 -12px;padding:0;font-size:15px;transition:background .2s,border-color .2s;display:flex;position:relative;transform:translate(0);box-shadow:0 1px 2px #0006}.InspectorControls-module__gNRB6W__IconButton svg{pointer-events:none}@media (hover:hover){.InspectorControls-module__gNRB6W__IconButton:hover{background:#0062b3cc;border-color:#fff6}}.InspectorControls-module__gNRB6W__IconButton:active,.InspectorControls-module__gNRB6W__IconButton[aria-expanded=true]{background:#0062b3b3;border-color:#ffffff4d;transform:translateY(1px)}.InspectorControls-module__gNRB6W__IconButton[data-active=true]{background:#0075d5e6;border-color:#fff6}.InspectorControls-module__gNRB6W__ButtonLabel{font-size:12px}.InspectorControls-module__gNRB6W__Toggle{margin:0;}.InspectorControls-module__gNRB6W__MapInfoButton{}@media (max-width:1279px){.InspectorControls-module__gNRB6W__Dropdown[data-open=false]{display:none}.InspectorControls-module__gNRB6W__Dropdown{background:#000c;border:1px solid #fff3;border-radius:4px;flex-direction:column;align-items:center;gap:12px;max-height:calc(100dvh - 56px);padding:12px;display:flex;position:absolute;top:calc(100% + 2px);left:2px;right:2px;overflow:auto;box-shadow:0 0 12px #0006}.InspectorControls-module__gNRB6W__Group{flex-wrap:wrap;gap:12px 20px}.InspectorControls-module__gNRB6W__LabelledButton{width:auto;padding:0 10px}}@media (max-width:639px){.InspectorControls-module__gNRB6W__Controls{border-radius:0;right:0}.InspectorControls-module__gNRB6W__MissionSelectWrapper{flex:1 1 0;min-width:0}.InspectorControls-module__gNRB6W__MissionSelectWrapper input{width:100%}.InspectorControls-module__gNRB6W__Toggle{flex:none}}@media (min-width:1280px){.InspectorControls-module__gNRB6W__Toggle,.InspectorControls-module__gNRB6W__LabelledButton .InspectorControls-module__gNRB6W__ButtonLabel,.InspectorControls-module__gNRB6W__MapInfoButton{display:none}} .CopyCoordinatesButton-module__BxovtG__Root{}.CopyCoordinatesButton-module__BxovtG__Root[data-copied=true]{background:#0075d5e6;border-color:#fff6}.CopyCoordinatesButton-module__BxovtG__ClipboardCheck{opacity:1;display:none}.CopyCoordinatesButton-module__BxovtG__Root[data-copied=true] .CopyCoordinatesButton-module__BxovtG__ClipboardCheck{animation:.22s linear infinite CopyCoordinatesButton-module__BxovtG__showClipboardCheck;display:block}.CopyCoordinatesButton-module__BxovtG__Root[data-copied=true] .CopyCoordinatesButton-module__BxovtG__MapPin{display:none}.CopyCoordinatesButton-module__BxovtG__ButtonLabel{}@keyframes CopyCoordinatesButton-module__BxovtG__showClipboardCheck{0%{opacity:1}to{opacity:.2}} .LoadDemoButton-module__kGZaoW__Root{}.LoadDemoButton-module__kGZaoW__ButtonLabel{}.LoadDemoButton-module__kGZaoW__DemoIcon{font-size:19px} +.JoinServerButton-module__DIR70a__Root{padding:0 5px;}.JoinServerButton-module__DIR70a__TextLabel{}.JoinServerButton-module__DIR70a__PingLabel{margin-right:2px;display:flex!important;}.JoinServerButton-module__DIR70a__LiveIcon{font-size:15px}.JoinServerButton-module__DIR70a__Pulsing{animation:1.2s ease-out infinite JoinServerButton-module__DIR70a__blink}@keyframes JoinServerButton-module__DIR70a__blink{0%{opacity:1}to{opacity:.25}} +.DebugElements-module__Cmeo9W__StatsPanel{bottom:0;right:0;top:auto!important;left:auto!important}.DebugElements-module__Cmeo9W__AxisLabel{pointer-events:none;font-size:12px}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=x]{color:#f90}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=y]{color:#9f0}.DebugElements-module__Cmeo9W__AxisLabel[data-axis=z]{color:#09f} +.FloatingLabel-module__8y09Ka__Label{color:#fff;white-space:nowrap;text-align:center;background:#00000080;border-radius:1px;padding:1px 3px;font-size:11px} .PlayerNameplate-module__zYDm0a__Root{pointer-events:none;white-space:nowrap;flex-direction:column;align-items:center;display:inline-flex}.PlayerNameplate-module__zYDm0a__Top{padding-bottom:20px;}.PlayerNameplate-module__zYDm0a__Bottom{padding-top:20px;}.PlayerNameplate-module__zYDm0a__IffArrow{width:12px;height:12px;image-rendering:pixelated;filter:drop-shadow(0 1px 2px #000000b3)}.PlayerNameplate-module__zYDm0a__Name{color:#fff;text-shadow:0 1px 3px #000000e6,0 0 1px #000000b3;font-size:11px}.PlayerNameplate-module__zYDm0a__HealthBar{background:#00000080;border:1px solid #fff3;width:60px;height:4px;margin:2px auto 0;overflow:hidden}.PlayerNameplate-module__zYDm0a__HealthFill{background:#2ecc40;height:100%} .FlagMarker-module__INpLba__Root{pointer-events:none;white-space:nowrap;flex-direction:column;align-items:center;gap:1px;display:inline-flex}.FlagMarker-module__INpLba__Distance{color:#fff;text-shadow:0 1px 3px #000000e6,0 0 1px #000000b3;opacity:.5;font-size:10px}.FlagMarker-module__INpLba__Icon{width:16px;height:16px;image-rendering:pixelated;opacity:.5;filter:drop-shadow(0 1px 3px #000c);-webkit-mask-image:var(--flag-icon-url);mask-image:var(--flag-icon-url);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-image:var(--flag-icon-url);-webkit-mask-position:50%;-webkit-mask-size:contain;-webkit-mask-repeat:no-repeat} -.DemoControls-module__PjV4fq__Root{color:#fff;z-index:2;background:#000000b3;align-items:center;gap:10px;padding:8px 12px;font-size:13px;display:flex;position:fixed;bottom:0;left:0;right:0}.DemoControls-module__PjV4fq__PlayPause{color:#fff;cursor:pointer;background:#03529399;border:1px solid #ffffff4d;border-radius:4px;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;padding:0;font-size:14px;display:flex}@media (hover:hover){.DemoControls-module__PjV4fq__PlayPause:hover{background:#0062b3cc}}.DemoControls-module__PjV4fq__Time{font-variant-numeric:tabular-nums;white-space:nowrap;flex-shrink:0}.DemoControls-module__PjV4fq__Seek[type=range]{flex:1 1 0;min-width:0;max-width:none}.DemoControls-module__PjV4fq__Speed{color:#fff;background:#0009;border:1px solid #ffffff4d;border-radius:3px;flex-shrink:0;padding:2px 4px;font-size:12px} .PlayerHUD-module__-E1Scq__PlayerHUD{z-index:1;pointer-events:none;position:absolute;inset:0}.PlayerHUD-module__-E1Scq__TopRight{align-items:flex-start;gap:6px;display:flex;position:absolute;top:56px;right:8px}.PlayerHUD-module__-E1Scq__Compass{flex-shrink:0;width:64px;height:64px;position:relative}.PlayerHUD-module__-E1Scq__CompassRing{image-rendering:auto;width:100%;height:100%;position:absolute;top:0;left:0}.PlayerHUD-module__-E1Scq__CompassNSEW{width:100%;height:100%;image-rendering:pixelated;position:absolute;top:0;left:0}.PlayerHUD-module__-E1Scq__Bars{flex-direction:column;gap:3px;padding-top:10px;display:flex}.PlayerHUD-module__-E1Scq__BarTrack{background:#00000080;border:1px solid #ffffff26;width:120px;height:10px;overflow:hidden}.PlayerHUD-module__-E1Scq__BarFillHealth{background:#2ecc40;height:100%;transition:width .15s ease-out}.PlayerHUD-module__-E1Scq__BarFillEnergy{background:#0af;height:100%;transition:width .15s ease-out}.PlayerHUD-module__-E1Scq__WeaponHUD{flex-direction:column;gap:2px;display:flex;position:absolute;top:50%;right:8px;transform:translateY(-50%)}.PlayerHUD-module__-E1Scq__WeaponSeparator{height:6px}.PlayerHUD-module__-E1Scq__ChatWindow{background:#00323ca6;max-width:420px;padding:4px 8px;font-size:12px;line-height:1.3;position:absolute;top:56px;left:0}.PlayerHUD-module__-E1Scq__ChatMessage{color:#2cacb5;padding:1px 0;transition:opacity .3s ease-out}.PlayerHUD-module__-E1Scq__ChatColor0{color:#2cacb5}.PlayerHUD-module__-E1Scq__ChatColor1{color:#04eb69}.PlayerHUD-module__-E1Scq__ChatColor2{color:#dbc880}.PlayerHUD-module__-E1Scq__ChatColor3{color:#4dfd5f}.PlayerHUD-module__-E1Scq__ChatColor4{color:#28e7f0}.PlayerHUD-module__-E1Scq__ChatColor5{color:#c8c832}.PlayerHUD-module__-E1Scq__ChatColor6{color:#c8c8c8}.PlayerHUD-module__-E1Scq__ChatColor7{color:#dcdc14}.PlayerHUD-module__-E1Scq__ChatColor8{color:#9696fa}.PlayerHUD-module__-E1Scq__ChatColor9{color:#3cdc96}.PlayerHUD-module__-E1Scq__TeamScores{font-family:monospace;font-size:12px;position:absolute;bottom:130px;left:0}.PlayerHUD-module__-E1Scq__TeamRow{background:#00323ca6;gap:6px;padding:2px 8px;display:flex}.PlayerHUD-module__-E1Scq__TeamRow+.PlayerHUD-module__-E1Scq__TeamRow{border-top:1px solid #80ffc826}.PlayerHUD-module__-E1Scq__TeamNameFriendly{color:#2ecc40;min-width:60px}.PlayerHUD-module__-E1Scq__TeamNameEnemy{color:#e44;min-width:60px}.PlayerHUD-module__-E1Scq__TeamScore{color:#fff;text-align:right;min-width:24px;font-weight:700}.PlayerHUD-module__-E1Scq__TeamCount{color:#9ba;text-align:right;min-width:24px}.PlayerHUD-module__-E1Scq__PackInventoryHUD{align-items:center;gap:4px;display:flex;position:absolute;bottom:100px;right:8px}.PlayerHUD-module__-E1Scq__PackInvItem{background:#00323ca6;border:1px solid #80ffc826;flex-direction:column;justify-content:center;align-items:center;gap:1px;padding:4px;display:flex}.PlayerHUD-module__-E1Scq__PackInvItemActive{border-color:#80ffc880;box-shadow:0 0 6px #80ffc84d}.PlayerHUD-module__-E1Scq__PackInvItemDim{opacity:.5}.PlayerHUD-module__-E1Scq__PackInvIcon{image-rendering:pixelated;display:block}.PlayerHUD-module__-E1Scq__PackInvCount{color:#bfe;text-align:center;min-width:12px;font-family:monospace;font-size:11px}.PlayerHUD-module__-E1Scq__PackInvInfinity{image-rendering:pixelated;opacity:.8;display:block}.PlayerHUD-module__-E1Scq__Reticle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.PlayerHUD-module__-E1Scq__ReticleImage{opacity:.85;width:64px;height:64px;image-rendering:pixelated}.PlayerHUD-module__-E1Scq__ReticleDot{background:#2ecc40b3;border-radius:50%;width:4px;height:4px;box-shadow:0 0 4px #2ecc4080} -.page-module__E0kJGG__CanvasContainer{z-index:0;position:absolute;inset:0}.page-module__E0kJGG__LoadingIndicator{pointer-events:none;z-index:1;opacity:.8;flex-direction:column;align-items:center;gap:16px;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.page-module__E0kJGG__LoadingIndicator[data-complete=true]{animation:.3s ease-out forwards page-module__E0kJGG__loadingComplete}.page-module__E0kJGG__Spinner{border:4px solid #fff3;border-top-color:#fff;border-radius:50%;width:48px;height:48px;animation:1s linear infinite page-module__E0kJGG__spin}.page-module__E0kJGG__Progress{background:#fff3;border-radius:2px;width:200px;height:4px;overflow:hidden}.page-module__E0kJGG__ProgressBar{background:#fff;border-radius:2px;height:100%;transition:width .1s ease-out}.page-module__E0kJGG__ProgressText{color:#ffffffb3;font-variant-numeric:tabular-nums;font-size:14px}@keyframes page-module__E0kJGG__spin{to{transform:rotate(360deg)}}@keyframes page-module__E0kJGG__loadingComplete{0%{opacity:1}to{opacity:0}} .page-module__v6zvCa__CanvasContainer{z-index:0;position:absolute;inset:0}.page-module__v6zvCa__LoadingIndicator{pointer-events:none;z-index:1;opacity:.8;flex-direction:column;align-items:center;gap:16px;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.page-module__v6zvCa__LoadingIndicator[data-complete=true]{animation:.3s ease-out forwards page-module__v6zvCa__loadingComplete}.page-module__v6zvCa__Spinner{border:4px solid #fff3;border-top-color:#fff;border-radius:50%;width:48px;height:48px;animation:1s linear infinite page-module__v6zvCa__spin}@keyframes page-module__v6zvCa__spin{to{transform:rotate(360deg)}}@keyframes page-module__v6zvCa__loadingComplete{0%{opacity:1}to{opacity:0}}.page-module__v6zvCa__Sidebar{-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);color:#fff;z-index:2;background:#000000b3;flex-direction:column;width:260px;font-size:13px;display:flex;position:fixed;top:0;bottom:0;left:0;overflow:hidden}.page-module__v6zvCa__SidebarSection{border-bottom:1px solid #ffffff1a;padding:10px 12px}.page-module__v6zvCa__SidebarSection:last-child{border-bottom:none}.page-module__v6zvCa__SectionLabel{text-transform:uppercase;letter-spacing:.05em;color:#fff6;margin-bottom:6px;font-size:10px}.page-module__v6zvCa__AnimationList{flex:1;padding:0 12px 12px;overflow-y:auto}.page-module__v6zvCa__AnimationItem{cursor:pointer;-webkit-user-select:none;user-select:none;border-radius:4px;align-items:center;gap:6px;padding:4px 6px;display:flex}.page-module__v6zvCa__AnimationItem:hover{background:#ffffff14}.page-module__v6zvCa__AnimationItem[data-active=true]{background:#ffffff26}.page-module__v6zvCa__PlayButton{color:#fff9;cursor:pointer;background:#ffffff1a;border:none;border-radius:4px;flex-shrink:0;justify-content:center;align-items:center;width:22px;height:22px;padding:0;font-size:11px;display:flex}.page-module__v6zvCa__PlayButton:hover{color:#fff;background:#fff3}.page-module__v6zvCa__AnimationItem[data-active=true] .page-module__v6zvCa__PlayButton{color:#fff;background:#64b4ff4d}.page-module__v6zvCa__AnimationName{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}.page-module__v6zvCa__ClipName{color:#ffffff4d;white-space:nowrap;flex-shrink:0;font-size:10px}.page-module__v6zvCa__CyclicIcon{color:#ffffff4d;title:"Cyclic (looping)";flex-shrink:0;font-size:13px}.page-module__v6zvCa__CheckboxField{align-items:center;gap:6px;display:flex} diff --git a/docs/_next/static/chunks/13f8b467e8aa89cb.js b/docs/_next/static/chunks/13f8b467e8aa89cb.js deleted file mode 100644 index 376611e8..00000000 --- a/docs/_next/static/chunks/13f8b467e8aa89cb.js +++ /dev/null @@ -1,166 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,42585,e=>{"use strict";var t=e.i(43476),a=e.i(932),o=e.i(71645),i=e.i(31067),r=e.i(90072);let n=o.forwardRef(({args:e,children:t,...a},r)=>{let n=o.useRef(null);return o.useImperativeHandle(r,()=>n.current),o.useLayoutEffect(()=>void 0),o.createElement("mesh",(0,i.default)({ref:n},a),o.createElement("boxGeometry",{attach:"geometry",args:e}),t)});var l=e.i(47071),s=e.i(71753),u=e.i(15080),c=e.i(12979),f=e.i(62395),v=e.i(75567),d=e.i(48066),m=e.i(47021);let p=` - #include - - #ifdef USE_FOG - #define USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; - #endif - - uniform float uTime; - uniform float uWaveMagnitude; - - varying vec3 vWorldPosition; - varying vec3 vViewVector; - varying float vDistance; - - // Wave function matching Tribes 2 engine - // Z = surfaceZ + (sin(X*0.05 + time) + sin(Y*0.05 + time)) * waveFactor - // waveFactor = waveAmplitude * 0.25 - // Note: Using xz for Three.js Y-up (Torque uses XY with Z-up) - float getWaveHeight(vec3 worldPos) { - float waveFactor = uWaveMagnitude * 0.25; - return (sin(worldPos.x * 0.05 + uTime) + sin(worldPos.z * 0.05 + uTime)) * waveFactor; - } - - void main() { - // Get world position for wave calculation - vec4 worldPos = modelMatrix * vec4(position, 1.0); - vWorldPosition = worldPos.xyz; - - // Apply wave displacement to Y (vertical axis in Three.js) - vec3 displaced = position; - displaced.y += getWaveHeight(worldPos.xyz); - - // Calculate final world position after displacement for fog - #ifdef USE_FOG - vec4 displacedWorldPos = modelMatrix * vec4(displaced, 1.0); - vFogWorldPosition = displacedWorldPos.xyz; - #endif - - // Calculate view vector for environment mapping - vViewVector = cameraPosition - worldPos.xyz; - vDistance = length(vViewVector); - - vec4 mvPosition = viewMatrix * modelMatrix * vec4(displaced, 1.0); - gl_Position = projectionMatrix * mvPosition; - - // Set fog depth (distance from camera) - normally done by fog_vertex include - // but we can't use that include because it references 'transformed' which we don't have - #ifdef USE_FOG - vFogDepth = length(mvPosition.xyz); - #endif - } -`,g=` - #include - - // Enable volumetric fog (must be defined before fog uniforms) - #ifdef USE_FOG - #define USE_VOLUMETRIC_FOG - #define USE_FOG_WORLD_POSITION - #endif - - uniform float uTime; - uniform float uOpacity; - uniform float uEnvMapIntensity; - uniform sampler2D uBaseTexture; - uniform sampler2D uEnvMapTexture; - - // Volumetric fog uniforms - #ifdef USE_FOG - uniform float fogVolumeData[12]; - uniform float cameraHeight; - uniform bool fogEnabled; - varying vec3 vFogWorldPosition; - #endif - - varying vec3 vWorldPosition; - varying vec3 vViewVector; - varying float vDistance; - - #define TWO_PI 6.283185307179586 - - // Constants from Tribes 2 engine - #define BASE_DRIFT_CYCLE_TIME 8.0 - #define BASE_DRIFT_RATE 0.02 - #define BASE_DRIFT_SCALAR 0.03 - #define TEXTURE_SCALE (1.0 / 48.0) - - // Environment map UV wobble constants - #define Q1 150.0 - #define Q2 2.0 - #define Q3 0.01 - - // Rotate UV coordinates - vec2 rotateUV(vec2 uv, float angle) { - float c = cos(angle); - float s = sin(angle); - return vec2( - uv.x * c - uv.y * s, - uv.x * s + uv.y * c - ); - } - - void main() { - // Calculate base texture UVs using world position (1/48 tiling) - vec2 baseUV = vWorldPosition.xz * TEXTURE_SCALE; - - // Phase (time in radians for drift cycle) - float phase = mod(uTime * (TWO_PI / BASE_DRIFT_CYCLE_TIME), TWO_PI); - - // Base texture drift - float baseDriftX = uTime * BASE_DRIFT_RATE; - float baseDriftY = cos(phase) * BASE_DRIFT_SCALAR; - - // === Phase 1a: First base texture pass (rotated 30 degrees) === - vec2 uv1a = rotateUV(baseUV, radians(30.0)); - - // === Phase 1b: Second base texture pass (rotated 60 degrees total, with drift) === - vec2 uv1b = rotateUV(baseUV + vec2(baseDriftX, baseDriftY), radians(60.0)); - - // Calculate cross-fade swing value - float A1 = cos(((vWorldPosition.x / Q1) + (uTime / Q2)) * 6.0); - float A2 = sin(((vWorldPosition.z / Q1) + (uTime / Q2)) * TWO_PI); - float swing = (A1 + A2) * 0.15 + 0.5; - - // Cross-fade alpha calculation from engine - float alpha1a = ((1.0 - swing) * uOpacity) / max(1.0 - (swing * uOpacity), 0.001); - float alpha1b = swing * uOpacity; - - // Sample base texture for both passes - vec4 texColor1a = texture2D(uBaseTexture, uv1a); - vec4 texColor1b = texture2D(uBaseTexture, uv1b); - - // Combined alpha and color - float combinedAlpha = 1.0 - (1.0 - alpha1a) * (1.0 - alpha1b); - vec3 baseColor = (texColor1a.rgb * alpha1a * (1.0 - alpha1b) + texColor1b.rgb * alpha1b) / max(combinedAlpha, 0.001); - - // === Phase 3: Environment map / specular === - vec3 reflectVec = -vViewVector; - reflectVec.y = abs(reflectVec.y); - if (reflectVec.y < 0.001) reflectVec.y = 0.001; - - vec2 envUV; - if (vDistance < 0.001) { - envUV = vec2(0.0); - } else { - float value = (vDistance - reflectVec.y) / (vDistance * vDistance); - envUV.x = reflectVec.x * value; - envUV.y = reflectVec.z * value; - } - - envUV = envUV * 0.5 + 0.5; - envUV.x += A1 * Q3; - envUV.y += A2 * Q3; - - vec4 envColor = texture2D(uEnvMapTexture, envUV); - vec3 finalColor = baseColor + envColor.rgb * envColor.a * uEnvMapIntensity; - - // Note: Tribes 2 water does NOT use lighting - Phase 2 (lightmap) is disabled - // in the original engine. Water colors come directly from textures. - - gl_FragColor = vec4(finalColor, combinedAlpha); - - // Apply volumetric fog using shared Torque-style fog shader - ${m.fogFragmentShader} - } -`;var h=e.i(79123);function x(e){let o,i,n=(0,a.c)(5),{surfaceTexture:s,attach:u}=e;n[0]!==s?(o=(0,c.textureToUrl)(s),n[0]=s,n[1]=o):o=n[1];let f=o,v=(0,l.useTexture)(f,T);return n[2]!==u||n[3]!==v?(i=(0,t.jsx)("meshStandardMaterial",{attach:u,map:v,transparent:!0,opacity:.8,side:r.DoubleSide}),n[2]=u,n[3]=v,n[4]=i):i=n[4],i}function T(e){return(0,v.setupTexture)(e)}let b=(0,o.memo)(function(e){let i,l,c,v,d,m,p,g,x,T,b,E,_,P,S,V,U,F,C,D,A,O,W,I,R=(0,a.c)(69),{object:z}=e,{debugMode:B}=(0,h.useDebug)();R[0]!==z?(i=(0,f.getRotation)(z),R[0]=z,R[1]=i):i=R[1];let j=i;R[2]!==z?(l=(0,f.getPosition)(z),R[2]=z,R[3]=l):l=R[3];let G=l;R[4]!==z?(c=(0,f.getScale)(z),R[4]=z,R[5]=c):c=R[5];let L=c,[N,Q,Y]=L,X=(0,u.useThree)(w),H=(W=(0,a.c)(1),I=(0,o.useRef)(null),W[0]===Symbol.for("react.memo_cache_sentinel")?(O=e=>{if(!I.current)return I.current=e.clone(),!0;let t=I.current.x===e.x&&I.current.y===e.y&&I.current.z===e.z;return t||I.current.copy(e),t},W[0]=O):O=W[0],O);R[6]!==z?(v=(0,f.getFloat)(z,"waveMagnitude")??1,R[6]=z,R[7]=v):v=R[7];let $=v,[q,Z,k]=G,J=q+1024,K=k+1024;R[8]!==J?(d=Math.round(J/8),R[8]=J,R[9]=d):d=R[9];let ee=d;R[10]!==K?(m=Math.round(K/8),R[10]=K,R[11]=m):m=R[11];let et=m,ea=8*(ee=Math.max(0,Math.min(2040,ee))),eo=8*(et=Math.max(0,Math.min(2040,et)));R[12]!==ea||R[13]!==eo||R[14]!==Z?(p=[ea,Z,eo],R[12]=ea,R[13]=eo,R[14]=Z,R[15]=p):p=R[15];let ei=p,er=M;R[16]!==X.position.x||R[17]!==X.position.z?(g=()=>er(X.position.x,X.position.z),R[16]=X.position.x,R[17]=X.position.z,R[18]=g):g=R[18];let[en,el]=(0,o.useState)(g);R[19]!==X.position||R[20]!==H?(x=()=>{if(!H(X.position))return;let e=er(X.position.x,X.position.z);el(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)},R[19]=X.position,R[20]=H,R[21]=x):x=R[21],(0,s.useFrame)(x),R[22]!==z?(T=(0,f.getProperty)(z,"surfaceTexture")??"liquidTiles/BlueWater",R[22]=z,R[23]=T):T=R[23];let es=T;R[24]!==z?(b=(0,f.getProperty)(z,"envMapTexture"),R[24]=z,R[25]=b):b=R[25];let eu=b;R[26]!==z?(E=(0,f.getFloat)(z,"surfaceOpacity")??.75,R[26]=z,R[27]=E):E=R[27];let ec=E;R[28]!==z?(_=(0,f.getFloat)(z,"envMapIntensity")??1,R[28]=z,R[29]=_):_=R[29];let ef=_;if(R[30]!==N||R[31]!==Q||R[32]!==Y){let e,[t,a]=(e=N<=1024&&Y<=1024?8:16,[Math.max(4,Math.ceil(N/e)),Math.max(4,Math.ceil(Y/e))]);(P=new r.PlaneGeometry(N,Y,t,a)).rotateX(-Math.PI/2),P.translate(N/2,Q,Y/2),R[30]=N,R[31]=Q,R[32]=Y,R[33]=P}else P=R[33];let ev=P;if(R[34]!==ev?(S=()=>()=>{ev.dispose()},V=[ev],R[34]=ev,R[35]=S,R[36]=V):(S=R[35],V=R[36]),(0,o.useEffect)(S,V),R[37]!==B||R[38]!==G[0]||R[39]!==G[1]||R[40]!==G[2]||R[41]!==L||R[42]!==N||R[43]!==Q||R[44]!==Y?(U=B&&(0,t.jsx)(n,{args:L,position:[G[0]+N/2,G[1]+Q/2,G[2]+Y/2],children:(0,t.jsx)("meshBasicMaterial",{color:"#00fbff",wireframe:!0})}),R[37]=B,R[38]=G[0],R[39]=G[1],R[40]=G[2],R[41]=L,R[42]=N,R[43]=Q,R[44]=Y,R[45]=U):U=R[45],R[46]!==ei||R[47]!==en||R[48]!==ev){let e;R[50]!==ei||R[51]!==ev?(e=e=>{let[a,o]=e,i=ei[0]+2048*a-1024,n=ei[2]+2048*o-1024;return(0,t.jsx)("mesh",{geometry:ev,position:[i,ei[1],n],children:(0,t.jsx)("meshStandardMaterial",{color:"#00fbff",transparent:!0,opacity:.4,wireframe:!0,side:r.DoubleSide})},`${a},${o}`)},R[50]=ei,R[51]=ev,R[52]=e):e=R[52],F=en.map(e),R[46]=ei,R[47]=en,R[48]=ev,R[49]=F}else F=R[49];return R[53]!==ei||R[54]!==ef||R[55]!==eu||R[56]!==ec||R[57]!==en||R[58]!==ev||R[59]!==es||R[60]!==$?(C=(0,t.jsx)(y,{reps:en,basePosition:ei,surfaceGeometry:ev,surfaceTexture:es,envMapTexture:eu,opacity:ec,waveMagnitude:$,envMapIntensity:ef}),R[53]=ei,R[54]=ef,R[55]=eu,R[56]=ec,R[57]=en,R[58]=ev,R[59]=es,R[60]=$,R[61]=C):C=R[61],R[62]!==F||R[63]!==C?(D=(0,t.jsx)(o.Suspense,{fallback:F,children:C}),R[62]=F,R[63]=C,R[64]=D):D=R[64],R[65]!==j||R[66]!==U||R[67]!==D?(A=(0,t.jsxs)("group",{quaternion:j,children:[U,D]}),R[65]=j,R[66]=U,R[67]=D,R[68]=A):A=R[68],A}),y=(0,o.memo)(function({reps:e,basePosition:a,surfaceGeometry:i,surfaceTexture:n,envMapTexture:u,opacity:f,waveMagnitude:m,envMapIntensity:x}){let T=(0,c.textureToUrl)(n),b=(0,c.textureToUrl)(u??"special/lush_env"),[y,w]=(0,l.useTexture)([T,b],e=>{(Array.isArray(e)?e:[e]).forEach(e=>{(0,v.setupTexture)(e),e.colorSpace=r.NoColorSpace,e.wrapS=r.RepeatWrapping,e.wrapT=r.RepeatWrapping})}),{animationEnabled:M}=(0,h.useSettings)(),E=(0,o.useMemo)(()=>{var e;return e={opacity:f,waveMagnitude:m,envMapIntensity:x,baseTexture:y,envMapTexture:w},new r.ShaderMaterial({uniforms:{uTime:{value:0},uOpacity:{value:e?.opacity??.75},uWaveMagnitude:{value:e?.waveMagnitude??1},uEnvMapIntensity:{value:e?.envMapIntensity??1},uBaseTexture:{value:e?.baseTexture??null},uEnvMapTexture:{value:e?.envMapTexture??null},fogColor:{value:new r.Color},fogNear:{value:1},fogFar:{value:2e3},fogVolumeData:d.globalFogUniforms.fogVolumeData,cameraHeight:d.globalFogUniforms.cameraHeight,fogEnabled:d.globalFogUniforms.fogEnabled},vertexShader:p,fragmentShader:g,transparent:!0,side:r.DoubleSide,depthWrite:!0,fog:!0})},[f,m,x,y,w]),_=(0,o.useRef)(0);return(0,s.useFrame)((e,t)=>{M?(_.current+=t,E.uniforms.uTime.value=_.current):(_.current=0,E.uniforms.uTime.value=0)}),(0,o.useEffect)(()=>()=>{E.dispose()},[E]),(0,t.jsx)(t.Fragment,{children:e.map(([e,o])=>{let r=a[0]+2048*e-1024,n=a[2]+2048*o-1024;return(0,t.jsx)("mesh",{geometry:i,material:E,position:[r,a[1],n]},`${e},${o}`)})})});function w(e){return e.camera}function M(e,t){let a=e+1024,o=t+1024,i=Math.trunc(a/2048),r=Math.trunc(o/2048);a<0&&i--,o<0&&r--;let n=[];for(let e=r-1;e<=r+1;e++)for(let t=i-1;t<=i+1;t++)n.push([t,e]);return n}e.s(["WaterBlock",0,b,"WaterMaterial",()=>x],42585)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/14c6376ae0b23060.js b/docs/_next/static/chunks/14c6376ae0b23060.js new file mode 100644 index 00000000..0dd685eb --- /dev/null +++ b/docs/_next/static/chunks/14c6376ae0b23060.js @@ -0,0 +1,38 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67191,e=>{e.v({Label:"FloatingLabel-module__8y09Ka__Label"})},89887,60099,e=>{"use strict";let t,n;var r=e.i(43476),i=e.i(932),s=e.i(71645),a=e.i(90072),o=e.i(71753),l=e.i(31067),c=e.i(88014),u=e.i(15080);let d=new a.Vector3,m=new a.Vector3,f=new a.Vector3,p=new a.Vector2;function y(e,t,n){let r=d.setFromMatrixPosition(e.matrixWorld);r.project(t);let i=n.width/2,s=n.height/2;return[r.x*i+i,-(r.y*s)+s]}let h=e=>1e-10>Math.abs(e)?0:e;function v(e,t,n=""){let r="matrix3d(";for(let n=0;16!==n;n++)r+=h(t[n]*e.elements[n])+(15!==n?",":")");return n+r}let b=(t=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>v(e,t)),g=(n=e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1],(e,t)=>v(e,n(t),"translate(-50%,-50%)")),E=s.forwardRef(({children:e,eps:t=.001,style:n,className:r,prepend:i,center:v,fullscreen:E,portal:S,distanceFactor:x,sprite:M=!1,transform:w=!1,occlude:k,onOcclude:j,castShadow:P,receiveShadow:W,material:_,geometry:I,zIndexRange:R=[0x1000037,0],calculatePosition:T=y,as:N="div",wrapperClass:B,pointerEvents:A="auto",...V},F)=>{let{gl:C,camera:O,scene:$,size:z,raycaster:L,events:D,viewport:q}=(0,u.useThree)(),[H]=s.useState(()=>document.createElement(N)),U=s.useRef(null),G=s.useRef(null),K=s.useRef(0),Y=s.useRef([0,0]),Z=s.useRef(null),J=s.useRef(null),Q=(null==S?void 0:S.current)||D.connected||C.domElement.parentNode,X=s.useRef(null),ee=s.useRef(!1),et=s.useMemo(()=>{var e;return k&&"blending"!==k||Array.isArray(k)&&k.length&&(e=k[0])&&"object"==typeof e&&"current"in e},[k]);s.useLayoutEffect(()=>{let e=C.domElement;k&&"blending"===k?(e.style.zIndex=`${Math.floor(R[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[k]),s.useLayoutEffect(()=>{if(G.current){let e=U.current=c.createRoot(H);if($.updateMatrixWorld(),w)H.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{let e=T(G.current,O,z);H.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return Q&&(i?Q.prepend(H):Q.appendChild(H)),()=>{Q&&Q.removeChild(H),e.unmount()}}},[Q,w]),s.useLayoutEffect(()=>{B&&(H.className=B)},[B]);let en=s.useMemo(()=>w?{position:"absolute",top:0,left:0,width:z.width,height:z.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:v?"translate3d(-50%,-50%,0)":"none",...E&&{top:-z.height/2,left:-z.width/2,width:z.width,height:z.height},...n},[n,v,E,z,w]),er=s.useMemo(()=>({position:"absolute",pointerEvents:A}),[A]);s.useLayoutEffect(()=>{var t,i;ee.current=!1,w?null==(t=U.current)||t.render(s.createElement("div",{ref:Z,style:en},s.createElement("div",{ref:J,style:er},s.createElement("div",{ref:F,className:r,style:n,children:e})))):null==(i=U.current)||i.render(s.createElement("div",{ref:F,style:en,className:r,children:e}))});let ei=s.useRef(!0);(0,o.useFrame)(e=>{if(G.current){O.updateMatrixWorld(),G.current.updateWorldMatrix(!0,!1);let e=w?Y.current:T(G.current,O,z);if(w||Math.abs(K.current-O.zoom)>t||Math.abs(Y.current[0]-e[0])>t||Math.abs(Y.current[1]-e[1])>t){var n;let t,r,i,s,o=(n=G.current,t=d.setFromMatrixPosition(n.matrixWorld),r=m.setFromMatrixPosition(O.matrixWorld),i=t.sub(r),s=O.getWorldDirection(f),i.angleTo(s)>Math.PI/2),l=!1;et&&(Array.isArray(k)?l=k.map(e=>e.current):"blending"!==k&&(l=[$]));let c=ei.current;l?ei.current=function(e,t,n,r){let i=d.setFromMatrixPosition(e.matrixWorld),s=i.clone();s.project(t),p.set(s.x,s.y),n.setFromCamera(p,t);let a=n.intersectObjects(r,!0);if(a.length){let e=a[0].distance;return i.distanceTo(n.ray.origin)({vertexShader:w?void 0:` + /* + This shader is from the THREE's SpriteMaterial. + We need to turn the backing plane into a Sprite + (make it always face the camera) if "transfrom" + is false. + */ + #include + + void main() { + vec2 center = vec2(0., 1.); + float rotation = 0.0; + + // This is somewhat arbitrary, but it seems to work well + // Need to figure out how to derive this dynamically if it even matters + float size = 0.03; + + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + + gl_Position = projectionMatrix * mvPosition; + } + `,fragmentShader:` + void main() { + gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); + } + `}),[w]);return s.createElement("group",(0,l.default)({},V,{ref:G}),k&&!et&&s.createElement("mesh",{castShadow:P,receiveShadow:W,ref:X},I||s.createElement("planeGeometry",null),_||s.createElement("shaderMaterial",{side:a.DoubleSide,vertexShader:es.vertexShader,fragmentShader:es.fragmentShader})))});e.s(["Html",()=>E],60099);var S=e.i(67191);let x=[0,0,0],M=new a.Vector3,w=(0,s.memo)(function(e){let t,n,a,l=(0,i.c)(11),{children:c,color:u,position:d,opacity:m}=e,f=void 0===u?"white":u,p=void 0===d?x:d,y=void 0===m?"fadeWithDistance":m,h="fadeWithDistance"===y,v=(0,s.useRef)(null),[b,g]=(0,s.useState)(0!==y),w=(0,s.useRef)(null);return l[0]!==h||l[1]!==b||l[2]!==y?(t=e=>{var t,n,r;let i,{camera:s}=e,a=v.current;if(!a)return;a.getWorldPosition(M);let o=(t=M.x,n=M.y,r=M.z,-((t-(i=s.matrixWorld.elements)[12])*i[8])+-((n-i[13])*i[9])+-((r-i[14])*i[10])<0);if(h){let e=o?1/0:s.position.distanceTo(M),t=e<200;if(b!==t&&g(t),w.current&&t){let t=Math.max(0,Math.min(1,1-e/200));w.current.style.opacity=t.toString()}}else{let e=!o&&0!==y;b!==e&&g(e),w.current&&(w.current.style.opacity=y.toString())}},l[0]=h,l[1]=b,l[2]=y,l[3]=t):t=l[3],(0,o.useFrame)(t),l[4]!==c||l[5]!==f||l[6]!==b||l[7]!==p?(n=b?(0,r.jsx)(E,{position:p,center:!0,children:(0,r.jsx)("div",{ref:w,className:S.default.Label,style:{color:f},children:c})}):null,l[4]=c,l[5]=f,l[6]=b,l[7]=p,l[8]=n):n=l[8],l[9]!==n?(a=(0,r.jsx)("group",{ref:v,children:n}),l[9]=n,l[10]=a):a=l[10],a});e.s(["FloatingLabel",0,w],89887)},31067,e=>{"use strict";function t(){return(t=Object.assign.bind()).apply(null,arguments)}e.s(["default",()=>t])},79474,(e,t,n)=>{"use strict";var r=e.r(71645).__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;n.c=function(e){return r.H.useMemoCache(e)}},932,(e,t,n)=>{"use strict";t.exports=e.r(79474)},55838,(e,t,n)=>{"use strict";var r=e.r(71645),i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},s=r.useState,a=r.useEffect,o=r.useLayoutEffect,l=r.useDebugValue;function c(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch(e){return!0}}var u="u"{"use strict";t.exports=e.r(55838)},52822,(e,t,n)=>{"use strict";var r=e.r(71645),i=e.r(2239),s="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},a=i.useSyncExternalStore,o=r.useRef,l=r.useEffect,c=r.useMemo,u=r.useDebugValue;n.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=o(null);if(null===d.current){var m={hasValue:!1,value:null};d.current=m}else m=d.current;var f=a(e,(d=c(function(){function e(e){if(!l){if(l=!0,a=e,e=r(e),void 0!==i&&m.hasValue){var t=m.value;if(i(t,e))return o=t}return o=e}if(t=o,s(a,e))return t;var n=r(e);return void 0!==i&&i(t,n)?(a=e,t):(a=e,o=n)}var a,o,l=!1,c=void 0===n?null:n;return[function(){return e(t())},null===c?void 0:function(){return e(c())}]},[t,n,r,i]))[0],d[1]);return l(function(){m.hasValue=!0,m.value=f},[f]),u(f),f}},30224,(e,t,n)=>{"use strict";t.exports=e.r(52822)},66748,8155,e=>{"use strict";var t=e.i(71645),n=e.i(30224);let r=e=>{let t,n=new Set,r=(e,r)=>{let i="function"==typeof e?e(t):e;if(!Object.is(i,t)){let e=t;t=(null!=r?r:"object"!=typeof i||null===i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,s={setState:r,getState:i,getInitialState:()=>a,subscribe:e=>(n.add(e),()=>n.delete(e))},a=t=e(r,i,s);return s},i=e=>e?r(e):r;e.s(["createStore",()=>i],8155);let{useSyncExternalStoreWithSelector:s}=n.default,a=e=>e;function o(e,n=a,r){let i=s(e.subscribe,e.getState,e.getInitialState,n,r);return t.default.useDebugValue(i),i}let l=(e,t)=>{let n=i(e),r=(e,r=t)=>o(n,e,r);return Object.assign(r,n),r},c=(e,t)=>e?l(e,t):l;e.s(["createWithEqualityFn",()=>c,"useStoreWithEqualityFn",()=>o],66748)},58647,79473,43595,e=>{"use strict";e.i(932);var t=e.i(8155);let n=e=>(t,n,r)=>{let i=r.subscribe;return r.subscribe=(e,t,n)=>{let s=e;if(t){let i=(null==n?void 0:n.equalityFn)||Object.is,a=e(r.getState());s=n=>{let r=e(n);if(!i(a,r)){let e=a;t(a=r,e)}},(null==n?void 0:n.fireImmediately)&&t(a,a)}return i(s)},e(t,n,r)};e.s(["subscribeWithSelector",()=>n],79473);var r=e.i(66748);function i(e){let t=new Map;for(let n of e.state.datablocks.values()){if("tsshapeconstructor"!==n._class)continue;let e=n.baseshape;if("string"!=typeof e)continue;let r=e.toLowerCase(),i=r.replace(/\.dts$/i,"")+"_",s=new Map;for(let e=0;e<=127;e++){let t=n[`sequence${e}`];if("string"!=typeof t)continue;let r=t.indexOf(" ");if(-1===r)continue;let a=t.slice(0,r).toLowerCase(),o=t.slice(r+1).trim().toLowerCase();if(!o||!a.startsWith(i)||!a.endsWith(".dsq"))continue;let l=a.slice(i.length,-4);l&&s.set(o,l)}s.size>0&&t.set(r,s)}return t}function s(e,t,n){let r=new Map;for(let n of e){let e=t.clipAction(n);r.set(n.name.toLowerCase(),e)}if(n)for(let[e,t]of n){let n=r.get(t);n&&!r.has(e)&&r.set(e,n)}return r}function a(e){return e.toLowerCase()}function o(e){let t=a(e.trim());return t.startsWith("$")?t.slice(1):t}e.s(["buildSequenceAliasMap",()=>i,"getAliasedActions",()=>s],43595);let l={runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0},playback:{recording:null,status:"stopped",timeMs:0,rate:1,durationMs:0,streamSnapshot:null}},c=(0,t.createStore)()(n(e=>({...l,setRuntime(t){let n=function(e){let t={},n={},r={},i={};for(let n of e.state.objectsById.values())t[n._id]=0,n._name&&(r[a(n._name)]=n._id,n._isDatablock&&(i[a(n._name)]=n._id));for(let t of e.state.globals.keys())n[o(t)]=0;return{objectVersionById:t,globalVersionByName:n,objectIdsByName:r,datablockIdsByName:i}}(t),r=i(t);e(e=>({...e,runtime:{runtime:t,sequenceAliases:r,objectVersionById:n.objectVersionById,globalVersionByName:n.globalVersionByName,objectIdsByName:n.objectIdsByName,datablockIdsByName:n.datablockIdsByName,lastRuntimeTick:0}}))},clearRuntime(){e(e=>({...e,runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0}}))},applyRuntimeBatch(t,n){0!==t.length&&e(e=>{let r={...e.runtime.objectVersionById},i={...e.runtime.globalVersionByName},s={...e.runtime.objectIdsByName},l={...e.runtime.datablockIdsByName},c=e=>{null!=e&&(r[e]=(r[e]??0)+1)};for(let e of t){if("object.created"===e.type){let t=e.object;if(c(e.objectId),t._name){let n=a(t._name);s[n]=e.objectId,t._isDatablock&&(l[n]=e.objectId)}c(t._parent?._id);continue}if("object.deleted"===e.type){let t=e.object;if(delete r[e.objectId],t?._name){let e=a(t._name);delete s[e],t._isDatablock&&delete l[e]}c(t?._parent?._id);continue}if("field.changed"===e.type){c(e.objectId);continue}if("global.changed"===e.type){let t=o(e.name);i[t]=(i[t]??0)+1;continue}}let u=n?.tick??(e.runtime.lastRuntimeTick>0?e.runtime.lastRuntimeTick+1:1);return{...e,runtime:{...e.runtime,objectVersionById:r,globalVersionByName:i,objectIdsByName:s,datablockIdsByName:l,lastRuntimeTick:u}}})},setRecording(t){let n=Math.max(0,(t?.duration??0)*1e3);e(e=>({...e,playback:{recording:t,status:"stopped",timeMs:0,rate:1,durationMs:n,streamSnapshot:null}}))},setPlaybackTime(t){e(e=>{var n,r,i;let s=(n=t,r=0,i=e.playback.durationMs,n<0?0:n>i?i:n);return{...e,playback:{...e.playback,timeMs:s}}})},setPlaybackStatus(t){e(e=>({...e,playback:{...e.playback,status:t}}))},setPlaybackRate(t){var n,r,i;let s=Number.isFinite(t)?(r=.01,i=16,(n=t)<.01?.01:n>16?16:n):1;e(e=>({...e,playback:{...e.playback,rate:s}}))},setPlaybackStreamSnapshot(t){e(e=>({...e,playback:{...e.playback,streamSnapshot:t}}))}}))),u=0;function d(){return u}function m(e,t){u+=e*t*1e3}function f(){return c}function p(e,t){return(0,r.useStoreWithEqualityFn)(c,e,t)}c.subscribe(e=>e.playback.status,e=>{"stopped"===e&&(u=0)}),e.s(["advanceEffectClock",()=>m,"effectNow",()=>d,"engineStore",0,c,"useEngineSelector",()=>p,"useEngineStoreApi",()=>f],58647)},13876,77964,92224,e=>{"use strict";function t(e){switch(e.renderType){case"TerrainBlock":case"InteriorInstance":case"Sky":case"Sun":case"WaterBlock":case"MissionArea":return!0;default:return!1}}e.i(58647),e.s(["isSceneEntity",()=>t],77964),e.i(932);var n=e.i(8155),r=e.i(66748);let i=(0,n.createStore)()(e=>({missionEntities:new Map,streamEntities:new Map,isStreaming:!1,version:0,setEntity(t){e(e=>{let n=new Map(e.missionEntities);return n.set(t.id,t),{missionEntities:n,version:e.version+1}})},deleteEntity(t){e(e=>{if(!e.missionEntities.has(t))return e;let n=new Map(e.missionEntities);return n.delete(t),{missionEntities:n,version:e.version+1}})},setEntities(t){e(e=>{let n=new Map(e.missionEntities);for(let e of t)n.set(e.id,e);return{missionEntities:n,version:e.version+1}})},setAllEntities(t){e(()=>{let e=new Map;for(let n of t)e.set(n.id,n);return{missionEntities:e}})},clearEntities(){e(e=>0===e.missionEntities.size?e:{missionEntities:new Map,version:e.version+1})},beginStreaming(){e(e=>e.isStreaming?e:{isStreaming:!0,streamEntities:new Map,version:e.version+1})},endStreaming(){e(e=>e.isStreaming?{isStreaming:!1,streamEntities:new Map,version:e.version+1}:e)},setStreamEntity(t){e(e=>{let n=new Map(e.streamEntities);return n.set(t.id,t),{streamEntities:n,version:e.version+1}})},deleteStreamEntity(t){e(e=>{if(!e.streamEntities.has(t))return e;let n=new Map(e.streamEntities);return n.delete(t),{streamEntities:n,version:e.version+1}})},setStreamEntities(t){e(e=>{let n=new Map(e.streamEntities);for(let e of t)n.set(e.id,e);return{streamEntities:n,version:e.version+1}})},setAllStreamEntities(t){e(e=>{let n=e.streamEntities,r=new Map;for(let e of t)r.set(e.id,e);return r.size===n.size&&[...r.keys()].every(e=>n.has(e))?e:{streamEntities:r,version:e.version+1}})},clearStreamEntities(){e(e=>0===e.streamEntities.size?e:{streamEntities:new Map,version:e.version+1})}}));function s(e){let t=e.isStreaming?e.streamEntities:e.missionEntities,n=[];for(let e of t.values())"None"!==e.renderType&&n.push(e);return n}function a(e,t){if(e.length!==t.length)return!1;for(let n=0;no,"useSceneSky",()=>u,"useSceneSun",()=>d],92224),e.s([],13876)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/164bc8495505bc95.js b/docs/_next/static/chunks/164bc8495505bc95.js new file mode 100644 index 00000000..fa59aa5f --- /dev/null +++ b/docs/_next/static/chunks/164bc8495505bc95.js @@ -0,0 +1,174 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,15823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",()=>t])},19273,80166,e=>{"use strict";e.i(47167);var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function i(e){setTimeout(e,0)}e.s(["systemSetTimeoutZero",()=>i,"timeoutManager",()=>r],80166);var s="u"=0&&e!==1/0}function u(e,t){return Math.max(e+(t||0)-Date.now(),0)}function l(e,t){return"function"==typeof e?e(t):e}function c(e,t){return"function"==typeof e?e(t):e}function h(e,t){let{type:r="all",exact:i,fetchStatus:s,predicate:n,queryKey:a,stale:o}=e;if(a){if(i){if(t.queryHash!==d(a,t.options))return!1}else if(!v(t.queryKey,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!s||s===t.state.fetchStatus)&&(!n||!!n(t))}function f(e,t){let{exact:r,status:i,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(p(t.options.mutationKey)!==p(n))return!1}else if(!v(t.options.mutationKey,n))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))}function d(e,t){return(t?.queryKeyHashFn||p)(e)}function p(e){return JSON.stringify(e,(e,t)=>b(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function v(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>v(e[r],t[r]))}var m=Object.prototype.hasOwnProperty;function g(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function y(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function b(e){if(!S(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function S(e){return"[object Object]"===Object.prototype.toString.call(e)}function T(e){return new Promise(t=>{r.setTimeout(t,e)})}function O(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?function e(t,r,i=0){if(t===r)return t;if(i>500)return r;let s=y(t)&&y(r);if(!s&&!(b(t)&&b(r)))return r;let n=(s?t:Object.keys(t)).length,a=s?r:Object.keys(r),o=a.length,u=s?Array(o):{},l=0;for(let c=0;cr?i.slice(1):i}function R(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var E=Symbol();function C(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==E?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function w(e,t){return"function"==typeof e?e(...t):!!e}function D(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e}e.s(["addConsumeAwareSignal",()=>D,"addToEnd",()=>F,"addToStart",()=>R,"ensureQueryFn",()=>C,"functionalUpdate",()=>a,"hashKey",()=>p,"hashQueryKeyByOptions",()=>d,"isServer",()=>s,"isValidTimeout",()=>o,"matchMutation",()=>f,"matchQuery",()=>h,"noop",()=>n,"partialMatchKey",()=>v,"replaceData",()=>O,"resolveEnabled",()=>c,"resolveStaleTime",()=>l,"shallowEqualObjects",()=>g,"shouldThrowError",()=>w,"skipToken",()=>E,"sleep",()=>T,"timeUntilStale",()=>u],19273)},75555,e=>{"use strict";var t=e.i(15823),r=e.i(19273),i=new class extends t.Subscribable{#r;#i;#s;constructor(){super(),this.#s=e=>{if(!r.isServer&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",()=>i])},40143,e=>{"use strict";let t,r,i,s,n,a;var o=e.i(80166).systemSetTimeoutZero,u=(t=[],r=0,i=e=>{e()},s=e=>{e()},n=o,{batch:e=>{let a;r++;try{a=e()}finally{let e;--r||(e=t,t=[],e.length&&n(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a=e=>{r?t.push(e):n(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}});e.s(["notifyManager",()=>u])},86491,14448,93803,36553,88587,e=>{"use strict";e.i(47167);var t=e.i(19273),r=e.i(40143),i=e.i(75555),s=e.i(15823),n=new class extends s.Subscribable{#n=!0;#i;#s;constructor(){super(),this.#s=e=>{if(!t.isServer&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};function a(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}function o(e){return Math.min(1e3*2**e,3e4)}function u(e){return(e??"online")!=="online"||n.isOnline()}e.s(["onlineManager",()=>n],14448),e.s(["pendingThenable",()=>a],93803);var l=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function c(e){let r,s=!1,c=0,h=a(),f=()=>i.focusManager.isFocused()&&("always"===e.networkMode||n.isOnline())&&e.canRun(),d=()=>u(e.networkMode)&&e.canRun(),p=e=>{"pending"===h.status&&(r?.(),h.resolve(e))},v=e=>{"pending"===h.status&&(r?.(),h.reject(e))},m=()=>new Promise(t=>{r=e=>{("pending"!==h.status||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===h.status&&e.onContinue?.()}),g=()=>{let r;if("pending"!==h.status)return;let i=0===c?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(p).catch(r=>{if("pending"!==h.status)return;let i=e.retry??3*!t.isServer,n=e.retryDelay??o,a="function"==typeof n?n(c,r):n,u=!0===i||"number"==typeof i&&cf()?void 0:m()).then(()=>{s?v(r):g()}))})};return{promise:h,status:()=>h.status,cancel:t=>{if("pending"===h.status){let r=new l(t);v(r),e.onCancel?.(r)}},continue:()=>(r?.(),h),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:d,start:()=>(d()?g():m().then(g),h)}}e.s(["CancelledError",()=>l,"canFetch",()=>u,"createRetryer",()=>c],36553);var h=e.i(80166),f=class{#a;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,t.isValidTimeout)(this.gcTime)&&(this.#a=h.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(t.isServer?1/0:3e5))}clearGcTimeout(){this.#a&&(h.timeoutManager.clearTimeout(this.#a),this.#a=void 0)}};e.s(["Removable",()=>f],88587);var d=class extends f{#o;#u;#l;#c;#h;#f;#d;constructor(e){super(),this.#d=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#l=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=m(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#f,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=m(this.options);void 0!==e.data&&(this.setState(v(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,r){let i=(0,t.replaceData)(this.state.data,e,this.options);return this.#p({data:i,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),i}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){let r=this.#h?.promise;return this.#h?.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some(e=>!1!==(0,t.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t.skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,t.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#d?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(e,r){let i;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&r?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let s=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,s.signal)})},a=()=>{let e,i=(0,t.ensureQueryFn)(this.options,r),s=(n(e={client:this.#c,queryKey:this.queryKey,meta:this.meta}),e);return(this.#d=!1,this.options.persister)?this.options.persister(i,s,this):i(s)},o=(n(i={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:a}),i);this.options.behavior?.onFetch(o,this),this.#u=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#p({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=c({initialPromise:r?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof l&&e.revert&&this.setState({...this.#u,fetchStatus:"idle"}),s.abort()},onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof l){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#p({type:"error",error:e}),this.#l.config.onError?.(e,this),this.#l.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#p(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...p(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...v(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#u=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function p(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:u(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function v(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function m(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",()=>d,"fetchState",()=>p],86491)},69230,e=>{"use strict";var t=e.i(75555),r=e.i(40143),i=e.i(86491),s=e.i(15823),n=e.i(93803),a=e.i(19273),o=e.i(80166),u=class extends s.Subscribable{constructor(e,t){super(),this.options=t,this.#c=e,this.#v=null,this.#m=(0,n.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#c;#g=void 0;#y=void 0;#b=void 0;#S;#T;#m;#v;#O;#F;#R;#E;#C;#w;#D=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#g.addObserver(this),l(this.#g,this.options)?this.#I():this.updateResult(),this.#U())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c(this.#g,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c(this.#g,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#P(),this.#g.removeObserver(this)}setOptions(e){let t=this.options,r=this.#g;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,a.resolveEnabled)(this.options.enabled,this.#g))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#M(),this.#g.setOptions(this.options),t._defaulted&&!(0,a.shallowEqualObjects)(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#g,observer:this});let i=this.hasListeners();i&&h(this.#g,r,this.options,t)&&this.#I(),this.updateResult(),i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||(0,a.resolveStaleTime)(this.options.staleTime,this.#g)!==(0,a.resolveStaleTime)(t.staleTime,this.#g))&&this.#_();let s=this.#Q();i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||s!==this.#w)&&this.#k(s)}getOptimisticResult(e){var t,r;let i=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(i,e);return t=this,r=s,(0,a.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#b=s,this.#T=this.options,this.#S=this.#g.state),s}getCurrentResult(){return this.#b}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#m.status||this.#m.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#D.add(e)}getCurrentQuery(){return this.#g}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#c.defaultQueryOptions(e),r=this.#c.getQueryCache().build(this.#c,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#I({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#b))}#I(e){this.#M();let t=this.#g.fetch(this.options,e);return e?.throwOnError||(t=t.catch(a.noop)),t}#_(){this.#x();let e=(0,a.resolveStaleTime)(this.options.staleTime,this.#g);if(a.isServer||this.#b.isStale||!(0,a.isValidTimeout)(e))return;let t=(0,a.timeUntilStale)(this.#b.dataUpdatedAt,e);this.#E=o.timeoutManager.setTimeout(()=>{this.#b.isStale||this.updateResult()},t+1)}#Q(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#g):this.options.refetchInterval)??!1}#k(e){this.#P(),this.#w=e,!a.isServer&&!1!==(0,a.resolveEnabled)(this.options.enabled,this.#g)&&(0,a.isValidTimeout)(this.#w)&&0!==this.#w&&(this.#C=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#I()},this.#w))}#U(){this.#_(),this.#k(this.#Q())}#x(){this.#E&&(o.timeoutManager.clearTimeout(this.#E),this.#E=void 0)}#P(){this.#C&&(o.timeoutManager.clearInterval(this.#C),this.#C=void 0)}createResult(e,t){let r,s=this.#g,o=this.options,u=this.#b,c=this.#S,d=this.#T,p=e!==s?e.state:this.#y,{state:v}=e,m={...v},g=!1;if(t._optimisticResults){let r=this.hasListeners(),n=!r&&l(e,t),a=r&&h(e,s,t,o);(n||a)&&(m={...m,...(0,i.fetchState)(v.data,e.options)}),"isRestoring"===t._optimisticResults&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:b,status:S}=m;r=m.data;let T=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===S){let e;u?.isPlaceholderData&&t.placeholderData===d?.placeholderData?(e=u.data,T=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#R?.state.data,this.#R):t.placeholderData,void 0!==e&&(S="success",r=(0,a.replaceData)(u?.data,e,t),g=!0)}if(t.select&&void 0!==r&&!T)if(u&&r===c?.data&&t.select===this.#O)r=this.#F;else try{this.#O=t.select,r=t.select(r),r=(0,a.replaceData)(u?.data,r,t),this.#F=r,this.#v=null}catch(e){this.#v=e}this.#v&&(y=this.#v,r=this.#F,b=Date.now(),S="error");let O="fetching"===m.fetchStatus,F="pending"===S,R="error"===S,E=F&&O,C=void 0!==r,w={status:S,fetchStatus:m.fetchStatus,isPending:F,isSuccess:"success"===S,isError:R,isInitialLoading:E,isLoading:E,data:r,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>p.dataUpdateCount||m.errorUpdateCount>p.errorUpdateCount,isFetching:O,isRefetching:O&&!F,isLoadingError:R&&!C,isPaused:"paused"===m.fetchStatus,isPlaceholderData:g,isRefetchError:R&&C,isStale:f(e,t),refetch:this.refetch,promise:this.#m,isEnabled:!1!==(0,a.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==w.data,r="error"===w.status&&!t,i=e=>{r?e.reject(w.error):t&&e.resolve(w.data)},a=()=>{i(this.#m=w.promise=(0,n.pendingThenable)())},o=this.#m;switch(o.status){case"pending":e.queryHash===s.queryHash&&i(o);break;case"fulfilled":(r||w.data!==o.value)&&a();break;case"rejected":r&&w.error===o.reason||a()}}return w}updateResult(){let e=this.#b,t=this.createResult(this.#g,this.options);if(this.#S=this.#g.state,this.#T=this.options,void 0!==this.#S.data&&(this.#R=this.#g),(0,a.shallowEqualObjects)(t,e))return;this.#b=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#D.size)return!0;let i=new Set(r??this.#D);return this.options.throwOnError&&i.add("error"),Object.keys(this.#b).some(t=>this.#b[t]!==e[t]&&i.has(t))};this.#L({listeners:r()})}#M(){let e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#g)return;let t=this.#g;this.#g=e,this.#y=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#U()}#L(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#b)}),this.#c.getQueryCache().notify({query:this.#g,type:"observerResultsUpdated"})})}};function l(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&c(e,t,t.refetchOnMount)}function c(e,t,r){if(!1!==(0,a.resolveEnabled)(t.enabled,e)&&"static"!==(0,a.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&f(e,t)}return!1}function h(e,t,r,i){return(e!==t||!1===(0,a.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&f(e,r)}function f(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,a.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",()=>u])},12598,e=>{"use strict";var t=e.i(71645),r=e.i(43476),i=t.createContext(void 0),s=e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r},n=({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s}));e.s(["QueryClientProvider",()=>n,"useQueryClient",()=>s])},69637,54440,e=>{"use strict";let t;e.i(47167);var r=e.i(71645),i=e.i(19273),s=e.i(40143),n=e.i(12598);e.i(43476);var a=r.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),o=r.createContext(!1);o.Provider;var u=(e,t)=>void 0===t.state.data,l=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(e??1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>t(r(...e)):t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},c=(e,t)=>e.isLoading&&e.isFetching&&!t,h=(e,t)=>e?.suspense&&t.isPending,f=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function d(e,t,u){let d,p=r.useContext(o),v=r.useContext(a),m=(0,n.useQueryClient)(u),g=m.defaultQueryOptions(e);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);let y=m.getQueryCache().get(g.queryHash);g._optimisticResults=p?"isRestoring":"optimistic",l(g),d=y?.state.error&&"function"==typeof g.throwOnError?(0,i.shouldThrowError)(g.throwOnError,[y.state.error,y]):g.throwOnError,(g.suspense||g.experimental_prefetchInRender||d)&&!v.isReset()&&(g.retryOnMount=!1),r.useEffect(()=>{v.clearReset()},[v]);let b=!m.getQueryCache().get(g.queryHash),[S]=r.useState(()=>new t(m,g)),T=S.getOptimisticResult(g),O=!p&&!1!==e.subscribed;if(r.useSyncExternalStore(r.useCallback(e=>{let t=O?S.subscribe(s.notifyManager.batchCalls(e)):i.noop;return S.updateResult(),t},[S,O]),()=>S.getCurrentResult(),()=>S.getCurrentResult()),r.useEffect(()=>{S.setOptions(g)},[g,S]),h(g,T))throw f(g,S,v);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&void 0===e.data||(0,i.shouldThrowError)(r,[e.error,s])))({result:T,errorResetBoundary:v,throwOnError:g.throwOnError,query:y,suspense:g.suspense}))throw T.error;if(m.getDefaultOptions().queries?._experimental_afterQuery?.(g,T),g.experimental_prefetchInRender&&!i.isServer&&c(T,p)){let e=b?f(g,S,v):y?.promise;e?.catch(i.noop).finally(()=>{S.updateResult()})}return g.notifyOnChangeProps?T:S.trackResult(T)}e.s(["defaultThrowOnError",()=>u,"ensureSuspenseTimers",()=>l,"fetchOptimistic",()=>f,"shouldSuspend",()=>h,"willFetch",()=>c],54440),e.s(["useBaseQuery",()=>d],69637)},51475,e=>{"use strict";var t=e.i(43476),r=e.i(71645),i=e.i(71753);let s=(0,r.createContext)(null);function n({children:e}){let n=(0,r.useRef)(void 0),a=(0,r.useRef)(0),o=(0,r.useRef)(0);(0,i.useFrame)((e,t)=>{for(a.current+=t;a.current>=.03125;)if(a.current-=.03125,o.current++,n.current)for(let e of n.current)e(o.current)});let u=(0,r.useCallback)(e=>(n.current??=new Set,n.current.add(e),()=>{n.current.delete(e)}),[]),l=(0,r.useCallback)(()=>o.current,[]),c=(0,r.useMemo)(()=>({subscribe:u,getTick:l}),[u,l]);return(0,t.jsx)(s.Provider,{value:c,children:e})}function a(e){let t=(0,r.useContext)(s);if(!t)throw Error("useTick must be used within a TickProvider");let i=(0,r.useRef)(e);i.current=e,(0,r.useEffect)(()=>t.subscribe(e=>i.current(e)),[t])}e.s(["TICK_RATE",0,32,"TickProvider",()=>n,"useTick",()=>a])},47071,99143,e=>{"use strict";var t=e.i(71645),r=e.i(90072),i=e.i(15080),s=e.i(40859);e.s(["useLoader",()=>s.G],99143);var s=s;let n=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function a(e,a){let o=(0,i.useThree)(e=>e.gl),u=(0,s.G)(r.TextureLoader,n(e)?Object.values(e):e);return(0,t.useLayoutEffect)(()=>{null==a||a(u)},[a]),(0,t.useEffect)(()=>{if("initTexture"in o){let e=[];Array.isArray(u)?e=u:u instanceof r.Texture?e=[u]:n(u)&&(e=Object.values(u)),e.forEach(e=>{e instanceof r.Texture&&o.initTexture(e)})}},[o,u]),(0,t.useMemo)(()=>{if(!n(e))return u;{let t={},r=0;for(let i in e)t[i]=u[r++];return t}},[e,u])}a.preload=e=>s.G.preload(r.TextureLoader,e),a.clear=e=>s.G.clear(r.TextureLoader,e),e.s(["useTexture",()=>a],47071)},75567,e=>{"use strict";var t=e.i(90072);let r=new t.ImageBitmapLoader,i=new Map;function s(e,s){let n=i.get(e);if(n)return s&&n.image&&s(n),n;let a=new t.Texture;return a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s?.(a)}),a}function n(e){let s=i.get(e);return s?s.image?Promise.resolve(s):new Promise(e=>{let t=()=>{s.image?e(s):setTimeout(t,16)};t()}):new Promise((s,n)=>{let a=new t.Texture;a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s(a)},void 0,n)})}function a(e,r={}){let{repeat:i=[1,1],disableMipmaps:s=!1}=r;return e.wrapS=e.wrapT=t.RepeatWrapping,e.colorSpace=t.SRGBColorSpace,e.repeat.set(...i),e.flipY=!1,e.anisotropy=16,s?(e.generateMipmaps=!1,e.minFilter=t.LinearFilter):(e.generateMipmaps=!0,e.minFilter=t.LinearMipmapLinearFilter),e.magFilter=t.LinearFilter,e.needsUpdate=!0,e}function o(e){let r=new t.DataTexture(e,256,256,t.RedFormat,t.UnsignedByteType);return r.colorSpace=t.NoColorSpace,r.wrapS=r.wrapT=t.RepeatWrapping,r.generateMipmaps=!1,r.minFilter=t.LinearFilter,r.magFilter=t.LinearFilter,r.needsUpdate=!0,r}e.s(["loadTexture",()=>s,"loadTextureAsync",()=>n,"setupMask",()=>o,"setupTexture",()=>a])},47021,e=>{"use strict";var t=e.i(8560);let r=` +#ifdef USE_FOG + // Check fog enabled uniform - allows toggling without shader recompilation + #ifdef USE_VOLUMETRIC_FOG + if (!fogEnabled) { + // Skip all fog calculations when disabled + } else { + #endif + + float dist = vFogDepth; + + // Discard fragments at or beyond visible distance - matches Torque's behavior + // where objects beyond visibleDistance are not rendered at all. + // This prevents fully-fogged geometry from showing as silhouettes against + // the sky's fog-to-sky gradient. + if (dist >= fogFar) { + discard; + } + + // Step 1: Calculate distance-based haze (quadratic falloff) + // Since we discard at fogFar, haze never reaches 1.0 here + float haze = 0.0; + if (dist > fogNear) { + float fogScale = 1.0 / (fogFar - fogNear); + float distFactor = (dist - fogNear) * fogScale - 1.0; + haze = 1.0 - distFactor * distFactor; + } + + // Step 2: Calculate fog volume contributions + // Note: Per-volume colors are NOT used in Tribes 2 ($specialFog defaults to false) + // All fog uses the global fogColor - see Tribes2_Fog_System.md for details + float volumeFog = 0.0; + + #ifdef USE_VOLUMETRIC_FOG + { + #ifdef USE_FOG_WORLD_POSITION + float fragmentHeight = vFogWorldPosition.y; + #else + float fragmentHeight = cameraHeight; + #endif + + float deltaY = fragmentHeight - cameraHeight; + float absDeltaY = abs(deltaY); + + // Determine if we're going up (positive) or down (negative) + if (absDeltaY > 0.01) { + // Non-horizontal ray: ray-march through fog volumes + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + // Skip inactive volumes (visibleDistance = 0) + if (volVisDist <= 0.0) continue; + + // Calculate fog factor for this volume + // From Torque: factor = (1 / (volumeVisDist * visFactor)) * percentage + // where visFactor is smVisibleDistanceMod (a user quality pref, default 1.0) + // Since we don't have quality settings, we use visFactor = 1.0 + float factor = (1.0 / volVisDist) * volPct; + + // Find ray intersection with this volume's height range + float rayMinY = min(cameraHeight, fragmentHeight); + float rayMaxY = max(cameraHeight, fragmentHeight); + + // Check if ray intersects volume height range + if (rayMinY < volMaxH && rayMaxY > volMinH) { + float intersectMin = max(rayMinY, volMinH); + float intersectMax = min(rayMaxY, volMaxH); + float intersectHeight = intersectMax - intersectMin; + + // Calculate distance traveled through this volume using similar triangles: + // subDist / dist = intersectHeight / absDeltaY + float subDist = dist * (intersectHeight / absDeltaY); + + // Accumulate fog: fog += subDist * factor + volumeFog += subDist * factor; + } + } + } else { + // Near-horizontal ray: if camera is inside a volume, apply full fog for that volume + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + if (volVisDist <= 0.0) continue; + + // If camera is inside this volume, apply fog for full distance + if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { + float factor = (1.0 / volVisDist) * volPct; + volumeFog += dist * factor; + } + } + } + } + #endif + + // Step 3: Combine haze and volume fog + // Torque's clamping: if (bandPct + hazePct > 1) hazePct = 1 - bandPct + // This gives fog volumes priority over haze + float volPct = min(volumeFog, 1.0); + float hazePct = haze; + if (volPct + hazePct > 1.0) { + hazePct = 1.0 - volPct; + } + float fogFactor = hazePct + volPct; + + // Apply fog using global fogColor (per-volume colors not used in Tribes 2) + gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor); + + #ifdef USE_VOLUMETRIC_FOG + } // end fogEnabled check + #endif +#endif +`;function i(){t.ShaderChunk.fog_pars_fragment=` +#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif + + // Custom volumetric fog uniforms (only defined when USE_VOLUMETRIC_FOG is set) + // Format: [visDist, minH, maxH, percentage] x 3 volumes = 12 floats + #ifdef USE_VOLUMETRIC_FOG + uniform float fogVolumeData[12]; + uniform float cameraHeight; + #endif + + #ifdef USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; + #endif +#endif +`,t.ShaderChunk.fog_fragment=r,t.ShaderChunk.fog_pars_vertex=` +#ifdef USE_FOG + varying float vFogDepth; + #ifdef USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; + #endif +#endif +`,t.ShaderChunk.fog_vertex=` +#ifdef USE_FOG + // Use Euclidean distance from camera, not view-space z-depth + // This ensures fog doesn't change when rotating the camera + vFogDepth = length(mvPosition.xyz); + #ifdef USE_FOG_WORLD_POSITION + vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; + #endif +#endif +`}function s(e,t){e.uniforms.fogVolumeData=t.fogVolumeData,e.uniforms.cameraHeight=t.cameraHeight,e.uniforms.fogEnabled=t.fogEnabled,e.vertexShader=e.vertexShader.replace("#include ",`#include +#ifdef USE_FOG + #define USE_FOG_WORLD_POSITION + #define USE_VOLUMETRIC_FOG + varying vec3 vFogWorldPosition; +#endif`),e.vertexShader=e.vertexShader.replace("#include ",`#include +#ifdef USE_FOG + vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; +#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include +#ifdef USE_FOG + #define USE_VOLUMETRIC_FOG + uniform float fogVolumeData[12]; + uniform float cameraHeight; + uniform bool fogEnabled; + #define USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; +#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",r)}e.s(["fogFragmentShader",0,r,"injectCustomFog",()=>s,"installCustomFogShader",()=>i])},48066,e=>{"use strict";let t={fogVolumeData:{value:new Float32Array(12)},cameraHeight:{value:0},fogEnabled:{value:!0}};function r(e,i,s=!0){t.cameraHeight.value=e,t.fogVolumeData.value.set(i),t.fogEnabled.value=s}function i(){t.cameraHeight.value=0,t.fogVolumeData.value.fill(0),t.fogEnabled.value=!0}function s(e){let t=new Float32Array(12);for(let r=0;r<3;r++){let i=4*r,s=e[r];s&&(t[i+0]=s.visibleDistance,t[i+1]=s.minHeight,t[i+2]=s.maxHeight,t[i+3]=s.percentage)}return t}e.s(["globalFogUniforms",0,t,"packFogVolumeData",()=>s,"resetGlobalFogUniforms",()=>i,"updateGlobalFogUniforms",()=>r])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/1a2c6dc513278881.js b/docs/_next/static/chunks/1a2c6dc513278881.js new file mode 100644 index 00000000..8f44e0c5 --- /dev/null +++ b/docs/_next/static/chunks/1a2c6dc513278881.js @@ -0,0 +1,8 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,8597,e=>{"use strict";var t=e.i(71645);let r=(0,t.createContext)(null),s={didCatch:!1,error:null};class n extends t.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=s}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(s))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(s))}render(){let{children:e,fallbackRender:s,FallbackComponent:n,fallback:i}=this.props,{didCatch:a,error:o}=this.state,A=e;if(a){let e={error:o,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof s)A=s(e);else if(n)A=(0,t.createElement)(n,e);else if(void 0!==i)A=i;else throw o}return(0,t.createElement)(r.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},A)}}e.s(["ErrorBoundary",()=>n])},78140,e=>{"use strict";let t;var r=e.i(31067),s=e.i(71645),n=e.i(90072);function i(e,t){if(t===n.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==n.TriangleFanDrawMode&&t!==n.TriangleStripDrawMode)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let r=e.getIndex();if(null===r){let t=[],s=e.getAttribute("position");if(void 0===s)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;etypeof TextDecoder)return new TextDecoder().decode(e);let t="";for(let r=0,s=e.length;r=2.0 are supported."));return}let A=new z(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});A.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}A.setExtensions(i),A.setPlugins(a),A.parse(r,s)}parseAsync(e,t){let r=this;return new Promise(function(s,n){r.parse(e,t,s,n)})}}function c(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let u={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class C{constructor(e){this.parser=e,this.name=u.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,s=t.length;r=0))return null;else throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return t.loadTextureImage(e,n.source,i)}}class T{constructor(e){this.parser=e,this.name=u.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,s=r.json,n=s.textures[e];if(!n.extensions||!n.extensions[t])return null;let i=n.extensions[t],a=s.images[i.source],o=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then(function(n){if(n)return r.loadTextureImage(e,i.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class H{constructor(e){this.parser=e,this.name=u.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,s=r.json,n=s.textures[e];if(!n.extensions||!n.extensions[t])return null;let i=n.extensions[t],a=s.images[i.source],o=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then(function(n){if(n)return r.loadTextureImage(e,i.source,o);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class J{constructor(e){this.name=u.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(!r.extensions||!r.extensions[this.name])return null;{let e=r.extensions[this.name],s=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported)if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return s.then(function(t){let r=e.byteOffset||0,s=e.byteLength||0,i=e.count,a=e.byteStride,o=new Uint8Array(t,r,s);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(i,a,o,e.mode,e.filter).then(function(e){return e.buffer}):n.ready.then(function(){let t=new ArrayBuffer(i*a);return n.decodeGltfBuffer(new Uint8Array(t),i,a,o,e.mode,e.filter),t})})}}}class b{constructor(e){this.name=u.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;for(let e of t.meshes[r.mesh].primitives)if(e.mode!==v.TRIANGLES&&e.mode!==v.TRIANGLE_STRIP&&e.mode!==v.TRIANGLE_FAN&&void 0!==e.mode)return null;let s=r.extensions[this.name].attributes,i=[],a={};for(let e in s)i.push(this.parser.getDependency("accessor",s[e]).then(t=>(a[e]=t,a[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{let t=e.pop(),r=t.isGroup?t.children:[t],s=e[0].count,i=[];for(let e of r){let t=new n.Matrix4,r=new n.Vector3,o=new n.Quaternion,A=new n.Vector3(1,1,1),l=new n.InstancedMesh(e.geometry,e.material,s);for(let e=0;e=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},X={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},j={CUBICSPLINE:void 0,LINEAR:n.InterpolateLinear,STEP:n.InterpolateDiscrete};function Y(e,t,r){for(let s in r.extensions)void 0===e[s]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[s]=r.extensions[s])}function Z(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function W(e){let t="",r=Object.keys(e).sort();for(let s=0,n=r.length;stypeof navigator&&void 0!==navigator.userAgent&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=(s=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"u"{let r=this.associations.get(e);for(let[s,i]of(null!=r&&this.associations.set(t,r),e.children.entries()))n(i,t.children[s])};return n(r,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r=2&&a.setY(t,u[e*A+1]),A>=3&&a.setZ(t,u[e*A+2]),A>=4&&a.setW(t,u[e*A+3]),A>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return a})}loadTexture(e){let t=this.json,r=this.options,s=t.textures[e].source,n=t.images[s],i=this.textureLoader;if(n.uri){let e=r.manager.getHandler(n.uri);null!==e&&(i=e)}return this.loadTextureImage(e,s,i)}loadTextureImage(e,t,r){let s=this,i=this.json,a=i.textures[e],o=i.images[t],A=(o.uri||o.bufferView)+":"+a.sampler;if(this.textureCache[A])return this.textureCache[A];let l=this.loadImageSource(t,r).then(function(t){t.flipY=!1,t.name=a.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);let r=(i.samplers||{})[a.sampler]||{};return t.magFilter=N[r.magFilter]||n.LinearFilter,t.minFilter=N[r.minFilter]||n.LinearMipmapLinearFilter,t.wrapS=_[r.wrapS]||n.RepeatWrapping,t.wrapT=_[r.wrapT]||n.RepeatWrapping,s.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[A]=l,l}loadImageSource(e,t){let r=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=r.images[e],a=self.URL||self.webkitURL,o=i.uri||"",A=!1;if(void 0!==i.bufferView)o=this.getDependency("bufferView",i.bufferView).then(function(e){A=!0;let t=new Blob([e],{type:i.mimeType});return o=a.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(o).then(function(e){return new Promise(function(r,i){let a=r;!0===t.isImageBitmapLoader&&(a=function(e){let t=new n.Texture(e);t.needsUpdate=!0,r(t)}),t.load(n.LoaderUtils.resolveURL(e,s.path),a,void 0,i)})}).then(function(e){var t;return!0===A&&a.revokeObjectURL(o),Z(e,i),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e});return this.sourceCache[e]=l,l}assignTexture(e,t,r,s){let n=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((i=i.clone()).channel=r.texCoord),n.extensions[u.KHR_TEXTURE_TRANSFORM]){let e=void 0!==r.extensions?r.extensions[u.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=n.associations.get(i);i=n.extensions[u.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),n.associations.set(i,t)}}return void 0!==s&&("number"==typeof s&&(s=3001===s?A:l),"colorSpace"in i?i.colorSpace=s:i.encoding=s===A?3001:3e3),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,r=e.material,s=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,a=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new n.PointsMaterial,n.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){let e="LineBasicMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new n.LineBasicMaterial,n.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(s||i||a){let e="ClonedMaterial:"+r.uuid+":";s&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),a&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),a&&(t.flatShading=!0),s&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return n.MeshStandardMaterial}loadMaterial(e){let t,r=this,s=this.json,i=this.extensions,a=s.materials[e],o={},B=a.extensions||{},c=[];if(B[u.KHR_MATERIALS_UNLIT]){let e=i[u.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(o,a,r))}else{let s=a.pbrMetallicRoughness||{};if(o.color=new n.Color(1,1,1),o.opacity=1,Array.isArray(s.baseColorFactor)){let e=s.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],l),o.opacity=e[3]}void 0!==s.baseColorTexture&&c.push(r.assignTexture(o,"map",s.baseColorTexture,A)),o.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,o.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(c.push(r.assignTexture(o,"metalnessMap",s.metallicRoughnessTexture)),c.push(r.assignTexture(o,"roughnessMap",s.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}!0===a.doubleSided&&(o.side=n.DoubleSide);let C=a.alphaMode||"OPAQUE";if("BLEND"===C?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===C&&(o.alphaTest=void 0!==a.alphaCutoff?a.alphaCutoff:.5)),void 0!==a.normalTexture&&t!==n.MeshBasicMaterial&&(c.push(r.assignTexture(o,"normalMap",a.normalTexture)),o.normalScale=new n.Vector2(1,1),void 0!==a.normalTexture.scale)){let e=a.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==a.occlusionTexture&&t!==n.MeshBasicMaterial&&(c.push(r.assignTexture(o,"aoMap",a.occlusionTexture)),void 0!==a.occlusionTexture.strength&&(o.aoMapIntensity=a.occlusionTexture.strength)),void 0!==a.emissiveFactor&&t!==n.MeshBasicMaterial){let e=a.emissiveFactor;o.emissive=new n.Color().setRGB(e[0],e[1],e[2],l)}return void 0!==a.emissiveTexture&&t!==n.MeshBasicMaterial&&c.push(r.assignTexture(o,"emissiveMap",a.emissiveTexture,A)),Promise.all(c).then(function(){let s=new t(o);return a.name&&(s.name=a.name),Z(s,a),r.associations.set(s,{materials:e}),a.extensions&&Y(i,s,a),s})}createUniqueName(e){let t=n.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,s=this.primitiveCache,i=[];for(let a=0,o=e.length;a0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,s=t.weights.length;r1?new n.Group:1===t.length?t[0]:new n.Object3D)!==t[0])for(let e=0,r=t.length;e{let t=new Map;for(let[e,r]of s.associations)(e instanceof n.Material||e instanceof n.Texture)&&t.set(e,r);return e.traverse(e=>{let r=s.associations.get(e);null!=r&&t.set(e,r)}),t})(i),i})}_createAnimationTracks(e,t,r,s,i){let a,o=[],A=e.name?e.name:e.uuid,l=[];switch(X[i.path]===X.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(A),X[i.path]){case X.weights:a=n.NumberKeyframeTrack;break;case X.rotation:a=n.QuaternionKeyframeTrack;break;case X.position:case X.scale:a=n.VectorKeyframeTrack;break;default:a=1===r.itemSize?n.NumberKeyframeTrack:n.VectorKeyframeTrack}let B=void 0!==s.interpolation?j[s.interpolation]:n.InterpolateLinear,c=this._getArrayFromAccessor(r);for(let e=0,r=l.length;e{let r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(s)},r,s)}decodeDracoFile(e,t,r,s){let n={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,n).then(t)}decodeGeometry(e,t){let r;for(let e in t.attributeTypes){let r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}let s=JSON.stringify(t);if(et.has(e)){let t=et.get(e);if(t.key===s)return t.promise;if(0===e.byteLength)throw Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(n,i).then(s=>(r=s,new Promise((s,i)=>{r._callbacks[n]={resolve:s,reject:i},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return a.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),et.set(e,{key:s,promise:a}),a}_createGeometry(e){let t=new ee.BufferGeometry;e.index&&t.setIndex(new ee.BufferAttribute(e.index.array,1));for(let r=0;r{r.load(e,t,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{let r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let s=es.toString(),n=["/* draco decoder */",r,"\n/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengtht._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{let t=e.draco,r=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(n),n.byteLength);try{let e=function(e,t,r,s){var n,i,a;let o,A,l,B,c,u,C=s.attributeIDs,h=s.attributeTypes,d=t.GetEncodedGeometryType(r);if(d===e.TRIANGULAR_MESH)c=new e.Mesh,u=t.DecodeBufferToMesh(r,c);else if(d===e.POINT_CLOUD)c=new e.PointCloud,u=t.DecodeBufferToPointCloud(r,c);else throw Error("THREE.DRACOLoader: Unexpected geometry type.");if(!u.ok()||0===c.ptr)throw Error("THREE.DRACOLoader: Decoding failed: "+u.error_msg());let f={index:null,attributes:[]};for(let r in C){let n,i,a=self[h[r]];if(s.useUniqueIDs)i=C[r],n=t.GetAttributeByUniqueId(c,i);else{if(-1===(i=t.GetAttributeId(c,e[C[r]])))continue;n=t.GetAttribute(c,i)}f.attributes.push(function(e,t,r,s,n,i){let a=i.num_components(),o=r.num_points()*a,A=o*n.BYTES_PER_ELEMENT,l=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),B=e._malloc(A);t.GetAttributeDataArrayForAllPoints(r,i,l,A,B);let c=new n(e.HEAPF32.buffer,B,o).slice();return e._free(B),{name:s,array:c,itemSize:a}}(e,t,c,r,a,n))}return d===e.TRIANGULAR_MESH&&(n=e,i=t,a=c,o=3*a.num_faces(),A=4*o,l=n._malloc(A),i.GetTrianglesUInt32Array(a,A,l),B=new Uint32Array(n.HEAPF32.buffer,l,o).slice(),n._free(l),f.index={array:B,itemSize:1}),e.destroy(c),f}(t,r,a,i),n=e.attributes.map(e=>e.array.buffer);e.index&&n.push(e.index.array.buffer),self.postMessage({type:"decode",id:s.id,geometry:e},n)}catch(e){console.error(e),self.postMessage({type:"error",id:s.id,error:e.message})}finally{t.destroy(a),t.destroy(r)}})}}}var en=e.i(99143);let ei=function(e){let t=new Map,r=new Map,s=e.clone();return function e(t,r,s){s(t,r);for(let n=0;n{let C={keys:B,deep:a,inject:l,castShadow:o,receiveShadow:A};if(Array.isArray(t=s.useMemo(()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse(t=>{t.isSkinnedMesh&&(e=!0)}),e)return ei(t)}return t},[t,e])))return s.createElement("group",(0,r.default)({},c,{ref:u}),t.map(e=>s.createElement(ea,(0,r.default)({key:e.uuid,object:e},C))),i);let{children:h,...d}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:i,castShadow:a,receiveShadow:o}){let A={};for(let r of t)A[r]=e[r];return r&&(A.geometry&&"materialsOnly"!==r&&(A.geometry=A.geometry.clone()),A.material&&"geometriesOnly"!==r&&(A.material=A.material.clone())),i&&(A="function"==typeof i?{...A,children:i(e)}:s.isValidElement(i)?{...A,children:i}:{...A,...i}),e instanceof n.Mesh&&(a&&(A.castShadow=!0),o&&(A.receiveShadow=!0)),A}(t,C),f=t.type[0].toLowerCase()+t.type.slice(1);return s.createElement(f,(0,r.default)({},d,c,{ref:u}),t.children.map(e=>"Bone"===e.type?s.createElement("primitive",(0,r.default)({key:e.uuid,object:e},C)):s.createElement(ea,(0,r.default)({key:e.uuid,object:e},C,{isChild:!0}))),i,h)}),eo=null,eA="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function el(e=!0,r=!0,s){return n=>{s&&s(n),e&&(eo||(eo=new er),eo.setDecoderPath("string"==typeof e?e:eA),n.setDRACOLoader(eo)),r&&n.setMeshoptDecoder((()=>{let e;if(t)return t;let r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),s=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let n="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(r)&&(n="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");let i=WebAssembly.instantiate(function(e){let t=new Uint8Array(e.length);for(let r=0;r96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let r=0;for(let n=0;n{(e=t.instance).exports.__wasm_call_ctors()});function a(t,r,s,n,i,a){let o=e.exports.sbrk,A=s+3&-4,l=o(A*n),B=o(i.length),c=new Uint8Array(e.exports.memory.buffer);c.set(i,B);let u=t(l,s,n,B,i.length);if(0===u&&a&&a(l,A,n),r.set(c.subarray(l,l+s*n)),o(l-o(0)),0!==u)throw Error(`Malformed buffer data: ${u}`)}let o={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},A={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return t={ready:i,supported:!0,decodeVertexBuffer(t,r,s,n,i){a(e.exports.meshopt_decodeVertexBuffer,t,r,s,n,e.exports[o[i]])},decodeIndexBuffer(t,r,s,n){a(e.exports.meshopt_decodeIndexBuffer,t,r,s,n)},decodeIndexSequence(t,r,s,n){a(e.exports.meshopt_decodeIndexSequence,t,r,s,n)},decodeGltfBuffer(t,r,s,n,i,l){a(e.exports[A[i]],t,r,s,n,e.exports[o[l]])}}})())}}let eB=(e,t,r,s)=>(0,en.useLoader)(B,e,el(t,r,s));eB.preload=(e,t,r,s)=>en.useLoader.preload(B,e,el(t,r,s)),eB.clear=e=>en.useLoader.clear(B,e),eB.setDecoderPath=e=>{eA=e},e.s(["useGLTF",()=>eB],78140)},82816,e=>{"use strict";function t(e){let t=new Map,r=new Map,s=e.clone();return function e(t,r,s){s(t,r);for(let n=0;nt])},25947,71505,6655,e=>{"use strict";var t=e.i(43476),r=e.i(932),s=e.i(71645);let n=/borg|xorg|porg|dorg|plant|tree|bush|fern|vine|grass|leaf|flower|frond|palm|foliage/i;function i(e){return n.test(e)}let a=(0,s.createContext)(null);function o(){let e=(0,s.useContext)(a);if(!e)throw Error("useShapeInfo must be used within ShapeInfoProvider");return e}function A(e){let s,n,o,A=(0,r.c)(10),{children:l,object:B,shapeName:c,type:u}=e;A[0]!==c?(s=i(c),A[0]=c,A[1]=s):s=A[1];let C=s;A[2]!==C||A[3]!==B||A[4]!==c||A[5]!==u?(n={object:B,shapeName:c,type:u,isOrganic:C},A[2]=C,A[3]=B,A[4]=c,A[5]=u,A[6]=n):n=A[6];let h=n;return A[7]!==l||A[8]!==h?(o=(0,t.jsx)(a.Provider,{value:h,children:l}),A[7]=l,A[8]=h,A[9]=o):o=A[9],o}e.s(["ShapeInfoProvider",()=>A,"isOrganicShape",()=>i,"useShapeInfo",()=>o],25947);var l=e.i(47071);e.i(47167);var B=e.i(69230),c=e.i(69637),u=e.i(54440),C=e.i(90072),h=e.i(12979),d=e.i(75567),f=e.i(51475),m=e.i(79123);let p=1/30,M=new Map;function F(e){let t=e[0].image,r=t.width,s=t.height,n=e.length,i=Math.ceil(Math.sqrt(n)),a=Math.ceil(n/i),o=document.createElement("canvas");o.width=r*i,o.height=s*a;let A=o.getContext("2d");e.forEach((e,t)=>{let n=Math.floor(t/i);A.drawImage(e.image,t%i*r,n*s)});let l=new C.CanvasTexture(o);return l.colorSpace=C.SRGBColorSpace,l.generateMipmaps=!1,l.minFilter=C.NearestFilter,l.magFilter=C.NearestFilter,l.wrapS=C.ClampToEdgeWrapping,l.wrapT=C.ClampToEdgeWrapping,l.repeat.set(1/i,1/a),{texture:l,columns:i,rows:a,frameCount:n,frameOffsetSeconds:[],totalDurationSeconds:0,lastFrame:-1}}function E(e,t){let r=0;e.frameOffsetSeconds=t.map(e=>r+=e.frameCount*p),e.totalDurationSeconds=r}function G(e,t){if(t===e.lastFrame)return;e.lastFrame=t;let r=t%e.columns,s=e.rows-1-Math.floor(t/e.columns);e.texture.offset.set(r/e.columns,s/e.rows)}function I(e,t){let r=e.totalDurationSeconds;if(r<=0)return 0;let s=t;s>r&&(s-=r*Math.floor(s/r));for(let t=0;t(0,h.iflTextureToUrl)(t.name,e)),n=F(await Promise.all(s.map(d.loadTextureAsync)));return E(n,r),M.set(e,n),n}function D(e){var t;let s,n,i,a,o=(0,r.c)(14),{animationEnabled:A}=(0,m.useSettings)();o[0]!==e?(s={queryKey:["ifl",e],queryFn:()=>(0,h.loadImageFrameList)(e)},o[0]=e,o[1]=s):s=o[1];let{data:C}=(t=s,(0,c.useBaseQuery)({...t,enabled:!0,suspense:!0,throwOnError:u.defaultThrowOnError,placeholderData:void 0},B.QueryObserver,void 0));if(o[2]!==C||o[3]!==e){let t;o[5]!==e?(t=t=>(0,h.iflTextureToUrl)(t.name,e),o[5]=e,o[6]=t):t=o[6],n=C.map(t),o[2]=C,o[3]=e,o[4]=n}else n=o[4];let d=n,p=(0,l.useTexture)(d);o[7]!==C||o[8]!==e||o[9]!==p?((i=M.get(e))||(i=F(p),M.set(e,i)),E(i,C),o[7]=C,o[8]=e,o[9]=p,o[10]=i):i=o[10];let g=i;return o[11]!==A||o[12]!==g?(a=e=>{let t=e/f.TICK_RATE,r=A?I(g,t):0;G(g,r)},o[11]=A,o[12]=g,o[13]=a):a=o[13],(0,f.useTick)(a),g.texture}e.s(["getFrameIndexForTime",()=>I,"loadIflAtlas",()=>g,"updateAtlasFrame",()=>G,"useIflTexture",()=>D],71505);function R(e){e.uniforms.shapeDirectionalFactor={value:1},e.uniforms.shapeAmbientFactor={value:1.5},e.fragmentShader=e.fragmentShader.replace("#include ",`#include +uniform float shapeDirectionalFactor; +uniform float shapeAmbientFactor; +`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include + // Apply shape-specific lighting multipliers + reflectedLight.directDiffuse *= shapeDirectionalFactor; + reflectedLight.indirectDiffuse *= shapeAmbientFactor; +`)}e.s(["injectShapeLighting",()=>R],6655)},85557,e=>{"use strict";e.s(["ANIM_TRANSITION_TIME",()=>A,"DEFAULT_EYE_HEIGHT",()=>o,"STREAM_TICK_SEC",()=>l,"_r90",()=>h,"_r90inv",()=>d,"entityTypeColor",()=>D,"getKeyframeAtTime",()=>F,"getPosedNodeTransform",()=>E,"processShapeScene",()=>g,"replaceWithShapeMaterial",()=>G,"setQuaternionFromDir",()=>M,"setupEffectTexture",()=>m,"torqueHorizontalFovToThreeVerticalFov",()=>f,"torqueVecToThree",()=>p],85557);var t=e.i(90072),r=e.i(91907),s=e.i(25947),n=e.i(71505),i=e.i(75567),a=e.i(12979);let o=2.1,A=.25,l=.032,B=new t.Vector3,c=new t.Vector3,u=new t.Matrix4,C=new t.Vector3(0,1,0),h=new t.Quaternion().setFromAxisAngle(new t.Vector3(0,1,0),Math.PI/2),d=h.clone().invert();function f(e,t){return 180*(2*Math.atan(Math.tan(Math.max(.01,Math.min(179.99,e))*Math.PI/180/2)/(Number.isFinite(t)&&t>1e-6?t:4/3)))/Math.PI}function m(e){e.wrapS=t.ClampToEdgeWrapping,e.wrapT=t.ClampToEdgeWrapping,e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter,e.colorSpace=t.NoColorSpace,e.flipY=!1,e.needsUpdate=!0}function p(e,t){return t.set(e[1],e[2],e[0])}function M(e,t){B.crossVectors(e,C),1e-8>B.lengthSq()&&B.set(-1,0,0),B.normalize(),c.crossVectors(B,e).normalize(),u.set(B.x,e.x,c.x,0,B.y,e.y,c.y,0,B.z,e.z,c.z,0,0,0,0,1),t.setFromRotationMatrix(u)}function F(e,t){if(0===e.length)return null;if(t<=e[0].time)return e[0];if(t>=e[e.length-1].time)return e[e.length-1];let r=0,s=e.length-1;for(;s-r>1;){let n=r+s>>1;e[n].time<=t?r=n:s=n}return e[r]}function E(e,r,s,n){let i=e.clone(!0),a=r.find(e=>"Root"===e.name);if(a){let e=new t.AnimationMixer(i);if(e.clipAction(a).play(),n)for(let t of n){let s=r.find(e=>e.name.toLowerCase()===t.toLowerCase());if(s){let t=e.clipAction(s);t.time=s.duration/2,t.setEffectiveTimeScale(0),t.play()}}e.setTime(0)}i.updateMatrixWorld(!0);let o=null,A=null;return(i.traverse(e=>{o||e.name!==s||(o=new t.Vector3,A=new t.Quaternion,e.getWorldPosition(o),e.getWorldQuaternion(A))}),o&&A)?{position:o,quaternion:A}:null}function G(e,s,n=!1){let o=e.userData?.resource_path,A=new Set(e.userData?.flag_names??[]);if(!o){let s=new t.MeshLambertMaterial({color:e.color,side:2,reflectivity:0});return(0,r.applyShapeShaderModifications)(s),{material:s}}if(A.has("IflMaterial")){let t=(0,r.createMaterialFromFlags)(e,null,A,n,s);if(Array.isArray(t)){let e=t[1];return{material:e,backMaterial:t[0],initialize:(t,r)=>I(e,o,t,r)}}return{material:t,initialize:(e,r)=>I(t,o,e,r)}}let l=(0,a.textureToUrl)(o),B=(0,i.loadTexture)(l),c=A.has("Translucent");n||c?(0,i.setupTexture)(B,{disableMipmaps:!0}):(0,i.setupTexture)(B);let u=(0,r.createMaterialFromFlags)(e,B,A,n,s);return Array.isArray(u)?{material:u[1],backMaterial:u[0]}:{material:u}}async function I(e,t,r,s){let i=`textures/${t}.ifl`,a=await (0,n.loadIflAtlas)(i);e.map=a.texture,e.needsUpdate=!0;let o=!1,A=r.onBeforeRender;return r.onBeforeRender=function(...e){A?.apply(this,e),o||(0,n.updateAtlasFrame)(a,(0,n.getFrameIndexForTime)(a,s()))},()=>{o=!0,r.onBeforeRender=A??(()=>{})}}function g(e,t){var r;let n,i=[],a=!!t&&(0,s.isOrganicShape)(t),o=null;e.traverse(e=>{!o&&e.skeleton&&(o=e.skeleton)});let A=o?(r=o,n=new Set,r.bones.forEach((e,t)=>{e.name.match(/^Hulk/i)&&n.add(t)}),n):new Set,l=[];for(let{parent:t,mesh:r}of(e.traverse(e=>{if(!e.isMesh)return;if(e.name.match(/^Hulk/i)||e.material?.name==="Unassigned"){e.visible=!1;return}let t=!!e.userData?.vis_sequence;if((e.userData?.vis??1)<.01&&(e.visible=!1),e.geometry){let t=function(e,t){if(0===t.size||!e.attributes.skinIndex)return e;let r=e.attributes.skinIndex,s=e.attributes.skinWeight,n=e.index,i=Array(r.count).fill(!1);for(let e=0;e.01&&t.has(a)){i[e]=!0;break}}if(n){let t=[],r=n.array;for(let e=0;e1){let t=0,r=0,s=0;for(let i of e)t+=n[3*i],r+=n[3*i+1],s+=n[3*i+2];let i=Math.sqrt(t*t+r*r+s*s);for(let a of(i>0&&(t/=i,r/=i,s/=i),e))n[3*a]=t,n[3*a+1]=r,n[3*a+2]=s}r.needsUpdate=!0}(t=t.clone()),e.geometry=t}let r=t?1:e.userData?.vis??1;if(Array.isArray(e.material))e.material=e.material.map(t=>{let s=G(t,r,a);if(s.initialize&&i.push({mesh:e,initialize:s.initialize}),s.backMaterial&&e.parent){let t=e.clone();t.material=s.backMaterial,l.push({parent:e.parent,mesh:t})}return s.material});else if(e.material){let t=G(e.material,r,a);if(t.initialize&&i.push({mesh:e,initialize:t.initialize}),e.material=t.material,t.backMaterial&&e.parent){let r=e.clone();r.material=t.backMaterial,l.push({parent:e.parent,mesh:r})}}}),l))t.add(r);return i}function D(e){switch(e.toLowerCase()){case"player":return"#00ff88";case"vehicle":return"#ff8800";case"projectile":return"#ff0044";case"deployable":return"#ffcc00";default:return"#8888ff"}}},91907,e=>{"use strict";e.s(["ShapeRenderer",()=>T,"applyShapeShaderModifications",()=>F,"createMaterialFromFlags",()=>E,"useStaticShape",()=>G]);var t=e.i(43476),r=e.i(932),s=e.i(71645),n=e.i(8597),i=e.i(78140),a=(e.i(47071),e.i(71753)),o=e.i(12979),A=e.i(90072),l=e.i(82816),B=(e.i(75567),e.i(79123)),c=e.i(25947);e.i(13876);var u=e.i(58647),C=e.i(89887),h=e.i(71505),d=e.i(47021),f=e.i(48066),m=e.i(6655),p=e.i(85557);function M(){let{recording:e}=u.engineStore.getState().playback;return null!=e?(0,u.effectNow)()/1e3:performance.now()/1e3}function F(e){e.onBeforeCompile=t=>{(0,d.injectCustomFog)(t,f.globalFogUniforms),e instanceof A.MeshLambertMaterial&&(0,m.injectShapeLighting)(t)}}function E(e,t,r,s,n=1,i=!1){let a=r.has("Translucent"),o=r.has("Additive"),l=r.has("SelfIlluminating"),B=n<1||i;if(l||o){let e=o||a||B,r=new A.MeshBasicMaterial({map:t,side:2,transparent:e,depthWrite:!e,alphaTest:0,fog:!0,...B&&{opacity:n},...o&&{blending:A.AdditiveBlending}});return F(r),r}if(s||a){let e={map:t,transparent:B,alphaTest:.5*!B,...B&&{opacity:n,depthWrite:!1},reflectivity:0},r=new A.MeshLambertMaterial({...e,side:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),s=new A.MeshLambertMaterial({...e,side:0});return F(r),F(s),[r,s]}let c=new A.MeshLambertMaterial({map:t,side:2,reflectivity:0,...B&&{transparent:!0,opacity:n,depthWrite:!1}});return F(c),c}function G(e){let t,s=(0,r.c)(2);s[0]!==e?(t=(0,o.shapeToUrl)(e),s[0]=e,s[1]=t):t=s[1];let n=t;return(0,i.useGLTF)(n)}function I(e){let s,n,i,a,o=(0,r.c)(9),{color:A,label:l}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("boxGeometry",{args:[10,10,10]}),o[0]=s):s=o[0],o[1]!==A?(n=(0,t.jsx)("meshStandardMaterial",{color:A,wireframe:!0}),o[1]=A,o[2]=n):n=o[2],o[3]!==A||o[4]!==l?(i=l?(0,t.jsx)(C.FloatingLabel,{color:A,children:l}):null,o[3]=A,o[4]=l,o[5]=i):i=o[5],o[6]!==n||o[7]!==i?(a=(0,t.jsxs)("mesh",{children:[s,n,i]}),o[6]=n,o[7]=i,o[8]=a):a=o[8],a}function g(e){let s,n=(0,r.c)(4),{color:i,label:a}=e,{debugMode:o}=(0,B.useDebug)();return n[0]!==i||n[1]!==o||n[2]!==a?(s=o?(0,t.jsx)(I,{color:i,label:a}):null,n[0]=i,n[1]=o,n[2]=a,n[3]=s):s=n[3],s}let D=new Set(["octahedron.dts"]);function R(e){let s,n,i,a,o=(0,r.c)(6),{label:A}=e,{debugMode:l}=(0,B.useDebug)();return l?(o[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("icosahedronGeometry",{args:[1,1]}),n=(0,t.jsx)("meshBasicMaterial",{color:"cyan",wireframe:!0}),o[0]=s,o[1]=n):(s=o[0],n=o[1]),o[2]!==A?(i=A?(0,t.jsx)(C.FloatingLabel,{color:"cyan",children:A}):null,o[2]=A,o[3]=i):i=o[3],o[4]!==i?(a=(0,t.jsxs)("mesh",{children:[s,n,i]}),o[4]=i,o[5]=a):a=o[5],a):null}let T=(0,s.memo)(function(e){let i,a,o,A,l,B=(0,r.c)(17),{loadingColor:u,streamEntity:C,children:h}=e,d=void 0===u?"yellow":u,{object:f,shapeName:m}=(0,c.useShapeInfo)();if(!m){let e,r=`${f?._id}: `;return B[0]!==r?(e=(0,t.jsx)(g,{color:"orange",label:r}),B[0]=r,B[1]=e):e=B[1],e}if(D.has(m.toLowerCase())){let e,r=`${f?._id}: ${m}`;return B[2]!==r?(e=(0,t.jsx)(R,{label:r}),B[2]=r,B[3]=e):e=B[3],e}let p=`${f?._id}: ${m}`;return B[4]!==p?(i=(0,t.jsx)(g,{color:"red",label:p}),B[4]=p,B[5]=i):i=B[5],B[6]!==d?(a=(0,t.jsx)(I,{color:d}),B[6]=d,B[7]=a):a=B[7],B[8]!==C?(o=(0,t.jsx)(J,{streamEntity:C}),B[8]=C,B[9]=o):o=B[9],B[10]!==h||B[11]!==a||B[12]!==o?(A=(0,t.jsxs)(s.Suspense,{fallback:a,children:[o,h]}),B[10]=h,B[11]=a,B[12]=o,B[13]=A):A=B[13],B[14]!==i||B[15]!==A?(l=(0,t.jsx)(n.ErrorBoundary,{fallback:i,children:A}),B[14]=i,B[15]=A,B[16]=l):l=B[16],l}),H=(0,s.memo)(function({gltf:e,streamEntity:r}){let{object:n,shapeName:i}=(0,c.useShapeInfo)(),{debugMode:o}=(0,B.useDebug)(),{animationEnabled:d}=(0,B.useSettings)(),f=(0,u.useEngineSelector)(e=>e.runtime.runtime),{clonedScene:m,mixer:F,clipsByName:E,visNodesBySequence:G,iflMeshes:I}=(0,s.useMemo)(()=>{let t=l.clone(e.scene),r=[];for(let{mesh:e,hasVisSequence:s}of(t.traverse(e=>{if(!e.isMesh||!e.material)return;let t=Array.isArray(e.material)?e.material[0]:e.material;if(!t?.userData)return;let s=new Set(t.userData.flag_names??[]),n=t.userData.resource_path;if(s.has("IflMaterial")&&n){let t=e.userData,s=t?.ifl_sequence?String(t.ifl_sequence).toLowerCase():void 0,i=t?.ifl_duration?Number(t.ifl_duration):void 0,a=t?.ifl_sequence?!!t.ifl_cyclic:void 0,o=t?.ifl_tool_begin!=null?Number(t.ifl_tool_begin):void 0;r.push({mesh:e,iflPath:`textures/${n}.ifl`,hasVisSequence:!!t?.vis_sequence,iflSequence:s,iflDuration:i,iflCyclic:a,iflToolBegin:o})}}),(0,p.processShapeScene)(t,i??void 0),r))s||(e.visible=!0);let s=new Map;t.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let r=t.vis_keyframes,n=t.vis_duration,i=(t.vis_sequence??"").toLowerCase();if(!i||!Array.isArray(r)||r.length<=1||!n||n<=0)return;let a=s.get(i);a||(a=[],s.set(i,a)),a.push({mesh:e,keyframes:r,duration:n,cyclic:!!t.vis_cyclic})});let n=new Map;for(let t of e.animations)n.set(t.name.toLowerCase(),t);let a=n.size>0?new A.AnimationMixer(t):null;return{clonedScene:t,mixer:a,clipsByName:n,visNodesBySequence:s,iflMeshes:r}},[e]),g=(0,s.useRef)(new Map),D=(0,s.useRef)(new Map),R=(0,s.useRef)([]),T=(0,s.useRef)(0);(0,s.useRef)(d).current=d;let H=(0,s.useRef)(r);H.current=r;let J=(0,s.useRef)(null),b=(0,s.useRef)(null),y=(0,s.useRef)(void 0);(0,s.useEffect)(()=>{for(let e of(R.current=[],D.current.clear(),I))(0,h.loadIflAtlas)(e.iflPath).then(t=>{let r=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;r&&(r.map=t.texture,r.needsUpdate=!0);let s={atlas:t,sequenceName:e.iflSequence,sequenceDuration:e.iflDuration,cyclic:e.iflCyclic,toolBegin:e.iflToolBegin};R.current.push(s),D.current.set(e.mesh,t)}).catch(t=>{console.warn(`[ShapeModel] Failed to load IFL atlas for ${e.iflPath}:`,t)})},[I]);let L=(0,s.useMemo)(()=>{let t=new Map,r=e.scene.userData?.dts_sequence_names,s=e.scene.userData?.dts_sequence_cyclic;if("string"==typeof r&&"string"==typeof s)try{let e=JSON.parse(r),n=JSON.parse(s);for(let r=0;r{let e=g.current,t=null==H.current;function r(t,r){let n=r.toLowerCase();s(t);let i=E.get(n),a=G.get(n),o={sequence:n,startTime:M()};if(i&&F){let e=F.clipAction(i);L.get(n)??!0?e.setLoop(A.LoopRepeat,1/0):(e.setLoop(A.LoopOnce,1),e.clampWhenFinished=!0),e.reset().play(),o.action=e}if(a){for(let e of a)!function(e){if(e.mesh.visible=!0,e.mesh.material?.isMeshStandardMaterial){let t=e.mesh.material,r=(0,p.replaceWithShapeMaterial)(t,e.mesh.userData?.vis??0);e.mesh.material=r.material}e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.transparent=!0,e.mesh.material.depthWrite=!1);let t=D.current.get(e.mesh);t&&e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.map=t.texture,e.mesh.material.needsUpdate=!0)}(e);o.visNodes=a}e.set(t,o)}function s(t){let r=e.get(t);if(r){if(r.action&&r.action.stop(),r.visNodes)for(let e of r.visNodes)e.mesh.visible=!1,e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.opacity=e.keyframes[0]);e.delete(t)}}if(J.current=r,b.current=s,!t)return()=>{for(let t of(J.current=null,b.current=null,y.current=void 0,[...e.keys()]))s(t)};let i=[];for(let[t,a]of(f&&(i.push(f.$.onMethodCalled("ShapeBase","playThread",(e,t,s)=>{e._id===n?._id&&r(Number(t),String(s))})),i.push(f.$.onMethodCalled("ShapeBase","stopThread",(e,t)=>{e._id===n?._id&&s(Number(t))})),i.push(f.$.onMethodCalled("ShapeBase","pauseThread",(t,r)=>{if(t._id!==n?._id)return;let s=e.get(Number(r));s?.action&&(s.action.paused=!0)}))),[[0,"power"],[1,"ambient"]]))(E.has(a)||G.has(a))&&r(t,a);return()=>{for(let t of(i.forEach(e=>e()),J.current=null,b.current=null,y.current=void 0,[...e.keys()]))s(t)}},[F,E,G,L,n,f]);let x=(0,s.useMemo)(()=>{let t=e.scene.userData?.dts_sequence_names;if("string"==typeof t)try{return JSON.parse(t).map(e=>e.toLowerCase())}catch{}return e.animations.map(e=>e.name.toLowerCase())},[e]);return(0,a.useFrame)((e,t)=>{let r=g.current,s=null!=H.current,n=u.engineStore.getState().playback,i=s?"playing"===n.status?t*n.rate:0:t,a=H.current?.threads,o=y.current;if(a!==o){let e=J.current,t=b.current;if(e&&t){y.current=a;let s=[];if(a)for(let e of a)s[e.index]=e;let n=[];if(o)for(let e of o)n[e.index]=e;let i=Math.max(s.length,n.length);for(let a=0;a0)for(let e of(T.current+=i,l)){if(!d){(0,h.updateAtlasFrame)(e.atlas,0);continue}if(e.sequenceName&&e.sequenceDuration){let t=0;for(let[,s]of r)if(s.sequence===e.sequenceName){let r=M()-s.startTime,n=e.sequenceDuration;t=(e.cyclic?r/n%1:Math.min(r/n,1))*n+(e.toolBegin??0);break}(0,h.updateAtlasFrame)(e.atlas,(0,h.getFrameIndexForTime)(e.atlas,t))}else(0,h.updateAtlasFrame)(e.atlas,(0,h.getFrameIndexForTime)(e.atlas,T.current))}}),(0,t.jsxs)("group",{rotation:[0,Math.PI/2,0],children:[(0,t.jsx)("primitive",{object:m}),o?(0,t.jsxs)(C.FloatingLabel,{children:[n?._id,": ",i]}):null]})});function J(e){let s,n=(0,r.c)(3),{streamEntity:i}=e,{shapeName:a}=(0,c.useShapeInfo)(),o=G(a);return n[0]!==o||n[1]!==i?(s=(0,t.jsx)(H,{gltf:o,streamEntity:i}),n[0]=o,n[1]=i,n[2]=s):s=n[2],s}}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/1cf33c843f96e1c9.js b/docs/_next/static/chunks/1cf33c843f96e1c9.js deleted file mode 100644 index f20da4c4..00000000 --- a/docs/_next/static/chunks/1cf33c843f96e1c9.js +++ /dev/null @@ -1 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66438,e=>{e.v({Bullet:"GuiMarkup-module__CLgNnq__Bullet",GuiMarkup:"GuiMarkup-module__CLgNnq__GuiMarkup"})},41973,e=>{e.v({Body:"MapInfoDialog-module__m0lXla__Body",CloseButton:"MapInfoDialog-module__m0lXla__CloseButton",Dialog:"MapInfoDialog-module__m0lXla__Dialog",Footer:"MapInfoDialog-module__m0lXla__Footer",Hint:"MapInfoDialog-module__m0lXla__Hint",Left:"MapInfoDialog-module__m0lXla__Left",MapBlurb:"MapInfoDialog-module__m0lXla__MapBlurb",MapMeta:"MapInfoDialog-module__m0lXla__MapMeta",MapPlanet:"MapInfoDialog-module__m0lXla__MapPlanet",MapQuote:"MapInfoDialog-module__m0lXla__MapQuote",MusicButton:"MapInfoDialog-module__m0lXla__MusicButton",MusicTrack:"MapInfoDialog-module__m0lXla__MusicTrack",MusicTrackName:"MapInfoDialog-module__m0lXla__MusicTrackName",Overlay:"MapInfoDialog-module__m0lXla__Overlay",PreviewImage:"MapInfoDialog-module__m0lXla__PreviewImage",PreviewImageFloating:"MapInfoDialog-module__m0lXla__PreviewImageFloating",Section:"MapInfoDialog-module__m0lXla__Section",SectionTitle:"MapInfoDialog-module__m0lXla__SectionTitle",Title:"MapInfoDialog-module__m0lXla__Title"})},94247,e=>{"use strict";var t=e.i(43476),a=e.i(932),l=e.i(71645),n=e.i(11152),r=e.i(66027),i=e.i(12979),s=e.i(91996),o=e.i(66438);let u=new Set(["spop","spush","lmargin","font","color","bitmap","a","/a"]),c=new Map;function m(e){let l,n=(0,a.c)(5),{name:r}=e;n[0]!==r?(l=function(e){let t;if(c.has(e))return c.get(e);try{t=(0,i.getUrlForPath)((0,s.getStandardTextureResourceKey)(`textures/gui/${e}`))}catch{t=null}return c.set(e,t),t}(r),n[0]=r,n[1]=l):l=n[1];let u=l;if(u){let e;return n[2]!==u?(e=(0,t.jsx)("img",{src:u,alt:"",className:o.default.Bitmap}),n[2]=u,n[3]=e):e=n[3],e}if(/bullet/i.test(r)){let e;return n[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("span",{className:o.default.Bullet,children:"•"}),n[4]=e):e=n[4],e}return null}let p=/<(?:font|color|bitmap|just|lmargin|a):/i;function d(e){let n,r,i=(0,a.c)(4),{markup:s}=e;i[0]!==s?(n=function(e){let a=e.split(/<([^><]+)>/g).map((e,t)=>{if(t%2==0)return e?{type:"text",value:e}:null;{let[t,...a]=e.split(":");return u.has(t.toLowerCase())?{type:"tag",name:t,args:a}:{type:"text",value:`<${e}>`}}}).filter(e=>null!=e),n={type:"span",source:"root",style:{},children:[]},r=n,i=[r],s=e=>null!=e.children&&e.children.some(e=>"string"==typeof e||s(e));for(let e of a)switch(e.type){case"text":r.children.push(e.value);break;case"tag":switch(e.name){case"spush":{let e={type:"span",source:"spush",style:{},children:[]};r.children.push(e),r=e,i.push(r);break}case"spop":if("root"!==r.source){let e=i.pop();for(;"spush"!==e.source;)e=i.pop();r=i[i.length-1]}break;case"lmargin":break;case"font":{let t=function(e){let[t,a]=e;return{fontDescription:t,fontSize:a?Math.max(11,Math.min(parseInt(a.trim(),10),16)):void 0}}(e.args).fontSize;if(s(r)){let e={type:"span",source:"spush",style:{fontSize:t},children:[]};r.children.push(e),r=e,i.push(r)}else r.style.fontSize=t;break}case"color":if(s(r)){let t={type:"span",source:"spush",style:{color:`#${e.args[0].trim()}`},children:[]};r.children.push(t),r=t,i.push(r)}else r.style.color=`#${e.args[0].trim()}`;break;case"bitmap":{let t={type:"bitmap",value:e.args[0]};r.children.push(t);break}case"a":{let t=e.args[0].trim().split(" "),a=2===t.length&&"wwwlink"===t[0]?t[1]:t[0],l={type:"a",source:"a",value:`http://${a}`,style:{},children:[]};r.children.push(l),r=l,i.push(r);break}case"/a":{let e=i.pop();for(;"a"!==e.source;)e=i.pop();r=i[i.length-1]}}}return function e(a){switch(a.type){case"span":return l.default.createElement("span",{style:0===Object.keys(a.style).length?void 0:a.style},...a.children.map(t=>"string"==typeof t?t:e(t)));case"a":return l.default.createElement("a",{href:a.value,style:0===Object.keys(a.style).length?void 0:a.style,rel:"noopener noreferrer",target:"_blank"},...a.children.map(t=>"string"==typeof t?t:e(t)));case"bitmap":return(0,t.jsx)(m,{name:a.value})}}(n)}(s),i[0]=s,i[1]=n):n=i[1];let c=n;return i[2]!==c?(r=(0,t.jsx)("div",{className:o.default.GuiMarkup,children:c}),i[2]=c,i[3]=r):r=i[3],r}var f=e.i(41973);function h(e){let n,r,i,s=(0,a.c)(7),{src:o,alt:u,className:c}=e,m=void 0===c?f.default.PreviewImage:c,[p,d]=(0,l.useState)(null);return(s[0]!==o?(n=()=>{let e,t=!1;return fetch(o).then(M).then(y).then(g).then(a=>{!t&&a&&d(e=URL.createObjectURL(a))}).catch(_),()=>{t=!0,e&&URL.revokeObjectURL(e)}},r=[o],s[0]=o,s[1]=n,s[2]=r):(n=s[1],r=s[2]),(0,l.useEffect)(n,r),p)?(s[3]!==u||s[4]!==m||s[5]!==p?(i=(0,t.jsx)("img",{src:p,alt:u,className:m}),s[3]=u,s[4]=m,s[5]=p,s[6]=i):i=s[6],i):null}function _(){}function g(e){return new Promise(t=>{let a=document.createElement("canvas");a.width=e.width,a.height=e.height,a.getContext("2d")?.drawImage(e,0,0),e.close(),a.toBlob(t)})}function y(e){return createImageBitmap(e,{colorSpaceConversion:"none"})}function M(e){return e.blob()}function v(e){let r,s,o,u,c,m,p,d,h,_,g,y=(0,a.c)(22),{track:M}=e,[v,x]=(0,l.useState)(!1),[b,j]=(0,l.useState)(!0),k=(0,l.useRef)(null);y[0]!==M?(r=M.toLowerCase(),y[0]=M,y[1]=r):r=y[1];let I=`${i.RESOURCE_ROOT_URL}music/${r}.mp3`;y[2]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{k.current?.pause()},o=[],y[2]=s,y[3]=o):(s=y[2],o=y[3]),(0,l.useEffect)(s,o),y[4]!==v?(u=()=>{let e=k.current;e&&(v?e.pause():e.play().catch(()=>j(!1)))},y[4]=v,y[5]=u):u=y[5];let w=u;return y[6]===Symbol.for("react.memo_cache_sentinel")?(c=()=>x(!0),m=()=>x(!1),p=()=>j(!1),y[6]=c,y[7]=m,y[8]=p):(c=y[6],m=y[7],p=y[8]),y[9]!==I?(d=(0,t.jsx)("audio",{ref:k,src:I,loop:!0,onPlay:c,onPause:m,onError:p}),y[9]=I,y[10]=d):d=y[10],y[11]!==M?(h=(0,t.jsx)("span",{className:f.default.MusicTrackName,children:M}),y[11]=M,y[12]=h):h=y[12],y[13]!==b||y[14]!==v||y[15]!==w?(_=b&&(0,t.jsx)("button",{className:f.default.MusicButton,onClick:w,"aria-label":v?"Pause music":"Play music",children:v?(0,t.jsx)(n.FaVolumeUp,{}):(0,t.jsx)(n.FaVolumeMute,{})}),y[13]=b,y[14]=v,y[15]=w,y[16]=_):_=y[16],y[17]!==v||y[18]!==_||y[19]!==d||y[20]!==h?(g=(0,t.jsxs)("div",{className:f.default.MusicTrack,"data-playing":v,children:[d,h,_]}),y[17]=v,y[18]=_,y[19]=d,y[20]=h,y[21]=g):g=y[21],g}function x(e){var n,o,u;let c,m,_,g,y,M,x,I,w,N,B,S,D,P,C,L,T,X,E,R,U,O,F,$,K,Q,q,G,z,A,H,V,J,W,Y,Z,ee,et=(0,a.c)(102),{open:ea,onClose:el,missionName:en,missionType:er}=e,{data:ei}=((ee=(0,a.c)(2))[0]!==en?(Z={queryKey:["parsedMission",en],queryFn:()=>(0,i.loadMission)(en)},ee[0]=en,ee[1]=Z):Z=ee[1],(0,r.useQuery)(Z)),es=(0,l.useRef)(null);if(et[0]!==ea?(c=()=>{if(ea){es.current?.focus();try{document.exitPointerLock()}catch{}}},m=[ea],et[0]=ea,et[1]=c,et[2]=m):(c=et[1],m=et[2]),(0,l.useEffect)(c,m),et[3]!==el||et[4]!==ea?(_=()=>{if(!ea)return;let e=e=>{if("KeyI"===e.code||"Escape"===e.key)el();else if("k"===e.key&&(e.metaKey||e.ctrlKey))return void el();e.stopImmediatePropagation()};return window.addEventListener("keydown",e,{capture:!0}),window.addEventListener("keyup",k,{capture:!0}),()=>{window.removeEventListener("keydown",e,{capture:!0}),window.removeEventListener("keyup",k,{capture:!0})}},g=[ea,el],et[3]=el,et[4]=ea,et[5]=_,et[6]=g):(_=et[5],g=et[6]),(0,l.useEffect)(_,g),!ea)return null;et[7]!==ei?(y=ei?function(e){for(let t of e.body){if("ObjectDeclaration"!==t.type)continue;let{instanceName:e,body:a}=t;if(e&&"Identifier"===e.type&&"missiongroup"===e.name.toLowerCase()){let e={};for(let t of a){if("Assignment"!==t.type)continue;let{target:a,value:l}=t;"Identifier"===a.type&&"StringLiteral"===l.type&&(e[a.name.toLowerCase()]=l.value)}return e}}return{}}(ei.ast):{},et[7]=ei,et[8]=y):y=et[8];let eo=y;et[9]!==en||et[10]!==ei?(M=ei?function(e,t){if(e)try{let t=(0,s.getStandardTextureResourceKey)(`textures/gui/${e}`);return(0,i.getUrlForPath)(t)}catch{}try{let e=(0,s.getStandardTextureResourceKey)(`textures/gui/Load_${t}`);return(0,i.getUrlForPath)(e)}catch{}return null}(ei.bitmap,en):null,et[9]=en,et[10]=ei,et[11]=M):M=et[11];let eu=M,ec=ei?.displayName??en;et[12]!==er?(x=er.toLowerCase(),et[12]=er,et[13]=x):x=et[13];let em="singleplayer"===x,ep=eo.musictrack;if(et[14]!==eu||et[15]!==ec||et[16]!==em||et[17]!==er||et[18]!==el||et[19]!==ei){let e,a,l,r,i,s,c=ei?.missionString?(n=ei.missionString,s=er.toUpperCase(),n.split("\n").flatMap(e=>{let t=e.match(/^\[([^\]]+)\]/);return t&&!t[1].toUpperCase().split(/\s+/).includes(s)?[]:[e.replace(/^\[[^\]]+\]/,"")]}).join("\n")):null;if(et[38]!==ei?.missionQuote){if(o=r=ei?.missionQuote?.trim()??"",l="",e="",!(a=p.test(o)))for(let t of r.split("\n")){let a=t.trim();a.match(/^--[^-]/)?e=a.replace(/^-+\s*/,"").trim():a&&(l+=(l?"\n":"")+a)}et[38]=ei?.missionQuote,et[39]=e,et[40]=a,et[41]=l,et[42]=r}else e=et[39],a=et[40],l=et[41],r=et[42];(O=f.default.Overlay,F=el,P=es,C=f.default.Dialog,L=j,T=b,X="dialog",E="true",R="Map Information",U=-1,D=f.default.Body,$=f.default.Left,et[43]!==eu||et[44]!==ec||et[45]!==em?(K=eu&&em&&(0,t.jsx)(h,{className:f.default.PreviewImageFloating,src:eu,alt:`${ec} preview`},eu),et[43]=eu,et[44]=ec,et[45]=em,et[46]=K):K=et[46],et[47]!==ec?(I=(0,t.jsx)("h1",{className:f.default.Title,children:ec}),et[47]=ec,et[48]=I):I=et[48],et[49]!==ei?(i=ei?.planetName&&(0,t.jsx)("span",{className:f.default.MapPlanet,children:ei.planetName}),et[49]=ei,et[50]=i):i=et[50],et[51]!==i?(w=(0,t.jsx)("div",{className:f.default.MapMeta,children:i}),et[51]=i,et[52]=w):w=et[52],et[53]!==e||et[54]!==a||et[55]!==l||et[56]!==r?(N=a?(0,t.jsx)("blockquote",{className:f.default.MapQuote,children:(0,t.jsx)(d,{markup:r})}):l?(0,t.jsxs)("blockquote",{className:f.default.MapQuote,children:[(0,t.jsx)("p",{children:l}),e&&(0,t.jsxs)("cite",{children:["— ",e]})]}):null,et[53]=e,et[54]=a,et[55]=l,et[56]=r,et[57]=N):N=et[57],et[58]!==ei)?(B=ei?.missionBlurb&&(0,t.jsx)("div",{className:f.default.MapBlurb,children:(u=ei.missionBlurb,p.test(u))?(0,t.jsx)(d,{markup:ei.missionBlurb.trim()}):ei.missionBlurb.trim()}),et[58]=ei,et[59]=B):B=et[59],S=c&&c.trim()&&(0,t.jsx)("div",{className:f.default.Section,children:(0,t.jsx)(d,{markup:c})}),et[14]=eu,et[15]=ec,et[16]=em,et[17]=er,et[18]=el,et[19]=ei,et[20]=I,et[21]=w,et[22]=N,et[23]=B,et[24]=S,et[25]=D,et[26]=P,et[27]=C,et[28]=L,et[29]=T,et[30]=X,et[31]=E,et[32]=R,et[33]=U,et[34]=O,et[35]=F,et[36]=$,et[37]=K}else I=et[20],w=et[21],N=et[22],B=et[23],S=et[24],D=et[25],P=et[26],C=et[27],L=et[28],T=et[29],X=et[30],E=et[31],R=et[32],U=et[33],O=et[34],F=et[35],$=et[36],K=et[37];return et[60]!==ei?(Q=ei?.missionBriefing&&(0,t.jsxs)("div",{className:f.default.Section,children:[(0,t.jsx)("h2",{className:f.default.SectionTitle,children:"Mission Briefing"}),(0,t.jsx)(d,{markup:ei.missionBriefing})]}),et[60]=ei,et[61]=Q):Q=et[61],et[62]!==ep?(q=ep&&(0,t.jsx)(v,{track:ep}),et[62]=ep,et[63]=q):q=et[63],et[64]!==I||et[65]!==w||et[66]!==N||et[67]!==B||et[68]!==S||et[69]!==Q||et[70]!==q||et[71]!==$||et[72]!==K?(G=(0,t.jsxs)("div",{className:$,children:[K,I,w,N,B,S,Q,q]}),et[64]=I,et[65]=w,et[66]=N,et[67]=B,et[68]=S,et[69]=Q,et[70]=q,et[71]=$,et[72]=K,et[73]=G):G=et[73],et[74]!==eu||et[75]!==ec||et[76]!==em?(z=eu&&!em&&(0,t.jsx)(h,{src:eu,alt:`${ec} preview`},eu),et[74]=eu,et[75]=ec,et[76]=em,et[77]=z):z=et[77],et[78]!==D||et[79]!==G||et[80]!==z?(A=(0,t.jsxs)("div",{className:D,children:[G,z]}),et[78]=D,et[79]=G,et[80]=z,et[81]=A):A=et[81],et[82]!==el?(H=(0,t.jsx)("button",{className:f.default.CloseButton,onClick:el,children:"Close"}),et[82]=el,et[83]=H):H=et[83],et[84]===Symbol.for("react.memo_cache_sentinel")?(V=(0,t.jsx)("span",{className:f.default.Hint,children:"I or Esc to close"}),et[84]=V):V=et[84],et[85]!==H?(J=(0,t.jsxs)("div",{className:f.default.Footer,children:[H,V]}),et[85]=H,et[86]=J):J=et[86],et[87]!==P||et[88]!==C||et[89]!==L||et[90]!==T||et[91]!==X||et[92]!==E||et[93]!==R||et[94]!==U||et[95]!==A||et[96]!==J?(W=(0,t.jsxs)("div",{ref:P,className:C,onClick:L,onKeyDown:T,role:X,"aria-modal":E,"aria-label":R,tabIndex:U,children:[A,J]}),et[87]=P,et[88]=C,et[89]=L,et[90]=T,et[91]=X,et[92]=E,et[93]=R,et[94]=U,et[95]=A,et[96]=J,et[97]=W):W=et[97],et[98]!==O||et[99]!==F||et[100]!==W?(Y=(0,t.jsx)("div",{className:O,onClick:F,children:W}),et[98]=O,et[99]=F,et[100]=W,et[101]=Y):Y=et[101],Y}function b(e){return e.stopPropagation()}function j(e){return e.stopPropagation()}function k(e){e.stopImmediatePropagation()}e.s(["MapInfoDialog",()=>x],94247)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/1fe5719635cf5984.js b/docs/_next/static/chunks/1fe5719635cf5984.js new file mode 100644 index 00000000..7f3a7244 --- /dev/null +++ b/docs/_next/static/chunks/1fe5719635cf5984.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,29055,e=>{"use strict";var t=e.i(43476),n=e.i(71645),i=e.i(15080),a=e.i(71753),r=e.i(90072),o=e.i(12979),s=e.i(51434),l=e.i(79123),u=e.i(89887);e.i(13876);var c=e.i(58647);let m=new Map,d=new Map;function f(e,t=1){d.set(e,t)}function p(e){d.delete(e)}let h=0;function S(){return h}function g(){for(let[e]of(h++,d)){try{e.stop()}catch{}try{e.disconnect()}catch{}}d.clear()}function y(e,t){let n=t(e),i=n?.filename;if(!i)return null;let a=i.endsWith(".wav")?i:`${i}.wav`,r=n.description,o=null!=r?t(r):void 0,s=o?.is3D??!0,l=o?.isLooping??!1,u=o?.referenceDistance??20;return{filename:a,is3D:s,isLooping:l,refDist:u,maxDist:o?.maxDistance??100,volume:o?.volume??1}}function T(e,t,n,i,a){let s;try{s=(0,o.audioToUrl)(e.filename)}catch{return}let l=c.engineStore.getState().playback.rate,u=h;I(s,n,n=>{if(u===h)try{if(e.is3D&&a){let o=new r.PositionalAudio(t);o.setBuffer(n),o.setDistanceModel("inverse"),o.setRefDistance(e.refDist),o.setMaxDistance(e.maxDist),o.setRolloffFactor(1),o.setVolume(e.volume),o.setPlaybackRate(l),i&&o.position.copy(i),a.add(o),d.set(o,1),o.play(),o.source.onended=()=>{d.delete(o);try{o.disconnect()}catch{}a.remove(o)}}else{let i=new r.Audio(t);i.setBuffer(n),i.setVolume(e.volume),i.setPlaybackRate(l),d.set(i,1),i.play(),i.source.onended=()=>{d.delete(i);try{i.disconnect()}catch{}}}}catch{}})}function I(e,t,n){m.has(e)?n(m.get(e)):t.load(e,t=>{m.set(e,t),n(t)},void 0,t=>{console.error("Audio load error",e,t)})}c.engineStore.subscribe(e=>e.playback.rate,e=>{for(let[t,n]of d)try{t.setPlaybackRate(n*e)}catch{}});let w=(0,n.memo)(function({entity:e}){let{debugMode:c}=(0,l.useDebug)(),m=e.audioFileName??"",d=e.audioVolume??1,f=e.audioMinDistance??1,p=e.audioMaxDistance??1,h=e.audioMinLoopGap??0,S=e.audioMaxLoopGap??0,g=e.audioIs3D??!0?1:0,y=e.audioIsLooping??!0,[T,w,A]=e.position??[0,0,0],{scene:M,camera:k}=(0,i.useThree)(),{audioLoader:N,audioListener:v}=(0,s.useAudio)(),{audioEnabled:b}=(0,l.useSettings)(),x=(0,n.useRef)(null),R=(0,n.useRef)(null),_=(0,n.useRef)(null),L=(0,n.useRef)(!1),C=(0,n.useRef)(!1),O=(0,n.useRef)(new r.Vector3(T,w,A)),E=(0,n.useRef)(0),D=()=>{null!=R.current&&(clearTimeout(R.current),R.current=null),null!=_.current&&(clearTimeout(_.current),_.current=null)};(0,n.useEffect)(()=>{let e;if(N&&v){if(E.current++,g){let t=new r.PositionalAudio(v);t.position.copy(O.current),t.setDistanceModel("inverse"),t.setRefDistance(f),t.setMaxDistance(p),t.setRolloffFactor(1),t.setVolume(d),e=t,M.add(e)}else(e=new r.Audio(v)).setVolume(d);return x.current=e,()=>{D();try{e.stop()}catch{}try{e.disconnect()}catch{}g&&M.remove(e),x.current=null,L.current=!1,C.current=!1}}},[N,v,g,f,p,d,M]);let P=(e,t)=>{if(y)if(h>0||S>0){let n=Math.max(0,h),i=Math.max(n,S),a=n===i?n:Math.random()*(i-n)+n;e.loop=!1;let r=()=>{t===E.current&&(!1===e.isPlaying?R.current=setTimeout(()=>{if(t===E.current)try{e.play(),P(e,t)}catch{}},a):_.current=setTimeout(r,100))};_.current=setTimeout(r,100)}else e.setLoop(!0)},F=e=>{if(!N)return;let t=E.current;if(L.current)try{e.isPlaying||(e.play(),P(e,t))}catch{}else{let n;try{n=(0,o.audioToUrl)(m)}catch{return}I(n,N,n=>{if(t===E.current&&!e.buffer){e.setBuffer(n),L.current=!0;try{e.play(),P(e,t)}catch{}}})}};return(0,n.useEffect)(()=>{let e=x.current;e&&!g&&b&&m&&F(e)},[b,g,m,N,v]),(0,a.useFrame)(()=>{let e=x.current;if(!e||!g||!b||!m)return;let t=k.position.distanceTo(O.current),n=C.current,i=t<=p;if(i&&!n)C.current=!0,F(e);else if(!i&&n){C.current=!1,D();try{e.stop()}catch{}}}),(0,n.useEffect)(()=>{let e=x.current;if(e&&!b){D();try{e.stop()}catch{}C.current=!1}},[b]),c?(0,t.jsxs)("mesh",{position:O.current,children:[(0,t.jsx)("sphereGeometry",{args:[f,12,12]}),(0,t.jsx)("meshBasicMaterial",{color:"#00ff00",wireframe:!0,opacity:.05,transparent:!0,toneMapped:!1}),(0,t.jsx)(u.FloatingLabel,{color:"#00ff00",position:[0,f+1,0],children:m})]}):null});e.s(["AudioEmitter",0,w,"audioBufferCache",0,m,"getCachedAudioBuffer",()=>I,"getSoundGeneration",()=>S,"playOneShotSound",()=>T,"resolveAudioProfile",()=>y,"stopAllTrackedSounds",()=>g,"trackSound",()=>f,"untrackSound",()=>p])},9721,e=>{"use strict";var t=e.i(43476),n=e.i(932),i=e.i(71645),a=e.i(71753),r=e.i(90072),o=e.i(82816),s=e.i(85557);class l{states;seqIndexToName;currentStateIndex=0;delayTime=0;lastFireCount=-1;spinTimeScale=0;constructor(e,t){this.states=e,this.seqIndexToName=t,e.length>0&&(this.delayTime=e[0].timeoutValue??0)}get stateIndex(){return this.currentStateIndex}reset(){this.currentStateIndex=0,this.delayTime=this.states.length>0?this.states[0].timeoutValue??0:0,this.lastFireCount=-1}tick(e,t){if(0===this.states.length)return{sequenceName:null,isFiring:!1,spinTimeScale:0,reverse:!1,scaleAnimation:!1,timeoutValue:0,transitioned:!1,soundDataBlockIds:[],stateIndex:-1};let n=this.lastFireCount>=0&&t.fireCount!==this.lastFireCount;this.lastFireCount=t.fireCount;let i=[];if(n){let e=this.states.findIndex(e=>e.fire);if(e>=0&&e!==this.currentStateIndex){this.currentStateIndex=e,this.delayTime=this.states[e].timeoutValue??0;let t=this.states[e].soundDataBlockId;t>=0&&i.push(t)}}this.delayTime-=e;let a=n,r=this.evaluateTickTransitions(t),o=0;for(;r>=0&&o<32;){if(o++,a=!0,r===this.currentStateIndex){this.delayTime=this.states[r].timeoutValue??0;break}let e=this.states[this.currentStateIndex].spin,n=this.delayTime;this.currentStateIndex=r;let s=this.states[r].timeoutValue??0;this.delayTime=s;let l=this.states[r].soundDataBlockId;switch(l>=0&&i.push(l),this.states[r].spin){case 1:this.spinTimeScale=0;break;case 4:this.spinTimeScale=1;break;case 2:3===e&&s>0&&(this.delayTime*=1-n/s);break;case 3:2===e&&s>0&&(this.delayTime*=1-n/s)}r=this.evaluateEntryTransitions(t)}let s=this.states[this.currentStateIndex],l=s.timeoutValue??0;switch(s.spin){case 1:this.spinTimeScale=0;break;case 2:this.spinTimeScale=l>0?Math.max(0,1-this.delayTime/l):1;break;case 4:this.spinTimeScale=1;break;case 3:this.spinTimeScale=l>0?Math.max(0,this.delayTime/l):0}return{sequenceName:this.resolveSequenceName(s),isFiring:s.fire,spinTimeScale:this.spinTimeScale,reverse:!s.direction,scaleAnimation:s.scaleAnimation,timeoutValue:s.timeoutValue??0,transitioned:a,soundDataBlockIds:i,stateIndex:this.currentStateIndex}}evaluateTickTransitions(e){let t=this.states[this.currentStateIndex],n=this.delayTime<=0;if(!(n||!t.waitForTimeout))return -1;let i=this.evaluateConditions(t,e);if(-1!==i)return i;if(n){let e=t.transitionOnTimeout;if(-1!==e)return e}return -1}evaluateEntryTransitions(e){let t=this.states[this.currentStateIndex];return this.evaluateConditions(t,e)}evaluateConditions(e,t){let n=t.loaded?e.transitionOnLoaded:e.transitionOnNotLoaded;if(-1!==n)return n;let i=t.ammo?e.transitionOnAmmo:e.transitionOnNoAmmo;if(-1!==i)return i;let a=t.target?e.transitionOnTarget:e.transitionOnNoTarget;if(-1!==a)return a;let r=t.wet?e.transitionOnWet:e.transitionOnNotWet;if(-1!==r)return r;let o=t.triggerDown?e.transitionOnTriggerDown:e.transitionOnTriggerUp;return -1!==o?o:-1}resolveSequenceName(e){return null==e.sequence||e.sequence<0?null:this.seqIndexToName[e.sequence]??null}}var u=e.i(43595),c=e.i(91907),m=e.i(87297),d=e.i(51434),f=e.i(29055),p=e.i(12979),h=e.i(79123);e.i(13876);var S=e.i(58647),g=e.i(93784);let y=["root","run","back","side","fall","jump","land"];function T(e,t,n){let i=e.current;if(i){(0,f.untrackSound)(i);try{i.stop()}catch{}try{i.disconnect()}catch{}n?.remove(i),e.current=null,t.current=-1}}function I(e){let l,d,f,p,h,T,I,b,x,R,_,L,C,O,E,D,P,F,B,q,V=(0,n.c)(47),{entity:j}=e,W=(0,S.useEngineStoreApi)(),U=j.shapeName??j.dataBlock,G=(0,c.useStaticShape)(U);V[0]!==U?(l=e=>{let t=U?.toLowerCase();return t?e.runtime.sequenceAliases.get(t):void 0},V[0]=U,V[1]=l):l=V[1];let Y=(0,S.useEngineSelector)(l);V[2]!==G.scene?(h=o.clone(G.scene),d=(0,s.processShapeScene)(h),h.traverse(N),p=new r.AnimationMixer(h),f=null,h.traverse(e=>{f||"Mount0"!==e.name||(f=e)}),V[2]=G.scene,V[3]=d,V[4]=f,V[5]=p,V[6]=h):(d=V[3],f=V[4],p=V[5],h=V[6]),V[7]!==d||V[8]!==f||V[9]!==p||V[10]!==h?(T={clonedScene:h,mixer:p,mount0:f,iflInitializers:d},V[7]=d,V[8]=f,V[9]=p,V[10]=h,V[11]=T):T=V[11];let{clonedScene:z,mixer:K,mount0:H,iflInitializers:$}=T;V[12]===Symbol.for("react.memo_cache_sentinel")?(I=new Map,V[12]=I):I=V[12];let J=(0,i.useRef)(I);V[13]===Symbol.for("react.memo_cache_sentinel")?(b={head:null,headside:null},V[13]=b):b=V[13];let Q=(0,i.useRef)(b);V[14]===Symbol.for("react.memo_cache_sentinel")?(x=new Map,V[14]=x):x=V[14];let X=(0,i.useRef)(x),Z=(0,i.useRef)(null);V[15]===Symbol.for("react.memo_cache_sentinel")?(R={name:"root",timeScale:1},V[15]=R):R=V[15];let ee=(0,i.useRef)(R),et=(0,i.useRef)(!1),en=(0,i.useRef)(void 0);if(V[16]!==W||V[17]!==U){e:{let e=W.getState().playback,t=e.recording?.streamingPlayback,n=U?.toLowerCase();if(!t||!n){let e;V[19]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,V[19]=e):e=V[19],_=e;break e}let i=t.getShapeConstructorSequences(n);if(!i){let e;V[20]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,V[20]=e):e=V[20],_=e;break e}_=function(e,t){let n=new Map,i=[];for(let n of e){let e=n.indexOf(" ");if(-1===e)continue;let a=n.slice(0,e).toLowerCase(),r=n.slice(e+1).trim().toLowerCase();if(!r||!a.startsWith(t)||!a.endsWith(".dsq"))continue;let o=a.slice(t.length,-4);o&&i.push({clipName:o,alias:r})}let a=new Set;for(let e=0;e{let e=(0,u.getAliasedActions)(G.animations,K,Y);J.current=e;let t=e.get("root");t&&t.play(),ee.current={name:"root",timeScale:1};let n={head:null,headside:null};for(let{key:e,names:t}of[{key:"head",names:["head"]},{key:"headside",names:["headside"]}]){let i=G.animations.find(e=>t.includes(e.name.toLowerCase()));if(!i)continue;let a=i.clone(),o=Math.round(30*i.duration/2);r.AnimationUtils.makeClipAdditive(a,o,i,30);let s=K.clipAction(a);s.blendMode=r.AdditiveAnimationBlendMode,s.timeScale=0,s.weight=1,s.play(),n[e]=s}Q.current=n;let i=new Map,a=G.animations.find(k),o=a?Math.round(30*a.duration/2):0;for(let e of["lookde","lookms","looksn"]){let t=G.animations.find(t=>t.name.toLowerCase()===e);if(!t)continue;let n=t.clone(),s=a??t;r.AnimationUtils.makeClipAdditive(n,o,s,30);let l=K.clipAction(n);l.blendMode=r.AdditiveAnimationBlendMode,l.timeScale=0,l.weight=0,l.play(),i.set(e,l)}X.current=i;let s=i.get("lookde");return s&&(s.weight=1,Z.current="lookde"),K.update(0),()=>{K.stopAllAction(),J.current=new Map,Q.current={head:null,headside:null},X.current=new Map,Z.current=null}},C=[K,G.animations,Y],V[21]=G.animations,V[22]=K,V[23]=Y,V[24]=L,V[25]=C):(L=V[24],C=V[25]),(0,i.useEffect)(L,C),V[26]!==$?(O=()=>{let e=[];for(let{mesh:t,initialize:n}of $)n(t,M).then(t=>e.push(t)).catch(A);return()=>e.forEach(w)},E=[$],V[26]=$,V[27]=O,V[28]=E):(O=V[27],E=V[28]),(0,i.useEffect)(O,E);let ea=(0,i.useRef)(j.weaponShape),[er,eo]=(0,i.useState)(j.weaponShape);return V[29]!==ei||V[30]!==W||V[31]!==j.headPitch||V[32]!==j.headYaw||V[33]!==j.keyframes||V[34]!==j.weaponShape||V[35]!==K?(D=(e,t)=>{j.weaponShape!==ea.current&&(ea.current=j.weaponShape,eo(j.weaponShape));let n=W.getState().playback,i="playing"===n.status,a=g.streamPlaybackStore.getState().time,o=(0,s.getKeyframeAtTime)(j.keyframes??[],a),l=o?.damageState!=null&&o.damageState>=1,u=J.current;if(l&&!et.current){et.current=!0;let e=null!=o.actionAnim?ei.get(o.actionAnim):void 0;if(e){let t=u.get(e.clipName);if(t){let n=u.get(ee.current.name.toLowerCase());n&&n.fadeOut(s.ANIM_TRANSITION_TIME),t.setLoop(r.LoopOnce,1),t.clampWhenFinished=!0,t.reset().fadeIn(s.ANIM_TRANSITION_TIME).play(),ee.current={name:e.clipName,timeScale:1},en.current=o.actionAnim}}}if(!l&&et.current){et.current=!1,en.current=void 0;let e=u.get(ee.current.name.toLowerCase());e&&(e.stop(),e.setLoop(r.LoopRepeat,1/0),e.clampWhenFinished=!1),ee.current={name:"root",timeScale:1};let t=u.get("root");t&&t.reset().play()}let c=o?.actionAnim,m=en.current;if(!et.current&&c!==m){en.current=c;let e=null!=m&&m>=7;if(null!=c&&c>=7){let e=ei.get(c);if(e){let t=u.get(e.clipName);if(t){let n=u.get(ee.current.name.toLowerCase());n&&n.fadeOut(s.ANIM_TRANSITION_TIME),t.setLoop(r.LoopOnce,1),t.clampWhenFinished=!0,t.reset().fadeIn(s.ANIM_TRANSITION_TIME).play(),ee.current={name:e.clipName,timeScale:1}}}}else if(e){let e=ei.get(m);if(e){let t=u.get(e.clipName);t&&(t.fadeOut(s.ANIM_TRANSITION_TIME),t.setLoop(r.LoopRepeat,1/0),t.clampWhenFinished=!1)}ee.current={name:"root",timeScale:1};let t=u.get("root");t&&t.reset().fadeIn(s.ANIM_TRANSITION_TIME).play()}}if(null!=c&&c>=7&&o?.actionAtEnd){let e=ei.get(c);if(e){let t=u.get(e.clipName);t&&(t.paused=!0)}}let d=null!=en.current&&en.current>=7;if(!et.current&&!d){let e=function(e,t){if(!e)return{animation:"root",timeScale:1};let[n,i,a]=e;if(a<-10)return{animation:"fall",timeScale:1};let r=-2*Math.atan2(t[1],t[3]),o=Math.cos(r),s=Math.sin(r),l=n*o+i*s,u=-n*s+i*o,c=-u,m=-l,d=Math.max(u,c,m,l);return d<.1?{animation:"root",timeScale:1}:d===u?{animation:"run",timeScale:1}:d===c?{animation:"back",timeScale:1}:d===m?{animation:"side",timeScale:1}:{animation:"side",timeScale:-1}}(o?.velocity,o?.rotation??[0,0,0,1]),t=ee.current;if(e.animation!==t.name||e.timeScale!==t.timeScale){let n=u.get(t.name.toLowerCase()),a=u.get(e.animation.toLowerCase());a&&(i&&n&&n!==a?(n.fadeOut(s.ANIM_TRANSITION_TIME),a.reset().fadeIn(s.ANIM_TRANSITION_TIME).play()):(n&&n!==a&&n.stop(),a.reset().play()),a.timeScale=e.timeScale,ee.current={name:e.animation,timeScale:e.timeScale})}}let f=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(j.weaponShape);if(f!==Z.current){let e=X.current,t=Z.current?e.get(Z.current):null,n=e.get(f);n&&(t&&(t.weight=0),n.weight=+!l,Z.current=f)}let{head:p,headside:h}=Q.current,S=Z.current?X.current.get(Z.current):null,y=+!l,T=j.headPitch??0,I=j.headYaw??0,w=(T+1)/2;S&&(S.time=w*S.getClip().duration,S.weight=y),p&&(p.time=w*p.getClip().duration,p.weight=y),h&&(h.time=(I+1)/2*h.getClip().duration,h.weight=y),i?K.update(t*n.rate):K.update(0)},V[29]=ei,V[30]=W,V[31]=j.headPitch,V[32]=j.headYaw,V[33]=j.keyframes,V[34]=j.weaponShape,V[35]=K,V[36]=D):D=V[36],(0,a.useFrame)(D),V[37]===Symbol.for("react.memo_cache_sentinel")?(P=[0,Math.PI/2,0],V[37]=P):P=V[37],V[38]!==z?(F=(0,t.jsx)("group",{rotation:P,children:(0,t.jsx)("primitive",{object:z})}),V[38]=z,V[39]=F):F=V[39],V[40]!==er||V[41]!==j||V[42]!==H?(B=er&&H&&(0,t.jsx)(m.ShapeErrorBoundary,{fallback:null,children:(0,t.jsx)(i.Suspense,{fallback:null,children:(0,t.jsx)(v,{entity:j,weaponShape:er,mount0:H})})},er),V[40]=er,V[41]=j,V[42]=H,V[43]=B):B=V[43],V[44]!==F||V[45]!==B?(q=(0,t.jsxs)(t.Fragment,{children:[F,B]}),V[44]=F,V[45]=B,V[46]=q):q=V[46],q}function w(e){return e()}function A(){}function M(){return g.streamPlaybackStore.getState().time}function k(e){return"lookde"===e.name.toLowerCase()}function N(e){if(e.isMesh&&e.material)for(let t of Array.isArray(e.material)?e.material:[e.material])t.side=r.FrontSide}function v(e){let t,u,m,g,y,I,w,A,M,k,N,v,_,L,C=(0,n.c)(38),{entity:O,weaponShape:E,mount0:D}=e,P=(0,S.useEngineStoreApi)(),F=(0,c.useStaticShape)(E);if(C[0]!==F.animations||C[1]!==F.scene){t=o.clone(F.scene),u=(0,s.processShapeScene)(t);let e=(0,s.getPosedNodeTransform)(F.scene,F.animations,"Mountpoint");if(e){let n=e.quaternion.clone().invert(),i=e.position.clone().negate().applyQuaternion(n);t.position.copy(i),t.quaternion.copy(n)}g=new Map,t.traverse(e=>{if(!e.isMesh)return;let t=e.userData,n=(t?.vis_sequence??"").toLowerCase();if(!n)return;let i=g.get(n);i||(i=[],g.set(n,i)),i.push(e)}),m=new r.AnimationMixer(t),C[0]=F.animations,C[1]=F.scene,C[2]=t,C[3]=u,C[4]=m,C[5]=g}else t=C[2],u=C[3],m=C[4],g=C[5];let B=m,q=F.scene;C[6]!==q||C[7]!==F.animations?(y=function(e,t){let n=e.userData?.dts_sequence_names;if("string"==typeof n)try{return JSON.parse(n).map(e=>e.toLowerCase())}catch{}return t.map(e=>e.name.toLowerCase())}(q,F.animations),C[6]=q,C[7]=F.animations,C[8]=y):y=C[8];let V=y;C[9]!==t||C[10]!==u||C[11]!==B||C[12]!==V||C[13]!==g?(I={weaponClone:t,weaponMixer:B,seqIndexToName:V,visNodesBySequence:g,weaponIflInitializers:u},C[9]=t,C[10]=u,C[11]=B,C[12]=V,C[13]=g,C[14]=I):I=C[14];let{weaponClone:j,weaponMixer:W,seqIndexToName:U,visNodesBySequence:G,weaponIflInitializers:Y}=I;C[15]===Symbol.for("react.memo_cache_sentinel")?(w=new Map,C[15]=w):w=C[15];let z=(0,i.useRef)(w),K=(0,i.useRef)(null);C[16]!==F.animations||C[17]!==W?(A=()=>{let e=new Map;for(let t of F.animations)e.set(t.name.toLowerCase(),W.clipAction(t));z.current=e;let t=e.get("spin");return t&&(t.setLoop(r.LoopRepeat,1/0),t.timeScale=0,t.play()),K.current=t??null,W.update(0),()=>{W.stopAllAction(),z.current=new Map,K.current=null,T(et,en)}},M=[W,F.animations],C[16]=F.animations,C[17]=W,C[18]=A,C[19]=M):(A=C[18],M=C[19]),(0,i.useEffect)(A,M),C[20]!==Y?(k=()=>{let e=[];for(let{mesh:t,initialize:n}of Y)n(t,R).then(t=>e.push(t)).catch(x);return()=>e.forEach(b)},N=[Y],C[20]=Y,C[21]=k,C[22]=N):(k=C[21],N=C[22]),(0,i.useEffect)(k,N);let{audioLoader:H,audioListener:$}=(0,d.useAudio)(),J=(0,h.useSettings)(),Q=J?.audioEnabled??!1,X=(0,i.useRef)(null),Z=(0,i.useRef)(null),ee=(0,i.useRef)(O.weaponImageStates),et=(0,i.useRef)(null),en=(0,i.useRef)(-1);return C[23]!==D||C[24]!==j?(v=()=>(D.add(j),()=>{D.remove(j)}),_=[j,D],C[23]=D,C[24]=j,C[25]=v,C[26]=_):(v=C[25],_=C[26]),(0,i.useEffect)(v,_),C[27]!==Q||C[28]!==$||C[29]!==H||C[30]!==P||C[31]!==O.weaponImageState||C[32]!==O.weaponImageStates||C[33]!==U||C[34]!==G||C[35]!==j||C[36]!==W?(L=(e,t)=>{let n=P.getState().playback,i="playing"===n.status,a=z.current,o=O.weaponImageState,u=O.weaponImageStates;u!==ee.current&&(ee.current=u,u&&u.length>0?X.current=new l(u,U):X.current=null,Z.current=null,T(et,en,j)),!X.current&&u&&u.length>0&&(X.current=new l(u,U));let c=X.current;if(c&&o&&i){let e=t*n.rate,i=c.tick(e,o);if(function(e,t,n,i){let a=e.sequenceName,o=n.current;if(a===o&&!e.transitioned)return;if(a!==o){if(o){let e=i.get(o);if(e)for(let t of e)t.visible=!1}if(a){let e=i.get(a);if(e)for(let t of e)t.visible=!0}}if(!a){if(o){let e=t.get(o);e&&e.fadeOut(s.ANIM_TRANSITION_TIME),n.current=null}return}let l=t.get(a);if(l&&(e.transitioned||a!==o)){let i=o?t.get(o):null;if(e.isFiring||e.timeoutValue>0?(l.setLoop(r.LoopOnce,1),l.clampWhenFinished=!0):(l.setLoop(r.LoopRepeat,1/0),l.clampWhenFinished=!1),e.scaleAnimation&&e.timeoutValue>0){let t=l.getClip().duration;l.timeScale=t>0?t/e.timeoutValue:1}else l.timeScale=e.reverse?-1:1;i&&i!==l?(i.fadeOut(s.ANIM_TRANSITION_TIME),l.reset().fadeIn(s.ANIM_TRANSITION_TIME).play()):l.reset().play(),n.current=a}}(i,a,Z,G),et.current&&i.stateIndex!==en.current&&T(et,en,j),Q&&H&&$&&i.soundDataBlockIds.length>0){let e=n.recording?.streamingPlayback.getDataBlockData.bind(n.recording.streamingPlayback);if(e)for(let t of i.soundDataBlockIds){let i=(0,f.resolveAudioProfile)(t,e);if(i)if(i.isLooping){if(!et.current)try{let e=(0,p.audioToUrl)(i.filename),t=(0,f.getSoundGeneration)();(0,f.getCachedAudioBuffer)(e,H,e=>{if(t!==(0,f.getSoundGeneration)()||et.current)return;let a=c.stateIndex,o=new r.PositionalAudio($);o.setBuffer(e),o.setDistanceModel("inverse"),o.setRefDistance(i.refDist),o.setMaxDistance(i.maxDist),o.setRolloffFactor(1),o.setVolume(i.volume),o.setPlaybackRate(n.rate),o.setLoop(!0),j.add(o),(0,f.trackSound)(o),o.play(),et.current=o,en.current=a})}catch{}}else(0,f.playOneShotSound)(i,$,H,void 0,j)}}K.current&&(K.current.timeScale=i.spinTimeScale)}i?W.update(t*n.rate):W.update(0)},C[27]=Q,C[28]=$,C[29]=H,C[30]=P,C[31]=O.weaponImageState,C[32]=O.weaponImageStates,C[33]=U,C[34]=G,C[35]=j,C[36]=W,C[37]=L):L=C[37],(0,a.useFrame)(L),null}function b(e){return e()}function x(){}function R(){return g.streamPlaybackStore.getState().time}function _(e){let t,a,r=(0,n.c)(7),{shapeName:o,eyeOffsetRef:l}=e,u=(0,c.useStaticShape)(o);return r[0]!==l||r[1]!==u.animations||r[2]!==u.scene?(t=()=>{let e=(0,s.getPosedNodeTransform)(u.scene,u.animations,"Eye");e?l.current.set(e.position.z,e.position.y,-e.position.x):l.current.set(0,s.DEFAULT_EYE_HEIGHT,0)},r[0]=l,r[1]=u.animations,r[2]=u.scene,r[3]=t):t=r[3],r[4]!==l||r[5]!==u?(a=[u,l],r[4]=l,r[5]=u,r[6]=a):a=r[6],(0,i.useEffect)(t,a),null}e.s(["PlayerEyeOffset",()=>_,"PlayerModel",()=>I],9721)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/20b7c805b0b1f5f3.js b/docs/_next/static/chunks/20b7c805b0b1f5f3.js deleted file mode 100644 index c8aa7a68..00000000 --- a/docs/_next/static/chunks/20b7c805b0b1f5f3.js +++ /dev/null @@ -1,362 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,55838,(e,n,t)=>{"use strict";var r=e.r(71645),a="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},i=r.useState,o=r.useEffect,l=r.useLayoutEffect,s=r.useDebugValue;function u(e){var n=e.getSnapshot;e=e.value;try{var t=n();return!a(e,t)}catch(e){return!0}}var c="u"{"use strict";n.exports=e.r(55838)},52822,(e,n,t)=>{"use strict";var r=e.r(71645),a=e.r(2239),i="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},o=a.useSyncExternalStore,l=r.useRef,s=r.useEffect,u=r.useMemo,c=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,n,t,r,a){var d=l(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;var p=o(e,(d=u(function(){function e(e){if(!s){if(s=!0,o=e,e=r(e),void 0!==a&&f.hasValue){var n=f.value;if(a(n,e))return l=n}return l=e}if(n=l,i(o,e))return n;var t=r(e);return void 0!==a&&a(n,t)?(o=e,n):(o=e,l=t)}var o,l,s=!1,u=void 0===t?null:t;return[function(){return e(n())},null===u?void 0:function(){return e(u())}]},[n,t,r,a]))[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),c(p),p}},30224,(e,n,t)=>{"use strict";n.exports=e.r(52822)},66936,(e,n,t)=>{"use strict";function r(e,n){var t=e.length;for(e.push(n);0>>1,a=e[r];if(0>>1;ro(s,t))uo(c,s)?(e[r]=c,e[u]=t,r=u):(e[r]=s,e[l]=t,r=l);else if(uo(c,t))e[r]=c,e[u]=t,r=u;else break}}return n}function o(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}if(t.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var l,s=performance;t.unstable_now=function(){return s.now()}}else{var u=Date,c=u.now();t.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,h=3,g=!1,_=!1,v=!1,S=!1,E="function"==typeof setTimeout?setTimeout:null,T="function"==typeof clearTimeout?clearTimeout:null,M="u">typeof setImmediate?setImmediate:null;function b(e){for(var n=a(f);null!==n;){if(null===n.callback)i(f);else if(n.startTime<=e)i(f),n.sortIndex=n.expirationTime,r(d,n);else break;n=a(f)}}function x(e){if(v=!1,b(e),!_)if(null!==a(d))_=!0,R||(R=!0,l());else{var n=a(f);null!==n&&U(x,n.startTime-e)}}var R=!1,C=-1,y=5,A=-1;function P(){return!!S||!(t.unstable_now()-Ae&&P());){var o=m.callback;if("function"==typeof o){m.callback=null,h=m.priorityLevel;var s=o(m.expirationTime<=e);if(e=t.unstable_now(),"function"==typeof s){m.callback=s,b(e),n=!0;break n}m===a(d)&&i(d),b(e)}else i(d);m=a(d)}if(null!==m)n=!0;else{var u=a(f);null!==u&&U(x,u.startTime-e),n=!1}}break e}finally{m=null,h=r,g=!1}}}finally{n?l():R=!1}}}if("function"==typeof M)l=function(){M(w)};else if("u">typeof MessageChannel){var L=new MessageChannel,N=L.port2;L.port1.onmessage=w,l=function(){N.postMessage(null)}}else l=function(){E(w,0)};function U(e,n){C=E(function(){e(t.unstable_now())},n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_forceFrameRate=function(e){0>e||125o?(e.sortIndex=i,r(f,e),null===a(d)&&e===a(f)&&(v?(T(C),C=-1):v=!0,U(x,i-o))):(e.sortIndex=s,r(d,e),_||g||(_=!0,R||(R=!0,l()))),e},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(e){var n=h;return function(){var t=h;h=n;try{return e.apply(this,arguments)}finally{h=t}}}},89499,(e,n,t)=>{"use strict";n.exports=e.r(66936)},40859,8560,8155,66748,46791,e=>{"use strict";let n,t,r,a,i,o,l,s,u;var c,d,f,p,m,h,g=e.i(47167),_=e.i(71645),v=e.i(90072),S=v;function E(){let e=null,n=!1,t=null,r=null;function a(n,i){t(n,i),r=e.requestAnimationFrame(a)}return{start:function(){!0===n||null!==t&&(r=e.requestAnimationFrame(a),n=!0)},stop:function(){e.cancelAnimationFrame(r),n=!1},setAnimationLoop:function(e){t=e},setContext:function(n){e=n}}}function T(e){let n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let r=n.get(t);r&&(e.deleteBuffer(r.buffer),n.delete(t))},update:function(t,r){if(t.isInterleavedBufferAttribute&&(t=t.data),t.isGLBufferAttribute){let e=n.get(t);(!e||e.versiontypeof Float16Array&&a instanceof Float16Array)r=e.HALF_FLOAT;else if(a instanceof Uint16Array)r=n.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(a instanceof Int16Array)r=e.SHORT;else if(a instanceof Uint32Array)r=e.UNSIGNED_INT;else if(a instanceof Int32Array)r=e.INT;else if(a instanceof Int8Array)r=e.BYTE;else if(a instanceof Uint8Array)r=e.UNSIGNED_BYTE;else if(a instanceof Uint8ClampedArray)r=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);return{buffer:l,type:r,bytesPerElement:a.BYTES_PER_ELEMENT,version:n.version,size:o}}(t,r));else if(a.versione.start-n.start);let n=0;for(let e=1;e 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n vColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, dp );\n #else\n shadow = step( dp, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},b={common:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new S.Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new S.Matrix3}},envmap:{envMap:{value:null},envMapRotation:{value:new S.Matrix3},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new S.Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new S.Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new S.Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new S.Matrix3},normalScale:{value:new S.Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new S.Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new S.Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new S.Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new S.Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new S.Color(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0},uvTransform:{value:new S.Matrix3}},sprite:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},center:{value:new S.Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new S.Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0}}},x={basic:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.fog]),vertexShader:M.meshbasic_vert,fragmentShader:M.meshbasic_frag},lambert:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.fog,b.lights,{emissive:{value:new S.Color(0)}}]),vertexShader:M.meshlambert_vert,fragmentShader:M.meshlambert_frag},phong:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.fog,b.lights,{emissive:{value:new S.Color(0)},specular:{value:new S.Color(1118481)},shininess:{value:30}}]),vertexShader:M.meshphong_vert,fragmentShader:M.meshphong_frag},standard:{uniforms:(0,S.mergeUniforms)([b.common,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.roughnessmap,b.metalnessmap,b.fog,b.lights,{emissive:{value:new S.Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag},toon:{uniforms:(0,S.mergeUniforms)([b.common,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.gradientmap,b.fog,b.lights,{emissive:{value:new S.Color(0)}}]),vertexShader:M.meshtoon_vert,fragmentShader:M.meshtoon_frag},matcap:{uniforms:(0,S.mergeUniforms)([b.common,b.bumpmap,b.normalmap,b.displacementmap,b.fog,{matcap:{value:null}}]),vertexShader:M.meshmatcap_vert,fragmentShader:M.meshmatcap_frag},points:{uniforms:(0,S.mergeUniforms)([b.points,b.fog]),vertexShader:M.points_vert,fragmentShader:M.points_frag},dashed:{uniforms:(0,S.mergeUniforms)([b.common,b.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:M.linedashed_vert,fragmentShader:M.linedashed_frag},depth:{uniforms:(0,S.mergeUniforms)([b.common,b.displacementmap]),vertexShader:M.depth_vert,fragmentShader:M.depth_frag},normal:{uniforms:(0,S.mergeUniforms)([b.common,b.bumpmap,b.normalmap,b.displacementmap,{opacity:{value:1}}]),vertexShader:M.meshnormal_vert,fragmentShader:M.meshnormal_frag},sprite:{uniforms:(0,S.mergeUniforms)([b.sprite,b.fog]),vertexShader:M.sprite_vert,fragmentShader:M.sprite_frag},background:{uniforms:{uvTransform:{value:new S.Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:M.background_vert,fragmentShader:M.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new S.Matrix3}},vertexShader:M.backgroundCube_vert,fragmentShader:M.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:M.cube_vert,fragmentShader:M.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:M.equirect_vert,fragmentShader:M.equirect_frag},distance:{uniforms:(0,S.mergeUniforms)([b.common,b.displacementmap,{referencePosition:{value:new S.Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:M.distance_vert,fragmentShader:M.distance_frag},shadow:{uniforms:(0,S.mergeUniforms)([b.lights,b.fog,{color:{value:new S.Color(0)},opacity:{value:1}}]),vertexShader:M.shadow_vert,fragmentShader:M.shadow_frag}};x.physical={uniforms:(0,S.mergeUniforms)([x.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new S.Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new S.Matrix3},clearcoatNormalScale:{value:new S.Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new S.Matrix3},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new S.Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new S.Matrix3},sheen:{value:0},sheenColor:{value:new S.Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new S.Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new S.Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new S.Matrix3},transmissionSamplerSize:{value:new S.Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new S.Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new S.Color(0)},specularColor:{value:new S.Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new S.Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new S.Matrix3},anisotropyVector:{value:new S.Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new S.Matrix3}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag};let R={r:0,b:0,g:0},C=new S.Euler,y=new S.Matrix4;function A(e,n,t,r,a,i,o){let l,s,u=new S.Color(0),c=+(!0!==i),d=null,f=0,p=null;function m(e){let r=!0===e.isScene?e.background:null;return r&&r.isTexture&&(r=(e.backgroundBlurriness>0?t:n).get(r)),r}function h(n,t){n.getRGB(R,(0,S.getUnlitUniformColorSpace)(e)),r.buffers.color.setClear(R.r,R.g,R.b,t,o)}return{getClearColor:function(){return u},setClearColor:function(e,n=1){u.set(e),h(u,c=n)},getClearAlpha:function(){return c},setClearAlpha:function(e){h(u,c=e)},render:function(n){let t=!1,a=m(n);null===a?h(u,c):a&&a.isColor&&(h(a,1),t=!0);let i=e.xr.getEnvironmentBlendMode();"additive"===i?r.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===i&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||t)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(n,t){let r=m(t);r&&(r.isCubeTexture||r.mapping===S.CubeUVReflectionMapping)?(void 0===s&&((s=new S.Mesh(new S.BoxGeometry(1,1,1),new S.ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:(0,S.cloneUniforms)(x.backgroundCube.uniforms),vertexShader:x.backgroundCube.vertexShader,fragmentShader:x.backgroundCube.fragmentShader,side:S.BackSide,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,n,t){this.matrixWorld.copyPosition(t.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(s)),C.copy(t.backgroundRotation),C.x*=-1,C.y*=-1,C.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(C.y*=-1,C.z*=-1),s.material.uniforms.envMap.value=r,s.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,s.material.uniforms.backgroundBlurriness.value=t.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,s.material.uniforms.backgroundRotation.value.setFromMatrix4(y.makeRotationFromEuler(C)),s.material.toneMapped=S.ColorManagement.getTransfer(r.colorSpace)!==S.SRGBTransfer,(d!==r||f!==r.version||p!==e.toneMapping)&&(s.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null)):r&&r.isTexture&&(void 0===l&&((l=new S.Mesh(new S.PlaneGeometry(2,2),new S.ShaderMaterial({name:"BackgroundMaterial",uniforms:(0,S.cloneUniforms)(x.background.uniforms),vertexShader:x.background.vertexShader,fragmentShader:x.background.fragmentShader,side:S.FrontSide,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),l.material.uniforms.t2D.value=r,l.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,l.material.toneMapped=S.ColorManagement.getTransfer(r.colorSpace)!==S.SRGBTransfer,!0===r.matrixAutoUpdate&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),(d!==r||f!==r.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),l.layers.enableAll(),n.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==s&&(s.geometry.dispose(),s.material.dispose(),s=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function P(e,n){let t=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},a=u(null),i=a,o=!1;function l(n){return e.bindVertexArray(n)}function s(n){return e.deleteVertexArray(n)}function u(e){let n=[],r=[],a=[];for(let e=0;e=0){let t=a[n],r=o[n];if(void 0===r&&("instanceMatrix"===n&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(r=e.instanceColor)),void 0===t||t.attribute!==r||r&&t.data!==r.data)return!0;l++}return i.attributesNum!==l||i.index!==r}(t,h,s,g))&&function(e,n,t,r){let a={},o=n.attributes,l=0,s=t.getAttributes();for(let n in s)if(s[n].location>=0){let t=o[n];void 0===t&&("instanceMatrix"===n&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(t=e.instanceColor));let r={};r.attribute=t,t&&t.data&&(r.data=t.data),a[n]=r,l++}i.attributes=a,i.attributesNum=l,i.index=r}(t,h,s,g),null!==g&&n.update(g,e.ELEMENT_ARRAY_BUFFER),(x||o)&&(o=!1,function(t,r,a,i){c();let o=i.attributes,l=a.getAttributes(),s=r.defaultAttributeValues;for(let r in l){let a=l[r];if(a.location>=0){let l=o[r];if(void 0===l&&("instanceMatrix"===r&&t.instanceMatrix&&(l=t.instanceMatrix),"instanceColor"===r&&t.instanceColor&&(l=t.instanceColor)),void 0!==l){let r=l.normalized,o=l.itemSize,s=n.get(l);if(void 0===s)continue;let u=s.buffer,c=s.type,p=s.bytesPerElement,h=c===e.INT||c===e.UNSIGNED_INT||l.gpuType===S.IntType;if(l.isInterleavedBufferAttribute){let n=l.data,s=n.stride,g=l.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";n="mediump"}return"mediump"===n&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==t.precision?t.precision:"highp",l=i(o);return l!==o&&((0,S.warn)("WebGLRenderer:",o,"not supported, using",l,"instead."),o=l),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==a)return a;if(!0===n.has("EXT_texture_filter_anisotropic")){let t=n.get("EXT_texture_filter_anisotropic");a=e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a},getMaxPrecision:i,textureFormatReadable:function(n){return n===S.RGBAFormat||r.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(t){let a=t===S.HalfFloatType&&(n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float"));return t===S.UnsignedByteType||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)||t===S.FloatType||!!a},precision:o,logarithmicDepthBuffer:!0===t.logarithmicDepthBuffer,reversedDepthBuffer:!0===t.reversedDepthBuffer&&n.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function N(e){let n=this,t=null,r=0,a=!1,i=!1,o=new S.Plane,l=new S.Matrix3,s={value:null,needsUpdate:!1};function u(e,t,r,a){let i=null!==e?e.length:0,u=null;if(0!==i){if(u=s.value,!0!==a||null===u){let n=r+4*i,a=t.matrixWorldInverse;l.getNormalMatrix(a),(null===u||u.length0),n.numPlanes=r,n.numIntersection=0)}}function U(e){let n=new WeakMap;function t(e,n){return n===S.EquirectangularReflectionMapping?e.mapping=S.CubeReflectionMapping:n===S.EquirectangularRefractionMapping&&(e.mapping=S.CubeRefractionMapping),e}function r(e){let t=e.target;t.removeEventListener("dispose",r);let a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}return{get:function(a){if(a&&a.isTexture){let i=a.mapping;if(i===S.EquirectangularReflectionMapping||i===S.EquirectangularRefractionMapping)if(n.has(a))return t(n.get(a).texture,a.mapping);else{let i=a.image;if(!i||!(i.height>0))return null;{let o=new S.WebGLCubeRenderTarget(i.height);return o.fromEquirectangularTexture(e,a),n.set(a,o),a.addEventListener("dispose",r),t(o.texture,a.mapping)}}}return a},dispose:function(){n=new WeakMap}}}let D=[.125,.215,.35,.446,.526,.582],I=new S.OrthographicCamera,F=new S.Color,O=null,B=0,G=0,H=!1,k=new S.Vector3;class V{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,t=.1,r=100,a={}){let{size:i=256,position:o=k}=a;O=this._renderer.getRenderTarget(),B=this._renderer.getActiveCubeFace(),G=this._renderer.getActiveMipmapLevel(),H=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(i);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,t,r,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=j(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=X(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=D[o-e+4-1]:0===o&&(l=0),t.push(l);let s=1/(i-2),u=-s,c=1+s,d=[u,u,c,u,c,c,u,u,c,c,u,c],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let n=e%3*2/3-1,t=e>2?0:-1,r=[n,t,0,n+2/3,t,0,n+2/3,t+1,0,n,t,0,n+2/3,t+1,0,n,t+1,0];f.set(r,18*e),p.set(d,12*e);let a=[e,e,e,e,e,e];m.set(a,6*e)}let h=new S.BufferGeometry;h.setAttribute("position",new S.BufferAttribute(f,3)),h.setAttribute("uv",new S.BufferAttribute(p,2)),h.setAttribute("faceIndex",new S.BufferAttribute(m,1)),r.push(new S.Mesh(h,null)),a>4&&a--}return{lodMeshes:r,sizeLods:n,sigmas:t}}(d)),this._blurMaterial=(a=d,i=e,o=n,r=new Float32Array(20),c=new S.Vector3(0,1,0),new S.ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/i,CUBEUV_TEXEL_HEIGHT:1/o,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})),this._ggxMaterial=(l=d,s=e,u=n,new S.ShaderMaterial({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/s,CUBEUV_TEXEL_HEIGHT:1/u,CUBEUV_MAX_MIP:`${l}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:q(),fragmentShader:` - - precision highp float; - precision highp int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform float roughness; - uniform float mipInt; - - #define ENVMAP_TYPE_CUBE_UV - #include - - #define PI 3.14159265359 - - // Van der Corput radical inverse - float radicalInverse_VdC(uint bits) { - bits = (bits << 16u) | (bits >> 16u); - bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); - bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); - bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); - bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); - return float(bits) * 2.3283064365386963e-10; // / 0x100000000 - } - - // Hammersley sequence - vec2 hammersley(uint i, uint N) { - return vec2(float(i) / float(N), radicalInverse_VdC(i)); - } - - // GGX VNDF importance sampling (Eric Heitz 2018) - // "Sampling the GGX Distribution of Visible Normals" - // https://jcgt.org/published/0007/04/01/ - vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { - float alpha = roughness * roughness; - - // Section 3.2: Transform view direction to hemisphere configuration - vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); - - // Section 4.1: Orthonormal basis - float lensq = Vh.x * Vh.x + Vh.y * Vh.y; - vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); - vec3 T2 = cross(Vh, T1); - - // Section 4.2: Parameterization of projected area - float r = sqrt(Xi.x); - float phi = 2.0 * PI * Xi.y; - float t1 = r * cos(phi); - float t2 = r * sin(phi); - float s = 0.5 * (1.0 + Vh.z); - t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; - - // Section 4.3: Reprojection onto hemisphere - vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; - - // Section 3.4: Transform back to ellipsoid configuration - return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); - } - - void main() { - vec3 N = normalize(vOutputDirection); - vec3 V = N; // Assume view direction equals normal for pre-filtering - - vec3 prefilteredColor = vec3(0.0); - float totalWeight = 0.0; - - // For very low roughness, just sample the environment directly - if (roughness < 0.001) { - gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); - return; - } - - // Tangent space basis for VNDF sampling - vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 tangent = normalize(cross(up, N)); - vec3 bitangent = cross(N, tangent); - - for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { - vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); - - // For PMREM, V = N, so in tangent space V is always (0, 0, 1) - vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); - - // Transform H back to world space - vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); - vec3 L = normalize(2.0 * dot(V, H) * H - V); - - float NdotL = max(dot(N, L), 0.0); - - if(NdotL > 0.0) { - // Sample environment at fixed mip level - // VNDF importance sampling handles the distribution filtering - vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); - - // Weight by NdotL for the split-sum approximation - // VNDF PDF naturally accounts for the visible microfacet distribution - prefilteredColor += sampleColor * NdotL; - totalWeight += NdotL; - } - } - - if (totalWeight > 0.0) { - prefilteredColor = prefilteredColor / totalWeight; - } - - gl_FragColor = vec4(prefilteredColor, 1.0); - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1}))}return r}_compileMaterial(e){let n=new S.Mesh(new S.BufferGeometry,e);this._renderer.compile(n,I)}_sceneToCubeUV(e,n,t,r,a){let i=new S.PerspectiveCamera(90,1,n,t),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],s=this._renderer,u=s.autoClear,c=s.toneMapping;s.getClearColor(F),s.toneMapping=S.NoToneMapping,s.autoClear=!1,s.state.buffers.depth.getReversed()&&(s.setRenderTarget(r),s.clearDepth(),s.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new S.Mesh(new S.BoxGeometry,new S.MeshBasicMaterial({name:"PMREM.Background",side:S.BackSide,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,f=d.material,p=!1,m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,p=!0):(f.color.copy(F),p=!0);for(let n=0;n<6;n++){let t=n%3;0===t?(i.up.set(0,o[n],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x+l[n],a.y,a.z)):1===t?(i.up.set(0,0,o[n]),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y+l[n],a.z)):(i.up.set(0,o[n],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y,a.z+l[n]));let u=this._cubeSize;W(r,t*u,n>2?u:0,u,u),s.setRenderTarget(r),p&&s.render(d,i),s.render(e,i)}s.toneMapping=c,s.autoClear=u,e.background=m}_textureToCubeUV(e,n){let t=this._renderer,r=e.mapping===S.CubeReflectionMapping||e.mapping===S.CubeRefractionMapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=j()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=X());let a=r?this._cubemapMaterial:this._equirectMaterial,i=this._lodMeshes[0];i.material=a,a.uniforms.envMap.value=e;let o=this._cubeSize;W(n,0,0,3*o,2*o),t.setRenderTarget(n),t.render(i,I)}_applyPMREM(e){let n=this._renderer,t=n.autoClear;n.autoClear=!1;let r=this._lodMeshes.length;for(let n=1;nd-4?t-d+4:0),m=4*(this._cubeSize-f);l.envMap.value=e.texture,l.roughness.value=c*(0+1.25*s),l.mipInt.value=d-n,W(a,p,m,3*f,2*f),r.setRenderTarget(a),r.render(o,I),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=d-t,W(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,I)}_blur(e,n,t,r,a){let i=this._pingPongRenderTarget;this._halfBlur(e,i,n,t,r,"latitudinal",a),this._halfBlur(i,e,t,t,r,"longitudinal",a)}_halfBlur(e,n,t,r,a,i,o){let l=this._renderer,s=this._blurMaterial;"latitudinal"!==i&&"longitudinal"!==i&&(0,S.error)("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[r];u.material=s;let c=s.uniforms,d=this._sizeLods[t]-1,f=isFinite(a)?Math.PI/(2*d):2*Math.PI/39,p=a/f,m=isFinite(a)?1+Math.floor(3*p):20;m>20&&(0,S.warn)(`sigmaRadians, ${a}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let h=[],g=0;for(let e=0;e<20;++e){let n=e/p,t=Math.exp(-n*n/2);h.push(t),0===e?g+=t:e_-4?r-_+4:0),E,3*v,2*v),l.setRenderTarget(n),l.render(u,I)}}function z(e,n,t){let r=new S.WebGLRenderTarget(e,n,t);return r.texture.mapping=S.CubeUVReflectionMapping,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function W(e,n,t,r,a){e.viewport.set(n,t,r,a),e.scissor.set(n,t,r,a)}function X(){return new S.ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - - #include - - void main() { - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})}function j(){return new S.ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - uniform float flipEnvMap; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - void main() { - - gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})}function q(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}function Y(e){let n=new WeakMap,t=null;function r(e){let t=e.target;t.removeEventListener("dispose",r);let a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}return{get:function(a){if(a&&a.isTexture){let i=a.mapping,o=i===S.EquirectangularReflectionMapping||i===S.EquirectangularRefractionMapping,l=i===S.CubeReflectionMapping||i===S.CubeRefractionMapping;if(o||l){let i=n.get(a),s=void 0!==i?i.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==s)return null===t&&(t=new V(e)),(i=o?t.fromEquirectangular(a,i):t.fromCubemap(a,i)).texture.pmremVersion=a.pmremVersion,n.set(a,i),i.texture;{if(void 0!==i)return i.texture;let s=a.image;return o&&s&&s.height>0||l&&s&&function(e){let n=0;for(let t=0;t<6;t++)void 0!==e[t]&&n++;return 6===n}(s)?(null===t&&(t=new V(e)),(i=o?t.fromEquirectangular(a):t.fromCubemap(a)).texture.pmremVersion=a.pmremVersion,n.set(a,i),a.addEventListener("dispose",r),i.texture):null}}}return a},dispose:function(){n=new WeakMap,null!==t&&(t.dispose(),t=null)}}}function K(e){let n={};function t(t){if(void 0!==n[t])return n[t];let r=e.getExtension(t);return n[t]=r,r}return{has:function(e){return null!==t(e)},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(e){let n=t(e);return null===n&&(0,S.warnOnce)("WebGLRenderer: "+e+" extension not supported."),n}}}function $(e,n,t,r){let a={},i=new WeakMap;function o(e){let l=e.target;for(let e in null!==l.index&&n.remove(l.index),l.attributes)n.remove(l.attributes[e]);l.removeEventListener("dispose",o),delete a[l.id];let s=i.get(l);s&&(n.remove(s),i.delete(l)),r.releaseStatesOfGeometry(l),!0===l.isInstancedBufferGeometry&&delete l._maxInstanceCount,t.memory.geometries--}function l(e){let t=[],r=e.index,a=e.attributes.position,o=0;if(null!==r){let e=r.array;o=r.version;for(let n=0,r=e.length;nn.maxTextureSize&&(m=Math.ceil(p/n.maxTextureSize),p=n.maxTextureSize);let h=new Float32Array(p*m*4*c),g=new S.DataArrayTexture(h,p,m,c);g.type=S.FloatType,g.needsUpdate=!0;let _=4*f;for(let n=0;n - #include - - void main() { - gl_FragColor = texture2D( tDiffuse, vUv ); - - #ifdef LINEAR_TONE_MAPPING - gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); - #elif defined( REINHARD_TONE_MAPPING ) - gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); - #elif defined( CINEON_TONE_MAPPING ) - gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); - #elif defined( ACES_FILMIC_TONE_MAPPING ) - gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); - #elif defined( AGX_TONE_MAPPING ) - gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); - #elif defined( NEUTRAL_TONE_MAPPING ) - gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); - #elif defined( CUSTOM_TONE_MAPPING ) - gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); - #endif - - #ifdef SRGB_TRANSFER - gl_FragColor = sRGBTransferOETF( gl_FragColor ); - #endif - }`,depthTest:!1,depthWrite:!1}),c=new S.Mesh(s,u),d=new S.OrthographicCamera(-1,1,1,-1,0,1),f=null,p=null,m=!1,h=null,g=[],_=!1;this.setSize=function(e,n){o.setSize(e,n),l.setSize(e,n);for(let t=0;t0&&!0===g[0].isRenderPass;let n=o.width,t=o.height;for(let e=0;e0)return e;let a=n*t,i=es[a];if(void 0===i&&(i=new Float32Array(a),es[a]=i),0!==n){r.toArray(i,0);for(let r=1,a=0;r!==n;++r)a+=t,e[r].toArray(i,a)}return i}function em(e,n){if(e.length!==n.length)return!1;for(let t=0,r=e.length;t0&&(this.seq=r.concat(a))}setValue(e,n,t,r){let a=this.map[n];void 0!==a&&a.setValue(e,t,r)}setOptional(e,n,t){let r=n[t];void 0!==r&&this.setValue(e,t,r)}static upload(e,n,t,r){for(let a=0,i=n.length;a!==i;++a){let i=n[a],o=t[i.id];!1!==o.needsUpdate&&i.setValue(e,o.value,r)}}static seqWithValue(e,n){let t=[];for(let r=0,a=e.length;r!==a;++r){let a=e[r];a.id in n&&t.push(a)}return t}}function e8(e,n,t){let r=e.createShader(n);return e.shaderSource(r,t),e.compileShader(r),r}let e9=0,e7=new S.Matrix3;function ne(e,n,t){let r=e.getShaderParameter(n,e.COMPILE_STATUS),a=(e.getShaderInfoLog(n)||"").trim();if(r&&""===a)return"";let i=/ERROR: 0:(\d+)/.exec(a);if(!i)return a;{let r=parseInt(i[1]);return t.toUpperCase()+"\n\n"+a+"\n\n"+function(e,n){let t=e.split("\n"),r=[],a=Math.max(n-6,0),i=Math.min(n+6,t.length);for(let e=a;e":" "} ${a}: ${t[e]}`)}return r.join("\n")}(e.getShaderSource(n),r)}}let nn={[S.LinearToneMapping]:"Linear",[S.ReinhardToneMapping]:"Reinhard",[S.CineonToneMapping]:"Cineon",[S.ACESFilmicToneMapping]:"ACESFilmic",[S.AgXToneMapping]:"AgX",[S.NeutralToneMapping]:"Neutral",[S.CustomToneMapping]:"Custom"},nt=new S.Vector3;function nr(e){return""!==e}function na(e,n){let t=n.numSpotLightShadows+n.numSpotLightMaps-n.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,n.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,n.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function ni(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}let no=/^[ \t]*#include +<([\w\d./]+)>/gm;function nl(e){return e.replace(no,nu)}let ns=new Map;function nu(e,n){let t=M[n];if(void 0===t){let e=ns.get(n);if(void 0!==e)t=M[e],(0,S.warn)('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,e);else throw Error("Can not resolve #include <"+n+">")}return nl(t)}let nc=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function nd(e){return e.replace(nc,nf)}function nf(e,n,t,r){let a="";for(let e=parseInt(n);e0&&(o+="\n"),(l=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(nr).join("\n")).length>0&&(l+="\n");else{let e,n,r,s,u;o=[np(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+g:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&!1===t.flatShading?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+m:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(nr).join("\n"),l=[np(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+g:"",t.envMap?"#define "+_:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+m:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==S.NoToneMapping?"#define TONE_MAPPING":"",t.toneMapping!==S.NoToneMapping?M.tonemapping_pars_fragment:"",t.toneMapping!==S.NoToneMapping?(a="toneMapping",void 0===(e=nn[i=t.toneMapping])?((0,S.warn)("WebGLProgram: Unsupported toneMapping:",i),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+e+"ToneMapping( color ); }"):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",M.colorspace_pars_fragment,(n=function(e){S.ColorManagement._getMatrix(e7,S.ColorManagement.workingColorSpace,e);let n=`mat3( ${e7.elements.map(e=>e.toFixed(4))} )`;switch(S.ColorManagement.getTransfer(e)){case S.LinearTransfer:return[n,"LinearTransferOETF"];case S.SRGBTransfer:return[n,"sRGBTransferOETF"];default:return(0,S.warn)("WebGLProgram: Unsupported color space: ",e),[n,"LinearTransferOETF"]}}(t.outputColorSpace),`vec4 linearToOutputTexel( vec4 value ) { - return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) ); -}`),(S.ColorManagement.getLuminanceCoefficients(nt),r=nt.x.toFixed(4),s=nt.y.toFixed(4),u=nt.z.toFixed(4),`float luminance( const in vec3 rgb ) { - const vec3 weights = vec3( ${r}, ${s}, ${u} ); - return dot( weights, rgb ); -}`),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"","\n"].filter(nr).join("\n")}f=ni(f=na(f=nl(f),t),t),p=ni(p=na(p=nl(p),t),t),f=nd(f),p=nd(p),!0!==t.isRawShaderMaterial&&(x="#version 300 es\n",o=[E,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+o,l=["#define varying in",t.glslVersion===S.GLSL3?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===S.GLSL3?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+l);let R=x+o+f,C=x+l+p,y=e8(c,c.VERTEX_SHADER,R),A=e8(c,c.FRAGMENT_SHADER,C);function P(n){if(e.debug.checkShaderErrors){let t=c.getProgramInfoLog(b)||"",r=c.getShaderInfoLog(y)||"",a=c.getShaderInfoLog(A)||"",i=t.trim(),s=r.trim(),u=a.trim(),d=!0,f=!0;if(!1===c.getProgramParameter(b,c.LINK_STATUS))if(d=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(c,b,y,A);else{let e=ne(c,y,"vertex"),t=ne(c,A,"fragment");(0,S.error)("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(b,c.VALIDATE_STATUS)+"\n\nMaterial Name: "+n.name+"\nMaterial Type: "+n.type+"\n\nProgram Info Log: "+i+"\n"+e+"\n"+t)}else""!==i?(0,S.warn)("WebGLProgram: Program Info Log:",i):(""===s||""===u)&&(f=!1);f&&(n.diagnostics={runnable:d,programLog:i,vertexShader:{log:s,prefix:o},fragmentShader:{log:u,prefix:l}})}c.deleteShader(y),c.deleteShader(A),s=new e6(c,b),u=function(e,n){let t={},r=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let a=0;a0,Y=i.clearcoat>0,K=i.dispersion>0,$=i.iridescence>0,Q=i.sheen>0,Z=i.transmission>0,J=q&&!!i.anisotropyMap,ee=Y&&!!i.clearcoatMap,en=Y&&!!i.clearcoatNormalMap,et=Y&&!!i.clearcoatRoughnessMap,er=$&&!!i.iridescenceMap,ea=$&&!!i.iridescenceThicknessMap,ei=Q&&!!i.sheenColorMap,eo=Q&&!!i.sheenRoughnessMap,el=!!i.specularMap,es=!!i.specularColorMap,eu=!!i.specularIntensityMap,ec=Z&&!!i.transmissionMap,ed=Z&&!!i.thicknessMap,ef=!!i.gradientMap,ep=!!i.alphaMap,em=i.alphaTest>0,eh=!!i.alphaHash,eg=!!i.extensions,e_=S.NoToneMapping;i.toneMapped&&(null===N||!0===N.isXRRenderTarget)&&(e_=e.toneMapping);let ev={shaderID:A,shaderType:i.type,shaderName:i.name,vertexShader:_,fragmentShader:v,defines:i.defines,customVertexShaderID:E,customFragmentShaderID:T,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:p,batching:I,batchingColor:I&&null!==g._colorsTexture,instancing:D,instancingColor:D&&null!==g.instanceColor,instancingMorph:D&&null!==g.morphTexture,outputColorSpace:null===N?e.outputColorSpace:!0===N.isXRRenderTarget?N.texture.colorSpace:S.LinearSRGBColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:F,matcap:O,envMap:B,envMapMode:B&&C.mapping,envMapCubeUVHeight:y,aoMap:G,lightMap:H,bumpMap:k,normalMap:V,displacementMap:z,emissiveMap:W,normalMapObjectSpace:V&&i.normalMapType===S.ObjectSpaceNormalMap,normalMapTangentSpace:V&&i.normalMapType===S.TangentSpaceNormalMap,metalnessMap:X,roughnessMap:j,anisotropy:q,anisotropyMap:J,clearcoat:Y,clearcoatMap:ee,clearcoatNormalMap:en,clearcoatRoughnessMap:et,dispersion:K,iridescence:$,iridescenceMap:er,iridescenceThicknessMap:ea,sheen:Q,sheenColorMap:ei,sheenRoughnessMap:eo,specularMap:el,specularColorMap:es,specularIntensityMap:eu,transmission:Z,transmissionMap:ec,thicknessMap:ed,gradientMap:ef,opaque:!1===i.transparent&&i.blending===S.NormalBlending&&!1===i.alphaToCoverage,alphaMap:ep,alphaTest:em,alphaHash:eh,combine:i.combine,mapUv:F&&h(i.map.channel),aoMapUv:G&&h(i.aoMap.channel),lightMapUv:H&&h(i.lightMap.channel),bumpMapUv:k&&h(i.bumpMap.channel),normalMapUv:V&&h(i.normalMap.channel),displacementMapUv:z&&h(i.displacementMap.channel),emissiveMapUv:W&&h(i.emissiveMap.channel),metalnessMapUv:X&&h(i.metalnessMap.channel),roughnessMapUv:j&&h(i.roughnessMap.channel),anisotropyMapUv:J&&h(i.anisotropyMap.channel),clearcoatMapUv:ee&&h(i.clearcoatMap.channel),clearcoatNormalMapUv:en&&h(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&h(i.clearcoatRoughnessMap.channel),iridescenceMapUv:er&&h(i.iridescenceMap.channel),iridescenceThicknessMapUv:ea&&h(i.iridescenceThicknessMap.channel),sheenColorMapUv:ei&&h(i.sheenColorMap.channel),sheenRoughnessMapUv:eo&&h(i.sheenRoughnessMap.channel),specularMapUv:el&&h(i.specularMap.channel),specularColorMapUv:es&&h(i.specularColorMap.channel),specularIntensityMapUv:eu&&h(i.specularIntensityMap.channel),transmissionMapUv:ec&&h(i.transmissionMap.channel),thicknessMapUv:ed&&h(i.thicknessMap.channel),alphaMapUv:ep&&h(i.alphaMap.channel),vertexTangents:!!b.attributes.tangent&&(V||q),vertexColors:i.vertexColors,vertexAlphas:!0===i.vertexColors&&!!b.attributes.color&&4===b.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!b.attributes.uv&&(F||ep),fog:!!M,useFog:!0===i.fog,fogExp2:!!M&&M.isFogExp2,flatShading:!0===i.flatShading&&!1===i.wireframe,sizeAttenuation:!0===i.sizeAttenuation,logarithmicDepthBuffer:f,reversedDepthBuffer:U,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==b.morphAttributes.position,morphNormals:void 0!==b.morphAttributes.normal,morphColors:void 0!==b.morphAttributes.color,morphTargetsCount:w,morphTextureStride:L,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:e_,decodeVideoTexture:F&&!0===i.map.isVideoTexture&&S.ColorManagement.getTransfer(i.map.colorSpace)===S.SRGBTransfer,decodeVideoTextureEmissive:W&&!0===i.emissiveMap.isVideoTexture&&S.ColorManagement.getTransfer(i.emissiveMap.colorSpace)===S.SRGBTransfer,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===S.DoubleSide,flipSided:i.side===S.BackSide,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:eg&&!0===i.extensions.clipCullDistance&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(eg&&!0===i.extensions.multiDraw||I)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:i.customProgramCacheKey()};return ev.vertexUv1s=u.has(1),ev.vertexUv2s=u.has(2),ev.vertexUv3s=u.has(3),u.clear(),ev},getProgramCacheKey:function(n){var t,r,a,i;let o=[];if(n.shaderID?o.push(n.shaderID):(o.push(n.customVertexShaderID),o.push(n.customFragmentShaderID)),void 0!==n.defines)for(let e in n.defines)o.push(e),o.push(n.defines[e]);return!1===n.isRawShaderMaterial&&(t=o,r=n,t.push(r.precision),t.push(r.outputColorSpace),t.push(r.envMapMode),t.push(r.envMapCubeUVHeight),t.push(r.mapUv),t.push(r.alphaMapUv),t.push(r.lightMapUv),t.push(r.aoMapUv),t.push(r.bumpMapUv),t.push(r.normalMapUv),t.push(r.displacementMapUv),t.push(r.emissiveMapUv),t.push(r.metalnessMapUv),t.push(r.roughnessMapUv),t.push(r.anisotropyMapUv),t.push(r.clearcoatMapUv),t.push(r.clearcoatNormalMapUv),t.push(r.clearcoatRoughnessMapUv),t.push(r.iridescenceMapUv),t.push(r.iridescenceThicknessMapUv),t.push(r.sheenColorMapUv),t.push(r.sheenRoughnessMapUv),t.push(r.specularMapUv),t.push(r.specularColorMapUv),t.push(r.specularIntensityMapUv),t.push(r.transmissionMapUv),t.push(r.thicknessMapUv),t.push(r.combine),t.push(r.fogExp2),t.push(r.sizeAttenuation),t.push(r.morphTargetsCount),t.push(r.morphAttributeCount),t.push(r.numDirLights),t.push(r.numPointLights),t.push(r.numSpotLights),t.push(r.numSpotLightMaps),t.push(r.numHemiLights),t.push(r.numRectAreaLights),t.push(r.numDirLightShadows),t.push(r.numPointLightShadows),t.push(r.numSpotLightShadows),t.push(r.numSpotLightShadowsWithMaps),t.push(r.numLightProbes),t.push(r.shadowMapType),t.push(r.toneMapping),t.push(r.numClippingPlanes),t.push(r.numClipIntersection),t.push(r.depthPacking),a=o,i=n,l.disableAll(),i.instancing&&l.enable(0),i.instancingColor&&l.enable(1),i.instancingMorph&&l.enable(2),i.matcap&&l.enable(3),i.envMap&&l.enable(4),i.normalMapObjectSpace&&l.enable(5),i.normalMapTangentSpace&&l.enable(6),i.clearcoat&&l.enable(7),i.iridescence&&l.enable(8),i.alphaTest&&l.enable(9),i.vertexColors&&l.enable(10),i.vertexAlphas&&l.enable(11),i.vertexUv1s&&l.enable(12),i.vertexUv2s&&l.enable(13),i.vertexUv3s&&l.enable(14),i.vertexTangents&&l.enable(15),i.anisotropy&&l.enable(16),i.alphaHash&&l.enable(17),i.batching&&l.enable(18),i.dispersion&&l.enable(19),i.batchingColor&&l.enable(20),i.gradientMap&&l.enable(21),a.push(l.mask),l.disableAll(),i.fog&&l.enable(0),i.useFog&&l.enable(1),i.flatShading&&l.enable(2),i.logarithmicDepthBuffer&&l.enable(3),i.reversedDepthBuffer&&l.enable(4),i.skinning&&l.enable(5),i.morphTargets&&l.enable(6),i.morphNormals&&l.enable(7),i.morphColors&&l.enable(8),i.premultipliedAlpha&&l.enable(9),i.shadowMapEnabled&&l.enable(10),i.doubleSided&&l.enable(11),i.flipSided&&l.enable(12),i.useDepthPacking&&l.enable(13),i.dithering&&l.enable(14),i.transmission&&l.enable(15),i.sheen&&l.enable(16),i.opaque&&l.enable(17),i.pointsUvs&&l.enable(18),i.decodeVideoTexture&&l.enable(19),i.decodeVideoTextureEmissive&&l.enable(20),i.alphaToCoverage&&l.enable(21),a.push(l.mask),o.push(e.outputColorSpace)),o.push(n.customProgramCacheKey),o.join()},getUniforms:function(e){let n,t=m[e.type];if(t){let e=x[t];n=S.UniformsUtils.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(n,t){let r=d.get(t);return void 0!==r?++r.usedTimes:(r=new nv(e,t,n,i),c.push(r),d.set(t,r)),r},releaseProgram:function(e){if(0==--e.usedTimes){let n=c.indexOf(e);c[n]=c[c.length-1],c.pop(),d.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:c,dispose:function(){s.dispose()}}}function nb(){let e=new WeakMap;return{has:function(n){return e.has(n)},get:function(n){let t=e.get(n);return void 0===t&&(t={},e.set(n,t)),t},remove:function(n){e.delete(n)},update:function(n,t,r){e.get(n)[t]=r},dispose:function(){e=new WeakMap}}}function nx(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.material.id!==n.material.id?e.material.id-n.material.id:e.z!==n.z?e.z-n.z:e.id-n.id}function nR(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.z!==n.z?n.z-e.z:e.id-n.id}function nC(){let e=[],n=0,t=[],r=[],a=[];function i(t,r,a,i,o,l){let s=e[n];return void 0===s?(s={id:t.id,object:t,geometry:r,material:a,groupOrder:i,renderOrder:t.renderOrder,z:o,group:l},e[n]=s):(s.id=t.id,s.object=t,s.geometry=r,s.material=a,s.groupOrder=i,s.renderOrder=t.renderOrder,s.z=o,s.group=l),n++,s}return{opaque:t,transmissive:r,transparent:a,init:function(){n=0,t.length=0,r.length=0,a.length=0},push:function(e,n,o,l,s,u){let c=i(e,n,o,l,s,u);o.transmission>0?r.push(c):!0===o.transparent?a.push(c):t.push(c)},unshift:function(e,n,o,l,s,u){let c=i(e,n,o,l,s,u);o.transmission>0?r.unshift(c):!0===o.transparent?a.unshift(c):t.unshift(c)},finish:function(){for(let t=n,r=e.length;t1&&t.sort(e||nx),r.length>1&&r.sort(n||nR),a.length>1&&a.sort(n||nR)}}}function ny(){let e=new WeakMap;return{get:function(n,t){let r,a=e.get(n);return void 0===a?(r=new nC,e.set(n,[r])):t>=a.length?(r=new nC,a.push(r)):r=a[t],r},dispose:function(){e=new WeakMap}}}function nA(){let e={};return{get:function(n){let t;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":t={direction:new S.Vector3,color:new S.Color};break;case"SpotLight":t={position:new S.Vector3,direction:new S.Vector3,color:new S.Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new S.Vector3,color:new S.Color,distance:0,decay:0};break;case"HemisphereLight":t={direction:new S.Vector3,skyColor:new S.Color,groundColor:new S.Color};break;case"RectAreaLight":t={color:new S.Color,position:new S.Vector3,halfWidth:new S.Vector3,halfHeight:new S.Vector3}}return e[n.id]=t,t}}}let nP=0;function nw(e,n){return 2*!!n.castShadow-2*!!e.castShadow+ +!!n.map-!!e.map}function nL(e){let n,t=new nA,r=(n={},{get:function(e){let t;if(void 0!==n[e.id])return n[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new S.Vector2};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new S.Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return n[e.id]=t,t}}),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)a.probe.push(new S.Vector3);let i=new S.Vector3,o=new S.Matrix4,l=new S.Matrix4;return{setup:function(n){let i=0,o=0,l=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let s=0,u=0,c=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;n.sort(nw);for(let e=0,E=n.length;e0&&(!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=b.LTC_FLOAT_1,a.rectAreaLTC2=b.LTC_FLOAT_2):(a.rectAreaLTC1=b.LTC_HALF_1,a.rectAreaLTC2=b.LTC_HALF_2)),a.ambient[0]=i,a.ambient[1]=o,a.ambient[2]=l;let E=a.hash;(E.directionalLength!==s||E.pointLength!==u||E.spotLength!==c||E.rectAreaLength!==d||E.hemiLength!==f||E.numDirectionalShadows!==p||E.numPointShadows!==m||E.numSpotShadows!==h||E.numSpotMaps!==g||E.numLightProbes!==v)&&(a.directional.length=s,a.spot.length=c,a.rectArea.length=d,a.point.length=u,a.hemi.length=f,a.directionalShadow.length=p,a.directionalShadowMap.length=p,a.pointShadow.length=m,a.pointShadowMap.length=m,a.spotShadow.length=h,a.spotShadowMap.length=h,a.directionalShadowMatrix.length=p,a.pointShadowMatrix.length=m,a.spotLightMatrix.length=h+g-_,a.spotLightMap.length=g,a.numSpotLightShadowsWithMaps=_,a.numLightProbes=v,E.directionalLength=s,E.pointLength=u,E.spotLength=c,E.rectAreaLength=d,E.hemiLength=f,E.numDirectionalShadows=p,E.numPointShadows=m,E.numSpotShadows=h,E.numSpotMaps=g,E.numLightProbes=v,a.version=nP++)},setupView:function(e,n){let t=0,r=0,s=0,u=0,c=0,d=n.matrixWorldInverse;for(let n=0,f=e.length;n=i.length?(a=new nN(e),i.push(a)):a=i[r],a},dispose:function(){n=new WeakMap}}}let nD=[new S.Vector3(1,0,0),new S.Vector3(-1,0,0),new S.Vector3(0,1,0),new S.Vector3(0,-1,0),new S.Vector3(0,0,1),new S.Vector3(0,0,-1)],nI=[new S.Vector3(0,-1,0),new S.Vector3(0,-1,0),new S.Vector3(0,0,1),new S.Vector3(0,0,-1),new S.Vector3(0,-1,0),new S.Vector3(0,-1,0)],nF=new S.Matrix4,nO=new S.Vector3,nB=new S.Vector3;function nG(e,n,t){let r=new S.Frustum,a=new S.Vector2,i=new S.Vector2,o=new S.Vector4,l=new S.MeshDepthMaterial,s=new S.MeshDistanceMaterial,u={},c=t.maxTextureSize,d={[S.FrontSide]:S.BackSide,[S.BackSide]:S.FrontSide,[S.DoubleSide]:S.DoubleSide},f=new S.ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new S.Vector2},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new S.BufferGeometry;m.setAttribute("position",new S.BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new S.Mesh(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=S.PCFShadowMap;let _=this.type;function v(n,t,r,a){let i=null,o=!0===r.isPointLight?n.customDistanceMaterial:n.customDepthMaterial;if(void 0!==o)i=o;else if(i=!0===r.isPointLight?s:l,e.localClippingEnabled&&!0===t.clipShadows&&Array.isArray(t.clippingPlanes)&&0!==t.clippingPlanes.length||t.displacementMap&&0!==t.displacementScale||t.alphaMap&&t.alphaTest>0||t.map&&t.alphaTest>0||!0===t.alphaToCoverage){let e=i.uuid,n=t.uuid,r=u[e];void 0===r&&(r={},u[e]=r);let a=r[n];void 0===a&&(a=i.clone(),r[n]=a,t.addEventListener("dispose",E)),i=a}return i.visible=t.visible,i.wireframe=t.wireframe,a===S.VSMShadowMap?i.side=null!==t.shadowSide?t.shadowSide:t.side:i.side=null!==t.shadowSide?t.shadowSide:d[t.side],i.alphaMap=t.alphaMap,i.alphaTest=!0===t.alphaToCoverage?.5:t.alphaTest,i.map=t.map,i.clipShadows=t.clipShadows,i.clippingPlanes=t.clippingPlanes,i.clipIntersection=t.clipIntersection,i.displacementMap=t.displacementMap,i.displacementScale=t.displacementScale,i.displacementBias=t.displacementBias,i.wireframeLinewidth=t.wireframeLinewidth,i.linewidth=t.linewidth,!0===r.isPointLight&&!0===i.isMeshDistanceMaterial&&(e.properties.get(i).light=r),i}function E(e){for(let n in e.target.removeEventListener("dispose",E),u){let t=u[n],r=e.target.uuid;r in t&&(t[r].dispose(),delete t[r])}}this.render=function(t,l,s){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===t.length)return;t.type===S.PCFSoftShadowMap&&((0,S.warn)("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),t.type=S.PCFShadowMap);let u=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),E=e.state;E.setBlending(S.NoBlending),!0===E.buffers.depth.getReversed()?E.buffers.color.setClear(0,0,0,0):E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);let T=_!==this.type;T&&l.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,d=t.length;uc||a.y>c)&&(a.x>c&&(i.x=Math.floor(c/g.x),a.x=i.x*g.x,m.mapSize.x=i.x),a.y>c&&(i.y=Math.floor(c/g.y),a.y=i.y*g.y,m.mapSize.y=i.y)),null===m.map||!0===T){if(null!==m.map&&(null!==m.map.depthTexture&&(m.map.depthTexture.dispose(),m.map.depthTexture=null),m.map.dispose()),this.type===S.VSMShadowMap){if(d.isPointLight){(0,S.warn)("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}m.map=new S.WebGLRenderTarget(a.x,a.y,{format:S.RGFormat,type:S.HalfFloatType,minFilter:S.LinearFilter,magFilter:S.LinearFilter,generateMipmaps:!1}),m.map.texture.name=d.name+".shadowMap",m.map.depthTexture=new S.DepthTexture(a.x,a.y,S.FloatType),m.map.depthTexture.name=d.name+".shadowMapDepth",m.map.depthTexture.format=S.DepthFormat,m.map.depthTexture.compareFunction=null,m.map.depthTexture.minFilter=S.NearestFilter,m.map.depthTexture.magFilter=S.NearestFilter}else{d.isPointLight?(m.map=new S.WebGLCubeRenderTarget(a.x),m.map.depthTexture=new S.CubeDepthTexture(a.x,S.UnsignedIntType)):(m.map=new S.WebGLRenderTarget(a.x,a.y),m.map.depthTexture=new S.DepthTexture(a.x,a.y,S.UnsignedIntType)),m.map.depthTexture.name=d.name+".shadowMap",m.map.depthTexture.format=S.DepthFormat;let n=e.state.buffers.depth.getReversed();this.type===S.PCFShadowMap?(m.map.depthTexture.compareFunction=n?S.GreaterEqualCompare:S.LessEqualCompare,m.map.depthTexture.minFilter=S.LinearFilter,m.map.depthTexture.magFilter=S.LinearFilter):(m.map.depthTexture.compareFunction=null,m.map.depthTexture.minFilter=S.NearestFilter,m.map.depthTexture.magFilter=S.NearestFilter)}m.camera.updateProjectionMatrix()}let _=m.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<_;t++){if(m.map.isWebGLCubeRenderTarget)e.setRenderTarget(m.map,t),e.clear();else{0===t&&(e.setRenderTarget(m.map),e.clear());let n=m.getViewport(t);o.set(i.x*n.x,i.y*n.y,i.x*n.z,i.y*n.w),E.viewport(o)}if(d.isPointLight){let e=m.camera,n=m.matrix,r=d.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),nO.setFromMatrixPosition(d.matrixWorld),e.position.copy(nO),nB.copy(e.position),nB.add(nD[t]),e.up.copy(nI[t]),e.lookAt(nB),e.updateMatrixWorld(),n.makeTranslation(-nO.x,-nO.y,-nO.z),nF.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),m._frustum.setFromProjectionMatrix(nF,e.coordinateSystem,e.reversedDepth)}else m.updateMatrices(d);r=m.getFrustum(),function t(a,i,o,l,s){if(!1===a.visible)return;if(a.layers.test(i.layers)&&(a.isMesh||a.isLine||a.isPoints)&&(a.castShadow||a.receiveShadow&&s===S.VSMShadowMap)&&(!a.frustumCulled||r.intersectsObject(a))){a.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,a.matrixWorld);let t=n.update(a),r=a.material;if(Array.isArray(r)){let n=t.groups;for(let u=0,c=n.length;u=1:-1!==L.indexOf("OpenGL ES")&&(w=parseFloat(/^OpenGL ES (\d)/.exec(L)[1])>=2);let N=null,U={},D=e.getParameter(e.SCISSOR_BOX),I=e.getParameter(e.VIEWPORT),F=new S.Vector4().fromArray(D),O=new S.Vector4().fromArray(I);function B(n,t,r,a){let i=new Uint8Array(4),o=e.createTexture();e.bindTexture(n,o),e.texParameteri(n,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(n,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;otypeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new S.Vector2,d=new WeakMap,f=new WeakMap,p=!1;try{p="u">typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function m(e,n){return p?new OffscreenCanvas(e,n):(0,S.createElementNS)("canvas")}function h(e,n,t){let r=1,a=z(e);if((a.width>t||a.height>t)&&(r=t/Math.max(a.width,a.height)),r<1)if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof VideoFrame&&e instanceof VideoFrame){let t=Math.floor(r*a.width),i=Math.floor(r*a.height);void 0===l&&(l=m(t,i));let o=n?m(t,i):l;return o.width=t,o.height=i,o.getContext("2d").drawImage(e,0,0,t,i),(0,S.warn)("WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+t+"x"+i+")."),o}else"data"in e&&(0,S.warn)("WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").");return e}function g(e){return e.generateMipmaps}function _(n){e.generateMipmap(n)}function v(t,r,a,i,o=!1){if(null!==t){if(void 0!==e[t])return e[t];(0,S.warn)("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}let l=r;if(r===e.RED&&(a===e.FLOAT&&(l=e.R32F),a===e.HALF_FLOAT&&(l=e.R16F),a===e.UNSIGNED_BYTE&&(l=e.R8)),r===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.R8UI),a===e.UNSIGNED_SHORT&&(l=e.R16UI),a===e.UNSIGNED_INT&&(l=e.R32UI),a===e.BYTE&&(l=e.R8I),a===e.SHORT&&(l=e.R16I),a===e.INT&&(l=e.R32I)),r===e.RG&&(a===e.FLOAT&&(l=e.RG32F),a===e.HALF_FLOAT&&(l=e.RG16F),a===e.UNSIGNED_BYTE&&(l=e.RG8)),r===e.RG_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RG8UI),a===e.UNSIGNED_SHORT&&(l=e.RG16UI),a===e.UNSIGNED_INT&&(l=e.RG32UI),a===e.BYTE&&(l=e.RG8I),a===e.SHORT&&(l=e.RG16I),a===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RGB8UI),a===e.UNSIGNED_SHORT&&(l=e.RGB16UI),a===e.UNSIGNED_INT&&(l=e.RGB32UI),a===e.BYTE&&(l=e.RGB8I),a===e.SHORT&&(l=e.RGB16I),a===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),a===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),a===e.UNSIGNED_INT&&(l=e.RGBA32UI),a===e.BYTE&&(l=e.RGBA8I),a===e.SHORT&&(l=e.RGBA16I),a===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(a===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),a===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let n=o?S.LinearTransfer:S.ColorManagement.getTransfer(i);a===e.FLOAT&&(l=e.RGBA32F),a===e.HALF_FLOAT&&(l=e.RGBA16F),a===e.UNSIGNED_BYTE&&(l=n===S.SRGBTransfer?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&n.get("EXT_color_buffer_float"),l}function E(n,t){let r;return n?null===t||t===S.UnsignedIntType||t===S.UnsignedInt248Type?r=e.DEPTH24_STENCIL8:t===S.FloatType?r=e.DEPTH32F_STENCIL8:t===S.UnsignedShortType&&(r=e.DEPTH24_STENCIL8,(0,S.warn)("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===t||t===S.UnsignedIntType||t===S.UnsignedInt248Type?r=e.DEPTH_COMPONENT24:t===S.FloatType?r=e.DEPTH_COMPONENT32F:t===S.UnsignedShortType&&(r=e.DEPTH_COMPONENT16),r}function T(e,n){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==S.NearestFilter&&e.minFilter!==S.LinearFilter?Math.log2(Math.max(n.width,n.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?n.mipmaps.length:1}function M(e){let n=e.target;n.removeEventListener("dispose",M),function(e){let n=r.get(e);if(void 0===n.__webglInit)return;let t=e.source,a=f.get(t);if(a){let r=a[n.__cacheKey];r.usedTimes--,0===r.usedTimes&&x(e),0===Object.keys(a).length&&f.delete(t)}r.remove(e)}(n),n.isVideoTexture&&d.delete(n)}function b(n){let t=n.target;t.removeEventListener("dispose",b),function(n){let t=r.get(n);if(n.depthTexture&&(n.depthTexture.dispose(),r.remove(n.depthTexture)),n.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(t.__webglFramebuffer[n]))for(let r=0;r0&&s.__version!==n.version){let e=n.image;if(null===e)(0,S.warn)("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void U(s,n,a);(0,S.warn)("WebGLRenderer: Texture marked for update but image is incomplete")}}else n.isExternalTexture&&(s.__webglTexture=n.sourceTexture?n.sourceTexture:null);t.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+a)}let y={[S.RepeatWrapping]:e.REPEAT,[S.ClampToEdgeWrapping]:e.CLAMP_TO_EDGE,[S.MirroredRepeatWrapping]:e.MIRRORED_REPEAT},A={[S.NearestFilter]:e.NEAREST,[S.NearestMipmapNearestFilter]:e.NEAREST_MIPMAP_NEAREST,[S.NearestMipmapLinearFilter]:e.NEAREST_MIPMAP_LINEAR,[S.LinearFilter]:e.LINEAR,[S.LinearMipmapNearestFilter]:e.LINEAR_MIPMAP_NEAREST,[S.LinearMipmapLinearFilter]:e.LINEAR_MIPMAP_LINEAR},P={[S.NeverCompare]:e.NEVER,[S.AlwaysCompare]:e.ALWAYS,[S.LessCompare]:e.LESS,[S.LessEqualCompare]:e.LEQUAL,[S.EqualCompare]:e.EQUAL,[S.GreaterEqualCompare]:e.GEQUAL,[S.GreaterCompare]:e.GREATER,[S.NotEqualCompare]:e.NOTEQUAL};function w(t,i){if((i.type===S.FloatType&&!1===n.has("OES_texture_float_linear")&&(i.magFilter===S.LinearFilter||i.magFilter===S.LinearMipmapNearestFilter||i.magFilter===S.NearestMipmapLinearFilter||i.magFilter===S.LinearMipmapLinearFilter||i.minFilter===S.LinearFilter||i.minFilter===S.LinearMipmapNearestFilter||i.minFilter===S.NearestMipmapLinearFilter||i.minFilter===S.LinearMipmapLinearFilter)&&(0,S.warn)("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(t,e.TEXTURE_WRAP_S,y[i.wrapS]),e.texParameteri(t,e.TEXTURE_WRAP_T,y[i.wrapT]),(t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY)&&e.texParameteri(t,e.TEXTURE_WRAP_R,y[i.wrapR]),e.texParameteri(t,e.TEXTURE_MAG_FILTER,A[i.magFilter]),e.texParameteri(t,e.TEXTURE_MIN_FILTER,A[i.minFilter]),i.compareFunction&&(e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,P[i.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic"))&&i.magFilter!==S.NearestFilter&&(i.minFilter===S.NearestMipmapLinearFilter||i.minFilter===S.LinearMipmapLinearFilter)&&(i.type!==S.FloatType||!1!==n.has("OES_texture_float_linear"))&&(i.anisotropy>1||r.get(i).__currentAnisotropy)){let o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,a.getMaxAnisotropy())),r.get(i).__currentAnisotropy=i.anisotropy}}function L(n,t){let r,a=!1;void 0===n.__webglInit&&(n.__webglInit=!0,t.addEventListener("dispose",M));let i=t.source,l=f.get(i);void 0===l&&(l={},f.set(i,l));let s=((r=[]).push(t.wrapS),r.push(t.wrapT),r.push(t.wrapR||0),r.push(t.magFilter),r.push(t.minFilter),r.push(t.anisotropy),r.push(t.internalFormat),r.push(t.format),r.push(t.type),r.push(t.generateMipmaps),r.push(t.premultiplyAlpha),r.push(t.flipY),r.push(t.unpackAlignment),r.push(t.colorSpace),r.join());if(s!==n.__cacheKey){void 0===l[s]&&(l[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,a=!0),l[s].usedTimes++;let r=l[n.__cacheKey];void 0!==r&&(l[n.__cacheKey].usedTimes--,0===r.usedTimes&&x(t)),n.__cacheKey=s,n.__webglTexture=l[s].texture}return a}function N(e,n,t){return Math.floor(Math.floor(e/t)/n)}function U(n,o,l){let s=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(s=e.TEXTURE_3D);let u=L(n,o),c=o.source;t.bindTexture(s,n.__webglTexture,e.TEXTURE0+l);let d=r.get(c);if(c.version!==d.__version||!0===u){let n;t.activeTexture(e.TEXTURE0+l);let r=S.ColorManagement.getPrimaries(S.ColorManagement.workingColorSpace),f=o.colorSpace===S.NoColorSpace?null:S.ColorManagement.getPrimaries(o.colorSpace),p=o.colorSpace===S.NoColorSpace||r===f?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let m=h(o.image,!1,a.maxTextureSize);m=V(o,m);let M=i.convert(o.format,o.colorSpace),b=i.convert(o.type),x=v(o.internalFormat,M,b,o.colorSpace,o.isVideoTexture);w(s,o);let R=o.mipmaps,C=!0!==o.isVideoTexture,y=void 0===d.__version||!0===u,A=c.dataReady,P=T(o,m);if(o.isDepthTexture)x=E(o.format===S.DepthStencilFormat,o.type),y&&(C?t.texStorage2D(e.TEXTURE_2D,1,x,m.width,m.height):t.texImage2D(e.TEXTURE_2D,0,x,m.width,m.height,0,M,b,null));else if(o.isDataTexture)if(R.length>0){C&&y&&t.texStorage2D(e.TEXTURE_2D,P,x,R[0].width,R[0].height);for(let r=0,a=R.length;re.start-n.start);let l=0;for(let e=1;e0){let a=(0,S.getByteLength)(n.width,n.height,o.format,o.type);for(let i of o.layerUpdates){let o=n.data.subarray(i*a/n.data.BYTES_PER_ELEMENT,(i+1)*a/n.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,i,n.width,n.height,1,M,o)}o.clearLayerUpdates()}else t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,n.width,n.height,m.depth,M,n.data)}else t.compressedTexImage3D(e.TEXTURE_2D_ARRAY,r,x,n.width,n.height,m.depth,0,n.data,0,0);else(0,S.warn)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else C?A&&t.texSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,n.width,n.height,m.depth,M,b,n.data):t.texImage3D(e.TEXTURE_2D_ARRAY,r,x,n.width,n.height,m.depth,0,M,b,n.data)}else{C&&y&&t.texStorage2D(e.TEXTURE_2D,P,x,R[0].width,R[0].height);for(let r=0,a=R.length;r0){let n=(0,S.getByteLength)(m.width,m.height,o.format,o.type);for(let r of o.layerUpdates){let a=m.data.subarray(r*n/m.data.BYTES_PER_ELEMENT,(r+1)*n/m.data.BYTES_PER_ELEMENT);t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,m.width,m.height,1,M,b,a)}o.clearLayerUpdates()}else t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,M,b,m.data)}else t.texImage3D(e.TEXTURE_2D_ARRAY,0,x,m.width,m.height,m.depth,0,M,b,m.data);else if(o.isData3DTexture)C?(y&&t.texStorage3D(e.TEXTURE_3D,P,x,m.width,m.height,m.depth),A&&t.texSubImage3D(e.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,M,b,m.data)):t.texImage3D(e.TEXTURE_3D,0,x,m.width,m.height,m.depth,0,M,b,m.data);else if(o.isFramebufferTexture){if(y)if(C)t.texStorage2D(e.TEXTURE_2D,P,x,m.width,m.height);else{let n=m.width,r=m.height;for(let a=0;a>=1,r>>=1}}else if(R.length>0){if(C&&y){let n=z(R[0]);t.texStorage2D(e.TEXTURE_2D,P,x,n.width,n.height)}for(let r=0,a=R.length;r>c),r=Math.max(1,a.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?t.texImage3D(u,c,p,n,r,a.depth,0,d,f,null):t.texImage2D(u,c,p,n,r,0,d,f,null)}t.bindFramebuffer(e.FRAMEBUFFER,n),k(a)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,h.__webglTexture,0,H(a)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,h.__webglTexture,c),t.bindFramebuffer(e.FRAMEBUFFER,null)}function I(n,t,r){if(e.bindRenderbuffer(e.RENDERBUFFER,n),t.depthBuffer){let a=t.depthTexture,i=a&&a.isDepthTexture?a.type:null,o=E(t.stencilBuffer,i),l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;k(t)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(t),o,t.width,t.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(t),o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,n)}else{let n=t.textures;for(let a=0;a{delete a.__boundDepthTexture,delete a.__depthDisposeCallback,e.removeEventListener("dispose",n)};e.addEventListener("dispose",n),a.__depthDisposeCallback=n}a.__boundDepthTexture=e}if(n.depthTexture&&!a.__autoAllocateDepthBuffer)if(i)for(let e=0;e<6;e++)F(a.__webglFramebuffer[e],n,e);else{let e=n.texture.mipmaps;e&&e.length>0?F(a.__webglFramebuffer[0],n,0):F(a.__webglFramebuffer,n,0)}else if(i){a.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[r]),void 0===a.__webglDepthbuffer[r])a.__webglDepthbuffer[r]=e.createRenderbuffer(),I(a.__webglDepthbuffer[r],n,!1);else{let t=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=a.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,t,e.RENDERBUFFER,i)}}else{let r=n.texture.mipmaps;if(r&&r.length>0?t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[0]):t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),void 0===a.__webglDepthbuffer)a.__webglDepthbuffer=e.createRenderbuffer(),I(a.__webglDepthbuffer,n,!1);else{let t=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=a.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,t,e.RENDERBUFFER,r)}}t.bindFramebuffer(e.FRAMEBUFFER,null)}let B=[],G=[];function H(e){return Math.min(a.maxSamples,e.samples)}function k(e){let t=r.get(e);return e.samples>0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==t.__useRenderToTexture}function V(e,n){let t=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||t!==S.LinearSRGBColorSpace&&t!==S.NoColorSpace&&(S.ColorManagement.getTransfer(t)===S.SRGBTransfer?(r!==S.RGBAFormat||a!==S.UnsignedByteType)&&(0,S.warn)("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):(0,S.error)("WebGLTextures: Unsupported texture color space:",t)),n}function z(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"u">typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){let e=R;return e>=a.maxTextures&&(0,S.warn)("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=C,this.setTexture2DArray=function(n,a){let i=r.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?U(i,n,a):(n.isExternalTexture&&(i.__webglTexture=n.sourceTexture?n.sourceTexture:null),t.bindTexture(e.TEXTURE_2D_ARRAY,i.__webglTexture,e.TEXTURE0+a))},this.setTexture3D=function(n,a){let i=r.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?U(i,n,a):t.bindTexture(e.TEXTURE_3D,i.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(n,o){let l=r.get(n);!0!==n.isCubeDepthTexture&&n.version>0&&l.__version!==n.version?function(n,o,l){if(6!==o.image.length)return;let s=L(n,o),u=o.source;t.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture,e.TEXTURE0+l);let c=r.get(u);if(u.version!==c.__version||!0===s){let n;t.activeTexture(e.TEXTURE0+l);let r=S.ColorManagement.getPrimaries(S.ColorManagement.workingColorSpace),d=o.colorSpace===S.NoColorSpace?null:S.ColorManagement.getPrimaries(o.colorSpace),f=o.colorSpace===S.NoColorSpace||r===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let p=o.isCompressedTexture||o.image[0].isCompressedTexture,m=o.image[0]&&o.image[0].isDataTexture,E=[];for(let e=0;e<6;e++)p||m?E[e]=m?o.image[e].image:o.image[e]:E[e]=h(o.image[e],!0,a.maxCubemapSize),E[e]=V(o,E[e]);let M=E[0],b=i.convert(o.format,o.colorSpace),x=i.convert(o.type),R=v(o.internalFormat,b,x,o.colorSpace),C=!0!==o.isVideoTexture,y=void 0===c.__version||!0===s,A=u.dataReady,P=T(o,M);if(w(e.TEXTURE_CUBE_MAP,o),p){C&&y&&t.texStorage2D(e.TEXTURE_CUBE_MAP,P,R,M.width,M.height);for(let r=0;r<6;r++){n=E[r].mipmaps;for(let a=0;a0&&P++;let r=z(E[0]);t.texStorage2D(e.TEXTURE_CUBE_MAP,P,R,r.width,r.height)}for(let r=0;r<6;r++)if(m){C?A&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,0,0,E[r].width,E[r].height,b,x,E[r].data):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,R,E[r].width,E[r].height,0,b,x,E[r].data);for(let a=0;a1;if(!d&&(void 0===s.__webglTexture&&(s.__webglTexture=e.createTexture()),s.__version=a.version,o.memory.textures++),c){l.__webglFramebuffer=[];for(let n=0;n<6;n++)if(a.mipmaps&&a.mipmaps.length>0){l.__webglFramebuffer[n]=[];for(let t=0;t0){l.__webglFramebuffer=[];for(let n=0;n0&&!1===k(n)){l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],t.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(let t=0;t0)for(let r=0;r0)for(let t=0;t0){if(!1===k(n)){let a=n.textures,i=n.width,o=n.height,l=e.COLOR_BUFFER_BIT,s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=r.get(n),d=a.length>1;if(d)for(let n=0;n0?t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let t=0;t= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class nj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(null===this.texture){let t=new S.ExternalTexture(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=t}}getMesh(e){if(null!==this.texture&&null===this.mesh){let n=e.cameras[0].viewport,t=new S.ShaderMaterial({vertexShader:nW,fragmentShader:nX,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new S.Mesh(new S.PlaneGeometry(20,20),t)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class nq extends S.EventDispatcher{constructor(e,n){super();const t=this;let r=null,a=1,i=null,o="local-floor",l=1,s=null,u=null,c=null,d=null,f=null,p=null;const m="u">typeof XRWebGLBinding,h=new nj,g={},_=n.getContextAttributes();let v=null,T=null;const M=[],b=[],x=new S.Vector2;let R=null;const C=new S.PerspectiveCamera;C.viewport=new S.Vector4;const y=new S.PerspectiveCamera;y.viewport=new S.Vector4;const A=[C,y],P=new S.ArrayCamera;let w=null,L=null;function N(e){let n=b.indexOf(e.inputSource);if(-1===n)return;let t=M[n];void 0!==t&&(t.update(e.inputSource,e.frame,s||i),t.dispatchEvent({type:e.type,data:e.inputSource}))}function U(){r.removeEventListener("select",N),r.removeEventListener("selectstart",N),r.removeEventListener("selectend",N),r.removeEventListener("squeeze",N),r.removeEventListener("squeezestart",N),r.removeEventListener("squeezeend",N),r.removeEventListener("end",U),r.removeEventListener("inputsourceschange",D);for(let e=0;e=0&&(b[r]=null,M[r].disconnect(t))}for(let n=0;n=b.length){b.push(t),r=e;break}else if(null===b[e]){b[e]=t,r=e;break}if(-1===r)break}let a=M[r];a&&a.connect(t)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getTargetRaySpace()},this.getControllerGrip=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getGripSpace()},this.getHand=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===t.isPresenting&&(0,S.warn)("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===t.isPresenting&&(0,S.warn)("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||i},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==d?d:f},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(r,n)),c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(u){if(null!==(r=u)){if(v=e.getRenderTarget(),r.addEventListener("select",N),r.addEventListener("selectstart",N),r.addEventListener("selectend",N),r.addEventListener("squeeze",N),r.addEventListener("squeezestart",N),r.addEventListener("squeezeend",N),r.addEventListener("end",U),r.addEventListener("inputsourceschange",D),!0!==_.xrCompatible&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(x),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let t=null,i=null,o=null;_.depth&&(o=_.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,t=_.stencil?S.DepthStencilFormat:S.DepthFormat,i=_.stencil?S.UnsignedInt248Type:S.UnsignedIntType);let l={colorFormat:n.RGBA8,depthFormat:o,scaleFactor:a};d=(c=this.getBinding()).createProjectionLayer(l),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new S.WebGLRenderTarget(d.textureWidth,d.textureHeight,{format:S.RGBAFormat,type:S.UnsignedByteType,depthTexture:new S.DepthTexture(d.textureWidth,d.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,t),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:4*!!_.antialias,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{let t={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(r,n,t),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),T=new S.WebGLRenderTarget(f.framebufferWidth,f.framebufferHeight,{format:S.RGBAFormat,type:S.UnsignedByteType,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===f.ignoreDepthValues,resolveStencilBuffer:!1===f.ignoreDepthValues})}T.isXRRenderTarget=!0,this.setFoveation(l),s=null,i=await r.requestReferenceSpace(o),G.setContext(r),G.start(),t.isPresenting=!0,t.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};const I=new S.Vector3,F=new S.Vector3;function O(e,n){null===n?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(n.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var n,t,a;if(null===r)return;let i=e.near,o=e.far;null!==h.texture&&(h.depthNear>0&&(i=h.depthNear),h.depthFar>0&&(o=h.depthFar)),P.near=y.near=C.near=i,P.far=y.far=C.far=o,(w!==P.near||L!==P.far)&&(r.updateRenderState({depthNear:P.near,depthFar:P.far}),w=P.near,L=P.far),P.layers.mask=6|e.layers.mask,C.layers.mask=3&P.layers.mask,y.layers.mask=5&P.layers.mask;let l=e.parent,s=P.cameras;O(P,l);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let a=n.get(r),i=a.envMap,o=a.envMapRotation;i&&(e.envMap.value=i,nY.copy(o),nY.x*=-1,nY.y*=-1,nY.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(nY.y*=-1,nY.z*=-1),e.envMapRotation.value.setFromMatrix4(nK.makeRotationFromEuler(nY)),e.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,t(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,t(r.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(n,t){t.color.getRGB(n.fogColor.value,(0,S.getUnlitUniformColorSpace)(e)),t.isFog?(n.fogNear.value=t.near,n.fogFar.value=t.far):t.isFogExp2&&(n.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,a,i,o,l){var s,u,c,d,f,p,m,h,g,_,v,E,T,M,b,x,R,C,y,A,P,w,L;let N;a.isMeshBasicMaterial||a.isMeshLambertMaterial?r(e,a):a.isMeshToonMaterial?(r(e,a),s=e,(u=a).gradientMap&&(s.gradientMap.value=u.gradientMap)):a.isMeshPhongMaterial?(r(e,a),c=e,d=a,c.specular.value.copy(d.specular),c.shininess.value=Math.max(d.shininess,1e-4)):a.isMeshStandardMaterial?(r(e,a),f=e,p=a,f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity),a.isMeshPhysicalMaterial&&(m=e,h=a,g=l,m.ior.value=h.ior,h.sheen>0&&(m.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),m.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(m.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,m.sheenColorMapTransform)),h.sheenRoughnessMap&&(m.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,m.sheenRoughnessMapTransform))),h.clearcoat>0&&(m.clearcoat.value=h.clearcoat,m.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(m.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,m.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(m.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===S.BackSide&&m.clearcoatNormalScale.value.negate())),h.dispersion>0&&(m.dispersion.value=h.dispersion),h.iridescence>0&&(m.iridescence.value=h.iridescence,m.iridescenceIOR.value=h.iridescenceIOR,m.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(m.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,m.iridescenceMapTransform)),h.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),h.transmission>0&&(m.transmission.value=h.transmission,m.transmissionSamplerMap.value=g.texture,m.transmissionSamplerSize.value.set(g.width,g.height),h.transmissionMap&&(m.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,m.transmissionMapTransform)),m.thickness.value=h.thickness,h.thicknessMap&&(m.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=h.attenuationDistance,m.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(m.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(m.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=h.specularIntensity,m.specularColor.value.copy(h.specularColor),h.specularColorMap&&(m.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,m.specularColorMapTransform)),h.specularIntensityMap&&(m.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,m.specularIntensityMapTransform)))):a.isMeshMatcapMaterial?(r(e,a),_=e,(v=a).matcap&&(_.matcap.value=v.matcap)):a.isMeshDepthMaterial?r(e,a):a.isMeshDistanceMaterial?(r(e,a),E=e,T=a,N=n.get(T).light,E.referencePosition.value.setFromMatrixPosition(N.matrixWorld),E.nearDistance.value=N.shadow.camera.near,E.farDistance.value=N.shadow.camera.far):a.isMeshNormalMaterial?r(e,a):a.isLineBasicMaterial?(M=e,b=a,M.diffuse.value.copy(b.color),M.opacity.value=b.opacity,b.map&&(M.map.value=b.map,t(b.map,M.mapTransform)),a.isLineDashedMaterial&&(x=e,R=a,x.dashSize.value=R.dashSize,x.totalSize.value=R.dashSize+R.gapSize,x.scale.value=R.scale)):a.isPointsMaterial?(C=e,y=a,A=i,P=o,C.diffuse.value.copy(y.color),C.opacity.value=y.opacity,C.size.value=y.size*A,C.scale.value=.5*P,y.map&&(C.map.value=y.map,t(y.map,C.uvTransform)),y.alphaMap&&(C.alphaMap.value=y.alphaMap,t(y.alphaMap,C.alphaMapTransform)),y.alphaTest>0&&(C.alphaTest.value=y.alphaTest)):a.isSpriteMaterial?(w=e,L=a,w.diffuse.value.copy(L.color),w.opacity.value=L.opacity,w.rotation.value=L.rotation,L.map&&(w.map.value=L.map,t(L.map,w.mapTransform)),L.alphaMap&&(w.alphaMap.value=L.alphaMap,t(L.alphaMap,w.alphaMapTransform)),L.alphaTest>0&&(w.alphaTest.value=L.alphaTest)):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}function nQ(e,n,t,r){let a={},i={},o=[],l=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function s(e){let n={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=48,n.storage=48):e.isMatrix4?(n.boundary=64,n.storage=64):e.isTexture?(0,S.warn)("WebGLRenderer: Texture samplers can not be part of an uniforms group."):(0,S.warn)("WebGLRenderer: Unsupported uniform value type.",e),n}function u(n){let t=n.target;t.removeEventListener("dispose",u);let r=o.indexOf(t.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(a[t.id]),delete a[t.id],delete i[t.id]}return{bind:function(e,n){let t=n.program;r.uniformBlockBinding(e,t)},update:function(t,c){var d;let f,p,m,h,g=a[t.id];void 0===g&&(function(e){let n=e.uniforms,t=0;for(let e=0,r=n.length;e0&&(t+=16-r),e.__size=t,e.__cache={}}(t),(d=t).__bindingPointIndex=f=function(){for(let e=0;etypeof WebGLRenderingContext&&F instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");n=F.getContextAttributes().alpha}else n=G;const q=new Set([S.RGBAIntegerFormat,S.RGIntegerFormat,S.RedIntegerFormat]),en=new Set([S.UnsignedByteType,S.UnsignedIntType,S.UnsignedShortType,S.UnsignedInt248Type,S.UnsignedShort4444Type,S.UnsignedShort5551Type]),er=new Uint32Array(4),ea=new Int32Array(4);let ei=null,eo=null;const el=[],es=[];let eu=null;this.domElement=I,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=S.NoToneMapping,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const ec=this;let ed=!1;this._outputColorSpace=S.SRGBColorSpace;let ef=0,ep=0,em=null,eh=-1,eg=null;const e_=new S.Vector4,ev=new S.Vector4;let eS=null;const eE=new S.Color(0);let eT=0,eM=I.width,eb=I.height,ex=1,eR=null,eC=null;const ey=new S.Vector4(0,0,eM,eb),eA=new S.Vector4(0,0,eM,eb);let eP=!1;const ew=new S.Frustum;let eL=!1,eN=!1;const eU=new S.Matrix4,eD=new S.Vector3,eI=new S.Vector4,eF={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let eO=!1;function eB(){return null===em?ex:1}let eG=F;function eH(e,n){return I.getContext(e,n)}try{if("setAttribute"in I&&I.setAttribute("data-engine",`three.js r${S.REVISION}`),I.addEventListener("webglcontextlost",ez,!1),I.addEventListener("webglcontextrestored",eW,!1),I.addEventListener("webglcontextcreationerror",eX,!1),null===eG){const e="webgl2";if(eG=eH(e,{alpha:!0,depth:O,stencil:B,antialias:H,premultipliedAlpha:k,preserveDrawingBuffer:V,powerPreference:z,failIfMajorPerformanceCaveat:W}),null===eG)if(eH(e))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(e){throw(0,S.error)("WebGLRenderer: "+e.message),e}function ek(){(t=new K(eG)).init(),C=new nz(eG,t),r=new L(eG,t,e,C),a=new nk(eG,t),r.reversedDepthBuffer&&X&&a.buffers.depth.setReversed(!0),i=new Z(eG),o=new nb,l=new nV(eG,t,a,o,r,C,i),s=new U(ec),u=new Y(ec),c=new T(eG),y=new P(eG,c),d=new $(eG,c,i,y),f=new ee(eG,d,c,i),b=new J(eG,r,l),_=new N(o),p=new nM(ec,s,u,t,r,y,_),m=new n$(ec,o),h=new ny,g=new nU(t),M=new A(ec,s,u,a,f,n,k),v=new nG(ec,f,r),D=new nQ(eG,i,r,a),x=new w(eG,t,i),R=new Q(eG,t,i),i.programs=p.programs,ec.capabilities=r,ec.extensions=t,ec.properties=o,ec.renderLists=h,ec.shadowMap=v,ec.state=a,ec.info=i}ek(),j!==S.UnsignedByteType&&(eu=new et(j,I.width,I.height,O,B));const eV=new nq(ec,eG);function ez(e){e.preventDefault(),(0,S.log)("WebGLRenderer: Context Lost."),ed=!0}function eW(){(0,S.log)("WebGLRenderer: Context Restored."),ed=!1;let e=i.autoReset,n=v.enabled,t=v.autoUpdate,r=v.needsUpdate,a=v.type;ek(),i.autoReset=e,v.enabled=n,v.autoUpdate=t,v.needsUpdate=r,v.type=a}function eX(e){(0,S.error)("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function ej(e){var n,t;let r,a=e.target;a.removeEventListener("dispose",ej),t=n=a,void 0!==(r=o.get(t).programs)&&(r.forEach(function(e){p.releaseProgram(e)}),t.isShaderMaterial&&p.releaseShaderCache(t)),o.remove(n)}function eq(e,n,t){!0===e.transparent&&e.side===S.DoubleSide&&!1===e.forceSinglePass?(e.side=S.BackSide,e.needsUpdate=!0,e2(e,n,t),e.side=S.FrontSide,e.needsUpdate=!0,e2(e,n,t),e.side=S.DoubleSide):e2(e,n,t)}this.xr=eV,this.getContext=function(){return eG},this.getContextAttributes=function(){return eG.getContextAttributes()},this.forceContextLoss=function(){let e=t.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=t.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ex},this.setPixelRatio=function(e){void 0!==e&&(ex=e,this.setSize(eM,eb,!1))},this.getSize=function(e){return e.set(eM,eb)},this.setSize=function(e,n,t=!0){eV.isPresenting?(0,S.warn)("WebGLRenderer: Can't change size while VR device is presenting."):(eM=e,eb=n,I.width=Math.floor(e*ex),I.height=Math.floor(n*ex),!0===t&&(I.style.width=e+"px",I.style.height=n+"px"),null!==eu&&eu.setSize(I.width,I.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(eM*ex,eb*ex).floor()},this.setDrawingBufferSize=function(e,n,t){eM=e,eb=n,ex=t,I.width=Math.floor(e*t),I.height=Math.floor(n*t),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(j===S.UnsignedByteType)return void console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");if(e){for(let n=0;np.matrixWorld.determinant(),E=function(e,n,t,i,c){var d,f;!0!==n.isScene&&(n=eF),l.resetTextureUnits();let p=n.fog,h=i.isMeshStandardMaterial?n.environment:null,g=null===em?ec.outputColorSpace:!0===em.isXRRenderTarget?em.texture.colorSpace:S.LinearSRGBColorSpace,v=(i.isMeshStandardMaterial?u:s).get(i.envMap||h),E=!0===i.vertexColors&&!!t.attributes.color&&4===t.attributes.color.itemSize,T=!!t.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),M=!!t.morphAttributes.position,x=!!t.morphAttributes.normal,R=!!t.morphAttributes.color,C=S.NoToneMapping;i.toneMapped&&(null===em||!0===em.isXRRenderTarget)&&(C=ec.toneMapping);let y=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,A=void 0!==y?y.length:0,P=o.get(i),w=eo.state.lights;if(!0===eL&&(!0===eN||e!==eg)){let n=e===eg&&i.id===eh;_.setState(i,e,n)}let L=!1;i.version===P.__version?P.needsLights&&P.lightsStateVersion!==w.state.version||P.outputColorSpace!==g||c.isBatchedMesh&&!1===P.batching?L=!0:c.isBatchedMesh||!0!==P.batching?c.isBatchedMesh&&!0===P.batchingColor&&null===c.colorTexture||c.isBatchedMesh&&!1===P.batchingColor&&null!==c.colorTexture||c.isInstancedMesh&&!1===P.instancing?L=!0:c.isInstancedMesh||!0!==P.instancing?c.isSkinnedMesh&&!1===P.skinning?L=!0:c.isSkinnedMesh||!0!==P.skinning?c.isInstancedMesh&&!0===P.instancingColor&&null===c.instanceColor||c.isInstancedMesh&&!1===P.instancingColor&&null!==c.instanceColor||c.isInstancedMesh&&!0===P.instancingMorph&&null===c.morphTexture||c.isInstancedMesh&&!1===P.instancingMorph&&null!==c.morphTexture||P.envMap!==v||!0===i.fog&&P.fog!==p||void 0!==P.numClippingPlanes&&(P.numClippingPlanes!==_.numPlanes||P.numIntersection!==_.numIntersection)||P.vertexAlphas!==E||P.vertexTangents!==T||P.morphTargets!==M||P.morphNormals!==x||P.morphColors!==R||P.toneMapping!==C?L=!0:P.morphTargetsCount!==A&&(L=!0):L=!0:L=!0:L=!0:(L=!0,P.__version=i.version);let N=P.currentProgram;!0===L&&(N=e2(i,n,c));let U=!1,I=!1,F=!1,O=N.getUniforms(),B=P.uniforms;if(a.useProgram(N.program)&&(U=!0,I=!0,F=!0),i.id!==eh&&(eh=i.id,I=!0),U||eg!==e){a.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(eG,"projectionMatrix",e.projectionMatrix),O.setValue(eG,"viewMatrix",e.matrixWorldInverse);let n=O.map.cameraPosition;void 0!==n&&n.setValue(eG,eD.setFromMatrixPosition(e.matrixWorld)),r.logarithmicDepthBuffer&&O.setValue(eG,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&O.setValue(eG,"isOrthographic",!0===e.isOrthographicCamera),eg!==e&&(eg=e,I=!0,F=!0)}if(P.needsLights&&(w.state.directionalShadowMap.length>0&&O.setValue(eG,"directionalShadowMap",w.state.directionalShadowMap,l),w.state.spotShadowMap.length>0&&O.setValue(eG,"spotShadowMap",w.state.spotShadowMap,l),w.state.pointShadowMap.length>0&&O.setValue(eG,"pointShadowMap",w.state.pointShadowMap,l)),c.isSkinnedMesh){O.setOptional(eG,c,"bindMatrix"),O.setOptional(eG,c,"bindMatrixInverse");let e=c.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(eG,"boneTexture",e.boneTexture,l))}c.isBatchedMesh&&(O.setOptional(eG,c,"batchingTexture"),O.setValue(eG,"batchingTexture",c._matricesTexture,l),O.setOptional(eG,c,"batchingIdTexture"),O.setValue(eG,"batchingIdTexture",c._indirectTexture,l),O.setOptional(eG,c,"batchingColorTexture"),null!==c._colorsTexture&&O.setValue(eG,"batchingColorTexture",c._colorsTexture,l));let G=t.morphAttributes;if((void 0!==G.position||void 0!==G.normal||void 0!==G.color)&&b.update(c,t,N),(I||P.receiveShadow!==c.receiveShadow)&&(P.receiveShadow=c.receiveShadow,O.setValue(eG,"receiveShadow",c.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=v,B.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==n.environment&&(B.envMapIntensity.value=n.environmentIntensity),void 0!==B.dfgLUT&&(B.dfgLUT.value=(null===nJ&&((nJ=new S.DataTexture(nZ,16,16,S.RGFormat,S.HalfFloatType)).name="DFG_LUT",nJ.minFilter=S.LinearFilter,nJ.magFilter=S.LinearFilter,nJ.wrapS=S.ClampToEdgeWrapping,nJ.wrapT=S.ClampToEdgeWrapping,nJ.generateMipmaps=!1,nJ.needsUpdate=!0),nJ)),I&&(O.setValue(eG,"toneMappingExposure",ec.toneMappingExposure),P.needsLights&&(d=B,f=F,d.ambientLightColor.needsUpdate=f,d.lightProbe.needsUpdate=f,d.directionalLights.needsUpdate=f,d.directionalLightShadows.needsUpdate=f,d.pointLights.needsUpdate=f,d.pointLightShadows.needsUpdate=f,d.spotLights.needsUpdate=f,d.spotLightShadows.needsUpdate=f,d.rectAreaLights.needsUpdate=f,d.hemisphereLights.needsUpdate=f),p&&!0===i.fog&&m.refreshFogUniforms(B,p),m.refreshMaterialUniforms(B,i,ex,eb,eo.state.transmissionRenderTarget[e.id]),e6.upload(eG,e4(P),B,l)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(e6.upload(eG,e4(P),B,l),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&O.setValue(eG,"center",c.center),O.setValue(eG,"modelViewMatrix",c.modelViewMatrix),O.setValue(eG,"normalMatrix",c.normalMatrix),O.setValue(eG,"modelMatrix",c.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){let e=i.uniformsGroups;for(let n=0,t=e.length;n{function r(){(a.forEach(function(e){o.get(e).currentProgram.isReady()&&a.delete(e)}),0===a.size)?n(e):setTimeout(r,10)}null!==t.get("KHR_parallel_shader_compile")?r():setTimeout(r,10)})};let eY=null;function eK(){eQ.stop()}function e$(){eQ.start()}const eQ=new E;function eZ(e,n,t,r){if(!1===e.visible)return;if(e.layers.test(n.layers)){if(e.isGroup)t=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(n);else if(e.isLight)eo.pushLight(e),e.castShadow&&eo.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ew.intersectsSprite(e)){r&&eI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(eU);let n=f.update(e),a=e.material;a.visible&&ei.push(e,n,a,t,eI.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ew.intersectsObject(e))){let n=f.update(e),a=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),eI.copy(e.boundingSphere.center)):(null===n.boundingSphere&&n.computeBoundingSphere(),eI.copy(n.boundingSphere.center)),eI.applyMatrix4(e.matrixWorld).applyMatrix4(eU)),Array.isArray(a)){let r=n.groups;for(let i=0,o=r.length;i0&&e1(i,n,t),o.length>0&&e1(o,n,t),l.length>0&&e1(l,n,t),a.buffers.depth.setTest(!0),a.buffers.depth.setMask(!0),a.buffers.color.setMask(!0),a.setPolygonOffset(!1)}function e0(e,n,a,i){if(null!==(!0===a.isScene?a.overrideMaterial:null))return;if(void 0===eo.state.transmissionRenderTarget[i.id]){let e=t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float");eo.state.transmissionRenderTarget[i.id]=new S.WebGLRenderTarget(1,1,{generateMipmaps:!0,type:e?S.HalfFloatType:S.UnsignedByteType,minFilter:S.LinearMipmapLinearFilter,samples:r.samples,stencilBuffer:B,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:S.ColorManagement.workingColorSpace})}let o=eo.state.transmissionRenderTarget[i.id],s=i.viewport||e_;o.setSize(s.z*ec.transmissionResolutionScale,s.w*ec.transmissionResolutionScale);let u=ec.getRenderTarget(),c=ec.getActiveCubeFace(),d=ec.getActiveMipmapLevel();ec.setRenderTarget(o),ec.getClearColor(eE),(eT=ec.getClearAlpha())<1&&ec.setClearColor(0xffffff,.5),ec.clear(),eO&&M.render(a);let f=ec.toneMapping;ec.toneMapping=S.NoToneMapping;let p=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),eo.setupLightsView(i),!0===eL&&_.setGlobalState(ec.clippingPlanes,i),e1(e,a,i),l.updateMultisampleRenderTarget(o),l.updateRenderTargetMipmap(o),!1===t.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let t=0,r=n.length;ttypeof self&&eQ.setContext(self),this.setAnimationLoop=function(e){eY=e,eV.setAnimationLoop(e),null===e?eQ.stop():eQ.start()},eV.addEventListener("sessionstart",eK),eV.addEventListener("sessionend",e$),this.render=function(e,n){if(void 0!==n&&!0!==n.isCamera)return void(0,S.error)("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===ed)return;let t=!0===eV.enabled&&!0===eV.isPresenting,r=null!==eu&&(null===em||t)&&eu.begin(ec,em);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),!0===eV.enabled&&!0===eV.isPresenting&&(null===eu||!1===eu.isCompositing())&&(!0===eV.cameraAutoUpdate&&eV.updateCamera(n),n=eV.getCamera()),!0===e.isScene&&e.onBeforeRender(ec,e,n,em),(eo=g.get(e,es.length)).init(n),es.push(eo),eU.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ew.setFromProjectionMatrix(eU,S.WebGLCoordinateSystem,n.reversedDepth),eN=this.localClippingEnabled,eL=_.init(this.clippingPlanes,eN),(ei=h.get(e,el.length)).init(),el.push(ei),!0===eV.enabled&&!0===eV.isPresenting){let e=ec.xr.getDepthSensingMesh();null!==e&&eZ(e,n,-1/0,ec.sortObjects)}eZ(e,n,0,ec.sortObjects),ei.finish(),!0===ec.sortObjects&&ei.sort(eR,eC),(eO=!1===eV.enabled||!1===eV.isPresenting||!1===eV.hasDepthSensing())&&M.addToRenderList(ei,e),this.info.render.frame++,!0===eL&&_.beginShadows();let a=eo.state.shadowsArray;if(v.render(a,e,n),!0===eL&&_.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(r&&eu.hasRenderPass())){let t=ei.opaque,r=ei.transmissive;if(eo.setupLights(),n.isArrayCamera){let a=n.cameras;if(r.length>0)for(let n=0,i=a.length;n0&&e0(t,r,e,n),eO&&M.render(e),eJ(ei,e,n)}null!==em&&0===ep&&(l.updateMultisampleRenderTarget(em),l.updateRenderTargetMipmap(em)),r&&eu.end(ec),!0===e.isScene&&e.onAfterRender(ec,e,n),y.resetDefaultState(),eh=-1,eg=null,es.pop(),es.length>0?(eo=es[es.length-1],!0===eL&&_.setGlobalState(ec.clippingPlanes,eo.state.camera)):eo=null,el.pop(),ei=el.length>0?el[el.length-1]:null},this.getActiveCubeFace=function(){return ef},this.getActiveMipmapLevel=function(){return ep},this.getRenderTarget=function(){return em},this.setRenderTargetTextures=function(e,n,t){let r=o.get(e);r.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===r.__autoAllocateDepthBuffer&&(r.__useRenderToTexture=!1),o.get(e.texture).__webglTexture=n,o.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:t,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,n){let t=o.get(e);t.__webglFramebuffer=n,t.__useDefaultFramebuffer=void 0===n};const e8=eG.createFramebuffer();this.setRenderTarget=function(e,n=0,t=0){em=e,ef=n,ep=t;let r=null,i=!1,s=!1;if(e){let u=o.get(e);if(void 0!==u.__useDefaultFramebuffer){a.bindFramebuffer(eG.FRAMEBUFFER,u.__webglFramebuffer),e_.copy(e.viewport),ev.copy(e.scissor),eS=e.scissorTest,a.viewport(e_),a.scissor(ev),a.setScissorTest(eS),eh=-1;return}if(void 0===u.__webglFramebuffer)l.setupRenderTarget(e);else if(u.__hasExternalTextures)l.rebindTextures(e,o.get(e.texture).__webglTexture,o.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let n=e.depthTexture;if(u.__boundDepthTexture!==n){if(null!==n&&o.has(n)&&(e.width!==n.image.width||e.height!==n.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");l.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(s=!0);let d=o.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(d[n])?d[n][t]:d[n],i=!0):r=e.samples>0&&!1===l.useMultisampledRTT(e)?o.get(e).__webglMultisampledFramebuffer:Array.isArray(d)?d[t]:d,e_.copy(e.viewport),ev.copy(e.scissor),eS=e.scissorTest}else e_.copy(ey).multiplyScalar(ex).floor(),ev.copy(eA).multiplyScalar(ex).floor(),eS=eP;if(0!==t&&(r=e8),a.bindFramebuffer(eG.FRAMEBUFFER,r)&&a.drawBuffers(e,r),a.viewport(e_),a.scissor(ev),a.setScissorTest(eS),i){let r=o.get(e.texture);eG.framebufferTexture2D(eG.FRAMEBUFFER,eG.COLOR_ATTACHMENT0,eG.TEXTURE_CUBE_MAP_POSITIVE_X+n,r.__webglTexture,t)}else if(s)for(let r=0;r=0&&n<=e.width-i&&t>=0&&t<=e.height-l&&(e.textures.length>1&&eG.readBuffer(eG.COLOR_ATTACHMENT0+c),eG.readPixels(n,t,i,l,C.convert(o),C.convert(u),s))}finally{let e=null!==em?o.get(em).__webglFramebuffer:null;a.bindFramebuffer(eG.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,n,t,i,l,s,u,c=0){if(!(e&&e.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let d=o.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(d=d[u]),d)if(n>=0&&n<=e.width-i&&t>=0&&t<=e.height-l){a.bindFramebuffer(eG.FRAMEBUFFER,d);let u=e.textures[c],f=u.format,p=u.type;if(!r.textureFormatReadable(f))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!r.textureTypeReadable(p))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let m=eG.createBuffer();eG.bindBuffer(eG.PIXEL_PACK_BUFFER,m),eG.bufferData(eG.PIXEL_PACK_BUFFER,s.byteLength,eG.STREAM_READ),e.textures.length>1&&eG.readBuffer(eG.COLOR_ATTACHMENT0+c),eG.readPixels(n,t,i,l,C.convert(f),C.convert(p),0);let h=null!==em?o.get(em).__webglFramebuffer:null;a.bindFramebuffer(eG.FRAMEBUFFER,h);let g=eG.fenceSync(eG.SYNC_GPU_COMMANDS_COMPLETE,0);return eG.flush(),await (0,S.probeAsync)(eG,g,4),eG.bindBuffer(eG.PIXEL_PACK_BUFFER,m),eG.getBufferSubData(eG.PIXEL_PACK_BUFFER,0,s),eG.deleteBuffer(m),eG.deleteSync(g),s}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(e,n=null,t=0){let r=Math.pow(2,-t),i=Math.floor(e.image.width*r),o=Math.floor(e.image.height*r),s=null!==n?n.x:0,u=null!==n?n.y:0;l.setTexture2D(e,0),eG.copyTexSubImage2D(eG.TEXTURE_2D,t,0,0,s,u,i,o),a.unbindTexture()};const e9=eG.createFramebuffer(),e7=eG.createFramebuffer();this.copyTextureToTexture=function(e,n,t=null,r=null,i=0,s=null){let u,c,d,f,p,m,h,g,_,v;null===s&&(0!==i?((0,S.warnOnce)("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=i,i=0):s=0);let E=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==t)u=t.max.x-t.min.x,c=t.max.y-t.min.y,d=t.isBox3?t.max.z-t.min.z:1,f=t.min.x,p=t.min.y,m=t.isBox3?t.min.z:0;else{let n=Math.pow(2,-i);u=Math.floor(E.width*n),c=Math.floor(E.height*n),d=e.isDataArrayTexture?E.depth:e.isData3DTexture?Math.floor(E.depth*n):1,f=0,p=0,m=0}null!==r?(h=r.x,g=r.y,_=r.z):(h=0,g=0,_=0);let T=C.convert(n.format),M=C.convert(n.type);n.isData3DTexture?(l.setTexture3D(n,0),v=eG.TEXTURE_3D):n.isDataArrayTexture||n.isCompressedArrayTexture?(l.setTexture2DArray(n,0),v=eG.TEXTURE_2D_ARRAY):(l.setTexture2D(n,0),v=eG.TEXTURE_2D),eG.pixelStorei(eG.UNPACK_FLIP_Y_WEBGL,n.flipY),eG.pixelStorei(eG.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),eG.pixelStorei(eG.UNPACK_ALIGNMENT,n.unpackAlignment);let b=eG.getParameter(eG.UNPACK_ROW_LENGTH),x=eG.getParameter(eG.UNPACK_IMAGE_HEIGHT),R=eG.getParameter(eG.UNPACK_SKIP_PIXELS),y=eG.getParameter(eG.UNPACK_SKIP_ROWS),A=eG.getParameter(eG.UNPACK_SKIP_IMAGES);eG.pixelStorei(eG.UNPACK_ROW_LENGTH,E.width),eG.pixelStorei(eG.UNPACK_IMAGE_HEIGHT,E.height),eG.pixelStorei(eG.UNPACK_SKIP_PIXELS,f),eG.pixelStorei(eG.UNPACK_SKIP_ROWS,p),eG.pixelStorei(eG.UNPACK_SKIP_IMAGES,m);let P=e.isDataArrayTexture||e.isData3DTexture,w=n.isDataArrayTexture||n.isData3DTexture;if(e.isDepthTexture){let t=o.get(e),r=o.get(n),l=o.get(t.__renderTarget),v=o.get(r.__renderTarget);a.bindFramebuffer(eG.READ_FRAMEBUFFER,l.__webglFramebuffer),a.bindFramebuffer(eG.DRAW_FRAMEBUFFER,v.__webglFramebuffer);for(let t=0;ttypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return S.WebGLCoordinateSystem}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let n=this.getContext();n.drawingBufferColorSpace=S.ColorManagement._getDrawingBufferColorSpace(e),n.unpackColorSpace=S.ColorManagement._getUnpackColorSpace()}}e.s(["PMREMGenerator",()=>V,"ShaderChunk",()=>M,"ShaderLib",()=>x,"UniformsLib",()=>b,"WebGLRenderer",()=>n0,"WebGLUtils",()=>nz],8560);var n1=e.i(30224);let n3=e=>{let n,t=new Set,r=(e,r)=>{let a="function"==typeof e?e(n):e;if(!Object.is(a,n)){let e=n;n=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},n,a),t.forEach(t=>t(n,e))}},a=()=>n,i={setState:r,getState:a,getInitialState:()=>o,subscribe:e=>(t.add(e),()=>t.delete(e))},o=n=e(r,a,i);return i},n2=e=>e?n3(e):n3;e.s(["createStore",()=>n2],8155);let{useSyncExternalStoreWithSelector:n4}=n1.default,n5=e=>e;function n6(e,n=n5,t){let r=n4(e.subscribe,e.getState,e.getInitialState,n,t);return _.default.useDebugValue(r),r}let n8=(e,n)=>{let t=n2(e),r=(e,r=n)=>n6(t,e,r);return Object.assign(r,t),r},n9=(e,n)=>e?n8(e,n):n8;e.s(["createWithEqualityFn",()=>n9,"useStoreWithEqualityFn",()=>n6],66748);let n7=[];function te(e,n,t=(e,n)=>e===n){if(e===n)return!0;if(!e||!n)return!1;let r=e.length;if(n.length!==r)return!1;for(let a=0;a0&&(a.timeout&&clearTimeout(a.timeout),a.timeout=setTimeout(a.remove,r.lifespan)),a.response;if(!t)throw a.promise}let a={keys:n,equal:r.equal,remove:()=>{let e=n7.indexOf(a);-1!==e&&n7.splice(e,1)},promise:("object"==typeof e&&"function"==typeof e.then?e:e(...n)).then(e=>{a.response=e,r.lifespan&&r.lifespan>0&&(a.timeout=setTimeout(a.remove,r.lifespan))}).catch(e=>a.error=e)};if(n7.push(a),!t)throw a.promise}var tt=e.i(89499),tr=e.i(43476),ta=_;function ti(e,n,t){if(!e)return;if(!0===t(e))return e;let r=n?e.return:e.child;for(;r;){let e=ti(r,n,t);if(e)return e;r=n?null:r.sibling}}function to(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(n){return e}}"u">typeof window&&((null==(c=window.document)?void 0:c.createElement)||(null==(d=window.navigator)?void 0:d.product)==="ReactNative")?ta.useLayoutEffect:ta.useEffect;let tl=to(ta.createContext(null));class ts extends ta.Component{render(){return ta.createElement(tl.Provider,{value:this._reactInternals},this.props.children)}}function tu(){let e=ta.useContext(tl);if(null===e)throw Error("its-fine: useFiber must be called within a !");let n=ta.useId();return ta.useMemo(()=>{for(let t of[e,null==e?void 0:e.alternate]){if(!t)continue;let e=ti(t,!1,e=>{let t=e.memoizedState;for(;t;){if(t.memoizedState===n)return!0;t=t.next}});if(e)return e}},[e,n])}let tc=Symbol.for("react.context"),td=e=>null!==e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===tc;function tf(){let e=function(){let e=tu(),[n]=ta.useState(()=>new Map);n.clear();let t=e;for(;t;){let e=t.type;td(e)&&e!==tl&&!n.has(e)&&n.set(e,ta.use(to(e))),t=t.return}return n}();return ta.useMemo(()=>Array.from(e.keys()).reduce((n,t)=>r=>ta.createElement(n,null,ta.createElement(t.Provider,{...r,value:e.get(t)})),e=>ta.createElement(ts,{...e})),[e])}function tp(e){let n=e.root;for(;n.getState().previousRoot;)n=n.getState().previousRoot;return n}e.s(["FiberProvider",()=>ts,"traverseFiber",()=>ti,"useContextBridge",()=>tf,"useFiber",()=>tu],46791),_.act;let tm=e=>e&&e.hasOwnProperty("current"),th=e=>null!=e&&("string"==typeof e||"number"==typeof e||e.isColor),tg="u">typeof window&&((null==(o=window.document)?void 0:o.createElement)||(null==(l=window.navigator)?void 0:l.product)==="ReactNative")?_.useLayoutEffect:_.useEffect;function t_(e){let n=_.useRef(e);return tg(()=>void(n.current=e),[e]),n}function tv(){let e=tu(),n=tf();return _.useMemo(()=>({children:t})=>{let r=ti(e,!0,e=>e.type===_.StrictMode)?_.StrictMode:_.Fragment;return(0,tr.jsx)(r,{children:(0,tr.jsx)(n,{children:t})})},[e,n])}function tS({set:e}){return tg(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}let tE=((s=class extends _.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}).getDerivedStateFromError=()=>({error:!0}),s);function tT(e){var n;let t="u">typeof window?null!=(n=window.devicePixelRatio)?n:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],t),e[1]):e}function tM(e){var n;return null==(n=e.__r3f)?void 0:n.root.getState()}let tb={obj:e=>e===Object(e)&&!tb.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,boo:e=>"boolean"==typeof e,und:e=>void 0===e,nul:e=>null===e,arr:e=>Array.isArray(e),equ(e,n,{arrays:t="shallow",objects:r="reference",strict:a=!0}={}){let i;if(typeof e!=typeof n||!!e!=!!n)return!1;if(tb.str(e)||tb.num(e)||tb.boo(e))return e===n;let o=tb.obj(e);if(o&&"reference"===r)return e===n;let l=tb.arr(e);if(l&&"reference"===t)return e===n;if((l||o)&&e===n)return!0;for(i in e)if(!(i in n))return!1;if(o&&"shallow"===t&&"shallow"===r){for(i in a?n:e)if(!tb.equ(e[i],n[i],{strict:a,objects:"reference"}))return!1}else for(i in a?n:e)if(e[i]!==n[i])return!1;if(tb.und(i)){if(l&&0===e.length&&0===n.length||o&&0===Object.keys(e).length&&0===Object.keys(n).length)return!0;if(e!==n)return!1}return!0}},tx=["children","key","ref"];function tR(e,n,t,r){let a=null==e?void 0:e.__r3f;return!a&&(a={root:n,type:t,parent:null,children:[],props:function(e){let n={};for(let t in e)tx.includes(t)||(n[t]=e[t]);return n}(r),object:e,eventCount:0,handlers:{},isHidden:!1},e&&(e.__r3f=a)),a}function tC(e,n){if(!n.includes("-")||n in e)return{root:e,key:n,target:e[n]};let t=e,r=n.split("-");for(let a of r){if("object"!=typeof t||null===t){if(void 0!==t)return{root:t,key:r.slice(r.indexOf(a)).join("-"),target:void 0};return{root:e,key:n,target:void 0}}n=a,e=t,t=t[n]}return{root:e,key:n,target:t}}let ty=/-\d+$/;function tA(e,n){if(tb.str(n.props.attach)){if(ty.test(n.props.attach)){let t=n.props.attach.replace(ty,""),{root:r,key:a}=tC(e.object,t);Array.isArray(r[a])||(r[a]=[])}let{root:t,key:r}=tC(e.object,n.props.attach);n.previousAttach=t[r],t[r]=n.object}else tb.fun(n.props.attach)&&(n.previousAttach=n.props.attach(e.object,n.object))}function tP(e,n){if(tb.str(n.props.attach)){let{root:t,key:r}=tC(e.object,n.props.attach),a=n.previousAttach;void 0===a?delete t[r]:t[r]=a}else null==n.previousAttach||n.previousAttach(e.object,n.object);delete n.previousAttach}let tw=[...tx,"args","dispose","attach","object","onUpdate","dispose"],tL=new Map,tN=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],tU=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function tD(e,n){var t,r;let a=e.__r3f,i=a&&tp(a).getState(),o=null==a?void 0:a.eventCount;for(let t in n){let o=n[t];if(tw.includes(t))continue;if(a&&tU.test(t)){"function"==typeof o?a.handlers[t]=o:delete a.handlers[t],a.eventCount=Object.keys(a.handlers).length;continue}if(void 0===o)continue;let{root:l,key:s,target:u}=tC(e,t);if(void 0===u&&("object"!=typeof l||null===l))throw Error(`R3F: Cannot set "${t}". Ensure it is an object before setting "${s}".`);u instanceof v.Layers&&o instanceof v.Layers?u.mask=o.mask:u instanceof v.Color&&th(o)?u.set(o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"function"==typeof u.copy&&null!=o&&o.constructor&&u.constructor===o.constructor?u.copy(o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&Array.isArray(o)?"function"==typeof u.fromArray?u.fromArray(o):u.set(...o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"number"==typeof o?"function"==typeof u.setScalar?u.setScalar(o):u.set(o):(l[s]=o,i&&!i.linear&&tN.includes(s)&&null!=(r=l[s])&&r.isTexture&&l[s].format===v.RGBAFormat&&l[s].type===v.UnsignedByteType&&(l[s].colorSpace=v.SRGBColorSpace))}if(null!=a&&a.parent&&null!=i&&i.internal&&null!=(t=a.object)&&t.isObject3D&&o!==a.eventCount){let e=a.object,n=i.internal.interaction.indexOf(e);n>-1&&i.internal.interaction.splice(n,1),a.eventCount&&null!==e.raycast&&i.internal.interaction.push(e)}return a&&void 0===a.props.attach&&(a.object.isBufferGeometry?a.props.attach="geometry":a.object.isMaterial&&(a.props.attach="material")),a&&tI(a),e}function tI(e){var n;if(!e.parent)return;null==e.props.onUpdate||e.props.onUpdate(e.object);let t=null==(n=e.root)||null==n.getState?void 0:n.getState();t&&0===t.internal.frames&&t.invalidate()}let tF=e=>null==e?void 0:e.isObject3D;function tO(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function tB(e,n,t,r){let a=t.get(n);a&&(t.delete(n),0===t.size&&(e.delete(r),a.target.releasePointerCapture(r)))}let tG=e=>!!(null!=e&&e.render),tH=_.createContext(null);function tk(){let e=_.useContext(tH);if(!e)throw Error("R3F: Hooks can only be used within the Canvas component!");return e}function tV(e=e=>e,n){return tk()(e,n)}function tz(e,n=0){let t=tk(),r=t.getState().internal.subscribe,a=t_(e);return tg(()=>r(a,n,t),[n,r,t]),null}let tW=new WeakMap;function tX(e,n){return function(t,...r){var a;let i;return"function"==typeof t&&(null==t||null==(a=t.prototype)?void 0:a.constructor)===t?(i=tW.get(t))||(i=new t,tW.set(t,i)):i=t,e&&e(i),Promise.all(r.map(e=>new Promise((t,r)=>i.load(e,e=>{var n;let r;tF(null==e?void 0:e.scene)&&Object.assign(e,(n=e.scene,r={nodes:{},materials:{},meshes:{}},n&&n.traverse(e=>{e.name&&(r.nodes[e.name]=e),e.material&&!r.materials[e.material.name]&&(r.materials[e.material.name]=e.material),e.isMesh&&!r.meshes[e.name]&&(r.meshes[e.name]=e)}),r)),t(e)},n,n=>r(Error(`Could not load ${e}: ${null==n?void 0:n.message}`))))))}}function tj(e,n,t,r){let a=Array.isArray(n)?n:[n],i=tn(tX(t,r),[e,...a],!1,{equal:tb.equ});return Array.isArray(n)?i:i[0]}tj.preload=function(e,n,t){let r,a=Array.isArray(n)?n:[n];tn(tX(t),[e,...a],!0,r)},tj.clear=function(e,n){var t=[e,...Array.isArray(n)?n:[n]];if(void 0===t||0===t.length)n7.splice(0,n7.length);else{let e=n7.find(e=>te(t,e.keys,e.equal));e&&e.remove()}};var tq={exports:{}},tY={exports:{}};tY.exports;let tK=(h||(h=1,m||(m=1,tY.exports=function(e){function n(e,n,t,r){return new rK(e,n,t,r)}function t(){}function r(e){var n="https://react.dev/errors/"+e;if(1oR||(e.current=ox[oR],ox[oR]=null,oR--)}function d(e,n){ox[++oR]=e.current,e.current=n}function f(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 0x1000000:case 0x2000000:return 0x3c00000&e;case 0x4000000:return 0x4000000;case 0x8000000:return 0x8000000;case 0x10000000:return 0x10000000;case 0x20000000:return 0x20000000;case 0x40000000:return 0;default:return e}}function p(e,n,t){var r=e.pendingLanes;if(0===r)return 0;var a=0,i=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var l=0x7ffffff&r;return 0!==l?0!=(r=l&~i)?a=f(r):0!=(o&=l)?a=f(o):t||0!=(t=l&~e)&&(a=f(t)):0!=(l=r&~i)?a=f(l):0!==o?a=f(o):t||0!=(t=r&~e)&&(a=f(t)),0===a?0:0!==n&&n!==a&&(n&i)==0&&((i=a&-a)>=(t=n&-n)||32===i&&(4194048&t)!=0)?n:a}function m(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)==0}function h(){var e=oN;return(0x3c00000&(oN<<=1))==0&&(oN=4194304),e}function v(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function S(e,n){e.pendingLanes|=n,0x10000000!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function E(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-oy(n);e.entangledLanes|=n,e.entanglements[r]=0x40000000|e.entanglements[r]|261930&t}function T(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-oy(t),a=1<)":-1a||s[r]!==u[a]){var c=` -`+s[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=r&&0<=a)break}}}finally{oK=!1,Error.prepareStackTrace=t}return(t=e?e.displayName||e.name:"")?C(t):""}function A(e){try{var n="",t=null;do n+=function(e,n){switch(e.tag){case 26:case 27:case 5:return C(e.type);case 16:return C("Lazy");case 13:return e.child!==n&&null!==n?C("Suspense Fallback"):C("Suspense");case 19:return C("SuspenseList");case 0:case 15:return y(e.type,!1);case 11:return y(e.type.render,!1);case 1:return y(e.type,!0);case 31:return C("Activity");default:return""}}(e,t),t=e,e=e.return;while(e)return n}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}function P(e,n){if("object"==typeof e&&null!==e){var t=o$.get(e);return void 0!==t?t:(n={value:e,source:n,stack:A(n)},o$.set(e,n),n)}return{value:e,source:n,stack:A(n)}}function w(e,n){oQ[oZ++]=o0,oQ[oZ++]=oJ,oJ=e,o0=n}function L(e,n,t){o1[o3++]=o4,o1[o3++]=o5,o1[o3++]=o2,o2=e;var r=o4;e=o5;var a=32-oy(r)-1;r&=~(1<>=o,a-=o,o4=1<<32-oy(n)+a|t<f?(p=d,d=null):p=d.sibling;var _=h(n,d,o[f],l);if(null===_){null===d&&(d=p);break}e&&d&&null===_.alternate&&t(n,d),r=s(_,r,f),null===c?u=_:c.sibling=_,c=_,d=p}if(f===o.length)return a(n,d),lt&&w(n,f),u;if(null===d){for(;fp?(_=f,f=null):_=f.sibling;var S=h(n,f,v.value,u);if(null===S){null===f&&(f=_);break}e&&f&&null===S.alternate&&t(n,f),o=s(S,o,p),null===d?c=S:d.sibling=S,d=S,f=_}if(v.done)return a(n,f),lt&&w(n,p),c;if(null===f){for(;!v.done;p++,v=l.next())null!==(v=m(n,v.value,u))&&(o=s(v,o,p),null===d?c=v:d.sibling=v,d=v);return lt&&w(n,p),c}for(f=i(f);!v.done;p++,v=l.next())null!==(v=g(f,n,p,v.value,u))&&(e&&null!==v.alternate&&f.delete(null===v.key?p:v.key),o=s(v,o,p),null===d?c=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return t(n,e)}),lt&&w(n,p),c}(c,d,f=_.call(f),p)}if("function"==typeof f.then)return n(c,d,eb(f),p);if(f.$$typeof===ad)return n(c,d,ee(c,f),p);eR(c,f)}return"string"==typeof f&&""!==f||"number"==typeof f||"bigint"==typeof f?(f=""+f,null!==d&&6===d.tag?(a(c,d.sibling),(p=o(d,f)).return=c):(a(c,d),(p=r1(f,c.mode,p)).return=c),u(c=p)):a(c,d)}(c,d,f,p);return lw=null,_}catch(e){if(e===lR||e===ly)throw e;var v=n(29,e,null,c.mode);return v.lanes=p,v.return=c,v}finally{}}}function ey(){for(var e=lI,n=lF=lI=0;ni?i:8);var o=aM.T,l={};aM.T=l,nZ(e,!1,n,t);try{var s=a(),u=aM.S;if(null!==u&&u(l,s),null!==s&&"object"==typeof s&&"function"==typeof s.then){var c,d,f=(c=[],d={status:"pending",value:null,reason:null,then:function(e){c.push(e)}},s.then(function(){d.status="fulfilled",d.value=r;for(var e=0;e";case sc:return":has("+(rf(e)||"")+")";case sd:return'[role="'+e.value+'"]';case sp:return'"'+e.value+'"';case sf:return'[data-testname="'+e.value+'"]';default:throw Error(r(365))}}function rp(e,n){var t=[];e=[e,0];for(var r=0;rsO&&(n.flags|=128,i=!0,tO(a,!1),n.lanes=4194304)}else{if(!i)if(null!==(e=eQ(o))){if(n.flags|=128,i=!0,n.updateQueue=e=e.updateQueue,tF(n,e),tO(a,!0),null===a.tail&&"hidden"===a.tailMode&&!o.alternate&&!lt)return tB(n),null}else 2*oO()-a.renderingStartTime>sO&&0x20000000!==t&&(n.flags|=128,i=!0,tO(a,!1),n.lanes=4194304);a.isBackwards?(o.sibling=n.child,n.child=o):(null!==(e=a.last)?e.sibling=o:n.child=o,a.last=o)}return null!==a.tail?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=oO(),e.sibling=null,t=lz.current,d(lz,i?1&t|2:1&t),lt&&w(n,a.treeForkCount),e):(tB(n),null);case 22:case 23:return e$(n),eX(),a=null!==n.memoizedState,null!==e?null!==e.memoizedState!==a&&(n.flags|=8192):a&&(n.flags|=8192),a?(0x20000000&t)!=0&&(128&n.flags)==0&&(tB(n),6&n.subtreeFlags&&(n.flags|=8192)):tB(n),null!==(t=n.updateQueue)&&tF(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),a=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(a=n.memoizedState.cachePool.pool),a!==t&&(n.flags|=2048),null!==e&&c(lx),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),q(lf),tB(n),null;case 25:case 30:return null}throw Error(r(156,n.tag))}(n.alternate,n,sR);if(null!==t){sv=t;return}if(null!==(n=n.sibling)){sv=n;return}sv=n=e}while(null!==n)0===sC&&(sC=5)}function rD(e,n){do{var t=function(e,n){switch(U(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 3:return q(lf),F(),(65536&(e=n.flags))!=0&&(128&e)==0?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return B(n),null;case 31:if(null!==n.memoizedState){if(e$(n),null===n.alternate)throw Error(r(340));z()}return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 13:if(e$(n),null!==(e=n.memoizedState)&&null!==e.dehydrated){if(null===n.alternate)throw Error(r(340));z()}return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 19:return c(lz),null;case 4:return F(),null;case 10:return q(n.type),null;case 22:case 23:return e$(n),eX(),null!==e&&c(lx),65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 24:return q(lf),null;default:return null}}(e.alternate,e);if(null!==t){t.flags&=32767,sv=t;return}if(null!==(t=e.return)&&(t.flags|=32768,t.subtreeFlags=0,t.deletions=null),!n&&null!==(e=e.sibling)){sv=e;return}sv=e=t}while(null!==e)sC=6,sv=null}function rI(e,n,t,a,i,o,l,s,u){e.cancelPendingCommit=null;do rH();while(0!==sH)if((6&sg)!=0)throw Error(r(327));if(null!==n){if(n===e.current)throw Error(r(177));if(function(e,n,t,r,a,i){var o=e.pendingLanes;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=t,e.entangledLanes&=t,e.errorRecoveryDisabledLanes&=t,e.shellSuspendCounter=0;var l=e.entanglements,s=e.expirationTimes,u=e.hiddenUpdates;for(t=o&~t;0t?32:t;t=aM.T;var i=aj();try{aX(a),aM.T=null,a=sX,sX=null;var o=sk,l=sz;if(sH=0,sV=sk=null,sz=0,(6&sg)!=0)throw Error(r(331));var s=sg;if(sg|=4,rs(o.current),rt(o,o.current,l,a),sg=s,eo(0,!1),oX&&"function"==typeof oX.onPostCommitFiberRoot)try{oX.onPostCommitFiberRoot(oW,o)}catch{}return!0}finally{aX(i),aM.T=t,rG(e,n)}}function rV(e,n,t){n=P(t,n),n=n9(e.stateNode,n,2),null!==(e=eF(e,n,2))&&(S(e,2),ei(e))}function rz(e,n,t){if(3===e.tag)rV(e,e,t);else for(;null!==n;){if(3===n.tag){rV(n,e,t);break}if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===sG||!sG.has(r))){e=P(t,e),null!==(r=eF(n,t=n7(2),2))&&(te(t,r,n,e),S(r,2),ei(r));break}}n=n.return}}function rW(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new sh;var a=new Set;r.set(n,a)}else void 0===(a=r.get(n))&&(a=new Set,r.set(n,a));a.has(t)||(sx=!0,a.add(t),e=rX.bind(null,e,n,t),n.then(e,e))}function rX(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,s_===e&&(sS&t)===t&&(4===sC||3===sC&&(0x3c00000&sS)===sS&&300>oO()-sI?(2&sg)==0&&rb(e,0):sP|=t,sL===sS&&(sL=0)),ei(e)}function rj(e,n){0===n&&(n=h()),null!==(e=ew(e,n))&&(S(e,n),ei(e))}function rq(e){var n=e.memoizedState,t=0;null!==n&&(t=n.retryLane),rj(e,t)}function rY(e,n){var t=0;switch(e.tag){case 31:case 13:var a=e.stateNode,i=e.memoizedState;null!==i&&(t=i.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==a&&a.delete(n),rj(e,t)}function rK(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function r$(e){return!(!(e=e.prototype)||!e.isReactComponent)}function rQ(e,t){var r=e.alternate;return null===r?((r=n(e.tag,t,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=0x3e00000&e.flags,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function rZ(e,n){e.flags&=0x3e00002;var t=e.alternate;return null===t?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=t.childLanes,e.lanes=t.lanes,e.child=t.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=t.memoizedProps,e.memoizedState=t.memoizedState,e.updateQueue=t.updateQueue,e.type=t.type,e.dependencies=null===(n=t.dependencies)?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function rJ(e,t,a,i,o,l){var s=0;if(i=e,"function"==typeof e)r$(e)&&(s=1);else if("string"==typeof e)s=oa&&ov?oi(e,a,o6.current)?26:oM(e)?27:5:oa?oi(e,a,o6.current)?26:5:ov&&oM(e)?27:5;else t:switch(e){case a_:return(e=n(31,a,t,o)).elementType=a_,e.lanes=l,e;case al:return r0(a.children,o,l,t);case as:s=8,o|=24;break;case au:return(e=n(12,a,t,2|o)).elementType=au,e.lanes=l,e;case ap:return(e=n(13,a,t,o)).elementType=ap,e.lanes=l,e;case am:return(e=n(19,a,t,o)).elementType=am,e.lanes=l,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case ad:s=10;break t;case ac:s=9;break t;case af:s=11;break t;case ah:s=14;break t;case ag:s=16,i=null;break t}s=29,a=Error(r(130,null===e?"null":typeof e,"")),i=null}return(t=n(s,a,t,o)).elementType=e,t.type=i,t.lanes=l,t}function r0(e,t,r,a){return(e=n(7,e,a,t)).lanes=r,e}function r1(e,t,r){return(e=n(6,e,null,t)).lanes=r,e}function r3(e){var t=n(18,null,null,0);return t.stateNode=e,t}function r2(e,t,r){return(t=n(4,null!==e.children?e.children:[],e.key,t)).lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function r4(e,n,t,r,a,i,o,l,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=aB,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=v(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=v(0),this.hiddenUpdates=v(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function r5(e,t,r,a,i,o,l,s,u,c,d,f){return e=new r4(e,t,r,l,u,c,d,f,s),t=1,!0===o&&(t|=24),o=n(3,null,null,t),e.current=o,o.stateNode=e,t=et(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:a,isDehydrated:r,cache:t},eU(o),e}function r6(e){var n=e._reactInternals;if(void 0===n)throw"function"==typeof e.render?Error(r(188)):Error(r(268,e=Object.keys(e).join(",")));return null===(e=null!==(e=o(n))?function e(n){var t=n.tag;if(5===t||26===t||27===t||6===t)return n;for(n=n.child;null!==n;){if(null!==(t=e(n)))return t;n=n.sibling}return null}(e):null)?null:aC(e.stateNode)}function r8(e,n,t,r,a,i){a=oC,null===r.context?r.context=a:r.pendingContext=a,(r=eI(n)).payload={element:t},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(t=eF(e,r,n))&&(r_(t,e,n),eO(t,e,n))}function r9(e,n){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var t=e.retryLane;e.retryLane=0!==t&&t>>=0)?32:31-(oA(e)/oP|0)|0},oA=Math.log,oP=Math.LN2,ow=256,oL=262144,oN=4194304,oU=at.unstable_scheduleCallback,oD=at.unstable_cancelCallback,oI=at.unstable_shouldYield,oF=at.unstable_requestPaint,oO=at.unstable_now,oB=at.unstable_ImmediatePriority,oG=at.unstable_UserBlockingPriority,oH=at.unstable_NormalPriority,ok=at.unstable_IdlePriority,oV=at.log,oz=at.unstable_setDisableYieldValue,oW=null,oX=null,oj="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},oq="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if("object"==typeof g.default&&"function"==typeof g.default.emit)return void g.default.emit("uncaughtException",e);console.error(e)},oY=Object.prototype.hasOwnProperty,oK=!1,o$=new WeakMap,oQ=[],oZ=0,oJ=null,o0=0,o1=[],o3=0,o2=null,o4=1,o5="",o6=u(null),o8=u(null),o9=u(null),o7=u(null),le=null,ln=null,lt=!1,lr=null,la=!1,li=Error(r(519)),lo=u(null),ll=null,ls=null,lu="u">typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach(function(e){return e()})}},lc=at.unstable_scheduleCallback,ld=at.unstable_NormalPriority,lf={$$typeof:ad,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},lp=null,lm=null,lh=!1,lg=!1,l_=!1,lv=0,lS=null,lE=0,lT=0,lM=null,lb=aM.S;aM.S=function(e,n){sF=oO(),"object"==typeof n&&null!==n&&"function"==typeof n.then&&function(e,n){if(null===lS){var t=lS=[];lE=0,lT=ef(),lM={status:"pending",value:void 0,then:function(e){t.push(e)}}}lE++,n.then(ep,ep)}(0,n),null!==lb&&lb(e,n)};var lx=u(null),lR=Error(r(460)),lC=Error(r(474)),ly=Error(r(542)),lA={then:function(){}},lP=null,lw=null,lL=0,lN=eC(!0),lU=eC(!1),lD=[],lI=0,lF=0,lO=!1,lB=!1,lG=u(null),lH=u(0),lk=u(null),lV=null,lz=u(0),lW=0,lX=null,lj=null,lq=null,lY=!1,lK=!1,l$=!1,lQ=0,lZ=0,lJ=null,l0=0,l1={readContext:J,use:nn,useCallback:eZ,useContext:eZ,useEffect:eZ,useImperativeHandle:eZ,useLayoutEffect:eZ,useInsertionEffect:eZ,useMemo:eZ,useReducer:eZ,useRef:eZ,useState:eZ,useDebugValue:eZ,useDeferredValue:eZ,useTransition:eZ,useSyncExternalStore:eZ,useId:eZ,useHostTransitionStatus:eZ,useFormState:eZ,useActionState:eZ,useOptimistic:eZ,useMemoCache:eZ,useCacheRefresh:eZ};l1.useEffectEvent=eZ;var l3={readContext:J,use:nn,useCallback:function(e,n){return e8().memoizedState=[e,void 0===n?null:n],e},useContext:J,useEffect:nL,useImperativeHandle:function(e,n,t){t=null!=t?t.concat([e]):null,nP(4194308,4,nF.bind(null,n,e),t)},useLayoutEffect:function(e,n){return nP(4194308,4,e,n)},useInsertionEffect:function(e,n){nP(4,2,e,n)},useMemo:function(e,n){var t=e8();n=void 0===n?null:n;var r=e();return t.memoizedState=[r,n],r},useReducer:function(e,n,t){var r=e8();if(void 0!==t)var a=t(n);else a=n;return r.memoizedState=r.baseState=a,r.queue=e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},e=e.dispatch=nK.bind(null,lX,e),[r.memoizedState,e]},useRef:function(e){return e8().memoizedState={current:e}},useState:function(e){var n=(e=np(e)).queue,t=n$.bind(null,lX,n);return n.dispatch=t,[e.memoizedState,t]},useDebugValue:nB,useDeferredValue:function(e,n){return nk(e8(),e,n)},useTransition:function(){var e=np(!1);return e=nz.bind(null,lX,e.queue,!0,!1),e8().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,t){var a=lX,i=e8();if(lt){if(void 0===t)throw Error(r(407));t=t()}else{if(t=n(),null===s_)throw Error(r(349));(127&sS)!=0||ns(a,n,t)}i.memoizedState=t;var o={value:t,getSnapshot:n};return i.queue=o,nL(nc.bind(null,a,o,e),[e]),a.flags|=2048,ny(9,{destroy:void 0},nu.bind(null,a,o,t,n),null),t},useId:function(){var e=e8(),n=s_.identifierPrefix;if(lt){var t=o5,r=o4;n="_"+n+"R_"+(t=(r&~(1<<32-oy(r)-1)).toString(32)+t),0<(t=lQ++)&&(n+="H"+t.toString(32)),n+="_"}else n="_"+n+"r_"+(t=l0++).toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:nX,useFormState:nM,useActionState:nM,useOptimistic:function(e){var n=e8();n.memoizedState=n.baseState=e;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=t,n=nZ.bind(null,lX,!0,t),t.dispatch=n,[e,n]},useMemoCache:nt,useCacheRefresh:function(){return e8().memoizedState=nY.bind(null,lX)},useEffectEvent:function(e){var n=e8(),t={impl:e};return n.memoizedState=t,function(){if((2&sg)!=0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}},l2={readContext:J,use:nn,useCallback:nG,useContext:J,useEffect:nN,useImperativeHandle:nO,useInsertionEffect:nD,useLayoutEffect:nI,useMemo:nH,useReducer:na,useRef:nA,useState:function(){return na(nr)},useDebugValue:nB,useDeferredValue:function(e,n){return nV(e9(),lj.memoizedState,e,n)},useTransition:function(){var e=na(nr)[0],n=e9().memoizedState;return["boolean"==typeof e?e:ne(e),n]},useSyncExternalStore:nl,useId:nj,useHostTransitionStatus:nX,useFormState:nb,useActionState:nb,useOptimistic:function(e,n){return nm(e9(),lj,e,n)},useMemoCache:nt,useCacheRefresh:nq};l2.useEffectEvent=nU;var l4={readContext:J,use:nn,useCallback:nG,useContext:J,useEffect:nN,useImperativeHandle:nO,useInsertionEffect:nD,useLayoutEffect:nI,useMemo:nH,useReducer:no,useRef:nA,useState:function(){return no(nr)},useDebugValue:nB,useDeferredValue:function(e,n){var t=e9();return null===lj?nk(t,e,n):nV(t,lj.memoizedState,e,n)},useTransition:function(){var e=no(nr)[0],n=e9().memoizedState;return["boolean"==typeof e?e:ne(e),n]},useSyncExternalStore:nl,useId:nj,useHostTransitionStatus:nX,useFormState:nC,useActionState:nC,useOptimistic:function(e,n){var t=e9();return null!==lj?nm(t,lj,e,n):(t.baseState=e,[e,t.queue.dispatch])},useMemoCache:nt,useCacheRefresh:nq};l4.useEffectEvent=nU;var l5={enqueueSetState:function(e,n,t){e=e._reactInternals;var r=rh(),a=eI(r);a.payload=n,null!=t&&(a.callback=t),null!==(n=eF(e,a,r))&&(r_(n,e,r),eO(n,e,r))},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=rh(),a=eI(r);a.tag=1,a.payload=n,null!=t&&(a.callback=t),null!==(n=eF(e,a,r))&&(r_(n,e,r),eO(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=rh(),r=eI(t);r.tag=2,null!=n&&(r.callback=n),null!==(n=eF(e,r,t))&&(r_(n,e,t),eO(n,e,t))}},l6=Error(r(461)),l8=!1,l9={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},l7=!1,se=!1,sn=!1,st="function"==typeof WeakSet?WeakSet:Set,sr=null,sa=null,si=!1,so=null,sl=8192,ss={getCacheForType:function(e){var n=J(lf),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t},cacheSignal:function(){return J(lf).controller.signal}},su=0,sc=1,sd=2,sf=3,sp=4;if("function"==typeof Symbol&&Symbol.for){var sm=Symbol.for;su=sm("selector.component"),sc=sm("selector.has_pseudo_class"),sd=sm("selector.role"),sf=sm("selector.test_id"),sp=sm("selector.text")}var sh="function"==typeof WeakMap?WeakMap:Map,sg=0,s_=null,sv=null,sS=0,sE=0,sT=null,sM=!1,sb=!1,sx=!1,sR=0,sC=0,sy=0,sA=0,sP=0,sw=0,sL=0,sN=null,sU=null,sD=!1,sI=0,sF=0,sO=1/0,sB=null,sG=null,sH=0,sk=null,sV=null,sz=0,sW=0,sX=null,sj=null,sq=0,sY=null;return ae.attemptContinuousHydration=function(e){if(13===e.tag||31===e.tag){var n=ew(e,0x4000000);null!==n&&r_(n,e,0x4000000),r7(e,0x4000000)}},ae.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag||31===e.tag){var n=rh(),t=ew(e,n=b(n));null!==t&&r_(t,e,n),r7(e,n)}},ae.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if((e=e.stateNode).current.memoizedState.isDehydrated){var n=f(e.pendingLanes);if(0!==n){for(e.pendingLanes|=2,e.entangledLanes|=2;n;){var t=1<<31-oy(n);e.entanglements[1]|=t,n&=~t}ei(e),(6&sg)==0&&(sO=oO()+500,eo(0,!1))}}break;case 31:case 13:null!==(n=ew(e,2))&&r_(n,e,2),rT(),r7(e,2)}},ae.batchedUpdates=function(e,n){return e(n)},ae.createComponentSelector=function(e){return{$$typeof:su,value:e}},ae.createContainer=function(e,n,t,r,a,i,o,l,s,u){return r5(e,n,!1,null,t,r,i,null,o,l,s,u)},ae.createHasPseudoClassSelector=function(e){return{$$typeof:sc,value:e}},ae.createHydrationContainer=function(e,n,t,r,a,i,o,l,s,u,c,d,f,p){var m;return(e=r5(t,r,!0,e,a,i,l,p,s,u,c,d)).context=oC,t=e.current,(a=eI(r=b(r=rh()))).callback=null!=(m=n)?m:null,eF(t,a,r),n=r,e.current.lanes=n,S(e,n),ei(e),e},ae.createPortal=function(e,n,t){var r=3=c&&o>=f&&i<=d&&l<=p){e.splice(n,1);break}if(a!==c||t.width!==u.width||pl){if(!(o!==f||t.height!==u.height||di)){c>a&&(u.width+=c-a,u.x=a),do&&(u.height+=f-o,u.y=o),pt&&(t=s)),s ")+` - -No matching component was found for: - `+e.join(" > ")}return null},ae.getPublicRootInstance=function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 27:case 5:return aC(e.child.stateNode);default:return e.child.stateNode}},ae.injectIntoDevTools=function(){var e={bundleType:0,version:ab,rendererPackageName:ax,currentDispatcherRef:aM,reconcilerVersion:"19.2.0"};if(null!==aR&&(e.rendererConfig=aR),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")e=!1;else{var n=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(n.isDisabled||!n.supportsFiber)e=!0;else{try{oW=n.inject(e),oX=n}catch{}e=!!n.checkDCE}}return e},ae.isAlreadyRendering=function(){return(6&sg)!=0},ae.observeVisibleRects=function(e,n,t,a){if(!a9)throw Error(r(363));var i=io(e=rm(e,n),t,a).disconnect;return{disconnect:function(){i()}}},ae.shouldError=function(){return null},ae.shouldSuspend=function(){return!1},ae.startHostTransition=function(e,n,a,i){if(5!==e.tag)throw Error(r(476));var o=nW(e).queue;nz(e,o,n,a2,null===a?t:function(){var n=nW(e);return null===n.next&&(n=e.alternate.memoizedState),nQ(e,n.next.queue,{},rh()),a(i)})},ae.updateContainer=function(e,n,t,r){var a=n.current,i=rh();return r8(a,i,e,n,t,r),i},ae.updateContainerSync=function(e,n,t,r){return r8(n.current,2,e,n,t,r),2},ae},tY.exports.default=tY.exports,Object.defineProperty(tY.exports,"__esModule",{value:!0})),tq.exports=tY.exports),(f=tq.exports)&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default"))?f.default:f,t$={},tQ=/^three(?=[A-Z])/,tZ=e=>`${e[0].toUpperCase()}${e.slice(1)}`,tJ=0;function t0(e){if("function"==typeof e){let n=`${tJ++}`;return t$[n]=e,n}Object.assign(t$,e)}function t1(e,n){let t=tZ(e),r=t$[t];if("primitive"!==e&&!r)throw Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if("primitive"===e&&!n.object)throw Error("R3F: Primitives without 'object' are invalid!");if(void 0!==n.args&&!Array.isArray(n.args))throw Error("R3F: The args prop must be an array!")}function t3(e){if(e.isHidden){var n;e.props.attach&&null!=(n=e.parent)&&n.object?tA(e.parent,e):tF(e.object)&&!1!==e.props.visible&&(e.object.visible=!0),e.isHidden=!1,tI(e)}}function t2(e,n,t){let r=n.root.getState();if(e.parent||e.object===r.scene){if(!n.object){var a,i;let e=t$[tZ(n.type)];n.object=null!=(a=n.props.object)?a:new e(...null!=(i=n.props.args)?i:[]),n.object.__r3f=n}if(tD(n.object,n.props),n.props.attach)tA(e,n);else if(tF(n.object)&&tF(e.object)){let r=e.object.children.indexOf(null==t?void 0:t.object);if(t&&-1!==r){let t=e.object.children.indexOf(n.object);-1!==t?(e.object.children.splice(t,1),e.object.children.splice(t{try{e.dispose()}catch{}};"u">typeof IS_REACT_ACT_ENVIRONMENT?n():(0,tt.unstable_scheduleCallback)(tt.unstable_IdlePriority,n)}}function t8(e,n,t){if(!n)return;n.parent=null;let r=e.children.indexOf(n);-1!==r&&e.children.splice(r,1),n.props.attach?tP(e,n):tF(n.object)&&tF(e.object)&&(e.object.remove(n.object),function(e,n){let{internal:t}=e.getState();t.interaction=t.interaction.filter(e=>e!==n),t.initialHits=t.initialHits.filter(e=>e!==n),t.hovered.forEach((e,r)=>{(e.eventObject===n||e.object===n)&&t.hovered.delete(r)}),t.capturedMap.forEach((e,r)=>{tB(t.capturedMap,n,e,r)})}(tp(n),n.object));let a=null!==n.props.dispose&&!1!==t;for(let e=n.children.length-1;e>=0;e--){let t=n.children[e];t8(n,t,a)}n.children.length=0,delete n.object.__r3f,a&&"primitive"!==n.type&&"Scene"!==n.object.type&&t6(n.object),void 0===t&&tI(n)}let t9=[],t7=()=>{},re={},rn=0,rt=(p={isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:function(e,n,t){var r;return t1(e=tZ(e)in t$?e:e.replace(tQ,""),n),"primitive"===e&&null!=(r=n.object)&&r.__r3f&&delete n.object.__r3f,tR(n.object,t,e,n)},removeChild:t8,appendChild:t4,appendInitialChild:t4,insertBefore:t5,appendChildToContainer(e,n){let t=e.getState().scene.__r3f;n&&t&&t4(t,n)},removeChildFromContainer(e,n){let t=e.getState().scene.__r3f;n&&t&&t8(t,n)},insertInContainerBefore(e,n,t){let r=e.getState().scene.__r3f;n&&t&&r&&t5(r,n,t)},getRootHostContext:()=>re,getChildHostContext:()=>re,commitUpdate(e,n,t,r,a){var i,o,l;t1(n,r);let s=!1;if("primitive"===e.type&&t.object!==r.object||(null==(i=r.args)?void 0:i.length)!==(null==(o=t.args)?void 0:o.length)?s=!0:null!=(l=r.args)&&l.some((e,n)=>{var r;return e!==(null==(r=t.args)?void 0:r[n])})&&(s=!0),s)t9.push([e,{...r},a]);else{let n=function(e,n){let t={};for(let r in n)if(!tw.includes(r)&&!tb.equ(n[r],e.props[r]))for(let e in t[r]=n[r],n)e.startsWith(`${r}-`)&&(t[e]=n[e]);for(let r in e.props){if(tw.includes(r)||n.hasOwnProperty(r))continue;let{root:a,key:i}=tC(e.object,r);if(a.constructor&&0===a.constructor.length){let e=function(e){let n=tL.get(e.constructor);try{n||(n=new e.constructor,tL.set(e.constructor,n))}catch(e){}return n}(a);tb.und(e)||(t[i]=e[i])}else t[i]=0}return t}(e,r);Object.keys(n).length&&(Object.assign(e.props,n),tD(e.object,n))}(null===a.sibling||(4&a.flags)==0)&&function(){for(let[e]of t9){let n=e.parent;if(n)for(let t of(e.props.attach?tP(n,e):tF(e.object)&&tF(n.object)&&n.object.remove(e.object),e.children))t.props.attach?tP(e,t):tF(t.object)&&tF(e.object)&&e.object.remove(t.object);e.isHidden&&t3(e),e.object.__r3f&&delete e.object.__r3f,"primitive"!==e.type&&t6(e.object)}for(let[r,a,i]of t9){r.props=a;let o=r.parent;if(o){let a=t$[tZ(r.type)];r.object=null!=(e=r.props.object)?e:new a(...null!=(n=r.props.args)?n:[]),r.object.__r3f=r;var e,n,t=r.object;for(let e of[i,i.alternate])if(null!==e)if("function"==typeof e.ref){null==e.refCleanup||e.refCleanup();let n=e.ref(t);"function"==typeof n&&(e.refCleanup=n)}else e.ref&&(e.ref.current=t);for(let e of(tD(r.object,r.props),r.props.attach?tA(o,r):tF(r.object)&&tF(o.object)&&o.object.add(r.object),r.children))e.props.attach?tA(r,e):tF(e.object)&&tF(r.object)&&r.object.add(e.object);tI(r)}}t9.length=0}()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>null==e?void 0:e.object,prepareForCommit:()=>null,preparePortalMount:e=>tR(e.getState().scene,e,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:function(e){if(!e.isHidden){var n;e.props.attach&&null!=(n=e.parent)&&n.object?tP(e.parent,e):tF(e.object)&&(e.object.visible=!1),e.isHidden=!0,tI(e)}},unhideInstance:t3,createTextInstance:t7,hideTextInstance:t7,unhideTextInstance:t7,scheduleTimeout:"function"==typeof setTimeout?setTimeout:void 0,cancelTimeout:"function"==typeof clearTimeout?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:_.createContext(null),setCurrentUpdatePriority(e){rn=e},getCurrentUpdatePriority:()=>rn,resolveUpdatePriority(){var e;if(0!==rn)return rn;switch("u">typeof window&&(null==(e=window.event)?void 0:e.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return 2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return 8;default:return 32}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:"9.5.0",applyViewTransitionName(e,n,t){},restoreViewTransitionName(e,n){},cancelViewTransitionName(e,n,t){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,n)=>!1,hasInstanceAffectedParent:(e,n)=>!1,suspendOnActiveViewTransition(e,n){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance:(e,n)=>e,cloneMutableTextInstance:e=>e,cloneRootViewTransitionContainer(e){throw Error("Not implemented.")},removeRootViewTransitionClone(e,n){throw Error("Not implemented.")},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,n){},commitNewChildToFragmentInstance(e,n){},deleteChildFromFragmentInstance(e,n){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,n,t)=>!1,maySuspendCommitInSyncRender:(e,n)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,n)=>null},(u=tK(p)).injectIntoDevTools(),u),rr=new Map,ra={objects:"shallow",strict:!1};function ri(e){var n,t;let r,a,i,o,l,s,u,c=rr.get(e),d=null==c?void 0:c.fiber,f=null==c?void 0:c.store;c&&console.warn("R3F.createRoot should only be called once!");let p="function"==typeof reportError?reportError:console.error,m=f||(n=rE,t=rT,l=(o=(i=n9((e,r)=>{let a,i=new v.Vector3,o=new v.Vector3,l=new v.Vector3;function s(e=r().camera,n=o,t=r().size){let{width:a,height:u,top:c,left:d}=t,f=a/u;n.isVector3?l.copy(n):l.set(...n);let p=e.getWorldPosition(i).distanceTo(l);if(e&&e.isOrthographicCamera)return{width:a/e.zoom,height:u/e.zoom,top:c,left:d,factor:1,distance:p,aspect:f};{let n=2*Math.tan(e.fov*Math.PI/180/2)*p,t=a/u*n;return{width:t,height:n,top:c,left:d,factor:a/t,distance:p,aspect:f}}}let u=n=>e(e=>({performance:{...e.performance,current:n}})),c=new v.Vector2;return{set:e,get:r,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(e=1)=>n(r(),e),advance:(e,n)=>t(e,n,r()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new v.Clock,pointer:c,mouse:c,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=r();a&&clearTimeout(a),e.performance.current!==e.performance.min&&u(e.performance.min),a=setTimeout(()=>u(r().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:n=>e(e=>({...e,events:{...e.events,...n}})),setSize:(n,t,a=0,i=0)=>{let l=r().camera,u={width:n,height:t,top:a,left:i};e(e=>({size:u,viewport:{...e.viewport,...s(l,o,u)}}))},setDpr:n=>e(e=>{let t=tT(n);return{viewport:{...e.viewport,dpr:t,initialDpr:e.viewport.initialDpr||t}}}),setFrameloop:(n="always")=>{let t=r().clock;t.stop(),t.elapsedTime=0,"never"!==n&&(t.start(),t.elapsedTime=0),e(()=>({frameloop:n}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:_.createRef(),active:!1,frames:0,priority:0,subscribe:(e,n,t)=>{let a=r().internal;return a.priority=a.priority+ +(n>0),a.subscribers.push({ref:e,priority:n,store:t}),a.subscribers=a.subscribers.sort((e,n)=>e.priority-n.priority),()=>{let t=r().internal;null!=t&&t.subscribers&&(t.priority=t.priority-(n>0),t.subscribers=t.subscribers.filter(n=>n.ref!==e))}}}}})).getState()).size,s=o.viewport.dpr,u=o.camera,i.subscribe(()=>{let{camera:e,size:n,viewport:t,gl:r,set:a}=i.getState();if(n.width!==l.width||n.height!==l.height||t.dpr!==s){l=n,s=t.dpr;!e.manual&&(e&&e.isOrthographicCamera?(e.left=-(n.width/2),e.right=n.width/2,e.top=n.height/2,e.bottom=-(n.height/2)):e.aspect=n.width/n.height,e.updateProjectionMatrix());t.dpr>0&&r.setPixelRatio(t.dpr);let a="u">typeof HTMLCanvasElement&&r.domElement instanceof HTMLCanvasElement;r.setSize(n.width,n.height,a)}e!==u&&(u=e,a(n=>({viewport:{...n.viewport,...n.viewport.getCurrentViewport(e)}})))}),i.subscribe(e=>n(e)),i),h=d||rt.createContainer(m,1,null,!1,null,"",p,p,p,null);c||rr.set(e,{fiber:h,store:m});let g=!1,S=null;return{async configure(n={}){var t,i;let o;S=new Promise(e=>o=e);let{gl:l,size:s,scene:u,events:c,onCreated:d,shadows:f=!1,linear:p=!1,flat:h=!1,legacy:_=!1,orthographic:E=!1,frameloop:T="always",dpr:M=[1,2],performance:b,raycaster:x,camera:R,onPointerMissed:C}=n,y=m.getState(),A=y.gl;if(!y.gl){let n={canvas:e,powerPreference:"high-performance",antialias:!0,alpha:!0},t="function"==typeof l?await l(n):l;A=tG(t)?t:new n0({...n,...l}),y.set({gl:A})}let P=y.raycaster;P||y.set({raycaster:P=new v.Raycaster});let{params:w,...L}=x||{};if(tb.equ(L,P,ra)||tD(P,{...L}),tb.equ(w,P.params,ra)||tD(P,{params:{...P.params,...w}}),!y.camera||y.camera===a&&!tb.equ(a,R,ra)){a=R;let e=null==R?void 0:R.isCamera,n=e?R:E?new v.OrthographicCamera(0,0,0,0,.1,1e3):new v.PerspectiveCamera(75,0,.1,1e3);!e&&(n.position.z=5,R&&(tD(n,R),!n.manual&&("aspect"in R||"left"in R||"right"in R||"bottom"in R||"top"in R)&&(n.manual=!0,n.updateProjectionMatrix())),y.camera||null!=R&&R.rotation||n.lookAt(0,0,0)),y.set({camera:n}),P.camera=n}if(!y.scene){let e;null!=u&&u.isScene?tR(e=u,m,"",{}):(tR(e=new v.Scene,m,"",{}),u&&tD(e,u)),y.set({scene:e})}c&&!y.events.handlers&&y.set({events:c(m)});let N=function(e,n){if(!n&&"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:n,height:t,top:r,left:a}=e.parentElement.getBoundingClientRect();return{width:n,height:t,top:r,left:a}}return!n&&"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...n}}(e,s);if(tb.equ(N,y.size,ra)||y.setSize(N.width,N.height,N.top,N.left),M&&y.viewport.dpr!==tT(M)&&y.setDpr(M),y.frameloop!==T&&y.setFrameloop(T),y.onPointerMissed||y.set({onPointerMissed:C}),b&&!tb.equ(b,y.performance,ra)&&y.set(e=>({performance:{...e.performance,...b}})),!y.xr){let e=(e,n)=>{let t=m.getState();"never"!==t.frameloop&&rT(e,!0,t,n)},n=()=>{let n=m.getState();n.gl.xr.enabled=n.gl.xr.isPresenting,n.gl.xr.setAnimationLoop(n.gl.xr.isPresenting?e:null),n.gl.xr.isPresenting||rE(n)},r={connect(){let e=m.getState().gl;e.xr.addEventListener("sessionstart",n),e.xr.addEventListener("sessionend",n)},disconnect(){let e=m.getState().gl;e.xr.removeEventListener("sessionstart",n),e.xr.removeEventListener("sessionend",n)}};"function"==typeof(null==(t=A.xr)?void 0:t.addEventListener)&&r.connect(),y.set({xr:r})}if(A.shadowMap){let e=A.shadowMap.enabled,n=A.shadowMap.type;if(A.shadowMap.enabled=!!f,tb.boo(f))A.shadowMap.type=v.PCFSoftShadowMap;else if(tb.str(f)){let e={basic:v.BasicShadowMap,percentage:v.PCFShadowMap,soft:v.PCFSoftShadowMap,variance:v.VSMShadowMap};A.shadowMap.type=null!=(i=e[f])?i:v.PCFSoftShadowMap}else tb.obj(f)&&Object.assign(A.shadowMap,f);(e!==A.shadowMap.enabled||n!==A.shadowMap.type)&&(A.shadowMap.needsUpdate=!0)}return v.ColorManagement.enabled=!_,g||(A.outputColorSpace=p?v.LinearSRGBColorSpace:v.SRGBColorSpace,A.toneMapping=h?v.NoToneMapping:v.ACESFilmicToneMapping),y.legacy!==_&&y.set(()=>({legacy:_})),y.linear!==p&&y.set(()=>({linear:p})),y.flat!==h&&y.set(()=>({flat:h})),!l||tb.fun(l)||tG(l)||tb.equ(l,A,ra)||tD(A,l),r=d,g=!0,o(),this},render(n){return g||S||this.configure(),S.then(()=>{rt.updateContainer((0,tr.jsx)(ro,{store:m,children:n,onCreated:r,rootElement:e}),h,null,()=>void 0)}),m},unmount(){rl(e)}}}function ro({store:e,children:n,onCreated:t,rootElement:r}){return tg(()=>{let n=e.getState();n.set(e=>({internal:{...e.internal,active:!0}})),t&&t(n),e.getState().events.connected||null==n.events.connect||n.events.connect(r)},[]),(0,tr.jsx)(tH.Provider,{value:e,children:n})}function rl(e,n){let t=rr.get(e),r=null==t?void 0:t.fiber;if(r){let a=null==t?void 0:t.store.getState();a&&(a.internal.active=!1),rt.updateContainer(null,r,null,()=>{a&&setTimeout(()=>{try{null==a.events.disconnect||a.events.disconnect(),null==(t=a.gl)||null==(r=t.renderLists)||null==r.dispose||r.dispose(),null==(i=a.gl)||null==i.forceContextLoss||i.forceContextLoss(),null!=(o=a.gl)&&o.xr&&a.xr.disconnect();var t,r,i,o,l=a.scene;for(let e in"Scene"!==l.type&&(null==l.dispose||l.dispose()),l){let n=l[e];(null==n?void 0:n.type)!=="Scene"&&(null==n||null==n.dispose||n.dispose())}rr.delete(e),n&&n(e)}catch(e){}},500)})}}function rs(e,n){let t={callback:e};return n.add(t),()=>void n.delete(t)}let ru=new Set,rc=new Set,rd=new Set,rf=e=>rs(e,ru),rp=e=>rs(e,rc);function rm(e,n){if(e.size)for(let{callback:t}of e.values())t(n)}function rh(e,n){switch(e){case"before":return rm(ru,n);case"after":return rm(rc,n);case"tail":return rm(rd,n)}}function rg(e,r,a){let i=r.clock.getDelta();"never"===r.frameloop&&"number"==typeof e&&(i=e-r.clock.elapsedTime,r.clock.oldTime=r.clock.elapsedTime,r.clock.elapsedTime=e),n=r.internal.subscribers;for(let e=0;e0)&&!(null!=(n=i.gl.xr)&&n.isPresenting)&&(r+=rg(e,i))}if(rv=!1,rh("after",e),0===r)return rh("tail",e),r_=!1,cancelAnimationFrame(a)}function rE(e,n=1){var t;if(!e)return rr.forEach(e=>rE(e.store.getState(),n));(null==(t=e.gl.xr)||!t.isPresenting)&&e.internal.active&&"never"!==e.frameloop&&(n>1?e.internal.frames=Math.min(60,e.internal.frames+n):rv?e.internal.frames=2:e.internal.frames=1,r_||(r_=!0,requestAnimationFrame(rS)))}function rT(e,n=!0,t,r){if(n&&rh("before",e),t)rg(e,t,r);else for(let n of rr.values())rg(e,n.store.getState());n&&rh("after",e)}let rM={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function rb(e){let{handlePointer:n}=function(e){function n(e){return e.filter(e=>["Move","Over","Enter","Out","Leave"].some(n=>{var t;return null==(t=e.__r3f)?void 0:t.handlers["onPointer"+n]}))}function t(n){let{internal:t}=e.getState();for(let e of t.hovered.values())if(!n.length||!n.find(n=>n.object===e.object&&n.index===e.index&&n.instanceId===e.instanceId)){let r=e.eventObject.__r3f;if(t.hovered.delete(tO(e)),null!=r&&r.eventCount){let t=r.handlers,a={...e,intersections:n};null==t.onPointerOut||t.onPointerOut(a),null==t.onPointerLeave||t.onPointerLeave(a)}}}function r(e,n){for(let t=0;tt([]);case"onLostPointerCapture":return n=>{let{internal:r}=e.getState();"pointerId"in n&&r.capturedMap.has(n.pointerId)&&requestAnimationFrame(()=>{r.capturedMap.has(n.pointerId)&&(r.capturedMap.delete(n.pointerId),t([]))})}}return function(i){let{onPointerMissed:o,internal:l}=e.getState();l.lastEvent.current=i;let s="onPointerMove"===a,u="onClick"===a||"onContextMenu"===a||"onDoubleClick"===a,c=function(n,t){let r=e.getState(),a=new Set,i=[],o=t?t(r.internal.interaction):r.internal.interaction;for(let e=0;e{let t=tM(e.object),r=tM(n.object);return t&&r&&r.events.priority-t.events.priority||e.distance-n.distance}).filter(e=>{let n=tO(e);return!a.has(n)&&(a.add(n),!0)});for(let e of(r.events.filter&&(l=r.events.filter(l,r)),l)){let n=e.object;for(;n;){var s;null!=(s=n.__r3f)&&s.eventCount&&i.push({...e,eventObject:n}),n=n.parent}}if("pointerId"in n&&r.internal.capturedMap.has(n.pointerId))for(let e of r.internal.capturedMap.get(n.pointerId).values())a.has(tO(e.intersection))||i.push(e.intersection);return i}(i,s?n:void 0),d=u?function(n){let{internal:t}=e.getState(),r=n.offsetX-t.initialClick[0],a=n.offsetY-t.initialClick[1];return Math.round(Math.sqrt(r*r+a*a))}(i):0;"onPointerDown"===a&&(l.initialClick=[i.offsetX,i.offsetY],l.initialHits=c.map(e=>e.eventObject)),u&&!c.length&&d<=2&&(r(i,l.interaction),o&&o(i)),s&&t(c),!function(e,n,r,a){if(e.length){let i={stopped:!1};for(let o of e){let l=tM(o.object);if(l||o.object.traverseAncestors(e=>{let n=tM(e);if(n)return l=n,!1}),l){let{raycaster:s,pointer:u,camera:c,internal:d}=l,f=new v.Vector3(u.x,u.y,0).unproject(c),p=e=>{var n,t;return null!=(n=null==(t=d.capturedMap.get(e))?void 0:t.has(o.eventObject))&&n},m=e=>{let t={intersection:o,target:n.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,t):d.capturedMap.set(e,new Map([[o.eventObject,t]])),n.target.setPointerCapture(e)},h=e=>{let n=d.capturedMap.get(e);n&&tB(d.capturedMap,o.eventObject,n,e)},g={};for(let e in n){let t=n[e];"function"!=typeof t&&(g[e]=t)}let _={...o,...g,pointer:u,intersections:e,stopped:i.stopped,delta:r,unprojectedPoint:f,ray:s.ray,camera:c,stopPropagation(){let r="pointerId"in n&&d.capturedMap.get(n.pointerId);(!r||r.has(o.eventObject))&&(_.stopped=i.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(e=>e.eventObject===o.eventObject)&&t([...e.slice(0,e.indexOf(o)),o]))},target:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},currentTarget:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},nativeEvent:n};if(a(_),!0===i.stopped)break}}}}(c,i,d,function(e){let n=e.eventObject,t=n.__r3f;if(!(null!=t&&t.eventCount))return;let o=t.handlers;if(s){if(o.onPointerOver||o.onPointerEnter||o.onPointerOut||o.onPointerLeave){let n=tO(e),t=l.hovered.get(n);t?t.stopped&&e.stopPropagation():(l.hovered.set(n,e),null==o.onPointerOver||o.onPointerOver(e),null==o.onPointerEnter||o.onPointerEnter(e))}null==o.onPointerMove||o.onPointerMove(e)}else{let t=o[a];t?(!u||l.initialHits.includes(n))&&(r(i,l.interaction.filter(e=>!l.initialHits.includes(e))),t(e)):u&&l.initialHits.includes(n)&&r(i,l.interaction.filter(e=>!l.initialHits.includes(e)))}})}}}}(e);return{priority:1,enabled:!0,compute(e,n,t){n.pointer.set(e.offsetX/n.size.width*2-1,-(2*(e.offsetY/n.size.height))+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(rM).reduce((e,t)=>({...e,[t]:n(t)}),{}),update:()=>{var n;let{events:t,internal:r}=e.getState();null!=(n=r.lastEvent)&&n.current&&t.handlers&&t.handlers.onPointerMove(r.lastEvent.current)},connect:n=>{let{set:t,events:r}=e.getState();if(null==r.disconnect||r.disconnect(),t(e=>({events:{...e.events,connected:n}})),r.handlers)for(let e in r.handlers){let t=r.handlers[e],[a,i]=rM[e];n.addEventListener(a,t,{passive:i})}},disconnect:()=>{let{set:n,events:t}=e.getState();if(t.connected){if(t.handlers)for(let e in t.handlers){let n=t.handlers[e],[r]=rM[e];t.connected.removeEventListener(r,n)}n(e=>({events:{...e.events,connected:void 0}}))}}}}e.s(["B",()=>tS,"C",()=>tV,"D",()=>tz,"E",()=>tE,"G",()=>tj,"a",()=>t_,"b",()=>tg,"c",()=>ri,"d",()=>rl,"e",()=>t0,"f",()=>rb,"i",()=>tm,"j",()=>rf,"k",()=>rp,"u",()=>tv],40859)},15080,e=>{"use strict";var n=e.i(40859);e.s(["useThree",()=>n.C])},71753,e=>{"use strict";var n=e.i(40859);e.s(["useFrame",()=>n.D])},79123,e=>{"use strict";var n=e.i(43476),t=e.i(71645);let r=(0,t.createContext)(null),a=(0,t.createContext)(null),i=(0,t.createContext)(null);function o(){return(0,t.useContext)(r)}function l(){return(0,t.useContext)(a)}function s(){return(0,t.useContext)(i)}function u({children:e,fogEnabledOverride:o,onClearFogEnabledOverride:l}){let[s,u]=(0,t.useState)(!0),[c,d]=(0,t.useState)(!1),[f,p]=(0,t.useState)(1),[m,h]=(0,t.useState)(90),[g,_]=(0,t.useState)(!1),[v,S]=(0,t.useState)(!0),[E,T]=(0,t.useState)(!1),[M,b]=(0,t.useState)("moveLookStick"),x=(0,t.useCallback)(e=>{u(e),l()},[l]),R=(0,t.useMemo)(()=>({fogEnabled:o??s,setFogEnabled:x,highQualityFog:c,setHighQualityFog:d,fov:m,setFov:h,audioEnabled:g,setAudioEnabled:_,animationEnabled:v,setAnimationEnabled:S}),[s,o,x,c,m,g,v]),C=(0,t.useMemo)(()=>({debugMode:E,setDebugMode:T}),[E,T]),y=(0,t.useMemo)(()=>({speedMultiplier:f,setSpeedMultiplier:p,touchMode:M,setTouchMode:b}),[f,p,M,b]);(0,t.useLayoutEffect)(()=>{let e={};try{e=JSON.parse(localStorage.getItem("settings"))||{}}catch(e){}null!=e.debugMode&&T(e.debugMode),null!=e.audioEnabled&&_(e.audioEnabled),null!=e.animationEnabled&&S(e.animationEnabled),null!=e.fogEnabled&&u(e.fogEnabled),null!=e.highQualityFog&&d(e.highQualityFog),null!=e.speedMultiplier&&p(e.speedMultiplier),null!=e.fov&&h(e.fov),null!=e.touchMode&&b(e.touchMode)},[]);let A=(0,t.useRef)(null);return(0,t.useEffect)(()=>(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{try{localStorage.setItem("settings",JSON.stringify({fogEnabled:s,highQualityFog:c,speedMultiplier:f,fov:m,audioEnabled:g,animationEnabled:v,debugMode:E,touchMode:M}))}catch(e){}},500),()=>{A.current&&clearTimeout(A.current)}),[s,c,f,m,g,v,E,M]),(0,n.jsx)(r.Provider,{value:R,children:(0,n.jsx)(a.Provider,{value:C,children:(0,n.jsx)(i.Provider,{value:y,children:e})})})}e.s(["SettingsProvider",()=>u,"useControls",()=>s,"useDebug",()=>l,"useSettings",()=>o])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/2400be5b6a2e4806.js b/docs/_next/static/chunks/2400be5b6a2e4806.js new file mode 100644 index 00000000..3fbd96ce --- /dev/null +++ b/docs/_next/static/chunks/2400be5b6a2e4806.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,85413,e=>{"use strict";var t=Object.defineProperty;class i{constructor(){((e,i,n)=>{let r,s;s=void 0,(r="symbol"!=typeof i?i+"":i)in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let i=this._listeners[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let i=t.slice(0);for(let t=0,n=i.length;ti])},32865,e=>{"use strict";var t=e.i(43476),i=e.i(932);e.i(13876);var n=e.i(58647);function r(e){let n,r=(0,i.c)(2),{children:s}=e;return r[0]!==s?(n=(0,t.jsx)(t.Fragment,{children:s}),r[0]=s,r[1]=n):n=r[1],n}function s(){return(0,n.useEngineSelector)(a)}function a(e){return e.playback.recording}function o(){return(0,n.useEngineSelector)(l)}function l(e){return"playing"===e.playback.status}function u(){return(0,n.useEngineSelector)(c)}function c(e){return e.playback.timeMs/1e3}function m(){return(0,n.useEngineSelector)(d)}function d(e){return e.playback.durationMs/1e3}function f(){return(0,n.useEngineSelector)(h)}function h(e){return e.playback.rate}function p(){let e,t,r,a,o,l,u=(0,i.c)(17),c=s(),m=(0,n.useEngineSelector)(v),d=(0,n.useEngineSelector)(b),f=(0,n.useEngineSelector)(g),h=(0,n.useEngineSelector)(y);u[0]!==m?(e=e=>{m(e)},u[0]=m,u[1]=e):e=u[1];let p=e;u[2]!==c||u[3]!==d?(t=()=>{c&&d("playing")},u[2]=c,u[3]=d,u[4]=t):t=u[4];let x=t;u[5]!==d?(r=()=>{d("paused")},u[5]=d,u[6]=r):r=u[6];let k=r;u[7]!==f?(a=e=>{f(1e3*e)},u[7]=f,u[8]=a):a=u[8];let S=a;u[9]!==h?(o=e=>{h(e)},u[9]=h,u[10]=o):o=u[10];let w=o;return u[11]!==k||u[12]!==x||u[13]!==S||u[14]!==p||u[15]!==w?(l={setRecording:p,play:x,pause:k,seek:S,setSpeed:w},u[11]=k,u[12]=x,u[13]=S,u[14]=p,u[15]=w,u[16]=l):l=u[16],l}function y(e){return e.setPlaybackRate}function g(e){return e.setPlaybackTime}function b(e){return e.setPlaybackStatus}function v(e){return e.setRecording}e.s(["RecordingProvider",()=>r,"useCurrentTime",()=>u,"useDuration",()=>m,"useIsPlaying",()=>o,"usePlaybackActions",()=>p,"useRecording",()=>s,"useSpeed",()=>f])},9672,e=>{"use strict";function t(e,t){return e[t.toLowerCase()]}function i(e,i){let n=t(e,i);if(null==n)return;let r=parseFloat(n);return Number.isFinite(r)?r:void 0}function n(e,i){let n=t(e,i);if(null==n)return;let r=parseInt(n,10);return Number.isFinite(r)?r:void 0}function r(e,t={x:0,y:0,z:0}){if(!e)return t;let i=e.split(" ").map(Number);return{x:i[0]??t.x,y:i[1]??t.y,z:i[2]??t.z}}function s(e,t={r:0,g:0,b:0}){if(!e)return t;let i=e.split(" ").map(Number);return{r:i[0]??t.r,g:i[1]??t.g,b:i[2]??t.b}}function a(e,t={r:.5,g:.5,b:.5,a:1}){if(!e)return t;let i=e.split(" ").map(Number);return{r:i[0]??t.r,g:i[1]??t.g,b:i[2]??t.b,a:i[3]??t.a}}function o(e,t){let i=r(e),n=(t??"1 0 0 0").split(" ").map(Number),s=n[0]??1,a=n[1]??0,o=n[2]??0,l=Math.PI/180*(n[3]??0),u=Math.sqrt(s*s+a*a+o*o),c=0,m=0,d=1;u>1e-8&&(c=s/u,m=a/u,d=o/u);let f=Math.cos(l),h=Math.sin(l),p=1-f,y=Array(16).fill(0);return y[0]=p*c*c+f,y[1]=p*c*m+h*d,y[2]=p*c*d-h*m,y[4]=p*c*m-h*d,y[5]=p*m*m+f,y[6]=p*m*d+h*c,y[8]=p*c*d+h*m,y[9]=p*m*d-h*c,y[10]=p*d*d+f,y[12]=i.x,y[13]=i.y,y[14]=i.z,y[15]=1,{elements:y,position:i}}function l(e){return{className:"TerrainBlock",ghostIndex:e._id,terrFileName:t(e,"terrainFile")??"",detailTextureName:t(e,"detailTexture")??"",squareSize:n(e,"squareSize")??8,emptySquareRuns:function(e){if(!e)return;let t=e.split(/\s+/).map(Number).filter(Number.isFinite);return t.length>0?t:void 0}(t(e,"emptySquares"))}}function u(e){return{className:"InteriorInstance",ghostIndex:e._id,interiorFile:t(e,"interiorFile")??"",transform:o(t(e,"position"),t(e,"rotation")),scale:r(t(e,"scale"),{x:1,y:1,z:1}),showTerrainInside:"1"===t(e,"showTerrainInside"),skinBase:t(e,"skinBase")??"",alarmState:!1}}function c(e){let a=[];for(let i=1;i<=3;i++){let n=function(e){if(!e)return null;let t=e.split(/\s+/).map(Number),i=t[0]??0,n=t[1]??0,r=t[2]??0;return 0===i&&0===n&&0===r?null:{visibleDistance:i,minHeight:n,maxHeight:r,color:{r:.5,g:.5,b:.5}}}(t(e,`fogVolume${i}`));n&&a.push(n)}let o=[];for(let n=0;n<3;n++){let r=t(e,`cloudText${n+1}`)??"",s=i(e,`cloudHeightPer[${n}]`)??i(e,`cloudheightper${n}`)??[.35,.25,.2][n],a=i(e,`cloudSpeed${n+1}`)??[1e-4,2e-4,3e-4][n];o.push({texture:r,heightPercent:s,speed:a})}return{className:"Sky",ghostIndex:e._id,materialList:t(e,"materialList")??"",fogColor:s(t(e,"fogColor")),visibleDistance:i(e,"visibleDistance")??1e3,fogDistance:i(e,"fogDistance")??0,skySolidColor:s(t(e,"SkySolidColor")),useSkyTextures:(n(e,"useSkyTextures")??1)!==0,fogVolumes:a,cloudLayers:o,windVelocity:r(t(e,"windVelocity"))}}function m(e){return{className:"Sun",ghostIndex:e._id,direction:r(t(e,"direction"),{x:.57735,y:.57735,z:-.57735}),color:a(t(e,"color"),{r:.7,g:.7,b:.7,a:1}),ambient:a(t(e,"ambient"),{r:.5,g:.5,b:.5,a:1})}}function d(e){let n=t(e,"area"),r={x:-512,y:-512,w:1024,h:1024};if(n){let e=n.split(/\s+/).map(Number);r={x:e[0]??r.x,y:e[1]??r.y,w:e[2]??r.w,h:e[3]??r.h}}return{className:"MissionArea",ghostIndex:e._id,area:r,flightCeiling:i(e,"flightCeiling")??2e3,flightCeilingRange:i(e,"flightCeilingRange")??50}}function f(e){return{className:"WaterBlock",ghostIndex:e._id,transform:o(t(e,"position"),t(e,"rotation")),scale:r(t(e,"scale"),{x:1,y:1,z:1}),surfaceName:t(e,"surfaceTexture")??"",envMapName:t(e,"envMapTexture")??"",surfaceOpacity:i(e,"surfaceOpacity")??.75,waveMagnitude:i(e,"waveMagnitude")??1,envMapIntensity:i(e,"envMapIntensity")??1}}e.s(["interiorFromMis",()=>u,"missionAreaFromMis",()=>d,"skyFromMis",()=>c,"sunFromMis",()=>m,"terrainFromMis",()=>l,"waterBlockFromMis",()=>f])},19402,47566,e=>{"use strict";function t(e,i={x:0,y:0,z:0}){return e&&"object"==typeof e&&"x"in e?e:i}function i(e,t={r:0,g:0,b:0}){return e&&"object"==typeof e&&"r"in e?e:t}function n(e,t={r:.5,g:.5,b:.5,a:1}){return e&&"object"==typeof e&&"r"in e?e:t}function r(e){if(e&&"object"==typeof e&&"elements"in e&&Array.isArray(e.elements))return e;if(e&&"object"==typeof e&&"position"in e&&"rotation"in e){let{position:t,rotation:i}=e,n=i.x*i.x,r=i.y*i.y,s=i.z*i.z,a=i.x*i.y,o=i.x*i.z,l=i.y*i.z,u=i.w*i.x,c=i.w*i.y,m=i.w*i.z;return{elements:[1-2*(r+s),2*(a+m),2*(o-c),0,2*(a-m),1-2*(n+s),2*(l+u),0,2*(o+c),2*(l-u),1-2*(n+r),0,t.x,t.y,t.z,1],position:{x:t.x,y:t.y,z:t.z}}}return{elements:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],position:{x:0,y:0,z:0}}}function s(e,s,a){switch(e){case"TerrainBlock":return{className:"TerrainBlock",ghostIndex:s,terrFileName:a.terrFileName??"",detailTextureName:a.detailTextureName??"",squareSize:a.squareSize??8,emptySquareRuns:a.emptySquareRuns};case"InteriorInstance":return{className:"InteriorInstance",ghostIndex:s,interiorFile:a.interiorFile??"",transform:r(a.transform),scale:t(a.scale,{x:1,y:1,z:1}),showTerrainInside:a.showTerrainInside??!1,skinBase:a.skinBase??"",alarmState:a.alarmState??!1};case"TSStatic":return{className:"TSStatic",ghostIndex:s,shapeName:a.shapeName??"",transform:r(a.transform),scale:t(a.scale,{x:1,y:1,z:1})};case"Sky":let o,l;return o=Array.isArray(a.fogVolumes)?a.fogVolumes.map(e=>({visibleDistance:e.visibleDistance??0,minHeight:e.minHeight??0,maxHeight:e.maxHeight??0,color:i(e.color)})):[],l=Array.isArray(a.cloudLayers)?a.cloudLayers.map(e=>({texture:e.texture??"",heightPercent:e.heightPercent??0,speed:e.speed??0})):[],{className:"Sky",ghostIndex:s,materialList:a.materialList??"",fogColor:i(a.fogColor),visibleDistance:a.visibleDistance??1e3,fogDistance:a.fogDistance??0,skySolidColor:i(a.skySolidColor),useSkyTextures:a.useSkyTextures??!0,fogVolumes:o,cloudLayers:l,windVelocity:t(a.windVelocity)};case"Sun":return{className:"Sun",ghostIndex:s,direction:t(a.direction,{x:.57735,y:.57735,z:-.57735}),color:n(a.color,{r:.7,g:.7,b:.7,a:1}),ambient:n(a.ambient,{r:.5,g:.5,b:.5,a:1}),textures:Array.isArray(a.textures)?a.textures:void 0};case"MissionArea":return{className:"MissionArea",ghostIndex:s,area:a.area??{x:-512,y:-512,w:1024,h:1024},flightCeiling:a.flightCeiling??2e3,flightCeilingRange:a.flightCeilingRange??50};case"WaterBlock":return{className:"WaterBlock",ghostIndex:s,transform:r(a.transform),scale:t(a.scale,{x:1,y:1,z:1}),surfaceName:a.surfaceName??"",envMapName:a.envMapName??"",surfaceOpacity:a.surfaceOpacity??.75,waveMagnitude:a.waveMagnitude??1,envMapIntensity:a.envMapIntensity??1};default:return null}}e.s([],19402),e.s(["ghostToSceneObject",()=>s],47566)},70847,e=>{"use strict";e.i(19402),e.i(47566),e.i(9672),e.i(63318),e.s([])},51434,e=>{"use strict";var t=e.i(43476),i=e.i(932),n=e.i(71645),r=e.i(15080),s=e.i(90072);e.i(13876);var a=e.i(58647);let o=(0,n.createContext)(void 0);function l(e){let l,m,d,f,h=(0,i.c)(7),{children:p}=e,{camera:y}=(0,r.useThree)();h[0]===Symbol.for("react.memo_cache_sentinel")?(l={audioLoader:null,audioListener:null},h[0]=l):l=h[0];let[g,b]=(0,n.useState)(l);return h[1]!==y?(m=()=>{let e=new s.AudioLoader,t=y.children.find(c);t||(t=new s.AudioListener,y.add(t)),t.setMasterVolume(.8),b({audioLoader:e,audioListener:t});let i=()=>{let e=t?.context;e&&"suspended"===e.state&&e.resume().finally(()=>{document.removeEventListener("click",i),document.removeEventListener("keydown",i)})};document.addEventListener("click",i),document.addEventListener("keydown",i);let n=a.engineStore.subscribe(u,e=>{let i=t?.context;i&&("paused"===e?i.suspend():"suspended"===i.state&&i.resume())});return()=>{document.removeEventListener("click",i),document.removeEventListener("keydown",i),n(),t&&y.remove(t)}},d=[y],h[1]=y,h[2]=m,h[3]=d):(m=h[2],d=h[3]),(0,n.useEffect)(m,d),h[4]!==g||h[5]!==p?(f=(0,t.jsx)(o.Provider,{value:g,children:p}),h[4]=g,h[5]=p,h[6]=f):f=h[6],f}function u(e){return e.playback.status}function c(e){return e instanceof s.AudioListener}function m(){let e=(0,n.useContext)(o);if(void 0===e)throw Error("useAudio must be used within AudioProvider");return e}e.s(["AudioProvider",()=>l,"useAudio",()=>m])},66027,e=>{"use strict";var t=e.i(69230),i=e.i(69637);function n(e,n){return(0,i.useBaseQuery)(e,t.QueryObserver,n)}e.s(["useQuery",()=>n])},63318,e=>{"use strict";var t=e.i(90072);function i(e){return[e.y,e.z,e.x]}function n(e){return[e.y,e.z,e.x]}function r(e){let i=e.elements,n=new t.Matrix4,r=n.elements;r[0]=i[5],r[1]=i[6],r[2]=i[4],r[3]=0,r[4]=i[9],r[5]=i[10],r[6]=i[8],r[7]=0,r[8]=i[1],r[9]=i[2],r[10]=i[0],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1;let s=new t.Quaternion;return s.setFromRotationMatrix(n),s.conjugate(),s}e.s(["matrixFToQuaternion",()=>r,"torqueScaleToThree",()=>n,"torqueToThree",()=>i])},68294,e=>{"use strict";var t=e.i(43476),i=e.i(90072),n=e.i(15080),r=e.i(71645);let s=(0,r.createContext)(null);function a(){let e=(0,r.useContext)(s);if(!e)throw Error("useCameras must be used within CamerasProvider");return e}function o({children:e}){let{camera:a}=(0,n.useThree)(),[o,l]=(0,r.useState)(-1),[u,c]=(0,r.useState)({}),[m,d]=(0,r.useState)(()=>({initialized:!1,position:null,quarternion:null})),f=(0,r.useCallback)(e=>{c(t=>({...t,[e.id]:e}))},[]),h=(0,r.useCallback)(e=>{c(t=>{let{[e.id]:i,...n}=t;return n})},[]),p=Object.keys(u).length,y=(0,r.useCallback)(e=>{if(e>=0&&e{y(p?(o+1)%p:-1)},[p,o,y]);(0,r.useEffect)(()=>{let e=()=>{let e=window.location.hash;if(e.startsWith("#c")){let[t,n]=e.slice(2).split("~"),r=t.split(",").map(e=>parseFloat(e)),s=n.split(",").map(e=>parseFloat(e));d({initialized:!0,position:new i.Vector3(...r),quarternion:new i.Quaternion(...s)})}else d({initialized:!0,position:null,quarternion:null})};return window.addEventListener("hashchange",e),e(),()=>{window.removeEventListener("hashchange",e)}},[]),(0,r.useEffect)(()=>{m.initialized&&m.position&&(a.position.copy(m.position),m.quarternion&&a.quaternion.copy(m.quarternion))},[a,m]),(0,r.useEffect)(()=>{m.initialized&&!m.position&&p>0&&-1===o&&y(0)},[p,y,o,m]);let b=(0,r.useMemo)(()=>({registerCamera:f,unregisterCamera:h,nextCamera:g,setCameraIndex:y,cameraCount:p}),[f,h,g,y,p]);return 0===p&&-1!==o&&l(-1),(0,t.jsx)(s.Provider,{value:b,children:e})}e.s(["CamerasProvider",()=>o,"useCameras",()=>a])},93784,e=>{"use strict";let t=(0,e.i(8155).createStore)()(()=>({time:0,playback:null,root:null,freeFlyCamera:!1,entities:new Map}));function i(){t.setState({time:0,playback:null,freeFlyCamera:!1})}e.s(["resetStreamPlayback",()=>i,"streamPlaybackStore",0,t])},8328,e=>{"use strict";let t=null;function i(e){t=e}function n(e,i){return t?t(e,i):null}function r(e,t){return(i,n)=>{let r=Math.max(0,Math.min(255,i/t+128)),s=Math.max(0,Math.min(255,n/t+128)),a=Math.floor(r),o=Math.floor(s),l=Math.min(a+1,255),u=Math.min(o+1,255),c=r-a,m=s-o;return((e[256*o+a]*(1-c)+e[256*o+l]*c)*(1-m)+(e[256*u+a]*(1-c)+e[256*u+l]*c)*m)/65535*2048}}e.s(["createTerrainHeightSampler",()=>r,"getTerrainHeightAt",()=>n,"setTerrainHeightSampler",()=>i])},84968,e=>{e.v(t=>Promise.all(["static/chunks/6e9a6efec350bf8d.js"].map(t=>e.l(t))).then(()=>t(90208)))},30814,e=>{e.v(t=>Promise.all(["static/chunks/1fe5719635cf5984.js"].map(t=>e.l(t))).then(()=>t(9721)))},44325,e=>{e.v(t=>Promise.all(["static/chunks/aed6ada67562a5fc.js"].map(t=>e.l(t))).then(()=>t(66789)))},62125,e=>{e.v(t=>Promise.all(["static/chunks/e5617268e3c7a140.js"].map(t=>e.l(t))).then(()=>t(64972)))},25147,e=>{e.v(t=>Promise.all(["static/chunks/6f1c1038c8b3b80c.js"].map(t=>e.l(t))).then(()=>t(63724)))},61921,e=>{e.v(t=>Promise.all(["static/chunks/687860f86433eb04.js"].map(t=>e.l(t))).then(()=>t(29055)))},18599,e=>{e.v(t=>Promise.all(["static/chunks/796073b9f885dcbc.js"].map(t=>e.l(t))).then(()=>t(42585)))},96239,e=>{e.v(t=>Promise.all(["static/chunks/1fe5719635cf5984.js","static/chunks/0c29da8d7ee18a67.js"].map(t=>e.l(t))).then(()=>t(21500)))},93884,e=>{e.v(t=>Promise.all(["static/chunks/99bc9f3ae93187f1.css","static/chunks/ca289845e0f08110.js"].map(t=>e.l(t))).then(()=>t(94737)))},96145,e=>{e.v(t=>Promise.all(["static/chunks/2677e6a5750bb60c.js"].map(t=>e.l(t))).then(()=>t(60505)))},38496,e=>{e.v(t=>Promise.all(["static/chunks/e16c267496b8de91.js"].map(t=>e.l(t))).then(()=>t(9962)))},59197,e=>{e.v(t=>Promise.all(["static/chunks/bd03a29a57c8ca45.css","static/chunks/718b5c36c0eed37e.js"].map(t=>e.l(t))).then(()=>t(94247)))}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/2677e6a5750bb60c.js b/docs/_next/static/chunks/2677e6a5750bb60c.js new file mode 100644 index 00000000..89891d1f --- /dev/null +++ b/docs/_next/static/chunks/2677e6a5750bb60c.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,60505,e=>{"use strict";var t=e.i(932),r=e.i(71645),n=e.i(71753),c=e.i(15080),i=e.i(90072),o=e.i(12631),a=e.i(12781),u=e.i(58647),l=e.i(93784),m=e.i(5729),s=e.i(79123),d=e.i(51475),p=e.i(89119);let v=1/d.TICK_RATE,y=new i.Vector3,E=new i.Vector3;function h(){let e,i,h,g,f,S,w,T,b,P,M,_,L,O,R=(0,t.c)(27),{adapter:I,gameStatus:A,sendMove:C}=(0,a.useLiveConnection)(),k=(0,u.useEngineStoreApi)(),{speedMultiplier:K}=(0,s.useControls)(),z=(0,r.useRef)(null),{gl:X}=(0,c.useThree)(),[,Y]=(0,o.useKeyboardControls)(),N=(0,r.useRef)(0),x=(0,r.useRef)(0);R[0]===Symbol.for("react.memo_cache_sentinel")?(e={yaw:0,pitch:0,prevYaw:0,prevPitch:0,initialized:!1,lastSyncedCamera:null},R[0]=e):e=R[0];let H=(0,r.useRef)(e),D=(0,r.useRef)(0);return R[1]!==I||R[2]!==A||R[3]!==k?(i=()=>{I&&("connected"===A||"authenticating"===A)?z.current!==I&&(console.log("[LiveObserver] wiring adapter to engine store"),k.getState().setRecording({source:"live",duration:1/0,missionName:null,gameType:null,streamingPlayback:I}),k.getState().setPlaybackStatus("playing"),z.current=I,H.current.initialized=!1,H.current.lastSyncedCamera=null):!I&&z.current&&(k.getState().setRecording(null),z.current=null,H.current.initialized=!1)},h=[I,A,k],R[1]=I,R[2]=A,R[3]=k,R[4]=i,R[5]=h):(i=R[4],h=R[5]),(0,r.useEffect)(i,h),R[6]!==X.domElement?(g=()=>{let e=!1,t=t=>{document.pointerLockElement?(N.current=N.current+.002*t.movementX,x.current=x.current+.002*t.movementY):e&&(N.current=N.current+t.movementX*m.MOUSE_SENSITIVITY,x.current=x.current+t.movementY*m.MOUSE_SENSITIVITY)},r=t=>{document.pointerLockElement||t.target!==X.domElement||(e=!0)},n=()=>{e=!1};return document.addEventListener("mousemove",t),document.addEventListener("mousedown",r),document.addEventListener("mouseup",n),()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mousedown",r),document.removeEventListener("mouseup",n)}},f=[X.domElement],R[6]=X.domElement,R[7]=g,R[8]=f):(g=R[7],f=R[8]),(0,r.useEffect)(g,f),R[9]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{let e=e=>{document.pointerLockElement&&z.current&&(e.stopImmediatePropagation(),z.current.cycleObserveNext())};return document.addEventListener("click",e,{capture:!0}),()=>{document.removeEventListener("click",e,{capture:!0})}},R[9]=S):S=R[9],R[10]!==X.domElement?(w=[X.domElement],R[10]=X.domElement,R[11]=w):w=R[11],(0,r.useEffect)(S,w),R[12]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{let e=e=>{if("KeyO"!==e.code||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||z.current&&(z.current.toggleObserverMode(),console.log(`[LiveObserver] observer mode: ${z.current.observerMode}`))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},b=[],R[12]=T,R[13]=b):(T=R[12],b=R[13]),(0,r.useEffect)(T,b),R[14]!==A||R[15]!==Y?(P=(e,t)=>{if(!z.current||"connected"!==A)return;let{lookUp:r,lookDown:n,lookLeft:c,lookRight:i}=Y();i&&(N.current=N.current+m.ARROW_LOOK_SPEED*t),c&&(N.current=N.current-m.ARROW_LOOK_SPEED*t),n&&(x.current=x.current+m.ARROW_LOOK_SPEED*t),r&&(x.current=x.current-m.ARROW_LOOK_SPEED*t)},R[14]=A,R[15]=Y,R[16]=P):P=R[16],(0,n.useFrame)(P),R[17]!==A||R[18]!==Y||R[19]!==C||R[20]!==K?(M=()=>{if(!z.current||"connected"!==A)return;let{forward:e,backward:t,left:r,right:n,up:c,down:i}=Y(),o=0,a=0,u=0;e&&(a=1),t&&(a-=1),r&&(o=-1),n&&(o+=1),c&&(u=1),i&&(u-=1);let l=N.current,m=x.current;N.current=0,x.current=0;let s=H.current;s.prevYaw=s.yaw,s.prevPitch=s.pitch,s.yaw=s.yaw+l,s.pitch=Math.max(-p.MAX_PITCH,Math.min(p.MAX_PITCH,s.pitch+m)),D.current=0;let d=Math.min(1,K);C({x:o*d,y:a*d,z:u*d,yaw:l,pitch:m,roll:0,trigger:[!1,!1,!1,!1,!1,!1],freeLook:!1})},R[17]=A,R[18]=Y,R[19]=C,R[20]=K,R[21]=M):M=R[21],(0,d.useTick)(M),R[22]!==A?(_=(e,t)=>{if(!z.current||"connected"!==A)return;let r=H.current,n=z.current.getSnapshot(),c=n?.camera;if(c&&c!==r.lastSyncedCamera&&"number"==typeof c.yaw&&"number"==typeof c.pitch){let e=N.current,t=x.current;r.prevYaw=r.initialized?r.yaw:c.yaw,r.prevPitch=r.initialized?r.pitch:c.pitch,r.yaw=c.yaw+e,r.pitch=Math.max(-p.MAX_PITCH,Math.min(p.MAX_PITCH,c.pitch+t)),r.lastSyncedCamera=c,r.initialized=!0}if(!r.initialized)return;D.current=D.current+t;let i=Math.min(1,D.current/v),o=r.prevYaw+(r.yaw-r.prevYaw)*i+N.current,a=Math.max(-p.MAX_PITCH,Math.min(p.MAX_PITCH,r.prevPitch+(r.pitch-r.prevPitch)*i+x.current)),[u,m,s,d]=(0,p.yawPitchToQuaternion)(o,a);if(c?.mode==="third-person"&&c.orbitTargetId){let t=l.streamPlaybackStore.getState().root,r=t?.children.find(e=>e.name===c.orbitTargetId);if(r){E.copy(r.position);let t=l.streamPlaybackStore.getState().entities.get(c.orbitTargetId);t?.renderType==="Player"&&(E.y=E.y+1);let n=Math.sin(a),i=Math.cos(a),u=Math.sin(o),m=Math.cos(o);if(y.set(-i,-u*n,-m*n),y.lengthSq()>1e-8){y.normalize();let t=Math.max(.1,c.orbitDistance??4);e.camera.position.copy(E).addScaledVector(y,t),e.camera.lookAt(E)}}}else e.camera.quaternion.set(u,m,s,d)},R[22]=A,R[23]=_):_=R[23],(0,n.useFrame)(_),R[24]!==k?(L=()=>()=>{z.current&&(k.getState().setRecording(null),z.current=null)},O=[k],R[24]=k,R[25]=L,R[26]=O):(L=R[25],O=R[26]),(0,r.useEffect)(L,O),null}e.s(["LiveObserver",()=>h])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/29cbf5720c3c6313.js b/docs/_next/static/chunks/29cbf5720c3c6313.js deleted file mode 100644 index 4502a5ad..00000000 --- a/docs/_next/static/chunks/29cbf5720c3c6313.js +++ /dev/null @@ -1,38 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13876,79473,43595,58647,e=>{"use strict";var t=e.i(932),r=e.i(8155);let n=e=>(t,r,n)=>{let i=n.subscribe;return n.subscribe=(e,t,r)=>{let o=e;if(t){let i=(null==r?void 0:r.equalityFn)||Object.is,a=e(n.getState());o=r=>{let n=e(r);if(!i(a,n)){let e=a;t(a=n,e)}},(null==r?void 0:r.fireImmediately)&&t(a,a)}return i(o)},e(t,r,n)};e.s(["subscribeWithSelector",()=>n],79473);var i=e.i(66748);function o(e){let t=new Map;for(let r of e.state.datablocks.values()){if("tsshapeconstructor"!==r._class)continue;let e=r.baseshape;if("string"!=typeof e)continue;let n=e.toLowerCase(),i=n.replace(/\.dts$/i,"")+"_",o=new Map;for(let e=0;e<=127;e++){let t=r[`sequence${e}`];if("string"!=typeof t)continue;let n=t.indexOf(" ");if(-1===n)continue;let a=t.slice(0,n).toLowerCase(),l=t.slice(n+1).trim().toLowerCase();if(!l||!a.startsWith(i)||!a.endsWith(".dsq"))continue;let s=a.slice(i.length,-4);s&&o.set(l,s)}o.size>0&&t.set(n,o)}return t}function a(e,t,r){let n=new Map;for(let r of e){let e=t.clipAction(r);n.set(r.name.toLowerCase(),e)}if(r)for(let[e,t]of r){let r=n.get(t);r&&!n.has(e)&&n.set(e,r)}return n}function l(e){return e.toLowerCase()}function s(e){let t=l(e.trim());return t.startsWith("$")?t.slice(1):t}e.s(["buildSequenceAliasMap",()=>o,"getAliasedActions",()=>a],43595);let c={runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0},playback:{recording:null,status:"stopped",timeMs:0,rate:1,durationMs:0,streamSnapshot:null}},u=(0,r.createStore)()(n(e=>({...c,setRuntime(t){let r=function(e){let t={},r={},n={},i={};for(let r of e.state.objectsById.values())t[r._id]=0,r._name&&(n[l(r._name)]=r._id,r._isDatablock&&(i[l(r._name)]=r._id));for(let t of e.state.globals.keys())r[s(t)]=0;return{objectVersionById:t,globalVersionByName:r,objectIdsByName:n,datablockIdsByName:i}}(t),n=o(t);e(e=>({...e,runtime:{runtime:t,sequenceAliases:n,objectVersionById:r.objectVersionById,globalVersionByName:r.globalVersionByName,objectIdsByName:r.objectIdsByName,datablockIdsByName:r.datablockIdsByName,lastRuntimeTick:0}}))},clearRuntime(){e(e=>({...e,runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0}}))},applyRuntimeBatch(t,r){0!==t.length&&e(e=>{let n={...e.runtime.objectVersionById},i={...e.runtime.globalVersionByName},o={...e.runtime.objectIdsByName},a={...e.runtime.datablockIdsByName},c=e=>{null!=e&&(n[e]=(n[e]??0)+1)};for(let e of t){if("object.created"===e.type){let t=e.object;if(c(e.objectId),t._name){let r=l(t._name);o[r]=e.objectId,t._isDatablock&&(a[r]=e.objectId)}c(t._parent?._id);continue}if("object.deleted"===e.type){let t=e.object;if(delete n[e.objectId],t?._name){let e=l(t._name);delete o[e],t._isDatablock&&delete a[e]}c(t?._parent?._id);continue}if("field.changed"===e.type){c(e.objectId);continue}if("global.changed"===e.type){let t=s(e.name);i[t]=(i[t]??0)+1;continue}}let u=r?.tick??(e.runtime.lastRuntimeTick>0?e.runtime.lastRuntimeTick+1:1);return{...e,runtime:{...e.runtime,objectVersionById:n,globalVersionByName:i,objectIdsByName:o,datablockIdsByName:a,lastRuntimeTick:u}}})},setDemoRecording(t){let r=Math.max(0,(t?.duration??0)*1e3);e(e=>({...e,playback:{recording:t,status:"stopped",timeMs:0,rate:1,durationMs:r,streamSnapshot:null}}))},setPlaybackTime(t){e(e=>{var r,n,i;let o=(r=t,n=0,i=e.playback.durationMs,r<0?0:r>i?i:r);return{...e,playback:{...e.playback,timeMs:o}}})},setPlaybackStatus(t){e(e=>({...e,playback:{...e.playback,status:t}}))},setPlaybackRate(t){var r,n,i;let o=Number.isFinite(t)?(n=.01,i=16,(r=t)<.01?.01:r>16?16:r):1;e(e=>({...e,playback:{...e.playback,rate:o}}))},setPlaybackStreamSnapshot(t){e(e=>({...e,playback:{...e.playback,streamSnapshot:t}}))}}))),d=0;function m(){return d}function f(e,t){d+=e*t*1e3}function y(){return u}function p(e,t){return(0,i.useStoreWithEqualityFn)(u,e,t)}function h(e){let r,n,i,o=(0,t.c)(7),a=p(b);o[0]!==e?(r=t=>null==e?-1:t.runtime.objectVersionById[e]??-1,o[0]=e,o[1]=r):r=o[1];let l=p(r);if(null==e||!a||-1===l)return;o[2]!==e||o[3]!==a.state.objectsById?(n=a.state.objectsById.get(e),o[2]=e,o[3]=a.state.objectsById,o[4]=n):n=o[4];let s=n;return o[5]!==s?(i=s?{...s}:void 0,o[5]=s,o[6]=i):i=o[6],i}function b(e){return e.runtime.runtime}function v(e){let r,n,i,o,a,s=(0,t.c)(11),c=p(g);s[0]!==e?(r=e?l(e):"",s[0]=e,s[1]=r):r=s[1];let u=r;s[2]!==u?(n=e=>u?e.runtime.objectIdsByName[u]:void 0,s[2]=u,s[3]=n):n=s[3];let d=p(n);s[4]!==d?(i=e=>null==d?-1:e.runtime.objectVersionById[d]??-1,s[4]=d,s[5]=i):i=s[5];let m=p(i);if(!c||!u||null==d||-1===m)return;s[6]!==d||s[7]!==c.state.objectsById?(o=c.state.objectsById.get(d),s[6]=d,s[7]=c.state.objectsById,s[8]=o):o=s[8];let f=o;return s[9]!==f?(a=f?{...f}:void 0,s[9]=f,s[10]=a):a=s[10],a}function g(e){return e.runtime.runtime}function x(e){let r,n,i,o,a,s=(0,t.c)(11),c=p(M);s[0]!==e?(r=e?l(e):"",s[0]=e,s[1]=r):r=s[1];let u=r;s[2]!==u?(n=e=>u?e.runtime.datablockIdsByName[u]:void 0,s[2]=u,s[3]=n):n=s[3];let d=p(n);s[4]!==d?(i=e=>null==d?-1:e.runtime.objectVersionById[d]??-1,s[4]=d,s[5]=i):i=s[5];let m=p(i);if(!c||!u||null==d||-1===m)return;s[6]!==d||s[7]!==c.state.objectsById?(o=c.state.objectsById.get(d),s[6]=d,s[7]=c.state.objectsById,s[8]=o):o=s[8];let f=o;return s[9]!==f?(a=f?{...f}:void 0,s[9]=f,s[10]=a):a=s[10],a}function M(e){return e.runtime.runtime}function j(e,r){let n,i,o,a,l=(0,t.c)(13);l[0]!==r?(n=void 0===r?[]:r,l[0]=r,l[1]=n):n=l[1];let s=n,c=p(I);l[2]!==e?(i=t=>null==e?-1:t.runtime.objectVersionById[e]??-1,l[2]=e,l[3]=i):i=l[3];let u=p(i);if(null==e){let e;return l[4]!==s?(e=s.map(w),l[4]=s,l[5]=e):e=l[5],e}if(!c||-1===u){let e;return l[6]!==s?(e=s.map(k),l[6]=s,l[7]=e):e=l[7],e}let d=c.state.objectsById;if(l[8]!==e||l[9]!==c.state.objectsById){a=Symbol.for("react.early_return_sentinel");e:{let t=d.get(e);if(!t?._children){let e;l[12]===Symbol.for("react.memo_cache_sentinel")?(e=[],l[12]=e):e=l[12],a=e;break e}o=t._children.map(B)}l[8]=e,l[9]=c.state.objectsById,l[10]=o,l[11]=a}else o=l[10],a=l[11];return a!==Symbol.for("react.early_return_sentinel")?a:o}function B(e){return e._id}function k(e){return e._id}function w(e){return e._id}function I(e){return e.runtime.runtime}u.subscribe(e=>e.playback.status,e=>{"stopped"===e&&(d=0)}),e.s(["advanceEffectClock",()=>f,"demoEffectNow",()=>m,"engineStore",0,u,"useDatablockByName",()=>x,"useEngineSelector",()=>p,"useEngineStoreApi",()=>y,"useRuntimeChildIds",()=>j,"useRuntimeObjectById",()=>h,"useRuntimeObjectByName",()=>v],58647),e.s([],13876)},67191,e=>{e.v({Label:"FloatingLabel-module__8y09Ka__Label"})},89887,60099,e=>{"use strict";let t,r;var n=e.i(43476),i=e.i(932),o=e.i(71645),a=e.i(90072),l=e.i(71753),s=e.i(31067),c=e.i(88014),u=e.i(15080);let d=new a.Vector3,m=new a.Vector3,f=new a.Vector3,y=new a.Vector2;function p(e,t,r){let n=d.setFromMatrixPosition(e.matrixWorld);n.project(t);let i=r.width/2,o=r.height/2;return[n.x*i+i,-(n.y*o)+o]}let h=e=>1e-10>Math.abs(e)?0:e;function b(e,t,r=""){let n="matrix3d(";for(let r=0;16!==r;r++)n+=h(t[r]*e.elements[r])+(15!==r?",":")");return r+n}let v=(t=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>b(e,t)),g=(r=e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1],(e,t)=>b(e,r(t),"translate(-50%,-50%)")),x=o.forwardRef(({children:e,eps:t=.001,style:r,className:n,prepend:i,center:b,fullscreen:x,portal:M,distanceFactor:j,sprite:B=!1,transform:k=!1,occlude:w,onOcclude:I,castShadow:P,receiveShadow:S,material:R,geometry:_,zIndexRange:T=[0x1000037,0],calculatePosition:A=p,as:E="div",wrapperClass:W,pointerEvents:D="auto",...N},F)=>{let{gl:V,camera:L,scene:C,size:$,raycaster:z,events:O,viewport:q}=(0,u.useThree)(),[H]=o.useState(()=>document.createElement(E)),G=o.useRef(null),U=o.useRef(null),K=o.useRef(0),Z=o.useRef([0,0]),J=o.useRef(null),Q=o.useRef(null),X=(null==M?void 0:M.current)||O.connected||V.domElement.parentNode,Y=o.useRef(null),ee=o.useRef(!1),et=o.useMemo(()=>{var e;return w&&"blending"!==w||Array.isArray(w)&&w.length&&(e=w[0])&&"object"==typeof e&&"current"in e},[w]);o.useLayoutEffect(()=>{let e=V.domElement;w&&"blending"===w?(e.style.zIndex=`${Math.floor(T[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[w]),o.useLayoutEffect(()=>{if(U.current){let e=G.current=c.createRoot(H);if(C.updateMatrixWorld(),k)H.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{let e=A(U.current,L,$);H.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return X&&(i?X.prepend(H):X.appendChild(H)),()=>{X&&X.removeChild(H),e.unmount()}}},[X,k]),o.useLayoutEffect(()=>{W&&(H.className=W)},[W]);let er=o.useMemo(()=>k?{position:"absolute",top:0,left:0,width:$.width,height:$.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:b?"translate3d(-50%,-50%,0)":"none",...x&&{top:-$.height/2,left:-$.width/2,width:$.width,height:$.height},...r},[r,b,x,$,k]),en=o.useMemo(()=>({position:"absolute",pointerEvents:D}),[D]);o.useLayoutEffect(()=>{var t,i;ee.current=!1,k?null==(t=G.current)||t.render(o.createElement("div",{ref:J,style:er},o.createElement("div",{ref:Q,style:en},o.createElement("div",{ref:F,className:n,style:r,children:e})))):null==(i=G.current)||i.render(o.createElement("div",{ref:F,style:er,className:n,children:e}))});let ei=o.useRef(!0);(0,l.useFrame)(e=>{if(U.current){L.updateMatrixWorld(),U.current.updateWorldMatrix(!0,!1);let e=k?Z.current:A(U.current,L,$);if(k||Math.abs(K.current-L.zoom)>t||Math.abs(Z.current[0]-e[0])>t||Math.abs(Z.current[1]-e[1])>t){var r;let t,n,i,o,l=(r=U.current,t=d.setFromMatrixPosition(r.matrixWorld),n=m.setFromMatrixPosition(L.matrixWorld),i=t.sub(n),o=L.getWorldDirection(f),i.angleTo(o)>Math.PI/2),s=!1;et&&(Array.isArray(w)?s=w.map(e=>e.current):"blending"!==w&&(s=[C]));let c=ei.current;s?ei.current=function(e,t,r,n){let i=d.setFromMatrixPosition(e.matrixWorld),o=i.clone();o.project(t),y.set(o.x,o.y),r.setFromCamera(y,t);let a=r.intersectObjects(n,!0);if(a.length){let e=a[0].distance;return i.distanceTo(r.ray.origin)({vertexShader:k?void 0:` - /* - This shader is from the THREE's SpriteMaterial. - We need to turn the backing plane into a Sprite - (make it always face the camera) if "transfrom" - is false. - */ - #include - - void main() { - vec2 center = vec2(0., 1.); - float rotation = 0.0; - - // This is somewhat arbitrary, but it seems to work well - // Need to figure out how to derive this dynamically if it even matters - float size = 0.03; - - vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); - vec2 scale; - scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); - scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); - - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - - gl_Position = projectionMatrix * mvPosition; - } - `,fragmentShader:` - void main() { - gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); - } - `}),[k]);return o.createElement("group",(0,s.default)({},N,{ref:U}),w&&!et&&o.createElement("mesh",{castShadow:P,receiveShadow:S,ref:Y},_||o.createElement("planeGeometry",null),R||o.createElement("shaderMaterial",{side:a.DoubleSide,vertexShader:eo.vertexShader,fragmentShader:eo.fragmentShader})))});e.s(["Html",()=>x],60099);var M=e.i(67191);let j=[0,0,0],B=new a.Vector3,k=(0,o.memo)(function(e){let t,r,a,s=(0,i.c)(11),{children:c,color:u,position:d,opacity:m}=e,f=void 0===u?"white":u,y=void 0===d?j:d,p=void 0===m?"fadeWithDistance":m,h="fadeWithDistance"===p,b=(0,o.useRef)(null),[v,g]=(0,o.useState)(0!==p),k=(0,o.useRef)(null);return s[0]!==h||s[1]!==v||s[2]!==p?(t=e=>{var t,r,n;let i,{camera:o}=e,a=b.current;if(!a)return;a.getWorldPosition(B);let l=(t=B.x,r=B.y,n=B.z,-((t-(i=o.matrixWorld.elements)[12])*i[8])+-((r-i[13])*i[9])+-((n-i[14])*i[10])<0);if(h){let e=l?1/0:o.position.distanceTo(B),t=e<200;if(v!==t&&g(t),k.current&&t){let t=Math.max(0,Math.min(1,1-e/200));k.current.style.opacity=t.toString()}}else{let e=!l&&0!==p;v!==e&&g(e),k.current&&(k.current.style.opacity=p.toString())}},s[0]=h,s[1]=v,s[2]=p,s[3]=t):t=s[3],(0,l.useFrame)(t),s[4]!==c||s[5]!==f||s[6]!==v||s[7]!==y?(r=v?(0,n.jsx)(x,{position:y,center:!0,children:(0,n.jsx)("div",{ref:k,className:M.default.Label,style:{color:f},children:c})}):null,s[4]=c,s[5]=f,s[6]=v,s[7]=y,s[8]=r):r=s[8],s[9]!==r?(a=(0,n.jsx)("group",{ref:b,children:r}),s[9]=r,s[10]=a):a=s[10],a});e.s(["FloatingLabel",0,k],89887)},29055,51434,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(15080),i=e.i(71753),o=e.i(90072),a=e.i(62395),l=e.i(12979),s=e.i(932);e.i(13876);var c=e.i(58647);let u=(0,r.createContext)(void 0);function d(e){let i,a,l,d,y=(0,s.c)(7),{children:p}=e,{camera:h}=(0,n.useThree)();y[0]===Symbol.for("react.memo_cache_sentinel")?(i={audioLoader:null,audioListener:null},y[0]=i):i=y[0];let[b,v]=(0,r.useState)(i);return y[1]!==h?(a=()=>{let e=new o.AudioLoader,t=h.children.find(f);t||(t=new o.AudioListener,h.add(t)),v({audioLoader:e,audioListener:t});let r=c.engineStore.subscribe(m,e=>{let r=t?.context;r&&("paused"===e?r.suspend():"playing"===e&&"suspended"===r.state&&r.resume())});return()=>{r()}},l=[h],y[1]=h,y[2]=a,y[3]=l):(a=y[2],l=y[3]),(0,r.useEffect)(a,l),y[4]!==b||y[5]!==p?(d=(0,t.jsx)(u.Provider,{value:b,children:p}),y[4]=b,y[5]=p,y[6]=d):d=y[6],d}function m(e){return e.playback.status}function f(e){return e instanceof o.AudioListener}function y(){let e=(0,r.useContext)(u);if(void 0===e)throw Error("useAudio must be used within AudioProvider");return e}e.s(["AudioProvider",()=>d,"useAudio",()=>y],51434);var p=e.i(79123),h=e.i(89887);let b=new Map,v=new Map;function g(e,t=1){v.set(e,t)}function x(e){v.delete(e)}function M(e,t){let r=t(e),n=r?.filename;if(!n)return null;let i=n.endsWith(".wav")?n:`${n}.wav`,o=r.description,a=null!=o?t(o):void 0,l=a?.is3D??!0,s=a?.isLooping??!1,c=a?.referenceDistance??20;return{filename:i,is3D:l,isLooping:s,refDist:c,maxDist:a?.maxDistance??100,volume:a?.volume??1}}function j(e,t,r,n,i){let a;try{a=(0,l.audioToUrl)(e.filename)}catch{return}let s=c.engineStore.getState().playback.rate;B(a,r,r=>{try{if(e.is3D&&i){let a=new o.PositionalAudio(t);a.setBuffer(r),a.setDistanceModel("inverse"),a.setRefDistance(e.refDist),a.setMaxDistance(e.maxDist),a.setRolloffFactor(1),a.setVolume(e.volume),a.setPlaybackRate(s),n&&a.position.copy(n),i.add(a),v.set(a,1),a.play(),a.source.onended=()=>{v.delete(a),a.disconnect(),i.remove(a)}}else{let n=new o.Audio(t);n.setBuffer(r),n.setVolume(e.volume),n.setPlaybackRate(s),v.set(n,1),n.play(),n.source.onended=()=>{v.delete(n),n.disconnect()}}}catch{}})}function B(e,t,r){b.has(e)?r(b.get(e)):t.load(e,t=>{b.set(e,t),r(t)},void 0,t=>{console.error("Audio load error",e,t)})}c.engineStore.subscribe(e=>e.playback.rate,e=>{for(let[t,r]of v)try{t.setPlaybackRate(r*e)}catch{}});let k=(0,r.memo)(function({object:e}){let{debugMode:s}=(0,p.useDebug)(),c=(0,a.getProperty)(e,"fileName")??"",u=(0,a.getFloat)(e,"volume")??1,d=(0,a.getFloat)(e,"minDistance")??1,m=(0,a.getFloat)(e,"maxDistance")??1,f=(0,a.getFloat)(e,"minLoopGap")??0,b=(0,a.getFloat)(e,"maxLoopGap")??0,v=(0,a.getInt)(e,"is3D")??0,[g,x,M]=(0,a.getPosition)(e),{scene:j,camera:k}=(0,n.useThree)(),{audioLoader:w,audioListener:I}=y(),{audioEnabled:P}=(0,p.useSettings)(),S=(0,r.useRef)(null),R=(0,r.useRef)(null),_=(0,r.useRef)(null),T=(0,r.useRef)(!1),A=(0,r.useRef)(!1),E=(0,r.useRef)(new o.Vector3(g,x,M)),W=()=>{R.current&&clearTimeout(R.current),_.current&&clearTimeout(_.current)};(0,r.useEffect)(()=>{let e;if(w&&I){if(v){let t=new o.PositionalAudio(I);t.position.copy(E.current),t.setDistanceModel("inverse"),t.setRefDistance(d),t.setMaxDistance(m),t.setRolloffFactor(1),t.setVolume(u),e=t,j.add(e)}else(e=new o.Audio(I)).setVolume(u);return S.current=e,()=>{W();try{e.stop()}catch{}e.disconnect(),v&&j.remove(e),T.current=!1,A.current=!1}}},[w,I,v,d,m,u,j]);let D=e=>{if(f>0||b>0){let t=Math.max(0,f),r=Math.max(t,b),n=t===r?t:Math.random()*(r-t)+t;e.loop=!1;let i=()=>{!1===e.isPlaying?R.current=setTimeout(()=>{try{e.play(),D(e)}catch{}},n):_.current=setTimeout(i,100)};_.current=setTimeout(i,100)}else e.setLoop(!0)},N=e=>{if(T.current)try{e.isPlaying||(e.play(),D(e))}catch{}else B((0,l.audioToUrl)(c),w,t=>{if(!e.buffer){e.setBuffer(t),T.current=!0;try{e.play(),D(e)}catch{}}})};return(0,r.useEffect)(()=>{let e=S.current;e&&!v&&P&&c&&N(e)},[P,v,c,w,I]),(0,i.useFrame)(()=>{let e=S.current;if(!e||!v||!P||!c)return;let t=k.position.distanceTo(E.current),r=A.current,n=t<=m;if(n&&!r)A.current=!0,N(e);else if(!n&&r){A.current=!1,W();try{e.stop()}catch{}}}),(0,r.useEffect)(()=>{let e=S.current;if(e&&!P){W();try{e.stop()}catch{}}},[P]),s?(0,t.jsxs)("mesh",{position:E.current,children:[(0,t.jsx)("sphereGeometry",{args:[d,12,12]}),(0,t.jsx)("meshBasicMaterial",{color:"#00ff00",wireframe:!0,opacity:.05,transparent:!0,toneMapped:!1}),(0,t.jsx)(h.FloatingLabel,{color:"#00ff00",position:[0,d+1,0],children:c})]}):null});e.s(["AudioEmitter",0,k,"audioBufferCache",0,b,"getCachedAudioBuffer",()=>B,"playOneShotSound",()=>j,"resolveAudioProfile",()=>M,"trackDemoSound",()=>g,"untrackDemoSound",()=>x],29055)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/2edeeda5ca6dc680.js b/docs/_next/static/chunks/2edeeda5ca6dc680.js new file mode 100644 index 00000000..37c36bfd --- /dev/null +++ b/docs/_next/static/chunks/2edeeda5ca6dc680.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75056,e=>{"use strict";var t=e.i(40859),r=e.i(71645),n=e.i(8560),i=e.i(90072);e.s(["ACESFilmicToneMapping",()=>i.ACESFilmicToneMapping,"AddEquation",()=>i.AddEquation,"AddOperation",()=>i.AddOperation,"AdditiveAnimationBlendMode",()=>i.AdditiveAnimationBlendMode,"AdditiveBlending",()=>i.AdditiveBlending,"AgXToneMapping",()=>i.AgXToneMapping,"AlphaFormat",()=>i.AlphaFormat,"AlwaysCompare",()=>i.AlwaysCompare,"AlwaysDepth",()=>i.AlwaysDepth,"AlwaysStencilFunc",()=>i.AlwaysStencilFunc,"AmbientLight",()=>i.AmbientLight,"AnimationAction",()=>i.AnimationAction,"AnimationClip",()=>i.AnimationClip,"AnimationLoader",()=>i.AnimationLoader,"AnimationMixer",()=>i.AnimationMixer,"AnimationObjectGroup",()=>i.AnimationObjectGroup,"AnimationUtils",()=>i.AnimationUtils,"ArcCurve",()=>i.ArcCurve,"ArrayCamera",()=>i.ArrayCamera,"ArrowHelper",()=>i.ArrowHelper,"AttachedBindMode",()=>i.AttachedBindMode,"Audio",()=>i.Audio,"AudioAnalyser",()=>i.AudioAnalyser,"AudioContext",()=>i.AudioContext,"AudioListener",()=>i.AudioListener,"AudioLoader",()=>i.AudioLoader,"AxesHelper",()=>i.AxesHelper,"BackSide",()=>i.BackSide,"BasicDepthPacking",()=>i.BasicDepthPacking,"BasicShadowMap",()=>i.BasicShadowMap,"BatchedMesh",()=>i.BatchedMesh,"Bone",()=>i.Bone,"BooleanKeyframeTrack",()=>i.BooleanKeyframeTrack,"Box2",()=>i.Box2,"Box3",()=>i.Box3,"Box3Helper",()=>i.Box3Helper,"BoxGeometry",()=>i.BoxGeometry,"BoxHelper",()=>i.BoxHelper,"BufferAttribute",()=>i.BufferAttribute,"BufferGeometry",()=>i.BufferGeometry,"BufferGeometryLoader",()=>i.BufferGeometryLoader,"ByteType",()=>i.ByteType,"Cache",()=>i.Cache,"Camera",()=>i.Camera,"CameraHelper",()=>i.CameraHelper,"CanvasTexture",()=>i.CanvasTexture,"CapsuleGeometry",()=>i.CapsuleGeometry,"CatmullRomCurve3",()=>i.CatmullRomCurve3,"CineonToneMapping",()=>i.CineonToneMapping,"CircleGeometry",()=>i.CircleGeometry,"ClampToEdgeWrapping",()=>i.ClampToEdgeWrapping,"Clock",()=>i.Clock,"Color",()=>i.Color,"ColorKeyframeTrack",()=>i.ColorKeyframeTrack,"ColorManagement",()=>i.ColorManagement,"CompressedArrayTexture",()=>i.CompressedArrayTexture,"CompressedCubeTexture",()=>i.CompressedCubeTexture,"CompressedTexture",()=>i.CompressedTexture,"CompressedTextureLoader",()=>i.CompressedTextureLoader,"ConeGeometry",()=>i.ConeGeometry,"ConstantAlphaFactor",()=>i.ConstantAlphaFactor,"ConstantColorFactor",()=>i.ConstantColorFactor,"Controls",()=>i.Controls,"CubeCamera",()=>i.CubeCamera,"CubeDepthTexture",()=>i.CubeDepthTexture,"CubeReflectionMapping",()=>i.CubeReflectionMapping,"CubeRefractionMapping",()=>i.CubeRefractionMapping,"CubeTexture",()=>i.CubeTexture,"CubeTextureLoader",()=>i.CubeTextureLoader,"CubeUVReflectionMapping",()=>i.CubeUVReflectionMapping,"CubicBezierCurve",()=>i.CubicBezierCurve,"CubicBezierCurve3",()=>i.CubicBezierCurve3,"CubicInterpolant",()=>i.CubicInterpolant,"CullFaceBack",()=>i.CullFaceBack,"CullFaceFront",()=>i.CullFaceFront,"CullFaceFrontBack",()=>i.CullFaceFrontBack,"CullFaceNone",()=>i.CullFaceNone,"Curve",()=>i.Curve,"CurvePath",()=>i.CurvePath,"CustomBlending",()=>i.CustomBlending,"CustomToneMapping",()=>i.CustomToneMapping,"CylinderGeometry",()=>i.CylinderGeometry,"Cylindrical",()=>i.Cylindrical,"Data3DTexture",()=>i.Data3DTexture,"DataArrayTexture",()=>i.DataArrayTexture,"DataTexture",()=>i.DataTexture,"DataTextureLoader",()=>i.DataTextureLoader,"DataUtils",()=>i.DataUtils,"DecrementStencilOp",()=>i.DecrementStencilOp,"DecrementWrapStencilOp",()=>i.DecrementWrapStencilOp,"DefaultLoadingManager",()=>i.DefaultLoadingManager,"DepthFormat",()=>i.DepthFormat,"DepthStencilFormat",()=>i.DepthStencilFormat,"DepthTexture",()=>i.DepthTexture,"DetachedBindMode",()=>i.DetachedBindMode,"DirectionalLight",()=>i.DirectionalLight,"DirectionalLightHelper",()=>i.DirectionalLightHelper,"DiscreteInterpolant",()=>i.DiscreteInterpolant,"DodecahedronGeometry",()=>i.DodecahedronGeometry,"DoubleSide",()=>i.DoubleSide,"DstAlphaFactor",()=>i.DstAlphaFactor,"DstColorFactor",()=>i.DstColorFactor,"DynamicCopyUsage",()=>i.DynamicCopyUsage,"DynamicDrawUsage",()=>i.DynamicDrawUsage,"DynamicReadUsage",()=>i.DynamicReadUsage,"EdgesGeometry",()=>i.EdgesGeometry,"EllipseCurve",()=>i.EllipseCurve,"EqualCompare",()=>i.EqualCompare,"EqualDepth",()=>i.EqualDepth,"EqualStencilFunc",()=>i.EqualStencilFunc,"EquirectangularReflectionMapping",()=>i.EquirectangularReflectionMapping,"EquirectangularRefractionMapping",()=>i.EquirectangularRefractionMapping,"Euler",()=>i.Euler,"EventDispatcher",()=>i.EventDispatcher,"ExternalTexture",()=>i.ExternalTexture,"ExtrudeGeometry",()=>i.ExtrudeGeometry,"FileLoader",()=>i.FileLoader,"Float16BufferAttribute",()=>i.Float16BufferAttribute,"Float32BufferAttribute",()=>i.Float32BufferAttribute,"FloatType",()=>i.FloatType,"Fog",()=>i.Fog,"FogExp2",()=>i.FogExp2,"FramebufferTexture",()=>i.FramebufferTexture,"FrontSide",()=>i.FrontSide,"Frustum",()=>i.Frustum,"FrustumArray",()=>i.FrustumArray,"GLBufferAttribute",()=>i.GLBufferAttribute,"GLSL1",()=>i.GLSL1,"GLSL3",()=>i.GLSL3,"GreaterCompare",()=>i.GreaterCompare,"GreaterDepth",()=>i.GreaterDepth,"GreaterEqualCompare",()=>i.GreaterEqualCompare,"GreaterEqualDepth",()=>i.GreaterEqualDepth,"GreaterEqualStencilFunc",()=>i.GreaterEqualStencilFunc,"GreaterStencilFunc",()=>i.GreaterStencilFunc,"GridHelper",()=>i.GridHelper,"Group",()=>i.Group,"HalfFloatType",()=>i.HalfFloatType,"HemisphereLight",()=>i.HemisphereLight,"HemisphereLightHelper",()=>i.HemisphereLightHelper,"IcosahedronGeometry",()=>i.IcosahedronGeometry,"ImageBitmapLoader",()=>i.ImageBitmapLoader,"ImageLoader",()=>i.ImageLoader,"ImageUtils",()=>i.ImageUtils,"IncrementStencilOp",()=>i.IncrementStencilOp,"IncrementWrapStencilOp",()=>i.IncrementWrapStencilOp,"InstancedBufferAttribute",()=>i.InstancedBufferAttribute,"InstancedBufferGeometry",()=>i.InstancedBufferGeometry,"InstancedInterleavedBuffer",()=>i.InstancedInterleavedBuffer,"InstancedMesh",()=>i.InstancedMesh,"Int16BufferAttribute",()=>i.Int16BufferAttribute,"Int32BufferAttribute",()=>i.Int32BufferAttribute,"Int8BufferAttribute",()=>i.Int8BufferAttribute,"IntType",()=>i.IntType,"InterleavedBuffer",()=>i.InterleavedBuffer,"InterleavedBufferAttribute",()=>i.InterleavedBufferAttribute,"Interpolant",()=>i.Interpolant,"InterpolateDiscrete",()=>i.InterpolateDiscrete,"InterpolateLinear",()=>i.InterpolateLinear,"InterpolateSmooth",()=>i.InterpolateSmooth,"InterpolationSamplingMode",()=>i.InterpolationSamplingMode,"InterpolationSamplingType",()=>i.InterpolationSamplingType,"InvertStencilOp",()=>i.InvertStencilOp,"KeepStencilOp",()=>i.KeepStencilOp,"KeyframeTrack",()=>i.KeyframeTrack,"LOD",()=>i.LOD,"LatheGeometry",()=>i.LatheGeometry,"Layers",()=>i.Layers,"LessCompare",()=>i.LessCompare,"LessDepth",()=>i.LessDepth,"LessEqualCompare",()=>i.LessEqualCompare,"LessEqualDepth",()=>i.LessEqualDepth,"LessEqualStencilFunc",()=>i.LessEqualStencilFunc,"LessStencilFunc",()=>i.LessStencilFunc,"Light",()=>i.Light,"LightProbe",()=>i.LightProbe,"Line",()=>i.Line,"Line3",()=>i.Line3,"LineBasicMaterial",()=>i.LineBasicMaterial,"LineCurve",()=>i.LineCurve,"LineCurve3",()=>i.LineCurve3,"LineDashedMaterial",()=>i.LineDashedMaterial,"LineLoop",()=>i.LineLoop,"LineSegments",()=>i.LineSegments,"LinearFilter",()=>i.LinearFilter,"LinearInterpolant",()=>i.LinearInterpolant,"LinearMipMapLinearFilter",()=>i.LinearMipMapLinearFilter,"LinearMipMapNearestFilter",()=>i.LinearMipMapNearestFilter,"LinearMipmapLinearFilter",()=>i.LinearMipmapLinearFilter,"LinearMipmapNearestFilter",()=>i.LinearMipmapNearestFilter,"LinearSRGBColorSpace",()=>i.LinearSRGBColorSpace,"LinearToneMapping",()=>i.LinearToneMapping,"LinearTransfer",()=>i.LinearTransfer,"Loader",()=>i.Loader,"LoaderUtils",()=>i.LoaderUtils,"LoadingManager",()=>i.LoadingManager,"LoopOnce",()=>i.LoopOnce,"LoopPingPong",()=>i.LoopPingPong,"LoopRepeat",()=>i.LoopRepeat,"MOUSE",()=>i.MOUSE,"Material",()=>i.Material,"MaterialLoader",()=>i.MaterialLoader,"MathUtils",()=>i.MathUtils,"Matrix2",()=>i.Matrix2,"Matrix3",()=>i.Matrix3,"Matrix4",()=>i.Matrix4,"MaxEquation",()=>i.MaxEquation,"Mesh",()=>i.Mesh,"MeshBasicMaterial",()=>i.MeshBasicMaterial,"MeshDepthMaterial",()=>i.MeshDepthMaterial,"MeshDistanceMaterial",()=>i.MeshDistanceMaterial,"MeshLambertMaterial",()=>i.MeshLambertMaterial,"MeshMatcapMaterial",()=>i.MeshMatcapMaterial,"MeshNormalMaterial",()=>i.MeshNormalMaterial,"MeshPhongMaterial",()=>i.MeshPhongMaterial,"MeshPhysicalMaterial",()=>i.MeshPhysicalMaterial,"MeshStandardMaterial",()=>i.MeshStandardMaterial,"MeshToonMaterial",()=>i.MeshToonMaterial,"MinEquation",()=>i.MinEquation,"MirroredRepeatWrapping",()=>i.MirroredRepeatWrapping,"MixOperation",()=>i.MixOperation,"MultiplyBlending",()=>i.MultiplyBlending,"MultiplyOperation",()=>i.MultiplyOperation,"NearestFilter",()=>i.NearestFilter,"NearestMipMapLinearFilter",()=>i.NearestMipMapLinearFilter,"NearestMipMapNearestFilter",()=>i.NearestMipMapNearestFilter,"NearestMipmapLinearFilter",()=>i.NearestMipmapLinearFilter,"NearestMipmapNearestFilter",()=>i.NearestMipmapNearestFilter,"NeutralToneMapping",()=>i.NeutralToneMapping,"NeverCompare",()=>i.NeverCompare,"NeverDepth",()=>i.NeverDepth,"NeverStencilFunc",()=>i.NeverStencilFunc,"NoBlending",()=>i.NoBlending,"NoColorSpace",()=>i.NoColorSpace,"NoNormalPacking",()=>i.NoNormalPacking,"NoToneMapping",()=>i.NoToneMapping,"NormalAnimationBlendMode",()=>i.NormalAnimationBlendMode,"NormalBlending",()=>i.NormalBlending,"NormalGAPacking",()=>i.NormalGAPacking,"NormalRGPacking",()=>i.NormalRGPacking,"NotEqualCompare",()=>i.NotEqualCompare,"NotEqualDepth",()=>i.NotEqualDepth,"NotEqualStencilFunc",()=>i.NotEqualStencilFunc,"NumberKeyframeTrack",()=>i.NumberKeyframeTrack,"Object3D",()=>i.Object3D,"ObjectLoader",()=>i.ObjectLoader,"ObjectSpaceNormalMap",()=>i.ObjectSpaceNormalMap,"OctahedronGeometry",()=>i.OctahedronGeometry,"OneFactor",()=>i.OneFactor,"OneMinusConstantAlphaFactor",()=>i.OneMinusConstantAlphaFactor,"OneMinusConstantColorFactor",()=>i.OneMinusConstantColorFactor,"OneMinusDstAlphaFactor",()=>i.OneMinusDstAlphaFactor,"OneMinusDstColorFactor",()=>i.OneMinusDstColorFactor,"OneMinusSrcAlphaFactor",()=>i.OneMinusSrcAlphaFactor,"OneMinusSrcColorFactor",()=>i.OneMinusSrcColorFactor,"OrthographicCamera",()=>i.OrthographicCamera,"PCFShadowMap",()=>i.PCFShadowMap,"PCFSoftShadowMap",()=>i.PCFSoftShadowMap,"PMREMGenerator",()=>n.PMREMGenerator,"Path",()=>i.Path,"PerspectiveCamera",()=>i.PerspectiveCamera,"Plane",()=>i.Plane,"PlaneGeometry",()=>i.PlaneGeometry,"PlaneHelper",()=>i.PlaneHelper,"PointLight",()=>i.PointLight,"PointLightHelper",()=>i.PointLightHelper,"Points",()=>i.Points,"PointsMaterial",()=>i.PointsMaterial,"PolarGridHelper",()=>i.PolarGridHelper,"PolyhedronGeometry",()=>i.PolyhedronGeometry,"PositionalAudio",()=>i.PositionalAudio,"PropertyBinding",()=>i.PropertyBinding,"PropertyMixer",()=>i.PropertyMixer,"QuadraticBezierCurve",()=>i.QuadraticBezierCurve,"QuadraticBezierCurve3",()=>i.QuadraticBezierCurve3,"Quaternion",()=>i.Quaternion,"QuaternionKeyframeTrack",()=>i.QuaternionKeyframeTrack,"QuaternionLinearInterpolant",()=>i.QuaternionLinearInterpolant,"R11_EAC_Format",()=>i.R11_EAC_Format,"RED_GREEN_RGTC2_Format",()=>i.RED_GREEN_RGTC2_Format,"RED_RGTC1_Format",()=>i.RED_RGTC1_Format,"REVISION",()=>i.REVISION,"RG11_EAC_Format",()=>i.RG11_EAC_Format,"RGBADepthPacking",()=>i.RGBADepthPacking,"RGBAFormat",()=>i.RGBAFormat,"RGBAIntegerFormat",()=>i.RGBAIntegerFormat,"RGBA_ASTC_10x10_Format",()=>i.RGBA_ASTC_10x10_Format,"RGBA_ASTC_10x5_Format",()=>i.RGBA_ASTC_10x5_Format,"RGBA_ASTC_10x6_Format",()=>i.RGBA_ASTC_10x6_Format,"RGBA_ASTC_10x8_Format",()=>i.RGBA_ASTC_10x8_Format,"RGBA_ASTC_12x10_Format",()=>i.RGBA_ASTC_12x10_Format,"RGBA_ASTC_12x12_Format",()=>i.RGBA_ASTC_12x12_Format,"RGBA_ASTC_4x4_Format",()=>i.RGBA_ASTC_4x4_Format,"RGBA_ASTC_5x4_Format",()=>i.RGBA_ASTC_5x4_Format,"RGBA_ASTC_5x5_Format",()=>i.RGBA_ASTC_5x5_Format,"RGBA_ASTC_6x5_Format",()=>i.RGBA_ASTC_6x5_Format,"RGBA_ASTC_6x6_Format",()=>i.RGBA_ASTC_6x6_Format,"RGBA_ASTC_8x5_Format",()=>i.RGBA_ASTC_8x5_Format,"RGBA_ASTC_8x6_Format",()=>i.RGBA_ASTC_8x6_Format,"RGBA_ASTC_8x8_Format",()=>i.RGBA_ASTC_8x8_Format,"RGBA_BPTC_Format",()=>i.RGBA_BPTC_Format,"RGBA_ETC2_EAC_Format",()=>i.RGBA_ETC2_EAC_Format,"RGBA_PVRTC_2BPPV1_Format",()=>i.RGBA_PVRTC_2BPPV1_Format,"RGBA_PVRTC_4BPPV1_Format",()=>i.RGBA_PVRTC_4BPPV1_Format,"RGBA_S3TC_DXT1_Format",()=>i.RGBA_S3TC_DXT1_Format,"RGBA_S3TC_DXT3_Format",()=>i.RGBA_S3TC_DXT3_Format,"RGBA_S3TC_DXT5_Format",()=>i.RGBA_S3TC_DXT5_Format,"RGBDepthPacking",()=>i.RGBDepthPacking,"RGBFormat",()=>i.RGBFormat,"RGBIntegerFormat",()=>i.RGBIntegerFormat,"RGB_BPTC_SIGNED_Format",()=>i.RGB_BPTC_SIGNED_Format,"RGB_BPTC_UNSIGNED_Format",()=>i.RGB_BPTC_UNSIGNED_Format,"RGB_ETC1_Format",()=>i.RGB_ETC1_Format,"RGB_ETC2_Format",()=>i.RGB_ETC2_Format,"RGB_PVRTC_2BPPV1_Format",()=>i.RGB_PVRTC_2BPPV1_Format,"RGB_PVRTC_4BPPV1_Format",()=>i.RGB_PVRTC_4BPPV1_Format,"RGB_S3TC_DXT1_Format",()=>i.RGB_S3TC_DXT1_Format,"RGDepthPacking",()=>i.RGDepthPacking,"RGFormat",()=>i.RGFormat,"RGIntegerFormat",()=>i.RGIntegerFormat,"RawShaderMaterial",()=>i.RawShaderMaterial,"Ray",()=>i.Ray,"Raycaster",()=>i.Raycaster,"RectAreaLight",()=>i.RectAreaLight,"RedFormat",()=>i.RedFormat,"RedIntegerFormat",()=>i.RedIntegerFormat,"ReinhardToneMapping",()=>i.ReinhardToneMapping,"RenderTarget",()=>i.RenderTarget,"RenderTarget3D",()=>i.RenderTarget3D,"RepeatWrapping",()=>i.RepeatWrapping,"ReplaceStencilOp",()=>i.ReplaceStencilOp,"ReverseSubtractEquation",()=>i.ReverseSubtractEquation,"RingGeometry",()=>i.RingGeometry,"SIGNED_R11_EAC_Format",()=>i.SIGNED_R11_EAC_Format,"SIGNED_RED_GREEN_RGTC2_Format",()=>i.SIGNED_RED_GREEN_RGTC2_Format,"SIGNED_RED_RGTC1_Format",()=>i.SIGNED_RED_RGTC1_Format,"SIGNED_RG11_EAC_Format",()=>i.SIGNED_RG11_EAC_Format,"SRGBColorSpace",()=>i.SRGBColorSpace,"SRGBTransfer",()=>i.SRGBTransfer,"Scene",()=>i.Scene,"ShaderChunk",()=>n.ShaderChunk,"ShaderLib",()=>n.ShaderLib,"ShaderMaterial",()=>i.ShaderMaterial,"ShadowMaterial",()=>i.ShadowMaterial,"Shape",()=>i.Shape,"ShapeGeometry",()=>i.ShapeGeometry,"ShapePath",()=>i.ShapePath,"ShapeUtils",()=>i.ShapeUtils,"ShortType",()=>i.ShortType,"Skeleton",()=>i.Skeleton,"SkeletonHelper",()=>i.SkeletonHelper,"SkinnedMesh",()=>i.SkinnedMesh,"Source",()=>i.Source,"Sphere",()=>i.Sphere,"SphereGeometry",()=>i.SphereGeometry,"Spherical",()=>i.Spherical,"SphericalHarmonics3",()=>i.SphericalHarmonics3,"SplineCurve",()=>i.SplineCurve,"SpotLight",()=>i.SpotLight,"SpotLightHelper",()=>i.SpotLightHelper,"Sprite",()=>i.Sprite,"SpriteMaterial",()=>i.SpriteMaterial,"SrcAlphaFactor",()=>i.SrcAlphaFactor,"SrcAlphaSaturateFactor",()=>i.SrcAlphaSaturateFactor,"SrcColorFactor",()=>i.SrcColorFactor,"StaticCopyUsage",()=>i.StaticCopyUsage,"StaticDrawUsage",()=>i.StaticDrawUsage,"StaticReadUsage",()=>i.StaticReadUsage,"StereoCamera",()=>i.StereoCamera,"StreamCopyUsage",()=>i.StreamCopyUsage,"StreamDrawUsage",()=>i.StreamDrawUsage,"StreamReadUsage",()=>i.StreamReadUsage,"StringKeyframeTrack",()=>i.StringKeyframeTrack,"SubtractEquation",()=>i.SubtractEquation,"SubtractiveBlending",()=>i.SubtractiveBlending,"TOUCH",()=>i.TOUCH,"TangentSpaceNormalMap",()=>i.TangentSpaceNormalMap,"TetrahedronGeometry",()=>i.TetrahedronGeometry,"Texture",()=>i.Texture,"TextureLoader",()=>i.TextureLoader,"TextureUtils",()=>i.TextureUtils,"Timer",()=>i.Timer,"TimestampQuery",()=>i.TimestampQuery,"TorusGeometry",()=>i.TorusGeometry,"TorusKnotGeometry",()=>i.TorusKnotGeometry,"Triangle",()=>i.Triangle,"TriangleFanDrawMode",()=>i.TriangleFanDrawMode,"TriangleStripDrawMode",()=>i.TriangleStripDrawMode,"TrianglesDrawMode",()=>i.TrianglesDrawMode,"TubeGeometry",()=>i.TubeGeometry,"UVMapping",()=>i.UVMapping,"Uint16BufferAttribute",()=>i.Uint16BufferAttribute,"Uint32BufferAttribute",()=>i.Uint32BufferAttribute,"Uint8BufferAttribute",()=>i.Uint8BufferAttribute,"Uint8ClampedBufferAttribute",()=>i.Uint8ClampedBufferAttribute,"Uniform",()=>i.Uniform,"UniformsGroup",()=>i.UniformsGroup,"UniformsLib",()=>n.UniformsLib,"UniformsUtils",()=>i.UniformsUtils,"UnsignedByteType",()=>i.UnsignedByteType,"UnsignedInt101111Type",()=>i.UnsignedInt101111Type,"UnsignedInt248Type",()=>i.UnsignedInt248Type,"UnsignedInt5999Type",()=>i.UnsignedInt5999Type,"UnsignedIntType",()=>i.UnsignedIntType,"UnsignedShort4444Type",()=>i.UnsignedShort4444Type,"UnsignedShort5551Type",()=>i.UnsignedShort5551Type,"UnsignedShortType",()=>i.UnsignedShortType,"VSMShadowMap",()=>i.VSMShadowMap,"Vector2",()=>i.Vector2,"Vector3",()=>i.Vector3,"Vector4",()=>i.Vector4,"VectorKeyframeTrack",()=>i.VectorKeyframeTrack,"VideoFrameTexture",()=>i.VideoFrameTexture,"VideoTexture",()=>i.VideoTexture,"WebGL3DRenderTarget",()=>i.WebGL3DRenderTarget,"WebGLArrayRenderTarget",()=>i.WebGLArrayRenderTarget,"WebGLCoordinateSystem",()=>i.WebGLCoordinateSystem,"WebGLCubeRenderTarget",()=>i.WebGLCubeRenderTarget,"WebGLRenderTarget",()=>i.WebGLRenderTarget,"WebGLRenderer",()=>n.WebGLRenderer,"WebGLUtils",()=>n.WebGLUtils,"WebGPUCoordinateSystem",()=>i.WebGPUCoordinateSystem,"WebXRController",()=>i.WebXRController,"WireframeGeometry",()=>i.WireframeGeometry,"WrapAroundEnding",()=>i.WrapAroundEnding,"ZeroCurvatureEnding",()=>i.ZeroCurvatureEnding,"ZeroFactor",()=>i.ZeroFactor,"ZeroSlopeEnding",()=>i.ZeroSlopeEnding,"ZeroStencilOp",()=>i.ZeroStencilOp,"createCanvasElement",()=>i.createCanvasElement,"error",()=>i.error,"getConsoleFunction",()=>i.getConsoleFunction,"log",()=>i.log,"setConsoleFunction",()=>i.setConsoleFunction,"warn",()=>i.warn,"warnOnce",()=>i.warnOnce],32009);var o=e.i(32009);function a(e,t){let r;return(...n)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...n),t)}}let l=["x","y","top","bottom","left","right","width","height"];var u=e.i(46791),s=e.i(43476);function c({ref:e,children:n,fallback:i,resize:u,style:c,gl:f,events:d=t.f,eventSource:p,eventPrefix:m,shadows:h,linear:v,flat:g,legacy:y,orthographic:b,frameloop:S,dpr:C,performance:x,raycaster:E,camera:A,scene:w,onPointerMissed:_,onCreated:T,...M}){r.useMemo(()=>(0,t.e)(o),[]);let R=(0,t.u)(),[O,I]=function({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){var o,u,s;let c=n||("u"(v.current=!0,()=>void(v.current=!1)));let[g,y,b]=(0,r.useMemo)(()=>{let e=()=>{let e,t;if(!p.current.element)return;let{left:r,top:n,width:o,height:a,bottom:u,right:s,x:c,y:f}=p.current.element.getBoundingClientRect(),m={left:r,top:n,width:o,height:a,bottom:u,right:s,x:c,y:f};p.current.element instanceof HTMLElement&&i&&(m.height=p.current.element.offsetHeight,m.width=p.current.element.offsetWidth),Object.freeze(m),v.current&&(e=p.current.lastBounds,t=m,!l.every(r=>e[r]===t[r]))&&d(p.current.lastBounds=m)};return[e,h?a(e,h):e,m?a(e,m):e]},[d,i,m,h]);function S(){p.current.scrollContainers&&(p.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",b,!0)),p.current.scrollContainers=null),p.current.resizeObserver&&(p.current.resizeObserver.disconnect(),p.current.resizeObserver=null),p.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",p.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",p.current.orientationHandler))}function C(){p.current.element&&(p.current.resizeObserver=new c(b),p.current.resizeObserver.observe(p.current.element),t&&p.current.scrollContainers&&p.current.scrollContainers.forEach(e=>e.addEventListener("scroll",b,{capture:!0,passive:!0})),p.current.orientationHandler=()=>{b()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",p.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",p.current.orientationHandler))}return o=b,u=!!t,(0,r.useEffect)(()=>{if(u)return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)},[o,u]),s=y,(0,r.useEffect)(()=>(window.addEventListener("resize",s),()=>void window.removeEventListener("resize",s)),[s]),(0,r.useEffect)(()=>{S(),C()},[t,b,y]),(0,r.useEffect)(()=>S,[]),[e=>{e&&e!==p.current.element&&(S(),p.current.element=e,p.current.scrollContainers=function e(t){let r=[];if(!t||t===document.body)return r;let{overflow:n,overflowX:i,overflowY:o}=window.getComputedStyle(t);return[n,i,o].some(e=>"auto"===e||"scroll"===e)&&r.push(t),[...r,...e(t.parentElement)]}(e),C())},f,g]}({scroll:!0,debounce:{scroll:50,resize:0},...u}),F=r.useRef(null),L=r.useRef(null);r.useImperativeHandle(e,()=>F.current);let P=(0,t.a)(_),[D,B]=r.useState(!1),[G,k]=r.useState(!1);if(D)throw D;if(G)throw G;let j=r.useRef(null);(0,t.b)(()=>{let e=F.current;I.width>0&&I.height>0&&e&&(j.current||(j.current=(0,t.c)(e)),async function(){await j.current.configure({gl:f,scene:w,events:d,shadows:h,linear:v,flat:g,legacy:y,orthographic:b,frameloop:S,dpr:C,performance:x,raycaster:E,camera:A,size:I,onPointerMissed:(...e)=>null==P.current?void 0:P.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(p?(0,t.i)(p)?p.current:p:L.current),m&&e.setEvents({compute:(e,t)=>{let r=e[m+"X"],n=e[m+"Y"];t.pointer.set(r/t.size.width*2-1,-(2*(n/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==T||T(e)}}),j.current.render((0,s.jsx)(R,{children:(0,s.jsx)(t.E,{set:k,children:(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)(t.B,{set:B}),children:null!=n?n:null})})}))}())}),r.useEffect(()=>{let e=F.current;if(e)return()=>(0,t.d)(e)},[]);let N=p?"none":"auto";return(0,s.jsx)("div",{ref:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:N,...c},...M,children:(0,s.jsx)("div",{ref:O,style:{width:"100%",height:"100%"},children:(0,s.jsx)("canvas",{ref:F,style:{display:"block"},children:i})})})}function f(e){return(0,s.jsx)(u.FiberProvider,{children:(0,s.jsx)(c,{...e})})}e.i(89499),e.s(["Canvas",()=>f],75056)},17751,e=>{"use strict";var t=e.i(19273),r=e.i(86491),n=e.i(40143),i=e.i(15823),o=class extends i.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,n,i){let o=n.queryKey,a=n.queryHash??(0,t.hashQueryKeyByOptions)(o,n),l=this.get(a);return l||(l=new r.Query({client:e,queryKey:o,queryHash:a,options:e.defaultQueryOptions(n),state:i,defaultOptions:e.getQueryDefaults(o)}),this.add(l)),l}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchQuery)(r,e))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(r=>(0,t.matchQuery)(e,r)):r}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},a=e.i(88587),l=e.i(36553),u=class extends a.Removable{#t;#r;#n;#i;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#r=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#r.includes(e)||(this.#r.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#r=this.#r.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#r.length||("pending"===this.state.status?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#o({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=(0,l.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#o({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#o({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let n="pending"===this.state.status,i=!this.#i.canStart();try{if(n)t();else{this.#o({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#o({type:"pending",context:t,variables:e,isPaused:i})}let o=await this.#i.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,r),await this.options.onSuccess?.(o,e,this.state.context,r),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(o,null,e,this.state.context,r),this.#o({type:"success",data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#o({type:"error",error:t}),t}finally{this.#n.runNext(this)}}#o(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),n.notifyManager.batch(()=>{this.#r.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}},s=i,c=class extends s.Subscribable{constructor(e={}){super(),this.config=e,this.#a=new Set,this.#l=new Map,this.#u=0}#a;#l;#u;build(e,t,r){let n=new u({client:e,mutationCache:this,mutationId:++this.#u,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#a.add(e);let t=f(e);if("string"==typeof t){let r=this.#l.get(t);r?r.push(e):this.#l.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#a.delete(e)){let t=f(e);if("string"==typeof t){let r=this.#l.get(t);if(r)if(r.length>1){let t=r.indexOf(e);-1!==t&&r.splice(t,1)}else r[0]===e&&this.#l.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=f(e);if("string"!=typeof t)return!0;{let r=this.#l.get(t),n=r?.find(e=>"pending"===e.state.status);return!n||n===e}}runNext(e){let t=f(e);if("string"!=typeof t)return Promise.resolve();{let r=this.#l.get(t)?.find(t=>t!==e&&t.state.isPaused);return r?.continue()??Promise.resolve()}}clear(){n.notifyManager.batch(()=>{this.#a.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#a.clear(),this.#l.clear()})}getAll(){return Array.from(this.#a)}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchMutation)(r,e))}findAll(e={}){return this.getAll().filter(r=>(0,t.matchMutation)(e,r))}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return n.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(t.noop))))}};function f(e){return e.options.scope?.id}var d=e.i(75555),p=e.i(14448);function m(e){return{onFetch:(r,n)=>{let i=r.options,o=r.fetchOptions?.meta?.fetchMore?.direction,a=r.state.data?.pages||[],l=r.state.data?.pageParams||[],u={pages:[],pageParams:[]},s=0,c=async()=>{let n=!1,c=(0,t.ensureQueryFn)(r.options,r.fetchOptions),f=async(e,i,o)=>{let a;if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);let l=(a={client:r.client,queryKey:r.queryKey,pageParam:i,direction:o?"backward":"forward",meta:r.options.meta},(0,t.addConsumeAwareSignal)(a,()=>r.signal,()=>n=!0),a),u=await c(l),{maxPages:s}=r.options,f=o?t.addToStart:t.addToEnd;return{pages:f(e.pages,u,s),pageParams:f(e.pageParams,i,s)}};if(o&&a.length){let e="backward"===o,t={pages:a,pageParams:l},r=(e?function(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}:h)(i,t);u=await f(t,r,e)}else{let t=e??a.length;do{let e=0===s?l[0]??i.initialPageParam:h(i,u);if(s>0&&null==e)break;u=await f(u,e),s++}while(sr.options.persister?.(c,{client:r.client,queryKey:r.queryKey,meta:r.options.meta,signal:r.signal},n):r.fetchFn=c}}}function h(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}var v=class{#s;#n;#c;#f;#d;#p;#m;#h;constructor(e={}){this.#s=e.queryCache||new o,this.#n=e.mutationCache||new c,this.#c=e.defaultOptions||{},this.#f=new Map,this.#d=new Map,this.#p=0}mount(){this.#p++,1===this.#p&&(this.#m=d.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#s.onFocus())}),this.#h=p.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#s.onOnline())}))}unmount(){this.#p--,0===this.#p&&(this.#m?.(),this.#m=void 0,this.#h?.(),this.#h=void 0)}isFetching(e){return this.#s.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#n.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#s.get(t.queryHash)?.state.data}ensureQueryData(e){let r=this.defaultQueryOptions(e),n=this.#s.build(this,r),i=n.state.data;return void 0===i?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(i))}getQueriesData(e){return this.#s.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,r,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#s.get(i.queryHash),a=o?.state.data,l=(0,t.functionalUpdate)(r,a);if(void 0!==l)return this.#s.build(this,i).setData(l,{...n,manual:!0})}setQueriesData(e,t,r){return n.notifyManager.batch(()=>this.#s.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#s.get(t.queryHash)?.state}removeQueries(e){let t=this.#s;n.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let r=this.#s;return n.notifyManager.batch(()=>(r.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,r={}){let i={revert:!0,...r};return Promise.all(n.notifyManager.batch(()=>this.#s.findAll(e).map(e=>e.cancel(i)))).then(t.noop).catch(t.noop)}invalidateQueries(e,t={}){return n.notifyManager.batch(()=>(this.#s.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,r={}){let i={...r,cancelRefetch:r.cancelRefetch??!0};return Promise.all(n.notifyManager.batch(()=>this.#s.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let r=e.fetch(void 0,i);return i.throwOnError||(r=r.catch(t.noop)),"paused"===e.state.fetchStatus?Promise.resolve():r}))).then(t.noop)}fetchQuery(e){let r=this.defaultQueryOptions(e);void 0===r.retry&&(r.retry=!1);let n=this.#s.build(this,r);return n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(t.noop).catch(t.noop)}fetchInfiniteQuery(e){return e.behavior=m(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(t.noop).catch(t.noop)}ensureInfiniteQueryData(e){return e.behavior=m(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return p.onlineManager.isOnline()?this.#n.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#s}getMutationCache(){return this.#n}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,r){this.#f.set((0,t.hashKey)(e),{queryKey:e,defaultOptions:r})}getQueryDefaults(e){let r=[...this.#f.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,r){this.#d.set((0,t.hashKey)(e),{mutationKey:e,defaultOptions:r})}getMutationDefaults(e){let r=[...this.#d.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let r={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return r.queryHash||(r.queryHash=(0,t.hashQueryKeyByOptions)(r.queryKey,r)),void 0===r.refetchOnReconnect&&(r.refetchOnReconnect="always"!==r.networkMode),void 0===r.throwOnError&&(r.throwOnError=!!r.suspense),!r.networkMode&&r.persister&&(r.networkMode="offlineFirst"),r.queryFn===t.skipToken&&(r.enabled=!1),r}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#s.clear(),this.#n.clear()}};e.s(["QueryClient",()=>v],17751)},81405,(e,t,r)=>{var n;e.e,(n=function(){function e(e){return i.appendChild(e.dom),e}function t(e){for(var t=0;ta+1e3&&(u.update(1e3*l/(e-a),100),a=e,l=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:i,setMode:t}}).Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),l=80*a,u=48*a,s=3*a,c=2*a,f=3*a,d=15*a,p=74*a,m=30*a,h=document.createElement("canvas");h.width=l,h.height=u,h.style.cssText="width:80px;height:48px";var v=h.getContext("2d");return v.font="bold "+9*a+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,l,u),v.fillStyle=t,v.fillText(e,s,c),v.fillRect(f,d,p,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(f,d,p,m),{dom:h,update:function(u,g){n=Math.min(n,u),i=Math.max(i,u),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,l,d),v.fillStyle=t,v.fillText(o(u)+" "+e+" ("+o(n)+"-"+o(i)+")",s,c),v.drawImage(h,f+a,d,p-a,m,f,d,p-a,m),v.fillRect(f+p-a,d,a,m),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(f+p-a,d,a,o((1-u/g)*m))}}},t.exports=n},55141,e=>{e.v({AxisLabel:"DebugElements-module__Cmeo9W__AxisLabel",StatsPanel:"DebugElements-module__Cmeo9W__StatsPanel"})},86855,e=>{"use strict";var t=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(40859),i=i,o=i,a=e.i(81405);function l(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}function u({showPanel:e=0,className:t,parent:r}){let u=function(e,t=[],r){let[i,o]=n.useState();return n.useLayoutEffect(()=>{let t=e();return o(t),l(void 0,t),()=>l(void 0,null)},t),i}(()=>new a.default,[]);return n.useEffect(()=>{if(u){let n=r&&r.current||document.body;u.showPanel(e),null==n||n.appendChild(u.dom);let a=(null!=t?t:"").split(" ").filter(e=>e);a.length&&u.dom.classList.add(...a);let l=(0,i.j)(()=>u.begin()),s=(0,o.k)(()=>u.end());return()=>{a.length&&u.dom.classList.remove(...a),null==n||n.removeChild(u.dom),l(),s()}}},[r,u,t,e]),null}var s=e.i(60099),c=e.i(79123),f=e.i(55141);function d(){let e,i,o=(0,r.c)(3),{debugMode:a}=(0,c.useDebug)(),l=(0,n.useRef)(null);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=l.current;e&&e.setColors("rgb(153, 255, 0)","rgb(0, 153, 255)","rgb(255, 153, 0)")},o[0]=e):e=o[0],(0,n.useEffect)(e),o[1]!==a?(i=a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u,{className:f.default.StatsPanel}),(0,t.jsx)("axesHelper",{ref:l,args:[70],renderOrder:999,children:(0,t.jsx)("lineBasicMaterial",{depthTest:!1,depthWrite:!1,fog:!1,vertexColors:!0})}),(0,t.jsx)(s.Html,{position:[80,0,0],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"y",children:"Y"})}),(0,t.jsx)(s.Html,{position:[0,80,0],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"z",children:"Z"})}),(0,t.jsx)(s.Html,{position:[0,0,80],center:!0,children:(0,t.jsx)("span",{className:f.default.AxisLabel,"data-axis":"x",children:"X"})})]}):null,o[1]=a,o[2]=i):i=o[2],i}e.s(["DebugElements",()=>d],86855)},38360,(e,t,r)=>{var n={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},i=Object.keys(n).join("|"),o=RegExp(i,"g"),a=RegExp(i,"");function l(e){return n[e]}var u=function(e){return e.replace(o,l)};t.exports=u,t.exports.has=function(e){return!!e.match(a)},t.exports.remove=u},11889,56373,86447,1559,18364,78440,59129,25998,70238,e=>{"use strict";e.i(47167);var t,r="u">typeof window&&!!(null==(t=window.document)?void 0:t.createElement);function n(e){return e?"self"in e?e.document:e.ownerDocument||document:document}function i(e){return e?"self"in e?e.self:n(e).defaultView||window:self}function o(e,t=!1){var r;let{activeElement:i}=n(e);if(!(null==i?void 0:i.nodeName))return null;if(l(i)&&(null==(r=i.contentDocument)?void 0:r.body))return o(i.contentDocument.body,t);if(t){let e=i.getAttribute("aria-activedescendant");if(e){let t=n(i).getElementById(e);if(t)return t}}return i}function a(e,t){return e===t||e.contains(t)}function l(e){return"IFRAME"===e.tagName}function u(e){let t=e.tagName.toLowerCase();return"button"===t||"input"===t&&!!e.type&&-1!==s.indexOf(e.type)}var s=["button","color","file","image","reset","submit"];function c(e){return"function"==typeof e.checkVisibility?e.checkVisibility():e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0}function f(e){try{let t=e instanceof HTMLInputElement&&null!==e.selectionStart,r="TEXTAREA"===e.tagName;return t||r||!1}catch(e){return!1}}function d(e){return e.isContentEditable||f(e)}function p(e){let t=0,r=0;if(f(e))t=e.selectionStart||0,r=e.selectionEnd||0;else if(e.isContentEditable){let i=n(e).getSelection();if((null==i?void 0:i.rangeCount)&&i.anchorNode&&a(e,i.anchorNode)&&i.focusNode&&a(e,i.focusNode)){let n=i.getRangeAt(0),o=n.cloneRange();o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),t=o.toString().length,o.setEnd(n.endContainer,n.endOffset),r=o.toString().length}}return{start:t,end:r}}function m(e,t){let r=null==e?void 0:e.getAttribute("role");return r&&-1!==["dialog","menu","listbox","tree","grid"].indexOf(r)?r:t}function h(e){if(!e)return null;let t=e=>"auto"===e||"scroll"===e;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:r}=getComputedStyle(e);if(t(r))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:r}=getComputedStyle(e);if(t(r))return e}return h(e.parentElement)||document.scrollingElement||document.body}function v(e,...t){/text|search|password|tel|url/i.test(e.type)&&e.setSelectionRange(...t)}function g(e,t){return t&&e.item(t)||null}var y=Symbol("FOCUS_SILENTLY");function b(e,t,r){if(!t||t===r)return!1;let n=e.item(t.id);return!!n&&(!r||n.element!==r)}function S(){}function C(e,t){return"function"==typeof Object.hasOwn?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function x(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}function E(e){return e}function A(e,t){if(!e){if("string"!=typeof t)throw Error("Invariant failed");throw Error(t)}}function w(e,...t){let r="function"==typeof e?e(...t):e;return null!=r&&!r}function _(e){return e.disabled||!0===e["aria-disabled"]||"true"===e["aria-disabled"]}function T(e){let t={};for(let r in e)void 0!==e[r]&&(t[r]=e[r]);return t}function M(...e){for(let t of e)if(void 0!==t)return t}var R=e.i(71645);function O(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function I(){return r&&!!navigator.maxTouchPoints}function F(){return!!r&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}function L(){return r&&F()&&/apple/i.test(navigator.vendor)}function P(e){return!!(e.currentTarget&&!a(e.currentTarget,e.target))}function D(e){return e.target===e.currentTarget}function B(e,t){let r=new FocusEvent("blur",t),n=e.dispatchEvent(r),i={...t,bubbles:!0};return e.dispatchEvent(new FocusEvent("focusout",i)),n}function G(e,t){let r=new MouseEvent("click",t);return e.dispatchEvent(r)}function k(e,t){let r=t||e.currentTarget,n=e.relatedTarget;return!n||!a(r,n)}function j(e,t,r,n){let i=(e=>{if(n){let t=setTimeout(e,n);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,o,!0),r()}),o=()=>{i(),r()};return e.addEventListener(t,o,{once:!0,capture:!0}),i}function N(e,t,r,n=window){let i=[];try{for(let o of(n.document.addEventListener(e,t,r),Array.from(n.frames)))i.push(N(e,t,r,o))}catch(e){}return()=>{try{n.document.removeEventListener(e,t,r)}catch(e){}for(let e of i)e()}}var U={...R},q=U.useId;U.useDeferredValue;var V=U.useInsertionEffect,H=r?R.useLayoutEffect:R.useEffect;function W(e){let t=(0,R.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return V?V(()=>{t.current=e}):t.current=e,(0,R.useCallback)((...e)=>{var r;return null==(r=t.current)?void 0:r.call(t,...e)},[])}function K(...e){return(0,R.useMemo)(()=>{if(e.some(Boolean))return t=>{for(let r of e)O(r,t)}},e)}function z(e){if(q){let t=q();return e||t}let[t,r]=(0,R.useState)(e);return H(()=>{if(e||t)return;let n=Math.random().toString(36).slice(2,8);r(`id-${n}`)},[e,t]),e||t}function Q(e,t){let r=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(r.current)return e();r.current=!0},t),(0,R.useEffect)(()=>()=>{r.current=!1},[])}function $(){return(0,R.useReducer)(()=>[],[])}function X(e){return W("function"==typeof e?e:()=>e)}function Y(e,t,r=[]){let n=(0,R.useCallback)(r=>(e.wrapElement&&(r=e.wrapElement(r)),t(r)),[...r,e.wrapElement]);return{...e,wrapElement:n}}function Z(e=!1,t){let[r,n]=(0,R.useState)(null);return{portalRef:K(n,t),portalNode:r,domReady:!e||r}}var J=!1,ee=!1,et=0,er=0;function en(e){let t,r;t=e.movementX||e.screenX-et,r=e.movementY||e.screenY-er,et=e.screenX,er=e.screenY,(t||r||0)&&(ee=!0)}function ei(){ee=!1}var eo=e.i(43476);function ea(e){let t=R.forwardRef((t,r)=>e({...t,ref:r}));return t.displayName=e.displayName||e.name,t}function el(e,t){return R.memo(e,t)}function eu(e,t){let r,{wrapElement:n,render:i,...o}=t,a=K(t.ref,i&&(0,R.isValidElement)(i)&&("ref"in i.props||"ref"in i)?({...i.props}).ref||i.ref:null);if(R.isValidElement(i)){let e={...i.props,ref:a};r=R.cloneElement(i,function(e,t){let r={...e};for(let n in t){if(!C(t,n))continue;if("className"===n){let n="className";r[n]=e[n]?`${e[n]} ${t[n]}`:t[n];continue}if("style"===n){let n="style";r[n]=e[n]?{...e[n],...t[n]}:t[n];continue}let i=t[n];if("function"==typeof i&&n.startsWith("on")){let t=e[n];if("function"==typeof t){r[n]=(...e)=>{i(...e),t(...e)};continue}}r[n]=i}return r}(o,e))}else r=i?i(o):(0,eo.jsx)(e,{...o});return n?n(r):r}function es(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function ec(e=[],t=[]){let r=R.createContext(void 0),n=R.createContext(void 0),i=()=>R.useContext(r),o=t=>e.reduceRight((e,r)=>(0,eo.jsx)(r,{...t,children:e}),(0,eo.jsx)(r.Provider,{...t}));return{context:r,scopedContext:n,useContext:i,useScopedContext:(e=!1)=>{let t=R.useContext(n),r=i();return e?t:t||r},useProviderContext:()=>{let e=R.useContext(n),t=i();if(!e||e!==t)return t},ContextProvider:o,ScopedContextProvider:e=>(0,eo.jsx)(o,{...e,children:t.reduceRight((t,r)=>(0,eo.jsx)(r,{...e,children:t}),(0,eo.jsx)(n.Provider,{...e}))})}}var ef=ec(),ed=ef.useContext;ef.useScopedContext,ef.useProviderContext;var ep=ec([ef.ContextProvider],[ef.ScopedContextProvider]),em=ep.useContext;ep.useScopedContext;var eh=ep.useProviderContext,ev=ep.ContextProvider,eg=ep.ScopedContextProvider,ey=(0,R.createContext)(void 0),eb=(0,R.createContext)(void 0),eS=(0,R.createContext)(!0),eC="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function ex(e){return!(!e.matches(eC)||!c(e)||e.closest("[inert]"))}function eE(e){if(!ex(e)||0>Number.parseInt(e.getAttribute("tabindex")||"0",10))return!1;if(!("form"in e)||!e.form||e.checked||"radio"!==e.type)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!("length"in t))return!0;let r=o(e);return!r||r===e||!("form"in r)||r.form!==e.form||r.name!==e.name}function eA(e,t){let r=Array.from(e.querySelectorAll(eC));t&&r.unshift(e);let n=r.filter(ex);return n.forEach((e,t)=>{var r;if(!l(e))return;let i=null==(r=e.contentDocument)?void 0:r.body;i&&n.splice(t,1,...eA(i))}),n}function ew(e,t,r){let n=Array.from(e.querySelectorAll(eC)),i=n.filter(eE);return(t&&eE(e)&&i.unshift(e),i.forEach((e,t)=>{var n;if(!l(e))return;let o=null==(n=e.contentDocument)?void 0:n.body;if(!o)return;let a=ew(o,!1,r);i.splice(t,1,...a)}),!i.length&&r)?n:i}function e_(e,t){var r;let n,i,a,l;return r=document.body,n=o(r),a=(i=eA(r,!1)).indexOf(n),(l=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?l[0]:null)||null}function eT(e,t){var r;let n,i,a,l;return r=document.body,n=o(r),a=(i=eA(r,!1).reverse()).indexOf(n),(l=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?l[0]:null)||null}function eM(e){let t=o(e);if(!t)return!1;if(t===e)return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&r===e.id}function eR(e){let t=o(e);if(!t)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&"id"in e&&(r===e.id||!!e.querySelector(`#${CSS.escape(r)}`))}function eO(e){!eR(e)&&ex(e)&&e.focus()}var eI=L(),eF=["text","search","url","tel","email","password","number","date","month","week","time","datetime","datetime-local"],eL=Symbol("safariFocusAncestor");function eP(e){return"input"===e.tagName.toLowerCase()&&!!e.type&&("radio"===e.type||"checkbox"===e.type)}function eD(e,t){return W(r=>{null==e||e(r),!r.defaultPrevented&&t&&(r.stopPropagation(),r.preventDefault())})}var eB=!1,eG=!0;function ek(e){let t=e.target;t&&"hasAttribute"in t&&!t.hasAttribute("data-focus-visible")&&(eG=!1)}function ej(e){e.metaKey||e.ctrlKey||e.altKey||(eG=!0)}var eN=es(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:r,onFocusVisible:n,...i}){var o,a,l,s,c;let f=(0,R.useRef)(null);(0,R.useEffect)(()=>{!e||eB||(N("mousedown",ek,!0),N("keydown",ej,!0),eB=!0)},[e]),eI&&(0,R.useEffect)(()=>{if(!e)return;let t=f.current;if(!t||!eP(t))return;let r="labels"in t?t.labels:null;if(!r)return;let n=()=>queueMicrotask(()=>t.focus());for(let e of r)e.addEventListener("mouseup",n);return()=>{for(let e of r)e.removeEventListener("mouseup",n)}},[e]);let d=e&&_(i),p=!!d&&!t,[m,h]=(0,R.useState)(!1);(0,R.useEffect)(()=>{e&&p&&m&&h(!1)},[e,p,m]),(0,R.useEffect)(()=>{if(!e||!m)return;let t=f.current;if(!t||"u"{ex(t)||h(!1)});return r.observe(t),()=>r.disconnect()},[e,m]);let v=eD(i.onKeyPressCapture,d),g=eD(i.onMouseDownCapture,d),y=eD(i.onClickCapture,d),b=i.onMouseDown,S=W(t=>{if(null==b||b(t),t.defaultPrevented||!e)return;let r=t.currentTarget;if(!eI||P(t)||!u(r)&&!eP(r))return;let n=!1,i=()=>{n=!0};r.addEventListener("focusin",i,{capture:!0,once:!0});let o=function(e){for(;e&&!ex(e);)e=e.closest(eC);return e||null}(r.parentElement);o&&(o[eL]=!0),j(r,"mouseup",()=>{r.removeEventListener("focusin",i,!0),o&&(o[eL]=!1),n||eO(r)})}),C=(t,r)=>{if(r&&(t.currentTarget=r),!e)return;let i=t.currentTarget;i&&eM(i)&&(null==n||n(t),t.defaultPrevented||(i.dataset.focusVisible="true",h(!0)))},x=i.onKeyDownCapture,E=W(t=>{if(null==x||x(t),t.defaultPrevented||!e||m||t.metaKey||t.altKey||t.ctrlKey||!D(t))return;let r=t.currentTarget;j(r,"focusout",()=>C(t,r))}),A=i.onFocusCapture,w=W(t=>{if(null==A||A(t),t.defaultPrevented||!e)return;if(!D(t))return void h(!1);let r=t.currentTarget;eG||function(e){let{tagName:t,readOnly:r,type:n}=e;return"TEXTAREA"===t&&!r||"SELECT"===t&&!r||("INPUT"!==t||r?!!e.isContentEditable||"combobox"===e.getAttribute("role")&&!!e.dataset.name:eF.includes(n))}(t.target)?j(t.target,"focusout",()=>C(t,r)):h(!1)}),M=i.onBlur,O=W(t=>{null==M||M(t),!e||k(t)&&(t.currentTarget.removeAttribute("data-focus-visible"),h(!1))}),I=(0,R.useContext)(eS),F=W(t=>{e&&r&&t&&I&&queueMicrotask(()=>{eM(t)||ex(t)&&t.focus()})}),L=function(e,t){let r=e=>{if("string"==typeof e)return e},[n,i]=(0,R.useState)(()=>r(void 0));return H(()=>{let t=e&&"current"in e?e.current:e;i((null==t?void 0:t.tagName.toLowerCase())||r(void 0))},[e,void 0]),n}(f),B=e&&(!L||"button"===L||"summary"===L||"input"===L||"select"===L||"textarea"===L||"a"===L),G=e&&(!L||"button"===L||"input"===L||"select"===L||"textarea"===L),U=i.style,q=(0,R.useMemo)(()=>p?{pointerEvents:"none",...U}:U,[p,U]);return i={"data-focus-visible":e&&m||void 0,"data-autofocus":r||void 0,"aria-disabled":d||void 0,...i,ref:K(f,F,i.ref),style:q,tabIndex:(o=e,a=p,l=B,s=G,c=i.tabIndex,o?a?l&&!s?-1:void 0:l?c:c||0:c),disabled:!!G&&!!p||void 0,contentEditable:d?void 0:i.contentEditable,onKeyPressCapture:v,onClickCapture:y,onMouseDownCapture:g,onMouseDown:S,onKeyDownCapture:E,onFocusCapture:w,onBlur:O},T(i)});function eU(e){let t=[];for(let r of e)t.push(...r);return t}function eq(e){return e.slice().reverse()}function eV(e,t,r){return W(n=>{var i;let o,a;if(null==t||t(n),n.defaultPrevented||n.isPropagationStopped()||!D(n)||"Shift"===n.key||"Control"===n.key||"Alt"===n.key||"Meta"===n.key||(!(o=n.target)||f(o))&&1===n.key.length&&!n.ctrlKey&&!n.metaKey)return;let l=e.getState(),u=null==(i=g(e,l.activeId))?void 0:i.element;if(!u)return;let{view:s,...c}=n;u!==(null==r?void 0:r.current)&&u.focus(),a=new KeyboardEvent(n.type,c),u.dispatchEvent(a)||n.preventDefault(),n.currentTarget.contains(u)&&n.stopPropagation()})}ea(function(e){return eu("div",eN(e))});var eH=es(function({store:e,composite:t=!0,focusOnMove:r=t,moveOnKeyPress:n=!0,...i}){let a=eh();A(e=e||a,!1);let l=(0,R.useRef)(null),u=(0,R.useRef)(null),s=function(e){let[t,r]=(0,R.useState)(!1),n=(0,R.useCallback)(()=>r(!0),[]),i=e.useState(t=>g(e,t.activeId));return(0,R.useEffect)(()=>{let e=null==i?void 0:i.element;!t||e&&(r(!1),e.focus({preventScroll:!0}))},[i,t]),n}(e),c=e.useState("moves"),[,d]=function(e){let[t,r]=(0,R.useState)(null);return H(()=>{if(null==t||!e)return;let r=null;return e(e=>(r=e,t)),()=>{e(r)}},[t,e]),[t,r]}(t?e.setBaseElement:null);(0,R.useEffect)(()=>{var n;if(!e||!c||!t||!r)return;let{activeId:i}=e.getState(),o=null==(n=g(e,i))?void 0:n.element;o&&("scrollIntoView"in o?(o.focus({preventScroll:!0}),o.scrollIntoView({block:"nearest",inline:"nearest",...void 0})):o.focus())},[e,c,t,r]),H(()=>{if(!e||!c||!t)return;let{baseElement:r,activeId:n}=e.getState();if(null!==n||!r)return;let i=u.current;u.current=null,i&&B(i,{relatedTarget:r}),eM(r)||r.focus()},[e,c,t]);let p=e.useState("activeId"),m=e.useState("virtualFocus");H(()=>{var r;if(!e||!t||!m)return;let n=u.current;if(u.current=null,!n)return;let i=(null==(r=g(e,p))?void 0:r.element)||o(n);i!==n&&B(n,{relatedTarget:i})},[e,p,m,t]);let h=eV(e,i.onKeyDownCapture,u),v=eV(e,i.onKeyUpCapture,u),S=i.onFocusCapture,C=W(t=>{var r;let n;if(null==S||S(t),t.defaultPrevented||!e)return;let{virtualFocus:i}=e.getState();if(!i)return;let o=t.relatedTarget,a=(n=(r=t.currentTarget)[y],delete r[y],n);D(t)&&a&&(t.stopPropagation(),u.current=o)}),x=i.onFocus,E=W(r=>{if(null==x||x(r),r.defaultPrevented||!t||!e)return;let{relatedTarget:n}=r,{virtualFocus:i}=e.getState();i?D(r)&&!b(e,n)&&queueMicrotask(s):D(r)&&e.setActiveId(null)}),w=i.onBlurCapture,_=W(t=>{var r;if(null==w||w(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:i}=e.getState();if(!n)return;let o=null==(r=g(e,i))?void 0:r.element,a=t.relatedTarget,l=b(e,a),s=u.current;u.current=null,D(t)&&l?(a===o?s&&s!==a&&B(s,t):o?B(o,t):s&&B(s,t),t.stopPropagation()):!b(e,t.target)&&o&&B(o,t)}),T=i.onKeyDown,M=X(n),O=W(t=>{var r;if(null==T||T(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!D(t))return;let{orientation:n,renderedItems:i,activeId:o}=e.getState(),a=g(e,o);if(null==(r=null==a?void 0:a.element)?void 0:r.isConnected)return;let l="horizontal"!==n,u="vertical"!==n,s=i.some(e=>!!e.rowId);if(("ArrowLeft"===t.key||"ArrowRight"===t.key||"Home"===t.key||"End"===t.key)&&f(t.currentTarget))return;let c={ArrowUp:(s||l)&&(()=>{if(s){let e=eU(eq(function(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}(i))).find(e=>!e.disabled);return null==e?void 0:e.id}return null==e?void 0:e.last()}),ArrowRight:(s||u)&&e.first,ArrowDown:(s||l)&&e.first,ArrowLeft:(s||u)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(c){let r=c();if(void 0!==r){if(!M(t))return;t.preventDefault(),e.move(r)}}});return i=Y(i,t=>(0,eo.jsx)(ev,{value:e,children:t}),[e]),i={"aria-activedescendant":e.useState(r=>{var n;if(e&&t&&r.virtualFocus)return null==(n=g(e,r.activeId))?void 0:n.id}),...i,ref:K(l,d,i.ref),onKeyDownCapture:h,onKeyUpCapture:v,onFocusCapture:C,onFocus:E,onBlurCapture:_,onKeyDown:O},i=eN({focusable:e.useState(e=>t&&(e.virtualFocus||null===e.activeId)),...i})});ea(function(e){return eu("div",eH(e))});var eW=ec();eW.useContext,eW.useScopedContext;var eK=eW.useProviderContext,ez=ec([eW.ContextProvider],[eW.ScopedContextProvider]);ez.useContext,ez.useScopedContext;var eQ=ez.useProviderContext,e$=ez.ContextProvider,eX=ez.ScopedContextProvider,eY=(0,R.createContext)(void 0),eZ=(0,R.createContext)(void 0),eJ=ec([e$],[eX]);eJ.useContext,eJ.useScopedContext;var e0=eJ.useProviderContext,e1=eJ.ContextProvider,e2=eJ.ScopedContextProvider,e3=es(function({store:e,...t}){let r=e0();return e=e||r,t={...t,ref:K(null==e?void 0:e.setAnchorElement,t.ref)}});ea(function(e){return eu("div",e3(e))});var e5=(0,R.createContext)(void 0),e4=ec([e1,ev],[e2,eg]),e8=e4.useContext,e6=e4.useScopedContext,e9=e4.useProviderContext,e7=e4.ContextProvider,te=e4.ScopedContextProvider,tt=(0,R.createContext)(void 0),tr=(0,R.createContext)(!1);function tn(e,t){let r=e.__unstableInternals;return A(r,"Invalid store"),r[t]}function ti(e,...t){let r=e,n=r,i=Symbol(),o=S,a=new Set,l=new Set,u=new Set,s=new Set,c=new Set,f=new WeakMap,d=new WeakMap,p=(e,t,r=s)=>(r.add(t),d.set(t,e),()=>{var e;null==(e=f.get(t))||e(),f.delete(t),d.delete(t),r.delete(t)}),m=(e,o,a=!1)=>{var u,p;if(!C(r,e))return;let m=(p=r[e],"function"==typeof o?o("function"==typeof p?p():p):o);if(m===r[e])return;if(!a)for(let r of t)null==(u=null==r?void 0:r.setState)||u.call(r,e,m);let h=r;r={...r,[e]:m};let v=Symbol();i=v,l.add(e);let g=(t,n,i)=>{var o;let a=d.get(t);(!a||a.some(t=>i?i.has(t):t===e))&&(null==(o=f.get(t))||o(),f.set(t,t(r,n)))};for(let e of s)g(e,h);queueMicrotask(()=>{if(i!==v)return;let e=r;for(let e of c)g(e,n,l);n=e,l.clear()})},h={getState:()=>r,setState:m,__unstableInternals:{setup:e=>(u.add(e),()=>u.delete(e)),init:()=>{let e=a.size,n=Symbol();a.add(n);let i=()=>{a.delete(n),a.size||o()};if(e)return i;let l=Object.keys(r).map(e=>x(...t.map(t=>{var r;let n=null==(r=null==t?void 0:t.getState)?void 0:r.call(t);if(n&&C(n,e))return tu(t,[e],t=>{m(e,t[e],!0)})}))),s=[];for(let e of u)s.push(e());return o=x(...l,...s,...t.map(ta)),i},subscribe:(e,t)=>p(e,t),sync:(e,t)=>(f.set(t,t(r,r)),p(e,t)),batch:(e,t)=>(f.set(t,t(r,n)),p(e,t,c)),pick:e=>ti(function(e,t){let r={};for(let n of t)C(e,n)&&(r[n]=e[n]);return r}(r,e),h),omit:e=>ti(function(e,t){let r={...e};for(let e of t)C(r,e)&&delete r[e];return r}(r,e),h)}};return h}function to(e,...t){if(e)return tn(e,"setup")(...t)}function ta(e,...t){if(e)return tn(e,"init")(...t)}function tl(e,...t){if(e)return tn(e,"subscribe")(...t)}function tu(e,...t){if(e)return tn(e,"sync")(...t)}function ts(e,...t){if(e)return tn(e,"batch")(...t)}function tc(e,...t){if(e)return tn(e,"omit")(...t)}function tf(...e){var t;let r={};for(let n of e){let e=null==(t=null==n?void 0:n.getState)?void 0:t.call(n);e&&Object.assign(r,e)}let n=ti(r,...e);return Object.assign({},...e,n)}function td(e,t){}function tp(e,t,r){if(!r)return!1;let n=e.find(e=>!e.disabled&&e.value);return(null==n?void 0:n.value)===t}function tm(e,t){return!!t&&null!=e&&(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase()))}var th=es(function({store:e,focusable:t=!0,autoSelect:r=!1,getAutoSelectId:n,setValueOnChange:i,showMinLength:o=0,showOnChange:a,showOnMouseDown:l,showOnClick:u=l,showOnKeyDown:s,showOnKeyPress:c=s,blurActiveItemOnClick:f,setValueOnClick:d=!0,moveOnKeyPress:g=!0,autoComplete:y="list",...b}){var C;let x,E=e9();A(e=e||E,!1);let _=(0,R.useRef)(null),[T,M]=$(),O=(0,R.useRef)(!1),I=(0,R.useRef)(!1),F=e.useState(e=>e.virtualFocus&&r),L="inline"===y||"both"===y,[P,D]=(0,R.useState)(L);C=[L],x=(0,R.useRef)(!1),H(()=>{if(x.current)return(()=>{L&&D(!0)})();x.current=!0},C),H(()=>()=>{x.current=!1},[]);let B=e.useState("value"),G=(0,R.useRef)(void 0);(0,R.useEffect)(()=>tu(e,["selectedValue","activeId"],(e,t)=>{G.current=t.selectedValue}),[]);let N=e.useState(e=>{var t;if(L&&P){if(e.activeValue&&Array.isArray(e.selectedValue)&&(e.selectedValue.includes(e.activeValue)||(null==(t=G.current)?void 0:t.includes(e.activeValue))))return;return e.activeValue}}),U=e.useState("renderedItems"),q=e.useState("open"),V=e.useState("contentElement"),Y=(0,R.useMemo)(()=>{if(!L||!P)return B;if(tp(U,N,F)){if(tm(B,N)){let e=(null==N?void 0:N.slice(B.length))||"";return B+e}return B}return N||B},[L,P,U,N,F,B]);(0,R.useEffect)(()=>{let e=_.current;if(!e)return;let t=()=>D(!0);return e.addEventListener("combobox-item-move",t),()=>{e.removeEventListener("combobox-item-move",t)}},[]),(0,R.useEffect)(()=>{if(!L||!P||!N||!tp(U,N,F)||!tm(B,N))return;let e=S;return queueMicrotask(()=>{let t=_.current;if(!t)return;let{start:r,end:n}=p(t),i=B.length,o=N.length;v(t,i,o),e=()=>{if(!eM(t))return;let{start:e,end:a}=p(t);e!==i||a===o&&v(t,r,n)}}),()=>e()},[T,L,P,N,U,F,B]);let Z=(0,R.useRef)(null),J=W(n),ee=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!q||!V)return;let t=h(V);if(!t)return;Z.current=t;let r=()=>{O.current=!1},n=()=>{if(!e||!O.current)return;let{activeId:t}=e.getState();null===t||t!==ee.current&&(O.current=!1)},i={passive:!0,capture:!0};return t.addEventListener("wheel",r,i),t.addEventListener("touchmove",r,i),t.addEventListener("scroll",n,i),()=>{t.removeEventListener("wheel",r,!0),t.removeEventListener("touchmove",r,!0),t.removeEventListener("scroll",n,!0)}},[q,V,e]),H(()=>{!B||I.current||(O.current=!0)},[B]),H(()=>{"always"!==F&&q||(O.current=q)},[F,q]);let et=e.useState("resetValueOnSelect");Q(()=>{var t,r;let n=O.current;if(!e||!q||!n&&!et)return;let{baseElement:i,contentElement:o,activeId:a}=e.getState();if(!i||eM(i)){if(null==o?void 0:o.hasAttribute("data-placing")){let e=new MutationObserver(M);return e.observe(o,{attributeFilter:["data-placing"]}),()=>e.disconnect()}if(F&&n){let r,n=J(U),i=void 0!==n?n:null!=(t=null==(r=U.find(e=>{var t;return!e.disabled&&(null==(t=e.element)?void 0:t.getAttribute("role"))!=="tab"}))?void 0:r.id)?t:e.first();ee.current=i,e.move(null!=i?i:null)}else{let t=null==(r=e.item(a||e.first()))?void 0:r.element;t&&"scrollIntoView"in t&&t.scrollIntoView({block:"nearest",inline:"nearest"})}}},[e,q,T,B,F,et,J,U]),(0,R.useEffect)(()=>{if(!L)return;let t=_.current;if(!t)return;let r=[t,V].filter(e=>!!e),n=t=>{r.every(e=>k(t,e))&&(null==e||e.setValue(Y))};for(let e of r)e.addEventListener("focusout",n);return()=>{for(let e of r)e.removeEventListener("focusout",n)}},[L,V,e,Y]);let er=e=>e.currentTarget.value.length>=o,en=b.onChange,ei=X(null!=a?a:er),eo=X(null!=i?i:!e.tag),ea=W(t=>{if(null==en||en(t),t.defaultPrevented||!e)return;let r=t.currentTarget,{value:n,selectionStart:i,selectionEnd:o}=r,a=t.nativeEvent;if(O.current=!0,"input"===a.type&&(a.isComposing&&(O.current=!1,I.current=!0),L)){let e="insertText"===a.inputType||"insertCompositionText"===a.inputType,t=i===n.length;D(e&&t)}if(eo(t)){let t=n===e.getState().value;e.setValue(n),queueMicrotask(()=>{v(r,i,o)}),L&&F&&t&&M()}ei(t)&&e.show(),F&&O.current||e.setActiveId(null)}),el=b.onCompositionEnd,eu=W(e=>{O.current=!0,I.current=!1,null==el||el(e),e.defaultPrevented||F&&M()}),es=b.onMouseDown,ec=X(null!=f?f:()=>!!(null==e?void 0:e.getState().includesBaseElement)),ef=X(d),ed=X(null!=u?u:er),ep=W(t=>{null==es||es(t),t.defaultPrevented||t.button||t.ctrlKey||e&&(ec(t)&&e.setActiveId(null),ef(t)&&e.setValue(Y),ed(t)&&j(t.currentTarget,"mouseup",e.show))}),em=b.onKeyDown,eh=X(null!=c?c:er),ev=W(t=>{if(null==em||em(t),t.repeat||(O.current=!1),t.defaultPrevented||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||!e)return;let{open:r}=e.getState();!r&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&eh(t)&&(t.preventDefault(),e.show())}),eg=b.onBlur,ey=W(e=>{if(O.current=!1,null==eg||eg(e),e.defaultPrevented)return}),eb=z(b.id),eS=e.useState(e=>null===e.activeId);return b={id:eb,role:"combobox","aria-autocomplete":"inline"===y||"list"===y||"both"===y||"none"===y?y:void 0,"aria-haspopup":m(V,"listbox"),"aria-expanded":q,"aria-controls":null==V?void 0:V.id,"data-active-item":eS||void 0,value:Y,...b,ref:K(_,b.ref),onChange:ea,onCompositionEnd:eu,onMouseDown:ep,onKeyDown:ev,onBlur:ey},b=eH({store:e,focusable:t,...b,moveOnKeyPress:e=>!w(g,e)&&(L&&D(!0),!0)}),{autoComplete:"off",...b=e3({store:e,...b})}}),tv=ea(function(e){return eu("input",th(e))});function tg(e){let t=e.relatedTarget;return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE?t:null}e.s(["Combobox",()=>tv],11889);var ty=Symbol("composite-hover"),tb=es(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:r=!!t,...n}){let i=em();A(e=e||i,!1);let o=((0,R.useEffect)(()=>{J||(N("mousemove",en,!0),N("mousedown",ei,!0),N("mouseup",ei,!0),N("keydown",ei,!0),N("scroll",ei,!0),J=!0)},[]),W(()=>ee)),l=n.onMouseMove,u=X(t),s=W(t=>{if((null==l||l(t),!t.defaultPrevented&&o())&&u(t)){if(!eR(t.currentTarget)){let t=null==e?void 0:e.getState().baseElement;t&&!eM(t)&&t.focus()}null==e||e.setActiveId(t.currentTarget.id)}}),c=n.onMouseLeave,f=X(r),d=W(t=>{var r;let n;null==c||c(t),!t.defaultPrevented&&o()&&((n=tg(t))&&a(t.currentTarget,n)||function(e){let t=tg(e);if(!t)return!1;do{if(C(t,ty)&&t[ty])return!0;t=t.parentElement}while(t)return!1}(t)||!u(t)||f(t)&&(null==e||e.setActiveId(null),null==(r=null==e?void 0:e.getState().baseElement)||r.focus()))}),p=(0,R.useCallback)(e=>{e&&(e[ty]=!0)},[]);return T(n={...n,ref:K(p,n.ref),onMouseMove:s,onMouseLeave:d})});el(ea(function(e){return eu("div",tb(e))}));var tS=es(function({store:e,shouldRegisterItem:t=!0,getItem:r=E,element:n,...i}){let o=ed();e=e||o;let a=z(i.id),l=(0,R.useRef)(n);return(0,R.useEffect)(()=>{let n=l.current;if(!a||!n||!t)return;let i=r({id:a,element:n});return null==e?void 0:e.renderItem(i)},[a,t,r,e]),T(i={...i,ref:K(l,i.ref)})});function tC(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return"Enter"===e.key?u(t)||"SUMMARY"===t.tagName||"A"===t.tagName:" "===e.key&&(u(t)||"SUMMARY"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName)}ea(function(e){return eu("div",tS(e))});var tx=Symbol("command"),tE=es(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let i,o,a=(0,R.useRef)(null),[l,s]=(0,R.useState)(!1);(0,R.useEffect)(()=>{a.current&&s(u(a.current))},[]);let[c,d]=(0,R.useState)(!1),p=(0,R.useRef)(!1),m=_(n),[h,v]=(i=n.onLoadedMetadataCapture,o=(0,R.useMemo)(()=>Object.assign(()=>{},{...i,[tx]:!0}),[i,tx,!0]),[null==i?void 0:i[tx],{onLoadedMetadataCapture:o}]),g=n.onKeyDown,y=W(n=>{null==g||g(n);let i=n.currentTarget;if(n.defaultPrevented||h||m||!D(n)||f(i)||i.isContentEditable)return;let o=e&&"Enter"===n.key,a=t&&" "===n.key,l="Enter"===n.key&&!e,u=" "===n.key&&!t;if(l||u)return void n.preventDefault();if(o||a){let e=tC(n);if(o){if(!e){n.preventDefault();let{view:e,...t}=n,o=()=>G(i,t);r&&/firefox\//i.test(navigator.userAgent)?j(i,"keyup",o):queueMicrotask(o)}}else a&&(p.current=!0,e||(n.preventDefault(),d(!0)))}}),b=n.onKeyUp,S=W(e=>{if(null==b||b(e),e.defaultPrevented||h||m||e.metaKey)return;let r=t&&" "===e.key;if(p.current&&r&&(p.current=!1,!tC(e))){e.preventDefault(),d(!1);let t=e.currentTarget,{view:r,...n}=e;queueMicrotask(()=>G(t,n))}});return eN(n={"data-active":c||void 0,type:l?"button":void 0,...v,...n,ref:K(a,n.ref),onKeyDown:y,onKeyUp:S})});ea(function(e){return eu("button",tE(e))});var{useSyncExternalStore:tA}=e.i(2239).default,tw=()=>()=>{};function t_(e,t=E){let r=R.useCallback(t=>e?tl(e,null,t):tw(),[e]),n=()=>{let r="string"==typeof t?t:null,n="function"==typeof t?t:null,i=null==e?void 0:e.getState();return n?n(i):i&&r&&C(i,r)?i[r]:void 0};return tA(r,n,n)}function tT(e,t){let r=R.useRef({}),n=R.useCallback(t=>e?tl(e,null,t):tw(),[e]),i=()=>{let n=null==e?void 0:e.getState(),i=!1,o=r.current;for(let e in t){let r=t[e];if("function"==typeof r){let t=r(n);t!==o[e]&&(o[e]=t,i=!0)}if("string"==typeof r){if(!n||!C(n,r))continue;let t=n[r];t!==o[e]&&(o[e]=t,i=!0)}}return i&&(r.current={...o}),r.current};return tA(n,i,i)}function tM(e,t,r,n){var i;let o,a=C(t,r)?t[r]:void 0,l=(i={value:a,setValue:n?t[n]:void 0},o=(0,R.useRef)(i),H(()=>{o.current=i}),o);H(()=>tu(e,[r],(e,t)=>{let{value:n,setValue:i}=l.current;i&&e[r]!==t[r]&&e[r]!==n&&i(e[r])}),[e,r]),H(()=>{if(void 0!==a)return e.setState(r,a),ts(e,[r],()=>{void 0!==a&&e.setState(r,a)})})}function tR(e,t){let[r,n]=R.useState(()=>e(t));H(()=>ta(r),[r]);let i=R.useCallback(e=>t_(r,e),[r]);return[R.useMemo(()=>({...r,useState:i}),[r,i]),W(()=>{n(r=>e({...t,...r.getState()}))})]}function tO(e,t,r,n=!1){var i;let o,a;if(!t||!r)return;let{renderedItems:l}=t.getState(),u=h(e);if(!u)return;let s=function(e,t=!1){let r=e.clientHeight,{top:n}=e.getBoundingClientRect(),i=1.5*Math.max(.875*r,r-40),o=t?r-i+n:i+n;return"HTML"===e.tagName?o+e.scrollTop:o}(u,n);for(let e=0;e=0){void 0!==a&&at||(e&&(null==g?void 0:g.baseElement)&&g.baseElement===e.baseElement?g.id:void 0),baseElement:e=>(null==e?void 0:e.baseElement)||void 0,isActiveItem:e=>!!e&&e.activeId===h,ariaSetSize:e=>null!=l?l:e&&(null==g?void 0:g.ariaSetSize)&&g.baseElement===e.baseElement?g.ariaSetSize:void 0,ariaPosInSet(e){if(null!=s)return s;if(!e||!(null==g?void 0:g.ariaPosInSet)||g.baseElement!==e.baseElement)return;let t=e.renderedItems.filter(e=>e.rowId===C);return g.ariaPosInSet+t.findIndex(e=>e.id===h)},isTabbable(t){if(!(null==t?void 0:t.renderedItems.length))return!0;if(t.virtualFocus)return!1;if(o)return!0;if(null===t.activeId)return!1;let r=null==e?void 0:e.item(t.activeId);return null!=r&&!!r.disabled||null==r||!r.element||t.activeId===h}}),O=(0,R.useCallback)(e=>{var t;let r={...e,id:h||e.id,rowId:C,disabled:!!S,children:null==(t=e.element)?void 0:t.textContent};return a?a(r):r},[h,C,S,a]),I=c.onFocus,F=(0,R.useRef)(!1),B=W(t=>{var r,i;if(null==I||I(t),t.defaultPrevented||P(t)||!h||!e||(r=e,!D(t)&&b(r,t.target)))return;let{virtualFocus:o,baseElement:a}=e.getState();e.setActiveId(h),d(t.currentTarget)&&function(e,t=!1){if(f(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let r=n(e).getSelection();null==r||r.selectAllChildren(e),t&&(null==r||r.collapseToEnd())}}(t.currentTarget),!o||!D(t)||!d(i=t.currentTarget)&&("INPUT"!==i.tagName||u(i))&&(null==a?void 0:a.isConnected)&&((L()&&t.currentTarget.hasAttribute("data-autofocus")&&t.currentTarget.scrollIntoView({block:"nearest",inline:"nearest"}),F.current=!0,t.relatedTarget===a||b(e,t.relatedTarget))?(a[y]=!0,a.focus({preventScroll:!0})):a.focus())}),G=c.onBlurCapture,k=W(t=>{if(null==G||G(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState();(null==r?void 0:r.virtualFocus)&&F.current&&(F.current=!1,t.preventDefault(),t.stopPropagation())}),j=c.onKeyDown,N=X(r),U=X(i),q=W(t=>{if(null==j||j(t),t.defaultPrevented||!D(t)||!e)return;let{currentTarget:r}=t,i=e.getState(),o=e.item(h),a=!!(null==o?void 0:o.rowId),l="horizontal"!==i.orientation,u="vertical"!==i.orientation,s=()=>!(!a&&!u&&i.baseElement&&f(i.baseElement)),c={ArrowUp:(a||l)&&e.up,ArrowRight:(a||u)&&e.next,ArrowDown:(a||l)&&e.down,ArrowLeft:(a||u)&&e.previous,Home:()=>{if(s())return!a||t.ctrlKey?null==e?void 0:e.first():null==e?void 0:e.previous(-1)},End:()=>{if(s())return!a||t.ctrlKey?null==e?void 0:e.last():null==e?void 0:e.next(-1)},PageUp:()=>tO(r,e,null==e?void 0:e.up,!0),PageDown:()=>tO(r,e,null==e?void 0:e.down)}[t.key];if(c){if(d(r)){let e=p(r),i=u&&"ArrowLeft"===t.key,o=u&&"ArrowRight"===t.key,a=l&&"ArrowUp"===t.key,s=l&&"ArrowDown"===t.key;if(o||s){let{length:t}=function(e){if(f(e))return e.value;if(e.isContentEditable){let t=n(e).createRange();return t.selectNodeContents(e),t.toString()}return""}(r);if(e.end!==t)return}else if((i||a)&&0!==e.start)return}let i=c();if(N(t)||void 0!==i){if(!U(t))return;t.preventDefault(),e.move(i)}}}),V=(0,R.useMemo)(()=>({id:h,baseElement:x}),[h,x]);return c={id:h,"data-active-item":E||void 0,...c=Y(c,e=>(0,eo.jsx)(ey.Provider,{value:V,children:e}),[V]),ref:K(v,c.ref),tabIndex:M?c.tabIndex:-1,onFocus:B,onBlurCapture:k,onKeyDown:q},c=tE(c),T({...c=tS({store:e,...c,getItem:O,shouldRegisterItem:!!h&&c.shouldRegisterItem}),"aria-setsize":A,"aria-posinset":w})});el(ea(function(e){return eu("button",tI(e))}));var tF=es(function({store:e,value:t,hideOnClick:r,setValueOnClick:n,selectValueOnClick:i=!0,resetValueOnSelect:o,focusOnHover:a=!1,moveOnKeyPress:l=!0,getItem:u,...s}){var c,d;let p=e6();A(e=e||p,!1);let{resetValueOnSelectState:m,multiSelectable:h,selected:v}=tT(e,{resetValueOnSelectState:"resetValueOnSelect",multiSelectable:e=>Array.isArray(e.selectedValue),selected:e=>(function(e,t){if(null!=t)return null!=e&&(Array.isArray(e)?e.includes(t):e===t)})(e.selectedValue,t)}),g=(0,R.useCallback)(e=>{let r={...e,value:t};return u?u(r):r},[t,u]);n=null!=n?n:!h,r=null!=r?r:null!=t&&!h;let y=s.onClick,b=X(n),S=X(i),C=X(null!=(c=null!=o?o:m)?c:h),x=X(r),E=W(r=>{null==y||y(r),r.defaultPrevented||function(e){let t=e.currentTarget;if(!t)return!1;let r=t.tagName.toLowerCase();return!!e.altKey&&("a"===r||"button"===r&&"submit"===t.type||"input"===r&&"submit"===t.type)}(r)||!function(e){let t=e.currentTarget;if(!t)return!1;let r=F();if(r&&!e.metaKey||!r&&!e.ctrlKey)return!1;let n=t.tagName.toLowerCase();return"a"===n||"button"===n&&"submit"===t.type||"input"===n&&"submit"===t.type}(r)&&(null!=t&&(S(r)&&(C(r)&&(null==e||e.resetValue()),null==e||e.setSelectedValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t)),b(r)&&(null==e||e.setValue(t))),x(r)&&(null==e||e.hide()))}),w=s.onKeyDown,_=W(t=>{if(null==w||w(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState().baseElement;!r||eM(r)||(1===t.key.length||"Backspace"===t.key||"Delete"===t.key)&&(queueMicrotask(()=>r.focus()),f(r)&&(null==e||e.setValue(r.value)))});h&&null!=v&&(s={"aria-selected":v,...s}),s=Y(s,e=>(0,eo.jsx)(tt.Provider,{value:t,children:(0,eo.jsx)(tr.Provider,{value:null!=v&&v,children:e})}),[t,v]),s={role:null!=(d=({menu:"menuitem",listbox:"option",tree:"treeitem"})[(0,R.useContext)(e5)])?d:"option",children:t,...s,onClick:E,onKeyDown:_};let T=X(l);return s=tI({store:e,...s,getItem:g,moveOnKeyPress:t=>{if(!T(t))return!1;let r=new Event("combobox-item-move"),n=null==e?void 0:e.getState().baseElement;return null==n||n.dispatchEvent(r),!0}}),s=tb({store:e,focusOnHover:a,...s})}),tL=el(ea(function(e){return eu("div",tF(e))}));e.s(["ComboboxItem",()=>tL],56373);var tP=e.i(74080);function tD(e,t){let r=setTimeout(t,e);return()=>clearTimeout(r)}function tB(...e){return e.join(", ").split(", ").reduce((e,t)=>{let r=t.endsWith("ms")?1:1e3,n=Number.parseFloat(t||"0s")*r;return n>e?n:e},0)}function tG(e,t,r){return!r&&!1!==t&&(!e||!!t)}var tk=es(function({store:e,alwaysVisible:t,...r}){let n=eK();A(e=e||n,!1);let i=(0,R.useRef)(null),o=z(r.id),[a,l]=(0,R.useState)(null),u=e.useState("open"),s=e.useState("mounted"),c=e.useState("animated"),f=e.useState("contentElement"),d=t_(e.disclosure,"contentElement");H(()=>{i.current&&(null==e||e.setContentElement(i.current))},[e]),H(()=>{let t;return null==e||e.setState("animated",e=>(t=e,!0)),()=>{void 0!==t&&(null==e||e.setState("animated",t))}},[e]),H(()=>{if(c){var e;let t;return(null==f?void 0:f.isConnected)?(e=()=>{l(u?"enter":s?"leave":null)},t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)}),()=>cancelAnimationFrame(t)):void l(null)}},[c,f,u,s]),H(()=>{if(!e||!c||!a||!f)return;let t=()=>null==e?void 0:e.setState("animating",!1),r=()=>(0,tP.flushSync)(t);if("leave"===a&&u||"enter"===a&&!u)return;if("number"==typeof c)return tD(c,r);let{transitionDuration:n,animationDuration:i,transitionDelay:o,animationDelay:l}=getComputedStyle(f),{transitionDuration:s="0",animationDuration:p="0",transitionDelay:m="0",animationDelay:h="0"}=d?getComputedStyle(d):{},v=tB(o,l,m,h)+tB(n,i,s,p);if(!v){"enter"===a&&e.setState("animated",!1),t();return}return tD(Math.max(v-1e3/60,0),r)},[e,c,f,d,u,a]);let p=tG(s,(r=Y(r,t=>(0,eo.jsx)(eX,{value:e,children:t}),[e])).hidden,t),m=r.style,h=(0,R.useMemo)(()=>p?{...m,display:"none"}:m,[p,m]);return T(r={id:o,"data-open":u||void 0,"data-enter":"enter"===a||void 0,"data-leave":"leave"===a||void 0,hidden:p,...r,ref:K(o?e.setContentElement:null,i,r.ref),style:h})}),tj=ea(function(e){return eu("div",tk(e))});ea(function({unmountOnHide:e,...t}){let r=eK();return!1===t_(t.store||r,t=>!e||(null==t?void 0:t.mounted))?null:(0,eo.jsx)(tj,{...t})});var tN=es(function({store:e,alwaysVisible:t,...r}){let n=e6(!0),i=e8(),o=!!(e=e||i)&&e===n;A(e,!1);let a=(0,R.useRef)(null),l=z(r.id),u=e.useState("mounted"),s=tG(u,r.hidden,t),c=s?{...r.style,display:"none"}:r.style,f=e.useState(e=>Array.isArray(e.selectedValue)),d=function(e,t,r){let n=function(e){let[t]=(0,R.useState)(e);return t}(r),[i,o]=(0,R.useState)(n);return(0,R.useEffect)(()=>{let r=e&&"current"in e?e.current:e;if(!r)return;let i=()=>{let e=r.getAttribute(t);o(null==e?n:e)},a=new MutationObserver(i);return a.observe(r,{attributeFilter:[t]}),i(),()=>a.disconnect()},[e,t,n]),i}(a,"role",r.role),p="listbox"===d||"tree"===d||"grid"===d,[m,h]=(0,R.useState)(!1),v=e.useState("contentElement");H(()=>{if(!u)return;let e=a.current;if(!e||v!==e)return;let t=()=>{h(!!e.querySelector("[role='listbox']"))},r=new MutationObserver(t);return r.observe(e,{subtree:!0,childList:!0,attributeFilter:["role"]}),t(),()=>r.disconnect()},[u,v]),m||(r={role:"listbox","aria-multiselectable":p&&f||void 0,...r}),r=Y(r,t=>(0,eo.jsx)(te,{value:e,children:(0,eo.jsx)(e5.Provider,{value:d,children:t})}),[e,d]);let g=!l||n&&o?null:e.setContentElement;return T(r={id:l,hidden:s,...r,ref:K(g,a,r.ref),style:c})}),tU=ea(function(e){return eu("div",tN(e))});e.s(["ComboboxList",()=>tU,"useComboboxList",()=>tN],86447);var tq=(0,R.createContext)(null),tV=es(function(e){return{...e,style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px",...e.style}}});ea(function(e){return eu("span",tV(e))});var tH=es(function(e){return tV(e={"data-focus-trap":"",tabIndex:0,"aria-hidden":!0,...e,style:{position:"fixed",top:0,left:0,...e.style}})}),tW=ea(function(e){return eu("span",tH(e))});function tK(e){queueMicrotask(()=>{null==e||e.focus()})}var tz=es(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:r,portalRef:i,portal:o=!0,...a}){let l=(0,R.useRef)(null),u=K(l,a.ref),s=(0,R.useContext)(tq),[c,f]=(0,R.useState)(null),[d,p]=(0,R.useState)(null),m=(0,R.useRef)(null),h=(0,R.useRef)(null),v=(0,R.useRef)(null),g=(0,R.useRef)(null);return H(()=>{let e=l.current;if(!e||!o)return void f(null);let t=r?"function"==typeof r?r(e):r:n(e).createElement("div");if(!t)return void f(null);let a=t.isConnected;if(a||(s||n(e).body).appendChild(t),t.id||(t.id=e.id?`portal/${e.id}`:function(e="id"){return`${e?`${e}-`:""}${Math.random().toString(36).slice(2,8)}`}()),f(t),O(i,t),!a)return()=>{t.remove(),O(i,null)}},[o,r,s,i]),H(()=>{if(!o||!e||!t)return;let r=n(t).createElement("span");return r.style.position="fixed",t.insertAdjacentElement("afterend",r),p(r),()=>{r.remove(),p(null)}},[o,e,t]),(0,R.useEffect)(()=>{if(!c||!e)return;let t=0,r=e=>{if(!k(e))return;let r="focusin"===e.type;if(cancelAnimationFrame(t),r){let e=c.querySelectorAll("[data-tabindex]"),t=e=>{let t=e.getAttribute("data-tabindex");e.removeAttribute("data-tabindex"),t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")};for(let r of(c.hasAttribute("data-tabindex")&&t(c),e))t(r);return}t=requestAnimationFrame(()=>{for(let e of ew(c,!0))!function(e){var t;let r=null!=(t=e.getAttribute("tabindex"))?t:"";e.setAttribute("data-tabindex",r),e.setAttribute("tabindex","-1")}(e)})};return c.addEventListener("focusin",r,!0),c.addEventListener("focusout",r,!0),()=>{cancelAnimationFrame(t),c.removeEventListener("focusin",r,!0),c.removeEventListener("focusout",r,!0)}},[c,e]),a={...a=Y(a,t=>{if(t=(0,eo.jsx)(tq.Provider,{value:c||s,children:t}),!o)return t;if(!c)return(0,eo.jsx)("span",{ref:u,id:a.id,style:{position:"fixed"},hidden:!0});t=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tW,{ref:h,"data-focus-trap":a.id,className:"__focus-trap-inner-before",onFocus:e=>{k(e,c)?tK(e_()):tK(m.current)}}),t,e&&c&&(0,eo.jsx)(tW,{ref:v,"data-focus-trap":a.id,className:"__focus-trap-inner-after",onFocus:e=>{k(e,c)?tK(eT()):tK(g.current)}})]}),c&&(t=(0,tP.createPortal)(t,c));let r=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tW,{ref:m,"data-focus-trap":a.id,className:"__focus-trap-outer-before",onFocus:e=>{e.relatedTarget!==g.current&&k(e,c)?tK(h.current):tK(eT())}}),e&&(0,eo.jsx)("span",{"aria-owns":null==c?void 0:c.id,style:{position:"fixed"}}),e&&c&&(0,eo.jsx)(tW,{ref:g,"data-focus-trap":a.id,className:"__focus-trap-outer-after",onFocus:e=>{if(k(e,c))tK(v.current);else{let e=e_();if(e===h.current)return void requestAnimationFrame(()=>{var e;return null==(e=e_())?void 0:e.focus()});tK(e)}}})]});return d&&e&&(r=(0,tP.createPortal)(r,d)),(0,eo.jsxs)(eo.Fragment,{children:[r,t]})},[c,s,o,a.id,e,d]),ref:u}});ea(function(e){return eu("div",tz(e))});var tQ=(0,R.createContext)(0);function t$({level:e,children:t}){let r=(0,R.useContext)(tQ),n=Math.max(Math.min(e||r+1,6),1);return(0,eo.jsx)(tQ.Provider,{value:n,children:t})}var tX=es(function({autoFocusOnShow:e=!0,...t}){return Y(t,t=>(0,eo.jsx)(eS.Provider,{value:e,children:t}),[e])});ea(function(e){return eu("div",tX(e))});var tY=new WeakMap;function tZ(e,t,r){tY.has(e)||tY.set(e,new Map);let n=tY.get(e),i=n.get(t);if(!i)return n.set(t,r()),()=>{var e;null==(e=n.get(t))||e(),n.delete(t)};let o=r(),a=()=>{o(),i(),n.delete(t)};return n.set(t,a),()=>{n.get(t)===a&&(o(),n.set(t,i))}}function tJ(e,t,r){return tZ(e,t,()=>{let n=e.getAttribute(t);return e.setAttribute(t,r),()=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)}})}function t0(e,t,r){return tZ(e,t,()=>{let n=t in e,i=e[t];return e[t]=r,()=>{n?e[t]=i:delete e[t]}})}function t1(e,t){return e?tZ(e,"style",()=>{let r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}):()=>{}}var t2=["SCRIPT","STYLE"];function t3(e){return`__ariakit-dialog-snapshot-${e}`}function t5(e,t,r,i){for(let o of t){if(!(null==o?void 0:o.isConnected))continue;let l=t.some(e=>!!e&&e!==o&&e.contains(o)),u=n(o),s=o;for(;o.parentElement&&o!==u.body;){if(null==i||i(o.parentElement,s),!l)for(let i of o.parentElement.children)(function(e,t,r){return!t2.includes(t.tagName)&&!!function(e,t){let r=n(t),i=t3(e);if(!r.body[i])return!0;for(;;){if(t===r.body)return!1;if(t[i])return!0;if(!t.parentElement)return!1;t=t.parentElement}}(e,t)&&!r.some(e=>e&&a(t,e))})(e,i,t)&&r(i,s);o=o.parentElement}}}function t4(e,...t){if(!e)return!1;let r=e.getAttribute("data-backdrop");return null!=r&&(""===r||"true"===r||!t.length||t.some(e=>r===e))}function t8(e="",t=!1){return`__ariakit-dialog-${t?"ancestor":"outside"}${e?`-${e}`:""}`}function t6(e,t=""){return x(t0(e,t8("",!0),!0),t0(e,t8(t,!0),!0))}function t9(e,t){if(e[t8(t,!0)])return!0;let r=t8(t);for(;;){if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}}function t7(e,t){let r=[],n=t.map(e=>null==e?void 0:e.id);return t5(e,t,t=>{t4(t,...n)||r.unshift(function(e,t=""){return x(t0(e,t8(),!0),t0(e,t8(t),!0))}(t,e))},(t,n)=>{n.hasAttribute("data-dialog")&&n.id!==e||r.unshift(t6(t,e))}),()=>{for(let e of r)e()}}function re({store:e,type:t,listener:r,capture:i,domReady:o}){let l=W(r),u=t_(e,"open"),s=(0,R.useRef)(!1);H(()=>{if(!u||!o)return;let{contentElement:t}=e.getState();if(!t)return;let r=()=>{s.current=!0};return t.addEventListener("focusin",r,!0),()=>t.removeEventListener("focusin",r,!0)},[e,u,o]),(0,R.useEffect)(()=>{if(u)return N(t,t=>{let{contentElement:r,disclosureElement:i}=e.getState(),o=t.target;!r||!o||!(!("HTML"===o.tagName||a(n(o).body,o))||a(r,o)||function(e,t){if(!e)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");if(r){let t=n(e).getElementById(r);if(t)return a(e,t)}return!1}(i,o)||o.hasAttribute("data-focus-trap")||function(e,t){if(!("clientY"in e))return!1;let r=t.getBoundingClientRect();return 0!==r.width&&0!==r.height&&r.top<=e.clientY&&e.clientY<=r.top+r.height&&r.left<=e.clientX&&e.clientX<=r.left+r.width}(t,r))&&(!s.current||t9(o,r.id))&&(o&&o[eL]||l(t))},i)},[u,i])}function rt(e,t){return"function"==typeof e?e(t):!!e}var rr=(0,R.createContext)({});function rn(){return"inert"in HTMLElement.prototype}function ri(e,t){if(!("style"in e))return S;if(rn())return t0(e,"inert",!0);let r=ew(e,!0).map(e=>{if(null==t?void 0:t.some(t=>t&&a(t,e)))return S;let r=tZ(e,"focus",()=>(e.focus=S,()=>{delete e.focus}));return x(tJ(e,"tabindex","-1"),r)});return x(...r,tJ(e,"aria-hidden","true"),t1(e,{pointerEvents:"none",userSelect:"none",cursor:"default"}))}function ro(e={}){let t=tf(e.store,tc(e.disclosure,["contentElement","disclosureElement"]));td(e,t);let r=null==t?void 0:t.getState(),n=M(e.open,null==r?void 0:r.open,e.defaultOpen,!1),i=M(e.animated,null==r?void 0:r.animated,!1),o=ti({open:n,animated:i,animating:!!i&&n,mounted:n,contentElement:M(null==r?void 0:r.contentElement,null),disclosureElement:M(null==r?void 0:r.disclosureElement,null)},t);return to(o,()=>tu(o,["animated","animating"],e=>{e.animated||o.setState("animating",!1)})),to(o,()=>tl(o,["open"],()=>{o.getState().animated&&o.setState("animating",!0)})),to(o,()=>tu(o,["open","animating"],e=>{o.setState("mounted",e.open||e.animating)})),{...o,disclosure:e.disclosure,setOpen:e=>o.setState("open",e),show:()=>o.setState("open",!0),hide:()=>o.setState("open",!1),toggle:()=>o.setState("open",e=>!e),stopAnimation:()=>o.setState("animating",!1),setContentElement:e=>o.setState("contentElement",e),setDisclosureElement:e=>o.setState("disclosureElement",e)}}function ra(e,t,r){return Q(t,[r.store,r.disclosure]),tM(e,r,"open","setOpen"),tM(e,r,"mounted","setMounted"),tM(e,r,"animated"),Object.assign(e,{disclosure:r.disclosure})}es(function(e){return e});var rl=ea(function(e){return eu("div",e)});function ru({store:e,backdrop:t,alwaysVisible:r,hidden:n}){let i=(0,R.useRef)(null),o=function(e={}){let[t,r]=tR(ro,e);return ra(t,r,e)}({disclosure:e}),a=t_(e,"contentElement");(0,R.useEffect)(()=>{let e=i.current;!e||a&&(e.style.zIndex=getComputedStyle(a).zIndex)},[a]),H(()=>{let e=null==a?void 0:a.id;if(!e)return;let t=i.current;if(t)return t6(t,e)},[a]);let l=tk({ref:i,store:o,role:"presentation","data-backdrop":(null==a?void 0:a.id)||"",alwaysVisible:r,hidden:null!=n?n:void 0,style:{position:"fixed",top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,R.isValidElement)(t))return(0,eo.jsx)(rl,{...l,render:t});let u="boolean"!=typeof t?t:"div";return(0,eo.jsx)(rl,{...l,render:(0,eo.jsx)(u,{})})}function rs(e={}){return ro(e)}Object.assign(rl,["a","button","details","dialog","div","form","h1","h2","h3","h4","h5","h6","header","img","input","label","li","nav","ol","p","section","select","span","summary","textarea","ul","svg"].reduce((e,t)=>(e[t]=ea(function(e){return eu(t,e)}),e),{}));var rc=L();function rf(e,t=!1){if(!e)return null;let r="current"in e?e.current:e;return r?t?ex(r)?r:null:r:null}var rd=es(function({store:e,open:t,onClose:l,focusable:s=!0,modal:f=!0,portal:d=!!f,backdrop:p=!!f,hideOnEscape:m=!0,hideOnInteractOutside:h=!0,getPersistentElements:v,preventBodyScroll:g=!!f,autoFocusOnShow:y=!0,autoFocusOnHide:b=!0,initialFocus:S,finalFocus:C,unmountOnHide:E,unstable_treeSnapshotKey:A,...w}){var _;let T,M,O,L=eQ(),P=(0,R.useRef)(null),D=function(e={}){let[t,r]=tR(rs,e);return ra(t,r,e)}({store:e||L,open:t,setOpen(e){if(e)return;let t=P.current;if(!t)return;let r=new Event("close",{bubbles:!1,cancelable:!0});l&&t.addEventListener("close",l,{once:!0}),t.dispatchEvent(r),r.defaultPrevented&&D.setOpen(!0)}}),{portalRef:B,domReady:G}=Z(d,w.portalRef),k=w.preserveTabOrder,U=t_(D,e=>k&&!f&&e.mounted),q=z(w.id),V=t_(D,"open"),Q=t_(D,"mounted"),J=t_(D,"contentElement"),ee=tG(Q,w.hidden,w.alwaysVisible);T=function({attribute:e,contentId:t,contentElement:r,enabled:i}){let[o,a]=$(),l=(0,R.useCallback)(()=>{if(!i||!r)return!1;let{body:o}=n(r),a=o.getAttribute(e);return!a||a===t},[o,i,r,e,t]);return(0,R.useEffect)(()=>{if(!i||!t||!r)return;let{body:o}=n(r);if(l())return o.setAttribute(e,t),()=>o.removeAttribute(e);let u=new MutationObserver(()=>(0,tP.flushSync)(a));return u.observe(o,{attributeFilter:[e]}),()=>u.disconnect()},[o,i,t,r,l,e]),l}({attribute:"data-dialog-prevent-body-scroll",contentElement:J,contentId:q,enabled:g&&!ee}),(0,R.useEffect)(()=>{var e,t;if(!T()||!J)return;let o=n(J),a=i(J),{documentElement:l,body:u}=o,s=l.style.getPropertyValue("--scrollbar-width"),c=s?Number.parseInt(s,10):a.innerWidth-l.clientWidth,f=Math.round(l.getBoundingClientRect().left)+l.scrollLeft?"paddingLeft":"paddingRight",d=F()&&!(r&&navigator.platform.startsWith("Mac")&&!I());return x((e="--scrollbar-width",t=`${c}px`,l?tZ(l,e,()=>{let r=l.style.getPropertyValue(e);return l.style.setProperty(e,t),()=>{r?l.style.setProperty(e,r):l.style.removeProperty(e)}}):()=>{}),d?(()=>{var e,t;let{scrollX:r,scrollY:n,visualViewport:i}=a,o=null!=(e=null==i?void 0:i.offsetLeft)?e:0,l=null!=(t=null==i?void 0:i.offsetTop)?t:0,s=t1(u,{position:"fixed",overflow:"hidden",top:`${-(n-Math.floor(l))}px`,left:`${-(r-Math.floor(o))}px`,right:"0",[f]:`${c}px`});return()=>{s(),a.scrollTo({left:r,top:n,behavior:"instant"})}})():t1(u,{overflow:"hidden",[f]:`${c}px`}))},[T,J]),_=t_(D,"open"),M=(0,R.useRef)(null),(0,R.useEffect)(()=>{if(!_){M.current=null;return}return N("mousedown",e=>{M.current=e.target},!0)},[_]),re({...O={store:D,domReady:G,capture:!0},type:"click",listener:e=>{let{contentElement:t}=D.getState(),r=M.current;r&&c(r)&&t9(r,null==t?void 0:t.id)&&rt(h,e)&&D.hide()}}),re({...O,type:"focusin",listener:e=>{let{contentElement:t}=D.getState();!t||e.target===n(t)||rt(h,e)&&D.hide()}}),re({...O,type:"contextmenu",listener:e=>{rt(h,e)&&D.hide()}});let{wrapElement:et,nestedDialogs:er}=function(e){let t=(0,R.useContext)(rr),[r,n]=(0,R.useState)([]),i=(0,R.useCallback)(e=>{var r;return n(t=>[...t,e]),x(null==(r=t.add)?void 0:r.call(t,e),()=>{n(t=>t.filter(t=>t!==e))})},[t]);H(()=>tu(e,["open","contentElement"],r=>{var n;if(r.open&&r.contentElement)return null==(n=t.add)?void 0:n.call(t,e)}),[e,t]);let o=(0,R.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,R.useCallback)(e=>(0,eo.jsx)(rr.Provider,{value:o,children:e}),[o]),nestedDialogs:r}}(D);w=Y(w,et,[et]),H(()=>{if(!V)return;let e=P.current,t=o(e,!0);!t||"BODY"===t.tagName||e&&a(e,t)||D.setDisclosureElement(t)},[D,V]),rc&&(0,R.useEffect)(()=>{if(!Q)return;let{disclosureElement:e}=D.getState();if(!e||!u(e))return;let t=()=>{let t=!1,r=()=>{t=!0};e.addEventListener("focusin",r,{capture:!0,once:!0}),j(e,"mouseup",()=>{e.removeEventListener("focusin",r,!0),t||eO(e)})};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},[D,Q]),(0,R.useEffect)(()=>{if(!Q||!G)return;let e=P.current;if(!e)return;let t=i(e),r=t.visualViewport||t,n=()=>{var r,n;let i=null!=(n=null==(r=t.visualViewport)?void 0:r.height)?n:t.innerHeight;e.style.setProperty("--dialog-viewport-height",`${i}px`)};return n(),r.addEventListener("resize",n),()=>{r.removeEventListener("resize",n)}},[Q,G]),(0,R.useEffect)(()=>{if(!f||!Q||!G)return;let e=P.current;if(e&&!e.querySelector("[data-dialog-dismiss]")){var t;let r;return t=D.hide,(r=n(e).createElement("button")).type="button",r.tabIndex=-1,r.textContent="Dismiss popup",Object.assign(r.style,{border:"0px",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0px",position:"absolute",whiteSpace:"nowrap",width:"1px"}),r.addEventListener("click",t),e.prepend(r),()=>{r.removeEventListener("click",t),r.remove()}}},[D,f,Q,G]),H(()=>{if(!rn()||V||!Q||!G)return;let e=P.current;if(e)return ri(e)},[V,Q,G]);let en=V&&G;H(()=>{if(q&&en)return function(e,t){let{body:r}=n(t[0]),i=[];return t5(e,t,t=>{i.push(t0(t,t3(e),!0))}),x(t0(r,t3(e),!0),()=>{for(let e of i)e()})}(q,[P.current])},[q,en,A]);let ei=W(v);H(()=>{if(!q||!en)return;let{disclosureElement:e}=D.getState(),t=[P.current,...ei()||[],...er.map(e=>e.getState().contentElement)];if(f){let e,r;return x(t7(q,t),(e=[],r=t.map(e=>null==e?void 0:e.id),t5(q,t,n=>{t4(n,...r)||!function(e,...t){if(!e)return!1;let r=e.getAttribute("data-focus-trap");return null!=r&&(!t.length||""!==r&&t.some(e=>r===e))}(n,...r)&&e.unshift(ri(n,t))},r=>{!r.hasAttribute("role")||t.some(e=>e&&a(e,r))||e.unshift(tJ(r,"role","none"))}),()=>{for(let t of e)t()}))}return t7(q,[e,...t])},[q,D,en,ei,er,f,A]);let ea=!!y,el=X(y),[eu,es]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(!V||!ea||!G||!(null==J?void 0:J.isConnected))return;let e=rf(S,!0)||J.querySelector("[data-autofocus=true],[autofocus]")||function(e,t,r){let[n]=ew(e,t,r);return n||null}(J,!0,d&&U)||J,t=ex(e);el(t?e:null)&&(es(!0),queueMicrotask(()=>{e.focus(),!rc||t&&e.scrollIntoView({block:"nearest",inline:"nearest"})}))},[V,ea,G,J,S,d,U,el]);let ec=!!b,ef=X(b),[ed,ep]=(0,R.useState)(!1);(0,R.useEffect)(()=>{if(V)return ep(!0),()=>ep(!1)},[V]);let em=(0,R.useCallback)((e,t=!0)=>{let r,{disclosureElement:i}=D.getState();if(!(!(r=o())||e&&a(e,r))&&ex(r))return;let l=rf(C)||i;if(null==l?void 0:l.id){let e=n(l),t=`[aria-activedescendant="${l.id}"]`,r=e.querySelector(t);r&&(l=r)}if(l&&!ex(l)){let e=l.closest("[data-dialog]");if(null==e?void 0:e.id){let t=n(e),r=`[aria-controls~="${e.id}"]`,i=t.querySelector(r);i&&(l=i)}}let u=l&&ex(l);!u&&t?requestAnimationFrame(()=>em(e,!1)):!ef(u?l:null)||u&&(null==l||l.focus({preventScroll:!0}))},[D,C,ef]),eh=(0,R.useRef)(!1);H(()=>{if(V||!ed||!ec)return;let e=P.current;eh.current=!0,em(e)},[V,ed,G,ec,em]),(0,R.useEffect)(()=>{if(!ed||!ec)return;let e=P.current;return()=>{if(eh.current){eh.current=!1;return}em(e)}},[ed,ec,em]);let ev=X(m);(0,R.useEffect)(()=>{if(G&&Q)return N("keydown",e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=P.current;if(!t||t9(t))return;let r=e.target;if(!r)return;let{disclosureElement:n}=D.getState();!("BODY"===r.tagName||a(t,r)||!n||a(n,r))||ev(e)&&D.hide()},!0)},[D,G,Q,ev]);let eg=(w=Y(w,e=>(0,eo.jsx)(t$,{level:f?1:void 0,children:e}),[f])).hidden,ey=w.alwaysVisible;w=Y(w,e=>p?(0,eo.jsxs)(eo.Fragment,{children:[(0,eo.jsx)(ru,{store:D,backdrop:p,hidden:eg,alwaysVisible:ey}),e]}):e,[D,p,eg,ey]);let[eb,eS]=(0,R.useState)(),[eC,eE]=(0,R.useState)();return w=tX({...w={id:q,"data-dialog":"",role:"dialog",tabIndex:s?-1:void 0,"aria-labelledby":eb,"aria-describedby":eC,...w=Y(w,e=>(0,eo.jsx)(eX,{value:D,children:(0,eo.jsx)(eY.Provider,{value:eS,children:(0,eo.jsx)(eZ.Provider,{value:eE,children:e})})}),[D]),ref:K(P,w.ref)},autoFocusOnShow:eu}),w=tz({portal:d,...w=eN({...w=tk({store:D,...w}),focusable:s}),portalRef:B,preserveTabOrder:U})});function rp(e,t=eQ){return ea(function(r){let n=t();return t_(r.store||n,e=>!r.unmountOnHide||(null==e?void 0:e.mounted)||!!r.open)?(0,eo.jsx)(e,{...r}):null})}rp(ea(function(e){return eu("div",rd(e))}),eQ);let rm=Math.min,rh=Math.max,rv=Math.round,rg=Math.floor,ry=e=>({x:e,y:e}),rb={left:"right",right:"left",bottom:"top",top:"bottom"},rS={start:"end",end:"start"};function rC(e,t){return"function"==typeof e?e(t):e}function rx(e){return e.split("-")[0]}function rE(e){return e.split("-")[1]}function rA(e){return"x"===e?"y":"x"}function rw(e){return"y"===e?"height":"width"}let r_=new Set(["top","bottom"]);function rT(e){return r_.has(rx(e))?"y":"x"}function rM(e){return e.replace(/start|end/g,e=>rS[e])}let rR=["left","right"],rO=["right","left"],rI=["top","bottom"],rF=["bottom","top"];function rL(e){return e.replace(/left|right|bottom|top/g,e=>rb[e])}function rP(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function rD(e){let{x:t,y:r,width:n,height:i}=e;return{width:n,height:i,top:r,left:t,right:t+n,bottom:r+i,x:t,y:r}}function rB(e,t,r){let n,{reference:i,floating:o}=e,a=rT(t),l=rA(rT(t)),u=rw(l),s=rx(t),c="y"===a,f=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,p=i[u]/2-o[u]/2;switch(s){case"top":n={x:f,y:i.y-o.height};break;case"bottom":n={x:f,y:i.y+i.height};break;case"right":n={x:i.x+i.width,y:d};break;case"left":n={x:i.x-o.width,y:d};break;default:n={x:i.x,y:i.y}}switch(rE(t)){case"start":n[l]-=p*(r&&c?-1:1);break;case"end":n[l]+=p*(r&&c?-1:1)}return n}async function rG(e,t){var r;void 0===t&&(t={});let{x:n,y:i,platform:o,rects:a,elements:l,strategy:u}=e,{boundary:s="clippingAncestors",rootBoundary:c="viewport",elementContext:f="floating",altBoundary:d=!1,padding:p=0}=rC(t,e),m=rP(p),h=l[d?"floating"===f?"reference":"floating":f],v=rD(await o.getClippingRect({element:null==(r=await (null==o.isElement?void 0:o.isElement(h)))||r?h:h.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(l.floating)),boundary:s,rootBoundary:c,strategy:u})),g="floating"===f?{x:n,y:i,width:a.floating.width,height:a.floating.height}:a.reference,y=await (null==o.getOffsetParent?void 0:o.getOffsetParent(l.floating)),b=await (null==o.isElement?void 0:o.isElement(y))&&await (null==o.getScale?void 0:o.getScale(y))||{x:1,y:1},S=rD(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:g,offsetParent:y,strategy:u}):g);return{top:(v.top-S.top+m.top)/b.y,bottom:(S.bottom-v.bottom+m.bottom)/b.y,left:(v.left-S.left+m.left)/b.x,right:(S.right-v.right+m.right)/b.x}}let rk=async(e,t,r)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:a}=r,l=o.filter(Boolean),u=await (null==a.isRTL?void 0:a.isRTL(t)),s=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:f}=rB(s,n,u),d=n,p={},m=0;for(let r=0;rtypeof window}function rq(e){return rW(e)?(e.nodeName||"").toLowerCase():"#document"}function rV(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function rH(e){var t;return null==(t=(rW(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function rW(e){return!!rU()&&(e instanceof Node||e instanceof rV(e).Node)}function rK(e){return!!rU()&&(e instanceof Element||e instanceof rV(e).Element)}function rz(e){return!!rU()&&(e instanceof HTMLElement||e instanceof rV(e).HTMLElement)}function rQ(e){return!(!rU()||"u"{try{return e.matches(t)}catch(e){return!1}})}let r0=["transform","translate","scale","rotate","perspective"],r1=["transform","translate","scale","rotate","perspective","filter"],r2=["paint","layout","strict","content"];function r3(e){let t=r5(),r=rK(e)?r6(e):e;return r0.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||r1.some(e=>(r.willChange||"").includes(e))||r2.some(e=>(r.contain||"").includes(e))}function r5(){return!("u"rK(e)&&"body"!==rq(e)),i=null,o="fixed"===r6(e).position,a=o?r7(e):e;for(;rK(a)&&!r8(a);){let t=r6(a),r=r3(a);r||"fixed"!==t.position||(i=null),(o?!r&&!i:!r&&"static"===t.position&&!!i&&nc.has(i.position)||rX(a)&&!r&&function e(t,r){let n=r7(t);return!(n===r||!rK(n)||r8(n))&&("fixed"===r6(n).position||e(n,r))}(e,a))?n=n.filter(e=>e!==a):i=t,a=r7(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=o[0],l=o.reduce((e,r)=>{let n=nf(t,r,i);return e.top=rh(n.top,e.top),e.right=rm(n.right,e.right),e.bottom=rm(n.bottom,e.bottom),e.left=rh(n.left,e.left),e},nf(t,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}},getOffsetParent:nm,getElementRects:nh,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:r}=nr(e);return{width:t,height:r}},getScale:ni,isElement:rK,isRTL:function(e){return"rtl"===r6(e).direction}};function ng(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ny(e=0,t=0,r=0,n=0){if("function"==typeof DOMRect)return new DOMRect(e,t,r,n);let i={x:e,y:t,width:r,height:n,top:t,right:e+r,bottom:t+n,left:e};return{...i,toJSON:()=>i}}function nb(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function nS(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}var nC=es(function({store:e,modal:t=!1,portal:r=!!t,preserveTabOrder:n=!0,autoFocusOnShow:i=!0,wrapperProps:o,fixed:a=!1,flip:l=!0,shift:u=0,slide:s=!0,overlap:c=!1,sameWidth:f=!1,fitViewport:d=!1,gutter:p,arrowPadding:m=4,overflowPadding:h=8,getAnchorRect:v,updatePosition:g,...y}){let b=e0();A(e=e||b,!1);let S=e.useState("arrowElement"),C=e.useState("anchorElement"),x=e.useState("disclosureElement"),E=e.useState("popoverElement"),w=e.useState("contentElement"),_=e.useState("placement"),T=e.useState("mounted"),M=e.useState("rendered"),O=(0,R.useRef)(null),[I,F]=(0,R.useState)(!1),{portalRef:L,domReady:P}=Z(r,y.portalRef),D=W(v),B=W(g),G=!!g;H(()=>{if(!(null==E?void 0:E.isConnected))return;E.style.setProperty("--popover-overflow-padding",`${h}px`);let t={contextElement:C||void 0,getBoundingClientRect:()=>{let e=null==D?void 0:D(C);return e||!C?function(e){if(!e)return ny();let{x:t,y:r,width:n,height:i}=e;return ny(t,r,n,i)}(e):C.getBoundingClientRect()}},r=async()=>{var r,n,i,o,v;let g,y,b;if(!T)return;S||(O.current=O.current||document.createElement("div"));let C=S||O.current,x=[(r={gutter:p,shift:u},void 0===(n=({placement:e})=>{var t;let n=((null==C?void 0:C.clientHeight)||0)/2,i="number"==typeof r.gutter?r.gutter+n:null!=(t=r.gutter)?t:n;return{crossAxis:e.split("-")[1]?void 0:r.shift,mainAxis:i,alignmentAxis:r.shift}})&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:a,middlewareData:l}=e,u=await rN(e,n);return a===(null==(t=l.offset)?void 0:t.placement)&&null!=(r=l.arrow)&&r.alignmentOffset?{}:{x:i+u.x,y:o+u.y,data:{...u,placement:a}}}}),function(e){var t;if(!1===e.flip)return;let r="string"==typeof e.flip?e.flip.split(" "):void 0;return A(!r||r.every(nb),!1),{name:"flip",options:t={padding:e.overflowPadding,fallbackPlacements:r},async fn(e){var r,n,i,o,a,l,u,s;let c,f,d,{placement:p,middlewareData:m,rects:h,initialPlacement:v,platform:g,elements:y}=e,{mainAxis:b=!0,crossAxis:S=!0,fallbackPlacements:C,fallbackStrategy:x="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:A=!0,...w}=rC(t,e);if(null!=(r=m.arrow)&&r.alignmentOffset)return{};let _=rx(p),T=rT(v),M=rx(v)===v,R=await (null==g.isRTL?void 0:g.isRTL(y.floating)),O=C||(M||!A?[rL(v)]:(c=rL(v),[rM(v),c,rM(c)])),I="none"!==E;!C&&I&&O.push(...(f=rE(v),d=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?rO:rR;return t?rR:rO;case"left":case"right":return t?rI:rF;default:return[]}}(rx(v),"start"===E,R),f&&(d=d.map(e=>e+"-"+f),A&&(d=d.concat(d.map(rM)))),d));let F=[v,...O],L=await g.detectOverflow(e,w),P=[],D=(null==(n=m.flip)?void 0:n.overflows)||[];if(b&&P.push(L[_]),S){let e,t,r,n,i=(l=p,u=h,void 0===(s=R)&&(s=!1),e=rE(l),r=rw(t=rA(rT(l))),n="x"===t?e===(s?"end":"start")?"right":"left":"start"===e?"bottom":"top",u.reference[r]>u.floating[r]&&(n=rL(n)),[n,rL(n)]);P.push(L[i[0]],L[i[1]])}if(D=[...D,{placement:p,overflows:P}],!P.every(e=>e<=0)){let e=((null==(i=m.flip)?void 0:i.index)||0)+1,t=F[e];if(t&&("alignment"!==S||T===rT(t)||D.every(e=>rT(e.placement)!==T||e.overflows[0]>0)))return{data:{index:e,overflows:D},reset:{placement:t}};let r=null==(o=D.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:o.placement;if(!r)switch(x){case"bestFit":{let e=null==(a=D.filter(e=>{if(I){let t=rT(e.placement);return t===T||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:a[0];e&&(r=e);break}case"initialPlacement":r=v}if(p!==r)return{reset:{placement:r}}}return{}}}}({flip:l,overflowPadding:h}),function(e){if(e.slide||e.overlap){var t,r;return{name:"shift",options:r={mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:(void 0===t&&(t={}),{options:t,fn(e){let{x:r,y:n,placement:i,rects:o,middlewareData:a}=e,{offset:l=0,mainAxis:u=!0,crossAxis:s=!0}=rC(t,e),c={x:r,y:n},f=rT(i),d=rA(f),p=c[d],m=c[f],h=rC(l,e),v="number"==typeof h?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(u){let e="y"===d?"height":"width",t=o.reference[d]-o.floating[e]+v.mainAxis,r=o.reference[d]+o.reference[e]-v.mainAxis;pr&&(p=r)}if(s){var g,y;let e="y"===d?"width":"height",t=rj.has(rx(i)),r=o.reference[f]-o.floating[e]+(t&&(null==(g=a.offset)?void 0:g[f])||0)+(t?0:v.crossAxis),n=o.reference[f]+o.reference[e]+(t?0:(null==(y=a.offset)?void 0:y[f])||0)-(t?v.crossAxis:0);mn&&(m=n)}return{[d]:p,[f]:m}}})},async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...s}=rC(r,e),c={x:t,y:n},f=await o.detectOverflow(e,s),d=rT(rx(i)),p=rA(d),m=c[p],h=c[d];if(a){let e="y"===p?"top":"left",t="y"===p?"bottom":"right",r=m+f[e],n=m-f[t];m=rh(r,rm(m,n))}if(l){let e="y"===d?"top":"left",t="y"===d?"bottom":"right",r=h+f[e],n=h-f[t];h=rh(r,rm(h,n))}let v=u.fn({...e,[p]:m,[d]:h});return{...v,data:{x:v.x-t,y:v.y-n,enabled:{[p]:a,[d]:l}}}}}}}({slide:s,shift:u,overlap:c,overflowPadding:h}),function(e,t){if(e){let r;return{name:"arrow",options:r={element:e,padding:t.arrowPadding},async fn(e){let{x:t,y:n,placement:i,rects:o,platform:a,elements:l,middlewareData:u}=e,{element:s,padding:c=0}=rC(r,e)||{};if(null==s)return{};let f=rP(c),d={x:t,y:n},p=rA(rT(i)),m=rw(p),h=await a.getDimensions(s),v="y"===p,g=v?"clientHeight":"clientWidth",y=o.reference[m]+o.reference[p]-d[p]-o.floating[m],b=d[p]-o.reference[p],S=await (null==a.getOffsetParent?void 0:a.getOffsetParent(s)),C=S?S[g]:0;C&&await (null==a.isElement?void 0:a.isElement(S))||(C=l.floating[g]||o.floating[m]);let x=C/2-h[m]/2-1,E=rm(f[v?"top":"left"],x),A=rm(f[v?"bottom":"right"],x),w=C-h[m]-A,_=C/2-h[m]/2+(y/2-b/2),T=rh(E,rm(_,w)),M=!u.arrow&&null!=rE(i)&&_!==T&&o.reference[m]/2-(_{},...f}=rC(o,e),d=await u.detectOverflow(e,f),p=rx(a),m=rE(a),h="y"===rT(a),{width:v,height:g}=l.floating;"top"===p||"bottom"===p?(n=p,i=m===(await (null==u.isRTL?void 0:u.isRTL(s.floating))?"start":"end")?"left":"right"):(i=p,n="end"===m?"top":"bottom");let y=g-d.top-d.bottom,b=v-d.left-d.right,S=rm(g-d[n],y),C=rm(v-d[i],b),x=!e.middlewareData.shift,E=S,A=C;if(null!=(t=e.middlewareData.shift)&&t.enabled.x&&(A=b),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(E=y),x&&!m){let e=rh(d.left,0),t=rh(d.right,0),r=rh(d.top,0),n=rh(d.bottom,0);h?A=v-2*(0!==e||0!==t?e+t:rh(d.left,d.right)):E=g-2*(0!==r||0!==n?r+n:rh(d.top,d.bottom))}await c({...e,availableWidth:A,availableHeight:E});let w=await u.getDimensions(s.floating);return v!==w.width||g!==w.height?{reset:{rects:!0}}:{}}}],w=await (v={placement:_,strategy:a?"fixed":"absolute",middleware:x},g=new Map,b={...(y={platform:nv,...v}).platform,_c:g},rk(t,E,{...y,platform:b}));null==e||e.setState("currentPlacement",w.placement),F(!0);let M=nS(w.x),R=nS(w.y);if(Object.assign(E.style,{top:"0",left:"0",transform:`translate3d(${M}px,${R}px,0)`}),C&&w.middlewareData.arrow){let{x:e,y:t}=w.middlewareData.arrow,r=w.placement.split("-")[0],n=C.clientWidth/2,i=C.clientHeight/2,o=null!=e?e+n:-n,a=null!=t?t+i:-i;E.style.setProperty("--popover-transform-origin",{top:`${o}px calc(100% + ${i}px)`,bottom:`${o}px ${-i}px`,left:`calc(100% + ${n}px) ${a}px`,right:`${-n}px ${a}px`}[r]),Object.assign(C.style,{left:null!=e?`${e}px`:"",top:null!=t?`${t}px`:"",[r]:"100%"})}},n=function(e,t,r,n){let i;void 0===n&&(n={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:u="function"==typeof IntersectionObserver,animationFrame:s=!1}=n,c=nn(e),f=o||a?[...c?ne(c):[],...ne(t)]:[];f.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),a&&e.addEventListener("resize",r)});let d=c&&u?function(e,t){let r,n=null,i=rH(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return!function a(l,u){void 0===l&&(l=!1),void 0===u&&(u=1),o();let s=e.getBoundingClientRect(),{left:c,top:f,width:d,height:p}=s;if(l||t(),!d||!p)return;let m={rootMargin:-rg(f)+"px "+-rg(i.clientWidth-(c+d))+"px "+-rg(i.clientHeight-(f+p))+"px "+-rg(c)+"px",threshold:rh(0,rm(1,u))||1},h=!0;function v(t){let n=t[0].intersectionRatio;if(n!==u){if(!h)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||ng(s,e.getBoundingClientRect())||a(),h=!1}try{n=new IntersectionObserver(v,{...m,root:i.ownerDocument})}catch(e){n=new IntersectionObserver(v,m)}n.observe(e)}(!0),o}(c,r):null,p=-1,m=null;l&&(m=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&m&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var e;null==(e=m)||e.observe(t)})),r()}),c&&!s&&m.observe(c),m.observe(t));let h=s?nl(e):null;return s&&function t(){let n=nl(e);h&&!ng(h,n)&&r(),h=n,i=requestAnimationFrame(t)}(),r(),()=>{var e;f.forEach(e=>{o&&e.removeEventListener("scroll",r),a&&e.removeEventListener("resize",r)}),null==d||d(),null==(e=m)||e.disconnect(),m=null,s&&cancelAnimationFrame(i)}}(t,E,async()=>{G?(await B({updatePosition:r}),F(!0)):await r()},{elementResize:"function"==typeof ResizeObserver});return()=>{F(!1),n()}},[e,M,E,S,C,E,_,T,P,a,l,u,s,c,f,d,p,m,h,D,G,B]),H(()=>{if(!T||!P||!(null==E?void 0:E.isConnected)||!(null==w?void 0:w.isConnected))return;let e=()=>{E.style.zIndex=getComputedStyle(w).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[T,P,E,w]);let k=a?"fixed":"absolute";return y=Y(y,t=>(0,eo.jsx)("div",{...o,style:{position:k,top:0,left:0,width:"max-content",...null==o?void 0:o.style},ref:null==e?void 0:e.setPopoverElement,children:t}),[e,k,o]),y={"data-placing":!I||void 0,...y=Y(y,t=>(0,eo.jsx)(e2,{value:e,children:t}),[e]),style:{position:"relative",...y.style}},y=rd({store:e,modal:t,portal:r,preserveTabOrder:n,preserveTabOrderAnchor:x||C,autoFocusOnShow:I&&i,...y,portalRef:L})});rp(ea(function(e){return eu("div",nC(e))}),e0);var nx=es(function({store:e,modal:t,tabIndex:r,alwaysVisible:i,autoFocusOnHide:o=!0,hideOnInteractOutside:a=!0,...l}){let u=e9();A(e=e||u,!1);let s=e.useState("baseElement"),c=(0,R.useRef)(!1),f=t_(e.tag,e=>null==e?void 0:e.renderedItems.length);return l=tN({store:e,alwaysVisible:i,...l}),l=nC({store:e,modal:t,alwaysVisible:i,backdrop:!1,autoFocusOnShow:!1,finalFocus:s,preserveTabOrderAnchor:null,unstable_treeSnapshotKey:f,...l,getPersistentElements(){var r;let i=(null==(r=l.getPersistentElements)?void 0:r.call(l))||[];if(!t||!e)return i;let{contentElement:o,baseElement:a}=e.getState();if(!a)return i;let u=n(a),s=[];if((null==o?void 0:o.id)&&s.push(`[aria-controls~="${o.id}"]`),(null==a?void 0:a.id)&&s.push(`[aria-controls~="${a.id}"]`),!s.length)return[...i,a];let c=s.join(",");return[...i,...u.querySelectorAll(c)]},autoFocusOnHide:e=>!w(o,e)&&(!c.current||(c.current=!1,!1)),hideOnInteractOutside(t){var r,n;let i=null==e?void 0:e.getState(),o=null==(r=null==i?void 0:i.contentElement)?void 0:r.id,l=null==(n=null==i?void 0:i.baseElement)?void 0:n.id;if(function(e,...t){if(!e)return!1;if("id"in e){let r=t.filter(Boolean).map(e=>`[aria-controls~="${e}"]`).join(", ");return!!r&&e.matches(r)}return!1}(t.target,o,l))return!1;let u="function"==typeof a?a(t):a;return u&&(c.current="click"===t.type),u}})}),nE=rp(ea(function(e){return eu("div",nx(e))}),e9);e.s(["ComboboxPopover",()=>nE],1559),(0,R.createContext)(null),(0,R.createContext)(null);var nA=ec([ev],[eg]),nw=nA.useContext;nA.useScopedContext,nA.useProviderContext,nA.ContextProvider,nA.ScopedContextProvider;var n_={id:null};function nT(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function nM(e,t){return e.filter(e=>e.rowId===t)}function nR(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}function nO(e){let t=0;for(let{length:r}of e)r>t&&(t=r);return t}var nI=L()&&I();function nF({tag:e,...t}={}){let r=tf(t.store,function(e,...t){if(e)return tn(e,"pick")(...t)}(e,["value","rtl"]));td(t,r);let i=null==e?void 0:e.getState(),o=null==r?void 0:r.getState(),a=M(t.activeId,null==o?void 0:o.activeId,t.defaultActiveId,null),l=function(e={}){var t;let r=null==(t=e.store)?void 0:t.getState(),i=function(e={}){var t,r;td(e,e.store);let i=null==(t=e.store)?void 0:t.getState(),o=M(e.items,null==i?void 0:i.items,e.defaultItems,[]),a=new Map(o.map(e=>[e.id,e])),l={items:o,renderedItems:M(null==i?void 0:i.renderedItems,[])},u=null==(r=e.store)?void 0:r.__unstablePrivateStore,s=ti({items:o,renderedItems:l.renderedItems},u),c=ti(l,e.store),f=e=>{var t;let r,n,i=(t=e=>e.element,r=e.map((e,t)=>[t,e]),n=!1,(r.sort(([e,r],[i,o])=>{var a;let l=t(r),u=t(o);return l!==u&&l&&u?(a=l,u.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)?(e>i&&(n=!0),-1):(et):e);s.setState("renderedItems",i),c.setState("renderedItems",i)};to(c,()=>ta(s)),to(s,()=>ts(s,["items"],e=>{c.setState("items",e.items)})),to(s,()=>ts(s,["renderedItems"],e=>{let t=!0,r=requestAnimationFrame(()=>{let{renderedItems:t}=c.getState();e.renderedItems!==t&&f(e.renderedItems)});if("function"!=typeof IntersectionObserver)return()=>cancelAnimationFrame(r);let i=new IntersectionObserver(()=>{if(t){t=!1;return}cancelAnimationFrame(r),r=requestAnimationFrame(()=>f(e.renderedItems))},{root:function(e){var t;let r=e.find(e=>!!e.element),i=[...e].reverse().find(e=>!!e.element),o=null==(t=null==r?void 0:r.element)?void 0:t.parentElement;for(;o&&(null==i?void 0:i.element);){let e=o;if(i&&e.contains(i.element))return o;o=o.parentElement}return n(o).body}(e.renderedItems)});for(let t of e.renderedItems)t.element&&i.observe(t.element);return()=>{cancelAnimationFrame(r),i.disconnect()}}));let d=(e,t,r=!1)=>{let n;return t(t=>{let r=t.findIndex(({id:t})=>t===e.id),i=t.slice();if(-1!==r){let o={...n=t[r],...e};i[r]=o,a.set(e.id,o)}else i.push(e),a.set(e.id,e);return i}),()=>{t(t=>{if(!n)return r&&a.delete(e.id),t.filter(({id:t})=>t!==e.id);let i=t.findIndex(({id:t})=>t===e.id);if(-1===i)return t;let o=t.slice();return o[i]=n,a.set(e.id,n),o})}},p=e=>d(e,e=>s.setState("items",e),!0);return{...c,registerItem:p,renderItem:e=>x(p(e),d(e,e=>s.setState("renderedItems",e))),item:e=>{if(!e)return null;let t=a.get(e);if(!t){let{items:r}=s.getState();(t=r.find(t=>t.id===e))&&a.set(e,t)}return t||null},__unstablePrivateStore:s}}(e),o=M(e.activeId,null==r?void 0:r.activeId,e.defaultActiveId),a=ti({...i.getState(),id:M(e.id,null==r?void 0:r.id,`id-${Math.random().toString(36).slice(2,8)}`),activeId:o,baseElement:M(null==r?void 0:r.baseElement,null),includesBaseElement:M(e.includesBaseElement,null==r?void 0:r.includesBaseElement,null===o),moves:M(null==r?void 0:r.moves,0),orientation:M(e.orientation,null==r?void 0:r.orientation,"both"),rtl:M(e.rtl,null==r?void 0:r.rtl,!1),virtualFocus:M(e.virtualFocus,null==r?void 0:r.virtualFocus,!1),focusLoop:M(e.focusLoop,null==r?void 0:r.focusLoop,!1),focusWrap:M(e.focusWrap,null==r?void 0:r.focusWrap,!1),focusShift:M(e.focusShift,null==r?void 0:r.focusShift,!1)},i,e.store);to(a,()=>tu(a,["renderedItems","activeId"],e=>{a.setState("activeId",t=>{var r;return void 0!==t?t:null==(r=nT(e.renderedItems))?void 0:r.id})}));let l=(e="next",t={})=>{var r,n;let i=a.getState(),{skip:o=0,activeId:l=i.activeId,focusShift:u=i.focusShift,focusLoop:s=i.focusLoop,focusWrap:c=i.focusWrap,includesBaseElement:f=i.includesBaseElement,renderedItems:d=i.renderedItems,rtl:p=i.rtl}=t,m="up"===e||"down"===e,h="next"===e||"down"===e,v=m?eU(function(e,t,r){let n=nO(e);for(let i of e)for(let e=0;ee.id===l);if(!g)return null==(n=nT(v))?void 0:n.id;let y=v.some(e=>e.rowId),b=v.indexOf(g),S=v.slice(b+1),C=nM(S,g.rowId);if(o){let e=C.filter(e=>l?!e.disabled&&e.id!==l:!e.disabled),t=e.slice(o)[0]||e[e.length-1];return null==t?void 0:t.id}let x=s&&(m?"horizontal"!==s:"vertical"!==s),E=y&&c&&(m?"horizontal"!==c:"vertical"!==c),A=h?(!y||m)&&x&&f:!!m&&f;if(x){let e=nT(function(e,t,r=!1){let n=e.findIndex(e=>e.id===t);return[...e.slice(n+1),...r?[n_]:[],...e.slice(0,n)]}(E&&!A?v:nM(v,g.rowId),l,A),l);return null==e?void 0:e.id}if(E){let e=nT(A?C:S,l);return A?(null==e?void 0:e.id)||null:null==e?void 0:e.id}let w=nT(C,l);return!w&&A?null:null==w?void 0:w.id};return{...i,...a,setBaseElement:e=>a.setState("baseElement",e),setActiveId:e=>a.setState("activeId",e),move:e=>{void 0!==e&&(a.setState("activeId",e),a.setState("moves",e=>e+1))},first:()=>{var e;return null==(e=nT(a.getState().renderedItems))?void 0:e.id},last:()=>{var e;return null==(e=nT(eq(a.getState().renderedItems)))?void 0:e.id},next:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("next",e)),previous:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("previous",e)),down:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("down",e)),up:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),l("up",e))}}({...t,activeId:a,includesBaseElement:M(t.includesBaseElement,null==o?void 0:o.includesBaseElement,!0),orientation:M(t.orientation,null==o?void 0:o.orientation,"vertical"),focusLoop:M(t.focusLoop,null==o?void 0:o.focusLoop,!0),focusWrap:M(t.focusWrap,null==o?void 0:o.focusWrap,!0),virtualFocus:M(t.virtualFocus,null==o?void 0:o.virtualFocus,!0)}),u=function({popover:e,...t}={}){let r=tf(t.store,tc(e,["arrowElement","anchorElement","contentElement","popoverElement","disclosureElement"]));td(t,r);let n=null==r?void 0:r.getState(),i=rs({...t,store:r}),o=M(t.placement,null==n?void 0:n.placement,"bottom"),a=ti({...i.getState(),placement:o,currentPlacement:o,anchorElement:M(null==n?void 0:n.anchorElement,null),popoverElement:M(null==n?void 0:n.popoverElement,null),arrowElement:M(null==n?void 0:n.arrowElement,null),rendered:Symbol("rendered")},i,r);return{...i,...a,setAnchorElement:e=>a.setState("anchorElement",e),setPopoverElement:e=>a.setState("popoverElement",e),setArrowElement:e=>a.setState("arrowElement",e),render:()=>a.setState("rendered",Symbol("rendered"))}}({...t,placement:M(t.placement,null==o?void 0:o.placement,"bottom-start")}),s=M(t.value,null==o?void 0:o.value,t.defaultValue,""),c=M(t.selectedValue,null==o?void 0:o.selectedValue,null==i?void 0:i.values,t.defaultSelectedValue,""),f=Array.isArray(c),d={...l.getState(),...u.getState(),value:s,selectedValue:c,resetValueOnSelect:M(t.resetValueOnSelect,null==o?void 0:o.resetValueOnSelect,f),resetValueOnHide:M(t.resetValueOnHide,null==o?void 0:o.resetValueOnHide,f&&!e),activeValue:null==o?void 0:o.activeValue},p=ti(d,l,u,r);return nI&&to(p,()=>tu(p,["virtualFocus"],()=>{p.setState("virtualFocus",!1)})),to(p,()=>{if(e)return x(tu(p,["selectedValue"],t=>{Array.isArray(t.selectedValue)&&e.setValues(t.selectedValue)}),tu(e,["values"],e=>{p.setState("selectedValue",e.values)}))}),to(p,()=>tu(p,["resetValueOnHide","mounted"],e=>{!e.resetValueOnHide||e.mounted||p.setState("value",s)})),to(p,()=>tu(p,["open"],e=>{e.open||(p.setState("activeId",a),p.setState("moves",0))})),to(p,()=>tu(p,["moves","activeId"],(e,t)=>{e.moves===t.moves&&p.setState("activeValue",void 0)})),to(p,()=>ts(p,["moves","renderedItems"],(e,t)=>{if(e.moves===t.moves)return;let{activeId:r}=p.getState(),n=l.item(r);p.setState("activeValue",null==n?void 0:n.value)})),{...u,...l,...p,tag:e,setValue:e=>p.setState("value",e),resetValue:()=>p.setState("value",d.value),setSelectedValue:e=>p.setState("selectedValue",e)}}function nL(e={}){var t,r,n,i,o,a,l,u;let s;t=e,s=nw();let[c,f]=tR(nF,e={id:z((r=t={...t,tag:void 0!==t.tag?t.tag:s}).id),...r});return Q(f,[(n=e).tag]),tM(c,n,"value","setValue"),tM(c,n,"selectedValue","setSelectedValue"),tM(c,n,"resetValueOnHide"),tM(c,n,"resetValueOnSelect"),Object.assign((a=c,Q(l=f,[(u=n).popover]),tM(a,u,"placement"),i=ra(a,l,u),o=i,Q(f,[n.store]),tM(o,n,"items","setItems"),tM(i=o,n,"activeId","setActiveId"),tM(i,n,"includesBaseElement"),tM(i,n,"virtualFocus"),tM(i,n,"orientation"),tM(i,n,"rtl"),tM(i,n,"focusLoop"),tM(i,n,"focusWrap"),tM(i,n,"focusShift"),i),{tag:n.tag})}function nP(e={}){let t=nL(e);return(0,eo.jsx)(e7,{value:t,children:e.children})}e.s(["useComboboxStore",()=>nL],18364),e.s(["ComboboxProvider",()=>nP],78440);var nD=(0,R.createContext)(void 0),nB=es(function(e){let[t,r]=(0,R.useState)();return T(e={role:"group","aria-labelledby":t,...e=Y(e,e=>(0,eo.jsx)(nD.Provider,{value:r,children:e}),[])})});ea(function(e){return eu("div",nB(e))});var nG=es(function({store:e,...t}){return nB(t)});ea(function(e){return eu("div",nG(e))});var nk=es(function({store:e,...t}){let r=e6();return A(e=e||r,!1),"grid"===m(e.useState("contentElement"))&&(t={role:"rowgroup",...t}),t=nG({store:e,...t})}),nj=ea(function(e){return eu("div",nk(e))});e.s(["ComboboxGroup",()=>nj],59129);var nN=es(function(e){let t=(0,R.useContext)(nD),r=z(e.id);return H(()=>(null==t||t(r),()=>null==t?void 0:t(void 0)),[t,r]),T(e={id:r,"aria-hidden":!0,...e})});ea(function(e){return eu("div",nN(e))});var nU=es(function({store:e,...t}){return nN(t)});ea(function(e){return eu("div",nU(e))});var nq=es(function(e){return nU(e)}),nV=ea(function(e){return eu("div",nq(e))});e.s(["ComboboxGroupLabel",()=>nV],25998);var nH=e.i(38360);let nW={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},nK=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function nz(e,t,r={}){let{keys:n,threshold:i=nW.MATCHES,baseSort:o=nK,sorter:a=e=>e.sort((e,t)=>(function(e,t,r){let{rank:n,keyIndex:i}=e,{rank:o,keyIndex:a}=t;return n!==o?n>o?-1:1:i===a?r(e,t):i{let l=nQ(i,s,c),u=t,{minRanking:f,maxRanking:d,threshold:p}=o;return l=nW.MATCHES?l=f:l>d&&(l=d),l>e&&(e=l,r=a,n=p,u=i),{rankedValue:u,rank:e,keyIndex:r,keyThreshold:n}},{rankedValue:l,rank:nW.NO_MATCH,keyIndex:-1,keyThreshold:c.threshold}):{rankedValue:l,rank:nQ(l,s,c),keyIndex:-1,keyThreshold:c.threshold}),{rank:d,keyThreshold:p=i}=f;return d>=p&&e.push({...f,item:o,index:a}),e},[])).map(({item:e})=>e)}function nQ(e,t,r){if(e=n$(e,r),(t=n$(t,r)).length>e.length)return nW.NO_MATCH;if(e===t)return nW.CASE_SENSITIVE_EQUAL;let n=function*(e,t){let r=-1;for(;(r=e.indexOf(t,r+1))>-1;)yield r;return -1}(e=e.toLowerCase(),t=t.toLowerCase()),i=n.next(),o=i.value;if(e.length===t.length&&0===o)return nW.EQUAL;if(0===o)return nW.STARTS_WITH;let a=i;for(;!a.done;){if(a.value>0&&" "===e[a.value-1])return nW.WORD_STARTS_WITH;a=n.next()}return o>0?nW.CONTAINS:1===t.length?nW.NO_MATCH:(function(e){let t="",r=" ";for(let n=0;n-1))return nW.NO_MATCH;return r=o-l,n=i/t.length,nW.MATCHES+1/r*n}(e,t)}function n$(e,{keepDiacritics:t}){return e=`${e}`,t||(e=(0,nH.default)(e)),e}nz.rankings=nW;let nX={maxRanking:1/0,minRanking:-1/0};e.s(["matchSorter",()=>nz],70238)},29402,(e,t,r)=>{var n,i,o,a,l="__lodash_hash_undefined__",u=1/0,s="[object Arguments]",c="[object Array]",f="[object Boolean]",d="[object Date]",p="[object Error]",m="[object Function]",h="[object Map]",v="[object Number]",g="[object Object]",y="[object Promise]",b="[object RegExp]",S="[object Set]",C="[object String]",x="[object Symbol]",E="[object WeakMap]",A="[object ArrayBuffer]",w="[object DataView]",_=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,T=/^\w*$/,M=/^\./,R=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,O=/\\(\\)?/g,I=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,L={};L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L[s]=L[c]=L[A]=L[f]=L[w]=L[d]=L[p]=L[m]=L[h]=L[v]=L[g]=L[b]=L[S]=L[C]=L[E]=!1;var P=e.g&&e.g.Object===Object&&e.g,D="object"==typeof self&&self&&self.Object===Object&&self,B=P||D||Function("return this")(),G=r&&!r.nodeType&&r,k=G&&t&&!t.nodeType&&t,j=k&&k.exports===G&&P.process,N=function(){try{return j&&j.binding("util")}catch(e){}}(),U=N&&N.isTypedArray;function q(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},ex.prototype.set=function(e,t){var r=this.__data__,n=e_(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},eE.prototype.clear=function(){this.__data__={hash:new eC,map:new(eu||ex),string:new eC}},eE.prototype.delete=function(e){return eP(this,e).delete(e)},eE.prototype.get=function(e){return eP(this,e).get(e)},eE.prototype.has=function(e){return eP(this,e).has(e)},eE.prototype.set=function(e,t){return eP(this,e).set(e,t),this},eA.prototype.add=eA.prototype.push=function(e){return this.__data__.set(e,l),this},eA.prototype.has=function(e){return this.__data__.has(e)},ew.prototype.clear=function(){this.__data__=new ex},ew.prototype.delete=function(e){return this.__data__.delete(e)},ew.prototype.get=function(e){return this.__data__.get(e)},ew.prototype.has=function(e){return this.__data__.has(e)},ew.prototype.set=function(e,t){var r=this.__data__;if(r instanceof ex){var n=r.__data__;if(!eu||n.length<199)return n.push([e,t]),this;r=this.__data__=new eE(n)}return r.set(e,t),this};var eT=(n=function(e,t){return e&&eM(e,t,e0)},function(e,t){if(null==e)return e;if(!ez(e))return n(e,t);for(var r=e.length,i=-1,o=Object(e);++il))return!1;var s=o.get(e);if(s&&o.get(t))return s==t;var c=-1,f=!0,d=1&i?new eA:void 0;for(o.set(e,t),o.set(t,e);++c-1&&e%1==0&&e-1&&e%1==0&&e<=0x1fffffffffffff}function eX(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eY(e){return!!e&&"object"==typeof e}function eZ(e){return"symbol"==typeof e||eY(e)&&ee.call(e)==x}var eJ=U?V(U):function(e){return eY(e)&&e$(e.length)&&!!L[ee.call(e)]};function e0(e){return ez(e)?function(e,t){var r=eK(e)||eW(e)?function(e,t){for(var r=-1,n=Array(e);++rt||o&&a&&u&&!l&&!s||n&&a&&u||!r&&u||!i)return 1;if(!n&&!o&&!s&&e=l)return u;return u*("desc"==r[n]?-1:1)}}return e.index-t.index}(e,t,r)});u--;)l[u]=l[u].value;return l}(e,t,r))}},97442,e=>{e.v({Group:"MissionSelect-module__N_AIjG__Group",GroupLabel:"MissionSelect-module__N_AIjG__GroupLabel",Input:"MissionSelect-module__N_AIjG__Input",InputWrapper:"MissionSelect-module__N_AIjG__InputWrapper",Item:"MissionSelect-module__N_AIjG__Item",ItemHeader:"MissionSelect-module__N_AIjG__ItemHeader",ItemMissionName:"MissionSelect-module__N_AIjG__ItemMissionName",ItemName:"MissionSelect-module__N_AIjG__ItemName",ItemType:"MissionSelect-module__N_AIjG__ItemType",ItemTypes:"MissionSelect-module__N_AIjG__ItemTypes",List:"MissionSelect-module__N_AIjG__List",NoResults:"MissionSelect-module__N_AIjG__NoResults",Popover:"MissionSelect-module__N_AIjG__Popover",SelectedName:"MissionSelect-module__N_AIjG__SelectedName",SelectedValue:"MissionSelect-module__N_AIjG__SelectedValue",Shortcut:"MissionSelect-module__N_AIjG__Shortcut"})},38847,e=>{"use strict";var t=e.i(80902),r=e.i(22289),n=e.i(71645);function i(e,t,n){try{return e(t)}catch(e){return(0,r.l)("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":""),t,e,n),null}}function o(e){function t(t){if(void 0===t)return null;let r="";if(Array.isArray(t)){if(void 0===t[0])return null;r=t[0]}return"string"==typeof t&&(r=t),i(e.parse,r)}return{type:"single",eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide:r=>t(r)??e}},withOptions(e){return{...this,...e}}}}let a=o({parse:e=>e,serialize:String});o({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),o({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),o({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(1&t.length?"0":"")+t}}),o({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});let l=o({parse:e=>"true"===e.toLowerCase(),serialize:String});function u(e,t){return e.valueOf()===t.valueOf()}o({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:u}),o({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:u}),o({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:u});let s=(0,t.r)(),c={};function f(e,r,n,o,a,l){let u=!1,s=Object.entries(e).reduce((e,[s,c])=>{var f;let d=r?.[s]??s,p=o[d],m="multi"===c.type?[]:null,h=void 0===p?("multi"===c.type?n?.getAll(d):n?.get(d))??m:p;return a&&l&&((f=a[d]??m)===h||null!==f&&null!==h&&"string"!=typeof f&&"string"!=typeof h&&f.length===h.length&&f.every((e,t)=>e===h[t]))?e[s]=l[s]??null:(u=!0,e[s]=((0,t.i)(h)?null:i(c.parse,h,d))??null,a&&(a[d]=h)),e},{});if(!u){let t=Object.keys(e),r=Object.keys(l??{});u=t.length!==r.length||t.some(e=>!r.includes(e))}return{state:s,hasChanged:u}}function d(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,e[r]??t[r]??null]))}function p(e,i={}){let{parse:o,type:a,serialize:l,eq:u,defaultValue:m,...h}=i,[{[e]:v},g]=function(e,i={}){let o=(0,n.useId)(),a=(0,r.i)(),l=(0,r.a)(),{history:u="replace",scroll:p=a?.scroll??!1,shallow:m=a?.shallow??!0,throttleMs:h=t.s.timeMs,limitUrlUpdates:v=a?.limitUrlUpdates,clearOnDefault:g=a?.clearOnDefault??!0,startTransition:y,urlKeys:b=c}=i,S=Object.keys(e).join(","),C=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(e=>[e,b[e]??e])),[S,JSON.stringify(b)]),x=(0,r.r)(Object.values(C)),E=x.searchParams,A=(0,n.useRef)({}),w=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(t=>[t,e[t].defaultValue??null])),[Object.values(e).map(({defaultValue:e})=>e).join(",")]),_=t.t.useQueuedQueries(Object.values(C)),[T,M]=(0,n.useState)(()=>f(e,b,E??new URLSearchParams,_).state),R=(0,n.useRef)(T);if((0,r.c)("[nuq+ %s `%s`] render - state: %O, iSP: %s",o,S,T,E),Object.keys(A.current).join("&")!==Object.values(C).join("&")){let{state:t,hasChanged:n}=f(e,b,E,_,A.current,R.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,S,{state:t,initialSearchParams:E,queuedQueries:_,queryRef:A.current,stateRef:R.current}),R.current=t,M(t)),A.current=Object.fromEntries(Object.entries(C).map(([t,r])=>[r,e[t]?.type==="multi"?E?.getAll(r):E?.get(r)??null]))}(0,n.useEffect)(()=>{let{state:t,hasChanged:n}=f(e,b,E,_,A.current,R.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,S,{state:t,initialSearchParams:E,queuedQueries:_,queryRef:A.current,stateRef:R.current}),R.current=t,M(t))},[Object.values(C).map(e=>`${e}=${E?.getAll(e)}`).join("&"),JSON.stringify(_)]),(0,n.useEffect)(()=>{let t=Object.keys(e).reduce((t,n)=>(t[n]=({state:t,query:i})=>{M(a=>{let{defaultValue:l}=e[n],u=C[n],s=t??l??null;return Object.is(a[n]??l??null,s)?((0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",o,S,u,t,l,R.current),a):(R.current={...R.current,[n]:s},A.current[u]=i,(0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",o,S,u,t,l,R.current),R.current)})},t),{});for(let n of Object.keys(e)){let e=C[n];(0,r.c)("[nuq+ %s `%s`] Subscribing to sync for `%s`",o,e,S),s.on(e,t[n])}return()=>{for(let n of Object.keys(e)){let e=C[n];(0,r.c)("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",o,e,S),s.off(e,t[n])}}},[S,C]);let O=(0,n.useCallback)((n,i={})=>{let a,c=Object.fromEntries(Object.keys(e).map(e=>[e,null])),f="function"==typeof n?n(d(R.current,w))??c:n??c;(0,r.c)("[nuq+ %s `%s`] setState: %O",o,S,f);let b=0,E=!1,A=[];for(let[n,o]of Object.entries(f)){let c=e[n],f=C[n];if(!c||void 0===o)continue;(i.clearOnDefault??c.clearOnDefault??g)&&null!==o&&void 0!==c.defaultValue&&(c.eq??((e,t)=>e===t))(o,c.defaultValue)&&(o=null);let d=null===o?null:(c.serialize??String)(o);s.emit(f,{state:o,query:d});let S={key:f,query:d,options:{history:i.history??c.history??u,shallow:i.shallow??c.shallow??m,scroll:i.scroll??c.scroll??p,startTransition:i.startTransition??c.startTransition??y}};if(i?.limitUrlUpdates?.method==="debounce"||v?.method==="debounce"||c.limitUrlUpdates?.method==="debounce"){!0===S.options.shallow&&console.warn((0,r.s)(422));let e=i?.limitUrlUpdates?.timeMs??v?.timeMs??c.limitUrlUpdates?.timeMs??t.s.timeMs,n=t.t.push(S,e,x,l);bt(e),E?t.n.flush(x,l):t.n.getPendingPromise(x));return a??_},[S,u,m,p,h,v?.method,v?.timeMs,y,C,x.updateUrl,x.getSearchParamsSnapshot,x.rateLimitFactor,l,w]);return[(0,n.useMemo)(()=>d(T,w),[T,w]),O]}({[e]:{parse:o??(e=>e),type:a,serialize:l,eq:u,defaultValue:m}},h);return[v,(0,n.useCallback)((t,r={})=>g(r=>({[e]:"function"==typeof t?t(r[e]):t}),r),[e,g])]}e.s(["createParser",()=>o,"parseAsBoolean",()=>l,"parseAsString",()=>a,"useQueryState",()=>p],38847)},32424,7368,e=>{"use strict";var t=e.i(12979);function r(){return async e=>{let r;try{r=(0,t.getUrlForPath)(e)}catch(t){return console.warn(`Script not in manifest: ${e} (${t})`),null}try{let t=await fetch(r);if(!t.ok)return console.error(`Script fetch failed: ${e} (${t.status})`),null;return await t.text()}catch(t){return console.error(`Script fetch error: ${e}`),console.error(t),null}}}e.s(["createScriptLoader",()=>r],32424),e.s(["ignoreScripts",0,["scripts/admin.cs","scripts/ai.cs","scripts/aiBotProfiles.cs","scripts/aiBountyGame.cs","scripts/aiChat.cs","scripts/aiCnH.cs","scripts/aiCTF.cs","scripts/aiDeathMatch.cs","scripts/aiDebug.cs","scripts/aiDefaultTasks.cs","scripts/aiDnD.cs","scripts/aiHumanTasks.cs","scripts/aiHunters.cs","scripts/aiInventory.cs","scripts/aiObjectiveBuilder.cs","scripts/aiObjectives.cs","scripts/aiRabbit.cs","scripts/aiSiege.cs","scripts/aiTDM.cs","scripts/aiTeamHunters.cs","scripts/deathMessages.cs","scripts/graphBuild.cs","scripts/navGraph.cs","scripts/serverTasks.cs","scripts/spdialog.cs"]],7368)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/3a7943ba4f8effca.css b/docs/_next/static/chunks/3a7943ba4f8effca.css deleted file mode 100644 index 129fdf58..00000000 --- a/docs/_next/static/chunks/3a7943ba4f8effca.css +++ /dev/null @@ -1 +0,0 @@ -.TouchControls-module__AkxfgW__Joystick{z-index:1;width:140px;height:140px;position:fixed;bottom:20px;left:50%;transform:translate(-50%)}.TouchControls-module__AkxfgW__Left{left:20px;transform:none;}.TouchControls-module__AkxfgW__Right{left:auto;right:20px;transform:none;} diff --git a/docs/_next/static/chunks/44bbdd420cb3ec27.js b/docs/_next/static/chunks/44bbdd420cb3ec27.js deleted file mode 100644 index 5c125a6c..00000000 --- a/docs/_next/static/chunks/44bbdd420cb3ec27.js +++ /dev/null @@ -1,362 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,55838,(e,n,t)=>{"use strict";var r=e.r(71645),a="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},i=r.useState,o=r.useEffect,l=r.useLayoutEffect,s=r.useDebugValue;function u(e){var n=e.getSnapshot;e=e.value;try{var t=n();return!a(e,t)}catch(e){return!0}}var c="u"{"use strict";n.exports=e.r(55838)},52822,(e,n,t)=>{"use strict";var r=e.r(71645),a=e.r(2239),i="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},o=a.useSyncExternalStore,l=r.useRef,s=r.useEffect,u=r.useMemo,c=r.useDebugValue;t.useSyncExternalStoreWithSelector=function(e,n,t,r,a){var d=l(null);if(null===d.current){var f={hasValue:!1,value:null};d.current=f}else f=d.current;var p=o(e,(d=u(function(){function e(e){if(!s){if(s=!0,o=e,e=r(e),void 0!==a&&f.hasValue){var n=f.value;if(a(n,e))return l=n}return l=e}if(n=l,i(o,e))return n;var t=r(e);return void 0!==a&&a(n,t)?(o=e,n):(o=e,l=t)}var o,l,s=!1,u=void 0===t?null:t;return[function(){return e(n())},null===u?void 0:function(){return e(u())}]},[n,t,r,a]))[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),c(p),p}},30224,(e,n,t)=>{"use strict";n.exports=e.r(52822)},66936,(e,n,t)=>{"use strict";function r(e,n){var t=e.length;for(e.push(n);0>>1,a=e[r];if(0>>1;ro(s,t))uo(c,s)?(e[r]=c,e[u]=t,r=u):(e[r]=s,e[l]=t,r=l);else if(uo(c,t))e[r]=c,e[u]=t,r=u;else break}}return n}function o(e,n){var t=e.sortIndex-n.sortIndex;return 0!==t?t:e.id-n.id}if(t.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var l,s=performance;t.unstable_now=function(){return s.now()}}else{var u=Date,c=u.now();t.unstable_now=function(){return u.now()-c}}var d=[],f=[],p=1,m=null,h=3,g=!1,_=!1,v=!1,S=!1,E="function"==typeof setTimeout?setTimeout:null,T="function"==typeof clearTimeout?clearTimeout:null,M="u">typeof setImmediate?setImmediate:null;function b(e){for(var n=a(f);null!==n;){if(null===n.callback)i(f);else if(n.startTime<=e)i(f),n.sortIndex=n.expirationTime,r(d,n);else break;n=a(f)}}function x(e){if(v=!1,b(e),!_)if(null!==a(d))_=!0,R||(R=!0,l());else{var n=a(f);null!==n&&U(x,n.startTime-e)}}var R=!1,C=-1,y=5,A=-1;function P(){return!!S||!(t.unstable_now()-Ae&&P());){var o=m.callback;if("function"==typeof o){m.callback=null,h=m.priorityLevel;var s=o(m.expirationTime<=e);if(e=t.unstable_now(),"function"==typeof s){m.callback=s,b(e),n=!0;break n}m===a(d)&&i(d),b(e)}else i(d);m=a(d)}if(null!==m)n=!0;else{var u=a(f);null!==u&&U(x,u.startTime-e),n=!1}}break e}finally{m=null,h=r,g=!1}}}finally{n?l():R=!1}}}if("function"==typeof M)l=function(){M(w)};else if("u">typeof MessageChannel){var L=new MessageChannel,N=L.port2;L.port1.onmessage=w,l=function(){N.postMessage(null)}}else l=function(){E(w,0)};function U(e,n){C=E(function(){e(t.unstable_now())},n)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_forceFrameRate=function(e){0>e||125o?(e.sortIndex=i,r(f,e),null===a(d)&&e===a(f)&&(v?(T(C),C=-1):v=!0,U(x,i-o))):(e.sortIndex=s,r(d,e),_||g||(_=!0,R||(R=!0,l()))),e},t.unstable_shouldYield=P,t.unstable_wrapCallback=function(e){var n=h;return function(){var t=h;h=n;try{return e.apply(this,arguments)}finally{h=t}}}},89499,(e,n,t)=>{"use strict";n.exports=e.r(66936)},40859,8560,8155,66748,46791,e=>{"use strict";let n,t,r,a,i,o,l,s,u;var c,d,f,p,m,h,g=e.i(47167),_=e.i(71645),v=e.i(90072),S=v;function E(){let e=null,n=!1,t=null,r=null;function a(n,i){t(n,i),r=e.requestAnimationFrame(a)}return{start:function(){!0===n||null!==t&&(r=e.requestAnimationFrame(a),n=!0)},stop:function(){e.cancelAnimationFrame(r),n=!1},setAnimationLoop:function(e){t=e},setContext:function(n){e=n}}}function T(e){let n=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),n.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);let r=n.get(t);r&&(e.deleteBuffer(r.buffer),n.delete(t))},update:function(t,r){if(t.isInterleavedBufferAttribute&&(t=t.data),t.isGLBufferAttribute){let e=n.get(t);(!e||e.versiontypeof Float16Array&&a instanceof Float16Array)r=e.HALF_FLOAT;else if(a instanceof Uint16Array)r=n.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(a instanceof Int16Array)r=e.SHORT;else if(a instanceof Uint32Array)r=e.UNSIGNED_INT;else if(a instanceof Int32Array)r=e.INT;else if(a instanceof Int8Array)r=e.BYTE;else if(a instanceof Uint8Array)r=e.UNSIGNED_BYTE;else if(a instanceof Uint8ClampedArray)r=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+a);return{buffer:l,type:r,bytesPerElement:a.BYTES_PER_ELEMENT,version:n.version,size:o}}(t,r));else if(a.versione.start-n.start);let n=0;for(let e=1;e 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n vColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, dp );\n #else\n shadow = step( dp, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},b={common:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new S.Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new S.Matrix3}},envmap:{envMap:{value:null},envMapRotation:{value:new S.Matrix3},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new S.Matrix3}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new S.Matrix3}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new S.Matrix3},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new S.Matrix3},normalScale:{value:new S.Vector2(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new S.Matrix3},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new S.Matrix3}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new S.Matrix3}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new S.Matrix3}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new S.Color(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0},uvTransform:{value:new S.Matrix3}},sprite:{diffuse:{value:new S.Color(0xffffff)},opacity:{value:1},center:{value:new S.Vector2(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new S.Matrix3},alphaMap:{value:null},alphaMapTransform:{value:new S.Matrix3},alphaTest:{value:0}}},x={basic:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.fog]),vertexShader:M.meshbasic_vert,fragmentShader:M.meshbasic_frag},lambert:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.fog,b.lights,{emissive:{value:new S.Color(0)}}]),vertexShader:M.meshlambert_vert,fragmentShader:M.meshlambert_frag},phong:{uniforms:(0,S.mergeUniforms)([b.common,b.specularmap,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.fog,b.lights,{emissive:{value:new S.Color(0)},specular:{value:new S.Color(1118481)},shininess:{value:30}}]),vertexShader:M.meshphong_vert,fragmentShader:M.meshphong_frag},standard:{uniforms:(0,S.mergeUniforms)([b.common,b.envmap,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.roughnessmap,b.metalnessmap,b.fog,b.lights,{emissive:{value:new S.Color(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag},toon:{uniforms:(0,S.mergeUniforms)([b.common,b.aomap,b.lightmap,b.emissivemap,b.bumpmap,b.normalmap,b.displacementmap,b.gradientmap,b.fog,b.lights,{emissive:{value:new S.Color(0)}}]),vertexShader:M.meshtoon_vert,fragmentShader:M.meshtoon_frag},matcap:{uniforms:(0,S.mergeUniforms)([b.common,b.bumpmap,b.normalmap,b.displacementmap,b.fog,{matcap:{value:null}}]),vertexShader:M.meshmatcap_vert,fragmentShader:M.meshmatcap_frag},points:{uniforms:(0,S.mergeUniforms)([b.points,b.fog]),vertexShader:M.points_vert,fragmentShader:M.points_frag},dashed:{uniforms:(0,S.mergeUniforms)([b.common,b.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:M.linedashed_vert,fragmentShader:M.linedashed_frag},depth:{uniforms:(0,S.mergeUniforms)([b.common,b.displacementmap]),vertexShader:M.depth_vert,fragmentShader:M.depth_frag},normal:{uniforms:(0,S.mergeUniforms)([b.common,b.bumpmap,b.normalmap,b.displacementmap,{opacity:{value:1}}]),vertexShader:M.meshnormal_vert,fragmentShader:M.meshnormal_frag},sprite:{uniforms:(0,S.mergeUniforms)([b.sprite,b.fog]),vertexShader:M.sprite_vert,fragmentShader:M.sprite_frag},background:{uniforms:{uvTransform:{value:new S.Matrix3},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:M.background_vert,fragmentShader:M.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new S.Matrix3}},vertexShader:M.backgroundCube_vert,fragmentShader:M.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:M.cube_vert,fragmentShader:M.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:M.equirect_vert,fragmentShader:M.equirect_frag},distance:{uniforms:(0,S.mergeUniforms)([b.common,b.displacementmap,{referencePosition:{value:new S.Vector3},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:M.distance_vert,fragmentShader:M.distance_frag},shadow:{uniforms:(0,S.mergeUniforms)([b.lights,b.fog,{color:{value:new S.Color(0)},opacity:{value:1}}]),vertexShader:M.shadow_vert,fragmentShader:M.shadow_frag}};x.physical={uniforms:(0,S.mergeUniforms)([x.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new S.Matrix3},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new S.Matrix3},clearcoatNormalScale:{value:new S.Vector2(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new S.Matrix3},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new S.Matrix3},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new S.Matrix3},sheen:{value:0},sheenColor:{value:new S.Color(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new S.Matrix3},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new S.Matrix3},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new S.Matrix3},transmissionSamplerSize:{value:new S.Vector2},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new S.Matrix3},attenuationDistance:{value:0},attenuationColor:{value:new S.Color(0)},specularColor:{value:new S.Color(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new S.Matrix3},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new S.Matrix3},anisotropyVector:{value:new S.Vector2},anisotropyMap:{value:null},anisotropyMapTransform:{value:new S.Matrix3}}]),vertexShader:M.meshphysical_vert,fragmentShader:M.meshphysical_frag};let R={r:0,b:0,g:0},C=new S.Euler,y=new S.Matrix4;function A(e,n,t,r,a,i,o){let l,s,u=new S.Color(0),c=+(!0!==i),d=null,f=0,p=null;function m(e){let r=!0===e.isScene?e.background:null;return r&&r.isTexture&&(r=(e.backgroundBlurriness>0?t:n).get(r)),r}function h(n,t){n.getRGB(R,(0,S.getUnlitUniformColorSpace)(e)),r.buffers.color.setClear(R.r,R.g,R.b,t,o)}return{getClearColor:function(){return u},setClearColor:function(e,n=1){u.set(e),h(u,c=n)},getClearAlpha:function(){return c},setClearAlpha:function(e){h(u,c=e)},render:function(n){let t=!1,a=m(n);null===a?h(u,c):a&&a.isColor&&(h(a,1),t=!0);let i=e.xr.getEnvironmentBlendMode();"additive"===i?r.buffers.color.setClear(0,0,0,1,o):"alpha-blend"===i&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||t)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(n,t){let r=m(t);r&&(r.isCubeTexture||r.mapping===S.CubeUVReflectionMapping)?(void 0===s&&((s=new S.Mesh(new S.BoxGeometry(1,1,1),new S.ShaderMaterial({name:"BackgroundCubeMaterial",uniforms:(0,S.cloneUniforms)(x.backgroundCube.uniforms),vertexShader:x.backgroundCube.vertexShader,fragmentShader:x.backgroundCube.fragmentShader,side:S.BackSide,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),s.geometry.deleteAttribute("uv"),s.onBeforeRender=function(e,n,t){this.matrixWorld.copyPosition(t.matrixWorld)},Object.defineProperty(s.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(s)),C.copy(t.backgroundRotation),C.x*=-1,C.y*=-1,C.z*=-1,r.isCubeTexture&&!1===r.isRenderTargetTexture&&(C.y*=-1,C.z*=-1),s.material.uniforms.envMap.value=r,s.material.uniforms.flipEnvMap.value=r.isCubeTexture&&!1===r.isRenderTargetTexture?-1:1,s.material.uniforms.backgroundBlurriness.value=t.backgroundBlurriness,s.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,s.material.uniforms.backgroundRotation.value.setFromMatrix4(y.makeRotationFromEuler(C)),s.material.toneMapped=S.ColorManagement.getTransfer(r.colorSpace)!==S.SRGBTransfer,(d!==r||f!==r.version||p!==e.toneMapping)&&(s.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),s.layers.enableAll(),n.unshift(s,s.geometry,s.material,0,0,null)):r&&r.isTexture&&(void 0===l&&((l=new S.Mesh(new S.PlaneGeometry(2,2),new S.ShaderMaterial({name:"BackgroundMaterial",uniforms:(0,S.cloneUniforms)(x.background.uniforms),vertexShader:x.background.vertexShader,fragmentShader:x.background.fragmentShader,side:S.FrontSide,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(l)),l.material.uniforms.t2D.value=r,l.material.uniforms.backgroundIntensity.value=t.backgroundIntensity,l.material.toneMapped=S.ColorManagement.getTransfer(r.colorSpace)!==S.SRGBTransfer,!0===r.matrixAutoUpdate&&r.updateMatrix(),l.material.uniforms.uvTransform.value.copy(r.matrix),(d!==r||f!==r.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=r,f=r.version,p=e.toneMapping),l.layers.enableAll(),n.unshift(l,l.geometry,l.material,0,0,null))},dispose:function(){void 0!==s&&(s.geometry.dispose(),s.material.dispose(),s=void 0),void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}}}function P(e,n){let t=e.getParameter(e.MAX_VERTEX_ATTRIBS),r={},a=u(null),i=a,o=!1;function l(n){return e.bindVertexArray(n)}function s(n){return e.deleteVertexArray(n)}function u(e){let n=[],r=[],a=[];for(let e=0;e=0){let t=a[n],r=o[n];if(void 0===r&&("instanceMatrix"===n&&e.instanceMatrix&&(r=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(r=e.instanceColor)),void 0===t||t.attribute!==r||r&&t.data!==r.data)return!0;l++}return i.attributesNum!==l||i.index!==r}(t,h,s,g))&&function(e,n,t,r){let a={},o=n.attributes,l=0,s=t.getAttributes();for(let n in s)if(s[n].location>=0){let t=o[n];void 0===t&&("instanceMatrix"===n&&e.instanceMatrix&&(t=e.instanceMatrix),"instanceColor"===n&&e.instanceColor&&(t=e.instanceColor));let r={};r.attribute=t,t&&t.data&&(r.data=t.data),a[n]=r,l++}i.attributes=a,i.attributesNum=l,i.index=r}(t,h,s,g),null!==g&&n.update(g,e.ELEMENT_ARRAY_BUFFER),(x||o)&&(o=!1,function(t,r,a,i){c();let o=i.attributes,l=a.getAttributes(),s=r.defaultAttributeValues;for(let r in l){let a=l[r];if(a.location>=0){let l=o[r];if(void 0===l&&("instanceMatrix"===r&&t.instanceMatrix&&(l=t.instanceMatrix),"instanceColor"===r&&t.instanceColor&&(l=t.instanceColor)),void 0!==l){let r=l.normalized,o=l.itemSize,s=n.get(l);if(void 0===s)continue;let u=s.buffer,c=s.type,p=s.bytesPerElement,h=c===e.INT||c===e.UNSIGNED_INT||l.gpuType===S.IntType;if(l.isInterleavedBufferAttribute){let n=l.data,s=n.stride,g=l.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";n="mediump"}return"mediump"===n&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let o=void 0!==t.precision?t.precision:"highp",l=i(o);return l!==o&&((0,S.warn)("WebGLRenderer:",o,"not supported, using",l,"instead."),o=l),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==a)return a;if(!0===n.has("EXT_texture_filter_anisotropic")){let t=n.get("EXT_texture_filter_anisotropic");a=e.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a},getMaxPrecision:i,textureFormatReadable:function(n){return n===S.RGBAFormat||r.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(t){let a=t===S.HalfFloatType&&(n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float"));return t===S.UnsignedByteType||r.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)||t===S.FloatType||!!a},precision:o,logarithmicDepthBuffer:!0===t.logarithmicDepthBuffer,reversedDepthBuffer:!0===t.reversedDepthBuffer&&n.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function N(e){let n=this,t=null,r=0,a=!1,i=!1,o=new S.Plane,l=new S.Matrix3,s={value:null,needsUpdate:!1};function u(e,t,r,a){let i=null!==e?e.length:0,u=null;if(0!==i){if(u=s.value,!0!==a||null===u){let n=r+4*i,a=t.matrixWorldInverse;l.getNormalMatrix(a),(null===u||u.length0),n.numPlanes=r,n.numIntersection=0)}}function U(e){let n=new WeakMap;function t(e,n){return n===S.EquirectangularReflectionMapping?e.mapping=S.CubeReflectionMapping:n===S.EquirectangularRefractionMapping&&(e.mapping=S.CubeRefractionMapping),e}function r(e){let t=e.target;t.removeEventListener("dispose",r);let a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}return{get:function(a){if(a&&a.isTexture){let i=a.mapping;if(i===S.EquirectangularReflectionMapping||i===S.EquirectangularRefractionMapping)if(n.has(a))return t(n.get(a).texture,a.mapping);else{let i=a.image;if(!i||!(i.height>0))return null;{let o=new S.WebGLCubeRenderTarget(i.height);return o.fromEquirectangularTexture(e,a),n.set(a,o),a.addEventListener("dispose",r),t(o.texture,a.mapping)}}}return a},dispose:function(){n=new WeakMap}}}let D=[.125,.215,.35,.446,.526,.582],I=new S.OrthographicCamera,F=new S.Color,O=null,B=0,G=0,H=!1,k=new S.Vector3;class V{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,t=.1,r=100,a={}){let{size:i=256,position:o=k}=a;O=this._renderer.getRenderTarget(),B=this._renderer.getActiveCubeFace(),G=this._renderer.getActiveMipmapLevel(),H=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(i);let l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,t,r,l,o),n>0&&this._blur(l,0,0,n),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=j(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=X(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?l=D[o-e+4-1]:0===o&&(l=0),t.push(l);let s=1/(i-2),u=-s,c=1+s,d=[u,u,c,u,c,c,u,u,c,c,u,c],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let n=e%3*2/3-1,t=e>2?0:-1,r=[n,t,0,n+2/3,t,0,n+2/3,t+1,0,n,t,0,n+2/3,t+1,0,n,t+1,0];f.set(r,18*e),p.set(d,12*e);let a=[e,e,e,e,e,e];m.set(a,6*e)}let h=new S.BufferGeometry;h.setAttribute("position",new S.BufferAttribute(f,3)),h.setAttribute("uv",new S.BufferAttribute(p,2)),h.setAttribute("faceIndex",new S.BufferAttribute(m,1)),r.push(new S.Mesh(h,null)),a>4&&a--}return{lodMeshes:r,sizeLods:n,sigmas:t}}(d)),this._blurMaterial=(a=d,i=e,o=n,r=new Float32Array(20),c=new S.Vector3(0,1,0),new S.ShaderMaterial({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/i,CUBEUV_TEXEL_HEIGHT:1/o,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform int samples; - uniform float weights[ n ]; - uniform bool latitudinal; - uniform float dTheta; - uniform float mipInt; - uniform vec3 poleAxis; - - #define ENVMAP_TYPE_CUBE_UV - #include - - vec3 getSample( float theta, vec3 axis ) { - - float cosTheta = cos( theta ); - // Rodrigues' axis-angle rotation - vec3 sampleDirection = vOutputDirection * cosTheta - + cross( axis, vOutputDirection ) * sin( theta ) - + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); - - return bilinearCubeUV( envMap, sampleDirection, mipInt ); - - } - - void main() { - - vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); - - if ( all( equal( axis, vec3( 0.0 ) ) ) ) { - - axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); - - } - - axis = normalize( axis ); - - gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); - gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); - - for ( int i = 1; i < n; i++ ) { - - if ( i >= samples ) { - - break; - - } - - float theta = dTheta * float( i ); - gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); - gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); - - } - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})),this._ggxMaterial=(l=d,s=e,u=n,new S.ShaderMaterial({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/s,CUBEUV_TEXEL_HEIGHT:1/u,CUBEUV_MAX_MIP:`${l}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:q(),fragmentShader:` - - precision highp float; - precision highp int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - uniform float roughness; - uniform float mipInt; - - #define ENVMAP_TYPE_CUBE_UV - #include - - #define PI 3.14159265359 - - // Van der Corput radical inverse - float radicalInverse_VdC(uint bits) { - bits = (bits << 16u) | (bits >> 16u); - bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); - bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); - bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); - bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); - return float(bits) * 2.3283064365386963e-10; // / 0x100000000 - } - - // Hammersley sequence - vec2 hammersley(uint i, uint N) { - return vec2(float(i) / float(N), radicalInverse_VdC(i)); - } - - // GGX VNDF importance sampling (Eric Heitz 2018) - // "Sampling the GGX Distribution of Visible Normals" - // https://jcgt.org/published/0007/04/01/ - vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { - float alpha = roughness * roughness; - - // Section 3.2: Transform view direction to hemisphere configuration - vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); - - // Section 4.1: Orthonormal basis - float lensq = Vh.x * Vh.x + Vh.y * Vh.y; - vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); - vec3 T2 = cross(Vh, T1); - - // Section 4.2: Parameterization of projected area - float r = sqrt(Xi.x); - float phi = 2.0 * PI * Xi.y; - float t1 = r * cos(phi); - float t2 = r * sin(phi); - float s = 0.5 * (1.0 + Vh.z); - t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; - - // Section 4.3: Reprojection onto hemisphere - vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; - - // Section 3.4: Transform back to ellipsoid configuration - return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); - } - - void main() { - vec3 N = normalize(vOutputDirection); - vec3 V = N; // Assume view direction equals normal for pre-filtering - - vec3 prefilteredColor = vec3(0.0); - float totalWeight = 0.0; - - // For very low roughness, just sample the environment directly - if (roughness < 0.001) { - gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); - return; - } - - // Tangent space basis for VNDF sampling - vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); - vec3 tangent = normalize(cross(up, N)); - vec3 bitangent = cross(N, tangent); - - for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { - vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); - - // For PMREM, V = N, so in tangent space V is always (0, 0, 1) - vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); - - // Transform H back to world space - vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); - vec3 L = normalize(2.0 * dot(V, H) * H - V); - - float NdotL = max(dot(N, L), 0.0); - - if(NdotL > 0.0) { - // Sample environment at fixed mip level - // VNDF importance sampling handles the distribution filtering - vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); - - // Weight by NdotL for the split-sum approximation - // VNDF PDF naturally accounts for the visible microfacet distribution - prefilteredColor += sampleColor * NdotL; - totalWeight += NdotL; - } - } - - if (totalWeight > 0.0) { - prefilteredColor = prefilteredColor / totalWeight; - } - - gl_FragColor = vec4(prefilteredColor, 1.0); - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1}))}return r}_compileMaterial(e){let n=new S.Mesh(new S.BufferGeometry,e);this._renderer.compile(n,I)}_sceneToCubeUV(e,n,t,r,a){let i=new S.PerspectiveCamera(90,1,n,t),o=[1,-1,1,1,1,1],l=[1,1,1,-1,-1,-1],s=this._renderer,u=s.autoClear,c=s.toneMapping;s.getClearColor(F),s.toneMapping=S.NoToneMapping,s.autoClear=!1,s.state.buffers.depth.getReversed()&&(s.setRenderTarget(r),s.clearDepth(),s.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new S.Mesh(new S.BoxGeometry,new S.MeshBasicMaterial({name:"PMREM.Background",side:S.BackSide,depthWrite:!1,depthTest:!1})));let d=this._backgroundBox,f=d.material,p=!1,m=e.background;m?m.isColor&&(f.color.copy(m),e.background=null,p=!0):(f.color.copy(F),p=!0);for(let n=0;n<6;n++){let t=n%3;0===t?(i.up.set(0,o[n],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x+l[n],a.y,a.z)):1===t?(i.up.set(0,0,o[n]),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y+l[n],a.z)):(i.up.set(0,o[n],0),i.position.set(a.x,a.y,a.z),i.lookAt(a.x,a.y,a.z+l[n]));let u=this._cubeSize;W(r,t*u,n>2?u:0,u,u),s.setRenderTarget(r),p&&s.render(d,i),s.render(e,i)}s.toneMapping=c,s.autoClear=u,e.background=m}_textureToCubeUV(e,n){let t=this._renderer,r=e.mapping===S.CubeReflectionMapping||e.mapping===S.CubeRefractionMapping;r?(null===this._cubemapMaterial&&(this._cubemapMaterial=j()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=X());let a=r?this._cubemapMaterial:this._equirectMaterial,i=this._lodMeshes[0];i.material=a,a.uniforms.envMap.value=e;let o=this._cubeSize;W(n,0,0,3*o,2*o),t.setRenderTarget(n),t.render(i,I)}_applyPMREM(e){let n=this._renderer,t=n.autoClear;n.autoClear=!1;let r=this._lodMeshes.length;for(let n=1;nd-4?t-d+4:0),m=4*(this._cubeSize-f);l.envMap.value=e.texture,l.roughness.value=c*(0+1.25*s),l.mipInt.value=d-n,W(a,p,m,3*f,2*f),r.setRenderTarget(a),r.render(o,I),l.envMap.value=a.texture,l.roughness.value=0,l.mipInt.value=d-t,W(e,p,m,3*f,2*f),r.setRenderTarget(e),r.render(o,I)}_blur(e,n,t,r,a){let i=this._pingPongRenderTarget;this._halfBlur(e,i,n,t,r,"latitudinal",a),this._halfBlur(i,e,t,t,r,"longitudinal",a)}_halfBlur(e,n,t,r,a,i,o){let l=this._renderer,s=this._blurMaterial;"latitudinal"!==i&&"longitudinal"!==i&&(0,S.error)("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[r];u.material=s;let c=s.uniforms,d=this._sizeLods[t]-1,f=isFinite(a)?Math.PI/(2*d):2*Math.PI/39,p=a/f,m=isFinite(a)?1+Math.floor(3*p):20;m>20&&(0,S.warn)(`sigmaRadians, ${a}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);let h=[],g=0;for(let e=0;e<20;++e){let n=e/p,t=Math.exp(-n*n/2);h.push(t),0===e?g+=t:e_-4?r-_+4:0),E,3*v,2*v),l.setRenderTarget(n),l.render(u,I)}}function z(e,n,t){let r=new S.WebGLRenderTarget(e,n,t);return r.texture.mapping=S.CubeUVReflectionMapping,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function W(e,n,t,r,a){e.viewport.set(n,t,r,a),e.scissor.set(n,t,r,a)}function X(){return new S.ShaderMaterial({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - varying vec3 vOutputDirection; - - uniform sampler2D envMap; - - #include - - void main() { - - vec3 outputDirection = normalize( vOutputDirection ); - vec2 uv = equirectUv( outputDirection ); - - gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})}function j(){return new S.ShaderMaterial({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:q(),fragmentShader:` - - precision mediump float; - precision mediump int; - - uniform float flipEnvMap; - - varying vec3 vOutputDirection; - - uniform samplerCube envMap; - - void main() { - - gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); - - } - `,blending:S.NoBlending,depthTest:!1,depthWrite:!1})}function q(){return` - - precision mediump float; - precision mediump int; - - attribute float faceIndex; - - varying vec3 vOutputDirection; - - // RH coordinate system; PMREM face-indexing convention - vec3 getDirection( vec2 uv, float face ) { - - uv = 2.0 * uv - 1.0; - - vec3 direction = vec3( uv, 1.0 ); - - if ( face == 0.0 ) { - - direction = direction.zyx; // ( 1, v, u ) pos x - - } else if ( face == 1.0 ) { - - direction = direction.xzy; - direction.xz *= -1.0; // ( -u, 1, -v ) pos y - - } else if ( face == 2.0 ) { - - direction.x *= -1.0; // ( -u, v, 1 ) pos z - - } else if ( face == 3.0 ) { - - direction = direction.zyx; - direction.xz *= -1.0; // ( -1, v, -u ) neg x - - } else if ( face == 4.0 ) { - - direction = direction.xzy; - direction.xy *= -1.0; // ( -u, -1, v ) neg y - - } else if ( face == 5.0 ) { - - direction.z *= -1.0; // ( u, v, -1 ) neg z - - } - - return direction; - - } - - void main() { - - vOutputDirection = getDirection( uv, faceIndex ); - gl_Position = vec4( position, 1.0 ); - - } - `}function Y(e){let n=new WeakMap,t=null;function r(e){let t=e.target;t.removeEventListener("dispose",r);let a=n.get(t);void 0!==a&&(n.delete(t),a.dispose())}return{get:function(a){if(a&&a.isTexture){let i=a.mapping,o=i===S.EquirectangularReflectionMapping||i===S.EquirectangularRefractionMapping,l=i===S.CubeReflectionMapping||i===S.CubeRefractionMapping;if(o||l){let i=n.get(a),s=void 0!==i?i.texture.pmremVersion:0;if(a.isRenderTargetTexture&&a.pmremVersion!==s)return null===t&&(t=new V(e)),(i=o?t.fromEquirectangular(a,i):t.fromCubemap(a,i)).texture.pmremVersion=a.pmremVersion,n.set(a,i),i.texture;{if(void 0!==i)return i.texture;let s=a.image;return o&&s&&s.height>0||l&&s&&function(e){let n=0;for(let t=0;t<6;t++)void 0!==e[t]&&n++;return 6===n}(s)?(null===t&&(t=new V(e)),(i=o?t.fromEquirectangular(a):t.fromCubemap(a)).texture.pmremVersion=a.pmremVersion,n.set(a,i),a.addEventListener("dispose",r),i.texture):null}}}return a},dispose:function(){n=new WeakMap,null!==t&&(t.dispose(),t=null)}}}function K(e){let n={};function t(t){if(void 0!==n[t])return n[t];let r=e.getExtension(t);return n[t]=r,r}return{has:function(e){return null!==t(e)},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(e){let n=t(e);return null===n&&(0,S.warnOnce)("WebGLRenderer: "+e+" extension not supported."),n}}}function $(e,n,t,r){let a={},i=new WeakMap;function o(e){let l=e.target;for(let e in null!==l.index&&n.remove(l.index),l.attributes)n.remove(l.attributes[e]);l.removeEventListener("dispose",o),delete a[l.id];let s=i.get(l);s&&(n.remove(s),i.delete(l)),r.releaseStatesOfGeometry(l),!0===l.isInstancedBufferGeometry&&delete l._maxInstanceCount,t.memory.geometries--}function l(e){let t=[],r=e.index,a=e.attributes.position,o=0;if(null!==r){let e=r.array;o=r.version;for(let n=0,r=e.length;nn.maxTextureSize&&(m=Math.ceil(p/n.maxTextureSize),p=n.maxTextureSize);let h=new Float32Array(p*m*4*c),g=new S.DataArrayTexture(h,p,m,c);g.type=S.FloatType,g.needsUpdate=!0;let _=4*f;for(let n=0;n - #include - - void main() { - gl_FragColor = texture2D( tDiffuse, vUv ); - - #ifdef LINEAR_TONE_MAPPING - gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); - #elif defined( REINHARD_TONE_MAPPING ) - gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); - #elif defined( CINEON_TONE_MAPPING ) - gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); - #elif defined( ACES_FILMIC_TONE_MAPPING ) - gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); - #elif defined( AGX_TONE_MAPPING ) - gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); - #elif defined( NEUTRAL_TONE_MAPPING ) - gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); - #elif defined( CUSTOM_TONE_MAPPING ) - gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); - #endif - - #ifdef SRGB_TRANSFER - gl_FragColor = sRGBTransferOETF( gl_FragColor ); - #endif - }`,depthTest:!1,depthWrite:!1}),c=new S.Mesh(s,u),d=new S.OrthographicCamera(-1,1,1,-1,0,1),f=null,p=null,m=!1,h=null,g=[],_=!1;this.setSize=function(e,n){o.setSize(e,n),l.setSize(e,n);for(let t=0;t0&&!0===g[0].isRenderPass;let n=o.width,t=o.height;for(let e=0;e0)return e;let a=n*t,i=es[a];if(void 0===i&&(i=new Float32Array(a),es[a]=i),0!==n){r.toArray(i,0);for(let r=1,a=0;r!==n;++r)a+=t,e[r].toArray(i,a)}return i}function em(e,n){if(e.length!==n.length)return!1;for(let t=0,r=e.length;t0&&(this.seq=r.concat(a))}setValue(e,n,t,r){let a=this.map[n];void 0!==a&&a.setValue(e,t,r)}setOptional(e,n,t){let r=n[t];void 0!==r&&this.setValue(e,t,r)}static upload(e,n,t,r){for(let a=0,i=n.length;a!==i;++a){let i=n[a],o=t[i.id];!1!==o.needsUpdate&&i.setValue(e,o.value,r)}}static seqWithValue(e,n){let t=[];for(let r=0,a=e.length;r!==a;++r){let a=e[r];a.id in n&&t.push(a)}return t}}function e8(e,n,t){let r=e.createShader(n);return e.shaderSource(r,t),e.compileShader(r),r}let e9=0,e7=new S.Matrix3;function ne(e,n,t){let r=e.getShaderParameter(n,e.COMPILE_STATUS),a=(e.getShaderInfoLog(n)||"").trim();if(r&&""===a)return"";let i=/ERROR: 0:(\d+)/.exec(a);if(!i)return a;{let r=parseInt(i[1]);return t.toUpperCase()+"\n\n"+a+"\n\n"+function(e,n){let t=e.split("\n"),r=[],a=Math.max(n-6,0),i=Math.min(n+6,t.length);for(let e=a;e":" "} ${a}: ${t[e]}`)}return r.join("\n")}(e.getShaderSource(n),r)}}let nn={[S.LinearToneMapping]:"Linear",[S.ReinhardToneMapping]:"Reinhard",[S.CineonToneMapping]:"Cineon",[S.ACESFilmicToneMapping]:"ACESFilmic",[S.AgXToneMapping]:"AgX",[S.NeutralToneMapping]:"Neutral",[S.CustomToneMapping]:"Custom"},nt=new S.Vector3;function nr(e){return""!==e}function na(e,n){let t=n.numSpotLightShadows+n.numSpotLightMaps-n.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,n.numDirLights).replace(/NUM_SPOT_LIGHTS/g,n.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,n.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,n.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,n.numPointLights).replace(/NUM_HEMI_LIGHTS/g,n.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,n.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,n.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,n.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,n.numPointLightShadows)}function ni(e,n){return e.replace(/NUM_CLIPPING_PLANES/g,n.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,n.numClippingPlanes-n.numClipIntersection)}let no=/^[ \t]*#include +<([\w\d./]+)>/gm;function nl(e){return e.replace(no,nu)}let ns=new Map;function nu(e,n){let t=M[n];if(void 0===t){let e=ns.get(n);if(void 0!==e)t=M[e],(0,S.warn)('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',n,e);else throw Error("Can not resolve #include <"+n+">")}return nl(t)}let nc=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function nd(e){return e.replace(nc,nf)}function nf(e,n,t,r){let a="";for(let e=parseInt(n);e0&&(o+="\n"),(l=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T].filter(nr).join("\n")).length>0&&(l+="\n");else{let e,n,r,s,u;o=[np(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+g:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&!1===t.flatShading?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+m:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(nr).join("\n"),l=[np(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,T,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.envMap?"#define "+g:"",t.envMap?"#define "+_:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&!1===t.flatShading?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+m:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==S.NoToneMapping?"#define TONE_MAPPING":"",t.toneMapping!==S.NoToneMapping?M.tonemapping_pars_fragment:"",t.toneMapping!==S.NoToneMapping?(a="toneMapping",void 0===(e=nn[i=t.toneMapping])?((0,S.warn)("WebGLProgram: Unsupported toneMapping:",i),"vec3 "+a+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+a+"( vec3 color ) { return "+e+"ToneMapping( color ); }"):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",M.colorspace_pars_fragment,(n=function(e){S.ColorManagement._getMatrix(e7,S.ColorManagement.workingColorSpace,e);let n=`mat3( ${e7.elements.map(e=>e.toFixed(4))} )`;switch(S.ColorManagement.getTransfer(e)){case S.LinearTransfer:return[n,"LinearTransferOETF"];case S.SRGBTransfer:return[n,"sRGBTransferOETF"];default:return(0,S.warn)("WebGLProgram: Unsupported color space: ",e),[n,"LinearTransferOETF"]}}(t.outputColorSpace),`vec4 linearToOutputTexel( vec4 value ) { - return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) ); -}`),(S.ColorManagement.getLuminanceCoefficients(nt),r=nt.x.toFixed(4),s=nt.y.toFixed(4),u=nt.z.toFixed(4),`float luminance( const in vec3 rgb ) { - const vec3 weights = vec3( ${r}, ${s}, ${u} ); - return dot( weights, rgb ); -}`),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"","\n"].filter(nr).join("\n")}f=ni(f=na(f=nl(f),t),t),p=ni(p=na(p=nl(p),t),t),f=nd(f),p=nd(p),!0!==t.isRawShaderMaterial&&(x="#version 300 es\n",o=[E,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+o,l=["#define varying in",t.glslVersion===S.GLSL3?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===S.GLSL3?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+l);let R=x+o+f,C=x+l+p,y=e8(c,c.VERTEX_SHADER,R),A=e8(c,c.FRAGMENT_SHADER,C);function P(n){if(e.debug.checkShaderErrors){let t=c.getProgramInfoLog(b)||"",r=c.getShaderInfoLog(y)||"",a=c.getShaderInfoLog(A)||"",i=t.trim(),s=r.trim(),u=a.trim(),d=!0,f=!0;if(!1===c.getProgramParameter(b,c.LINK_STATUS))if(d=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(c,b,y,A);else{let e=ne(c,y,"vertex"),t=ne(c,A,"fragment");(0,S.error)("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(b,c.VALIDATE_STATUS)+"\n\nMaterial Name: "+n.name+"\nMaterial Type: "+n.type+"\n\nProgram Info Log: "+i+"\n"+e+"\n"+t)}else""!==i?(0,S.warn)("WebGLProgram: Program Info Log:",i):(""===s||""===u)&&(f=!1);f&&(n.diagnostics={runnable:d,programLog:i,vertexShader:{log:s,prefix:o},fragmentShader:{log:u,prefix:l}})}c.deleteShader(y),c.deleteShader(A),s=new e6(c,b),u=function(e,n){let t={},r=e.getProgramParameter(n,e.ACTIVE_ATTRIBUTES);for(let a=0;a0,Y=i.clearcoat>0,K=i.dispersion>0,$=i.iridescence>0,Q=i.sheen>0,Z=i.transmission>0,J=q&&!!i.anisotropyMap,ee=Y&&!!i.clearcoatMap,en=Y&&!!i.clearcoatNormalMap,et=Y&&!!i.clearcoatRoughnessMap,er=$&&!!i.iridescenceMap,ea=$&&!!i.iridescenceThicknessMap,ei=Q&&!!i.sheenColorMap,eo=Q&&!!i.sheenRoughnessMap,el=!!i.specularMap,es=!!i.specularColorMap,eu=!!i.specularIntensityMap,ec=Z&&!!i.transmissionMap,ed=Z&&!!i.thicknessMap,ef=!!i.gradientMap,ep=!!i.alphaMap,em=i.alphaTest>0,eh=!!i.alphaHash,eg=!!i.extensions,e_=S.NoToneMapping;i.toneMapped&&(null===N||!0===N.isXRRenderTarget)&&(e_=e.toneMapping);let ev={shaderID:A,shaderType:i.type,shaderName:i.name,vertexShader:_,fragmentShader:v,defines:i.defines,customVertexShaderID:E,customFragmentShaderID:T,isRawShaderMaterial:!0===i.isRawShaderMaterial,glslVersion:i.glslVersion,precision:p,batching:I,batchingColor:I&&null!==g._colorsTexture,instancing:D,instancingColor:D&&null!==g.instanceColor,instancingMorph:D&&null!==g.morphTexture,outputColorSpace:null===N?e.outputColorSpace:!0===N.isXRRenderTarget?N.texture.colorSpace:S.LinearSRGBColorSpace,alphaToCoverage:!!i.alphaToCoverage,map:F,matcap:O,envMap:B,envMapMode:B&&C.mapping,envMapCubeUVHeight:y,aoMap:G,lightMap:H,bumpMap:k,normalMap:V,displacementMap:z,emissiveMap:W,normalMapObjectSpace:V&&i.normalMapType===S.ObjectSpaceNormalMap,normalMapTangentSpace:V&&i.normalMapType===S.TangentSpaceNormalMap,metalnessMap:X,roughnessMap:j,anisotropy:q,anisotropyMap:J,clearcoat:Y,clearcoatMap:ee,clearcoatNormalMap:en,clearcoatRoughnessMap:et,dispersion:K,iridescence:$,iridescenceMap:er,iridescenceThicknessMap:ea,sheen:Q,sheenColorMap:ei,sheenRoughnessMap:eo,specularMap:el,specularColorMap:es,specularIntensityMap:eu,transmission:Z,transmissionMap:ec,thicknessMap:ed,gradientMap:ef,opaque:!1===i.transparent&&i.blending===S.NormalBlending&&!1===i.alphaToCoverage,alphaMap:ep,alphaTest:em,alphaHash:eh,combine:i.combine,mapUv:F&&h(i.map.channel),aoMapUv:G&&h(i.aoMap.channel),lightMapUv:H&&h(i.lightMap.channel),bumpMapUv:k&&h(i.bumpMap.channel),normalMapUv:V&&h(i.normalMap.channel),displacementMapUv:z&&h(i.displacementMap.channel),emissiveMapUv:W&&h(i.emissiveMap.channel),metalnessMapUv:X&&h(i.metalnessMap.channel),roughnessMapUv:j&&h(i.roughnessMap.channel),anisotropyMapUv:J&&h(i.anisotropyMap.channel),clearcoatMapUv:ee&&h(i.clearcoatMap.channel),clearcoatNormalMapUv:en&&h(i.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:et&&h(i.clearcoatRoughnessMap.channel),iridescenceMapUv:er&&h(i.iridescenceMap.channel),iridescenceThicknessMapUv:ea&&h(i.iridescenceThicknessMap.channel),sheenColorMapUv:ei&&h(i.sheenColorMap.channel),sheenRoughnessMapUv:eo&&h(i.sheenRoughnessMap.channel),specularMapUv:el&&h(i.specularMap.channel),specularColorMapUv:es&&h(i.specularColorMap.channel),specularIntensityMapUv:eu&&h(i.specularIntensityMap.channel),transmissionMapUv:ec&&h(i.transmissionMap.channel),thicknessMapUv:ed&&h(i.thicknessMap.channel),alphaMapUv:ep&&h(i.alphaMap.channel),vertexTangents:!!b.attributes.tangent&&(V||q),vertexColors:i.vertexColors,vertexAlphas:!0===i.vertexColors&&!!b.attributes.color&&4===b.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!b.attributes.uv&&(F||ep),fog:!!M,useFog:!0===i.fog,fogExp2:!!M&&M.isFogExp2,flatShading:!0===i.flatShading&&!1===i.wireframe,sizeAttenuation:!0===i.sizeAttenuation,logarithmicDepthBuffer:f,reversedDepthBuffer:U,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==b.morphAttributes.position,morphNormals:void 0!==b.morphAttributes.normal,morphColors:void 0!==b.morphAttributes.color,morphTargetsCount:w,morphTextureStride:L,numDirLights:l.directional.length,numPointLights:l.point.length,numSpotLights:l.spot.length,numSpotLightMaps:l.spotLightMap.length,numRectAreaLights:l.rectArea.length,numHemiLights:l.hemi.length,numDirLightShadows:l.directionalShadowMap.length,numPointLightShadows:l.pointShadowMap.length,numSpotLightShadows:l.spotShadowMap.length,numSpotLightShadowsWithMaps:l.numSpotLightShadowsWithMaps,numLightProbes:l.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:i.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:e_,decodeVideoTexture:F&&!0===i.map.isVideoTexture&&S.ColorManagement.getTransfer(i.map.colorSpace)===S.SRGBTransfer,decodeVideoTextureEmissive:W&&!0===i.emissiveMap.isVideoTexture&&S.ColorManagement.getTransfer(i.emissiveMap.colorSpace)===S.SRGBTransfer,premultipliedAlpha:i.premultipliedAlpha,doubleSided:i.side===S.DoubleSide,flipSided:i.side===S.BackSide,useDepthPacking:i.depthPacking>=0,depthPacking:i.depthPacking||0,index0AttributeName:i.index0AttributeName,extensionClipCullDistance:eg&&!0===i.extensions.clipCullDistance&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(eg&&!0===i.extensions.multiDraw||I)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:i.customProgramCacheKey()};return ev.vertexUv1s=u.has(1),ev.vertexUv2s=u.has(2),ev.vertexUv3s=u.has(3),u.clear(),ev},getProgramCacheKey:function(n){var t,r,a,i;let o=[];if(n.shaderID?o.push(n.shaderID):(o.push(n.customVertexShaderID),o.push(n.customFragmentShaderID)),void 0!==n.defines)for(let e in n.defines)o.push(e),o.push(n.defines[e]);return!1===n.isRawShaderMaterial&&(t=o,r=n,t.push(r.precision),t.push(r.outputColorSpace),t.push(r.envMapMode),t.push(r.envMapCubeUVHeight),t.push(r.mapUv),t.push(r.alphaMapUv),t.push(r.lightMapUv),t.push(r.aoMapUv),t.push(r.bumpMapUv),t.push(r.normalMapUv),t.push(r.displacementMapUv),t.push(r.emissiveMapUv),t.push(r.metalnessMapUv),t.push(r.roughnessMapUv),t.push(r.anisotropyMapUv),t.push(r.clearcoatMapUv),t.push(r.clearcoatNormalMapUv),t.push(r.clearcoatRoughnessMapUv),t.push(r.iridescenceMapUv),t.push(r.iridescenceThicknessMapUv),t.push(r.sheenColorMapUv),t.push(r.sheenRoughnessMapUv),t.push(r.specularMapUv),t.push(r.specularColorMapUv),t.push(r.specularIntensityMapUv),t.push(r.transmissionMapUv),t.push(r.thicknessMapUv),t.push(r.combine),t.push(r.fogExp2),t.push(r.sizeAttenuation),t.push(r.morphTargetsCount),t.push(r.morphAttributeCount),t.push(r.numDirLights),t.push(r.numPointLights),t.push(r.numSpotLights),t.push(r.numSpotLightMaps),t.push(r.numHemiLights),t.push(r.numRectAreaLights),t.push(r.numDirLightShadows),t.push(r.numPointLightShadows),t.push(r.numSpotLightShadows),t.push(r.numSpotLightShadowsWithMaps),t.push(r.numLightProbes),t.push(r.shadowMapType),t.push(r.toneMapping),t.push(r.numClippingPlanes),t.push(r.numClipIntersection),t.push(r.depthPacking),a=o,i=n,l.disableAll(),i.instancing&&l.enable(0),i.instancingColor&&l.enable(1),i.instancingMorph&&l.enable(2),i.matcap&&l.enable(3),i.envMap&&l.enable(4),i.normalMapObjectSpace&&l.enable(5),i.normalMapTangentSpace&&l.enable(6),i.clearcoat&&l.enable(7),i.iridescence&&l.enable(8),i.alphaTest&&l.enable(9),i.vertexColors&&l.enable(10),i.vertexAlphas&&l.enable(11),i.vertexUv1s&&l.enable(12),i.vertexUv2s&&l.enable(13),i.vertexUv3s&&l.enable(14),i.vertexTangents&&l.enable(15),i.anisotropy&&l.enable(16),i.alphaHash&&l.enable(17),i.batching&&l.enable(18),i.dispersion&&l.enable(19),i.batchingColor&&l.enable(20),i.gradientMap&&l.enable(21),a.push(l.mask),l.disableAll(),i.fog&&l.enable(0),i.useFog&&l.enable(1),i.flatShading&&l.enable(2),i.logarithmicDepthBuffer&&l.enable(3),i.reversedDepthBuffer&&l.enable(4),i.skinning&&l.enable(5),i.morphTargets&&l.enable(6),i.morphNormals&&l.enable(7),i.morphColors&&l.enable(8),i.premultipliedAlpha&&l.enable(9),i.shadowMapEnabled&&l.enable(10),i.doubleSided&&l.enable(11),i.flipSided&&l.enable(12),i.useDepthPacking&&l.enable(13),i.dithering&&l.enable(14),i.transmission&&l.enable(15),i.sheen&&l.enable(16),i.opaque&&l.enable(17),i.pointsUvs&&l.enable(18),i.decodeVideoTexture&&l.enable(19),i.decodeVideoTextureEmissive&&l.enable(20),i.alphaToCoverage&&l.enable(21),a.push(l.mask),o.push(e.outputColorSpace)),o.push(n.customProgramCacheKey),o.join()},getUniforms:function(e){let n,t=m[e.type];if(t){let e=x[t];n=S.UniformsUtils.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(n,t){let r=d.get(t);return void 0!==r?++r.usedTimes:(r=new nv(e,t,n,i),c.push(r),d.set(t,r)),r},releaseProgram:function(e){if(0==--e.usedTimes){let n=c.indexOf(e);c[n]=c[c.length-1],c.pop(),d.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){s.remove(e)},programs:c,dispose:function(){s.dispose()}}}function nb(){let e=new WeakMap;return{has:function(n){return e.has(n)},get:function(n){let t=e.get(n);return void 0===t&&(t={},e.set(n,t)),t},remove:function(n){e.delete(n)},update:function(n,t,r){e.get(n)[t]=r},dispose:function(){e=new WeakMap}}}function nx(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.material.id!==n.material.id?e.material.id-n.material.id:e.z!==n.z?e.z-n.z:e.id-n.id}function nR(e,n){return e.groupOrder!==n.groupOrder?e.groupOrder-n.groupOrder:e.renderOrder!==n.renderOrder?e.renderOrder-n.renderOrder:e.z!==n.z?n.z-e.z:e.id-n.id}function nC(){let e=[],n=0,t=[],r=[],a=[];function i(t,r,a,i,o,l){let s=e[n];return void 0===s?(s={id:t.id,object:t,geometry:r,material:a,groupOrder:i,renderOrder:t.renderOrder,z:o,group:l},e[n]=s):(s.id=t.id,s.object=t,s.geometry=r,s.material=a,s.groupOrder=i,s.renderOrder=t.renderOrder,s.z=o,s.group=l),n++,s}return{opaque:t,transmissive:r,transparent:a,init:function(){n=0,t.length=0,r.length=0,a.length=0},push:function(e,n,o,l,s,u){let c=i(e,n,o,l,s,u);o.transmission>0?r.push(c):!0===o.transparent?a.push(c):t.push(c)},unshift:function(e,n,o,l,s,u){let c=i(e,n,o,l,s,u);o.transmission>0?r.unshift(c):!0===o.transparent?a.unshift(c):t.unshift(c)},finish:function(){for(let t=n,r=e.length;t1&&t.sort(e||nx),r.length>1&&r.sort(n||nR),a.length>1&&a.sort(n||nR)}}}function ny(){let e=new WeakMap;return{get:function(n,t){let r,a=e.get(n);return void 0===a?(r=new nC,e.set(n,[r])):t>=a.length?(r=new nC,a.push(r)):r=a[t],r},dispose:function(){e=new WeakMap}}}function nA(){let e={};return{get:function(n){let t;if(void 0!==e[n.id])return e[n.id];switch(n.type){case"DirectionalLight":t={direction:new S.Vector3,color:new S.Color};break;case"SpotLight":t={position:new S.Vector3,direction:new S.Vector3,color:new S.Color,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new S.Vector3,color:new S.Color,distance:0,decay:0};break;case"HemisphereLight":t={direction:new S.Vector3,skyColor:new S.Color,groundColor:new S.Color};break;case"RectAreaLight":t={color:new S.Color,position:new S.Vector3,halfWidth:new S.Vector3,halfHeight:new S.Vector3}}return e[n.id]=t,t}}}let nP=0;function nw(e,n){return 2*!!n.castShadow-2*!!e.castShadow+ +!!n.map-!!e.map}function nL(e){let n,t=new nA,r=(n={},{get:function(e){let t;if(void 0!==n[e.id])return n[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new S.Vector2};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new S.Vector2,shadowCameraNear:1,shadowCameraFar:1e3}}return n[e.id]=t,t}}),a={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)a.probe.push(new S.Vector3);let i=new S.Vector3,o=new S.Matrix4,l=new S.Matrix4;return{setup:function(n){let i=0,o=0,l=0;for(let e=0;e<9;e++)a.probe[e].set(0,0,0);let s=0,u=0,c=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0;n.sort(nw);for(let e=0,E=n.length;e0&&(!0===e.has("OES_texture_float_linear")?(a.rectAreaLTC1=b.LTC_FLOAT_1,a.rectAreaLTC2=b.LTC_FLOAT_2):(a.rectAreaLTC1=b.LTC_HALF_1,a.rectAreaLTC2=b.LTC_HALF_2)),a.ambient[0]=i,a.ambient[1]=o,a.ambient[2]=l;let E=a.hash;(E.directionalLength!==s||E.pointLength!==u||E.spotLength!==c||E.rectAreaLength!==d||E.hemiLength!==f||E.numDirectionalShadows!==p||E.numPointShadows!==m||E.numSpotShadows!==h||E.numSpotMaps!==g||E.numLightProbes!==v)&&(a.directional.length=s,a.spot.length=c,a.rectArea.length=d,a.point.length=u,a.hemi.length=f,a.directionalShadow.length=p,a.directionalShadowMap.length=p,a.pointShadow.length=m,a.pointShadowMap.length=m,a.spotShadow.length=h,a.spotShadowMap.length=h,a.directionalShadowMatrix.length=p,a.pointShadowMatrix.length=m,a.spotLightMatrix.length=h+g-_,a.spotLightMap.length=g,a.numSpotLightShadowsWithMaps=_,a.numLightProbes=v,E.directionalLength=s,E.pointLength=u,E.spotLength=c,E.rectAreaLength=d,E.hemiLength=f,E.numDirectionalShadows=p,E.numPointShadows=m,E.numSpotShadows=h,E.numSpotMaps=g,E.numLightProbes=v,a.version=nP++)},setupView:function(e,n){let t=0,r=0,s=0,u=0,c=0,d=n.matrixWorldInverse;for(let n=0,f=e.length;n=i.length?(a=new nN(e),i.push(a)):a=i[r],a},dispose:function(){n=new WeakMap}}}let nD=[new S.Vector3(1,0,0),new S.Vector3(-1,0,0),new S.Vector3(0,1,0),new S.Vector3(0,-1,0),new S.Vector3(0,0,1),new S.Vector3(0,0,-1)],nI=[new S.Vector3(0,-1,0),new S.Vector3(0,-1,0),new S.Vector3(0,0,1),new S.Vector3(0,0,-1),new S.Vector3(0,-1,0),new S.Vector3(0,-1,0)],nF=new S.Matrix4,nO=new S.Vector3,nB=new S.Vector3;function nG(e,n,t){let r=new S.Frustum,a=new S.Vector2,i=new S.Vector2,o=new S.Vector4,l=new S.MeshDepthMaterial,s=new S.MeshDistanceMaterial,u={},c=t.maxTextureSize,d={[S.FrontSide]:S.BackSide,[S.BackSide]:S.FrontSide,[S.DoubleSide]:S.DoubleSide},f=new S.ShaderMaterial({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new S.Vector2},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new S.BufferGeometry;m.setAttribute("position",new S.BufferAttribute(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new S.Mesh(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=S.PCFShadowMap;let _=this.type;function v(n,t,r,a){let i=null,o=!0===r.isPointLight?n.customDistanceMaterial:n.customDepthMaterial;if(void 0!==o)i=o;else if(i=!0===r.isPointLight?s:l,e.localClippingEnabled&&!0===t.clipShadows&&Array.isArray(t.clippingPlanes)&&0!==t.clippingPlanes.length||t.displacementMap&&0!==t.displacementScale||t.alphaMap&&t.alphaTest>0||t.map&&t.alphaTest>0||!0===t.alphaToCoverage){let e=i.uuid,n=t.uuid,r=u[e];void 0===r&&(r={},u[e]=r);let a=r[n];void 0===a&&(a=i.clone(),r[n]=a,t.addEventListener("dispose",E)),i=a}return i.visible=t.visible,i.wireframe=t.wireframe,a===S.VSMShadowMap?i.side=null!==t.shadowSide?t.shadowSide:t.side:i.side=null!==t.shadowSide?t.shadowSide:d[t.side],i.alphaMap=t.alphaMap,i.alphaTest=!0===t.alphaToCoverage?.5:t.alphaTest,i.map=t.map,i.clipShadows=t.clipShadows,i.clippingPlanes=t.clippingPlanes,i.clipIntersection=t.clipIntersection,i.displacementMap=t.displacementMap,i.displacementScale=t.displacementScale,i.displacementBias=t.displacementBias,i.wireframeLinewidth=t.wireframeLinewidth,i.linewidth=t.linewidth,!0===r.isPointLight&&!0===i.isMeshDistanceMaterial&&(e.properties.get(i).light=r),i}function E(e){for(let n in e.target.removeEventListener("dispose",E),u){let t=u[n],r=e.target.uuid;r in t&&(t[r].dispose(),delete t[r])}}this.render=function(t,l,s){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===t.length)return;t.type===S.PCFSoftShadowMap&&((0,S.warn)("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),t.type=S.PCFShadowMap);let u=e.getRenderTarget(),d=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),E=e.state;E.setBlending(S.NoBlending),!0===E.buffers.depth.getReversed()?E.buffers.color.setClear(0,0,0,0):E.buffers.color.setClear(1,1,1,1),E.buffers.depth.setTest(!0),E.setScissorTest(!1);let T=_!==this.type;T&&l.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,d=t.length;uc||a.y>c)&&(a.x>c&&(i.x=Math.floor(c/g.x),a.x=i.x*g.x,m.mapSize.x=i.x),a.y>c&&(i.y=Math.floor(c/g.y),a.y=i.y*g.y,m.mapSize.y=i.y)),null===m.map||!0===T){if(null!==m.map&&(null!==m.map.depthTexture&&(m.map.depthTexture.dispose(),m.map.depthTexture=null),m.map.dispose()),this.type===S.VSMShadowMap){if(d.isPointLight){(0,S.warn)("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}m.map=new S.WebGLRenderTarget(a.x,a.y,{format:S.RGFormat,type:S.HalfFloatType,minFilter:S.LinearFilter,magFilter:S.LinearFilter,generateMipmaps:!1}),m.map.texture.name=d.name+".shadowMap",m.map.depthTexture=new S.DepthTexture(a.x,a.y,S.FloatType),m.map.depthTexture.name=d.name+".shadowMapDepth",m.map.depthTexture.format=S.DepthFormat,m.map.depthTexture.compareFunction=null,m.map.depthTexture.minFilter=S.NearestFilter,m.map.depthTexture.magFilter=S.NearestFilter}else{d.isPointLight?(m.map=new S.WebGLCubeRenderTarget(a.x),m.map.depthTexture=new S.CubeDepthTexture(a.x,S.UnsignedIntType)):(m.map=new S.WebGLRenderTarget(a.x,a.y),m.map.depthTexture=new S.DepthTexture(a.x,a.y,S.UnsignedIntType)),m.map.depthTexture.name=d.name+".shadowMap",m.map.depthTexture.format=S.DepthFormat;let n=e.state.buffers.depth.getReversed();this.type===S.PCFShadowMap?(m.map.depthTexture.compareFunction=n?S.GreaterEqualCompare:S.LessEqualCompare,m.map.depthTexture.minFilter=S.LinearFilter,m.map.depthTexture.magFilter=S.LinearFilter):(m.map.depthTexture.compareFunction=null,m.map.depthTexture.minFilter=S.NearestFilter,m.map.depthTexture.magFilter=S.NearestFilter)}m.camera.updateProjectionMatrix()}let _=m.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t<_;t++){if(m.map.isWebGLCubeRenderTarget)e.setRenderTarget(m.map,t),e.clear();else{0===t&&(e.setRenderTarget(m.map),e.clear());let n=m.getViewport(t);o.set(i.x*n.x,i.y*n.y,i.x*n.z,i.y*n.w),E.viewport(o)}if(d.isPointLight){let e=m.camera,n=m.matrix,r=d.distance||e.far;r!==e.far&&(e.far=r,e.updateProjectionMatrix()),nO.setFromMatrixPosition(d.matrixWorld),e.position.copy(nO),nB.copy(e.position),nB.add(nD[t]),e.up.copy(nI[t]),e.lookAt(nB),e.updateMatrixWorld(),n.makeTranslation(-nO.x,-nO.y,-nO.z),nF.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),m._frustum.setFromProjectionMatrix(nF,e.coordinateSystem,e.reversedDepth)}else m.updateMatrices(d);r=m.getFrustum(),function t(a,i,o,l,s){if(!1===a.visible)return;if(a.layers.test(i.layers)&&(a.isMesh||a.isLine||a.isPoints)&&(a.castShadow||a.receiveShadow&&s===S.VSMShadowMap)&&(!a.frustumCulled||r.intersectsObject(a))){a.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,a.matrixWorld);let t=n.update(a),r=a.material;if(Array.isArray(r)){let n=t.groups;for(let u=0,c=n.length;u=1:-1!==L.indexOf("OpenGL ES")&&(w=parseFloat(/^OpenGL ES (\d)/.exec(L)[1])>=2);let N=null,U={},D=e.getParameter(e.SCISSOR_BOX),I=e.getParameter(e.VIEWPORT),F=new S.Vector4().fromArray(D),O=new S.Vector4().fromArray(I);function B(n,t,r,a){let i=new Uint8Array(4),o=e.createTexture();e.bindTexture(n,o),e.texParameteri(n,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(n,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;otypeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new S.Vector2,d=new WeakMap,f=new WeakMap,p=!1;try{p="u">typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function m(e,n){return p?new OffscreenCanvas(e,n):(0,S.createElementNS)("canvas")}function h(e,n,t){let r=1,a=z(e);if((a.width>t||a.height>t)&&(r=t/Math.max(a.width,a.height)),r<1)if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof VideoFrame&&e instanceof VideoFrame){let t=Math.floor(r*a.width),i=Math.floor(r*a.height);void 0===l&&(l=m(t,i));let o=n?m(t,i):l;return o.width=t,o.height=i,o.getContext("2d").drawImage(e,0,0,t,i),(0,S.warn)("WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+t+"x"+i+")."),o}else"data"in e&&(0,S.warn)("WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").");return e}function g(e){return e.generateMipmaps}function _(n){e.generateMipmap(n)}function v(t,r,a,i,o=!1){if(null!==t){if(void 0!==e[t])return e[t];(0,S.warn)("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+t+"'")}let l=r;if(r===e.RED&&(a===e.FLOAT&&(l=e.R32F),a===e.HALF_FLOAT&&(l=e.R16F),a===e.UNSIGNED_BYTE&&(l=e.R8)),r===e.RED_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.R8UI),a===e.UNSIGNED_SHORT&&(l=e.R16UI),a===e.UNSIGNED_INT&&(l=e.R32UI),a===e.BYTE&&(l=e.R8I),a===e.SHORT&&(l=e.R16I),a===e.INT&&(l=e.R32I)),r===e.RG&&(a===e.FLOAT&&(l=e.RG32F),a===e.HALF_FLOAT&&(l=e.RG16F),a===e.UNSIGNED_BYTE&&(l=e.RG8)),r===e.RG_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RG8UI),a===e.UNSIGNED_SHORT&&(l=e.RG16UI),a===e.UNSIGNED_INT&&(l=e.RG32UI),a===e.BYTE&&(l=e.RG8I),a===e.SHORT&&(l=e.RG16I),a===e.INT&&(l=e.RG32I)),r===e.RGB_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RGB8UI),a===e.UNSIGNED_SHORT&&(l=e.RGB16UI),a===e.UNSIGNED_INT&&(l=e.RGB32UI),a===e.BYTE&&(l=e.RGB8I),a===e.SHORT&&(l=e.RGB16I),a===e.INT&&(l=e.RGB32I)),r===e.RGBA_INTEGER&&(a===e.UNSIGNED_BYTE&&(l=e.RGBA8UI),a===e.UNSIGNED_SHORT&&(l=e.RGBA16UI),a===e.UNSIGNED_INT&&(l=e.RGBA32UI),a===e.BYTE&&(l=e.RGBA8I),a===e.SHORT&&(l=e.RGBA16I),a===e.INT&&(l=e.RGBA32I)),r===e.RGB&&(a===e.UNSIGNED_INT_5_9_9_9_REV&&(l=e.RGB9_E5),a===e.UNSIGNED_INT_10F_11F_11F_REV&&(l=e.R11F_G11F_B10F)),r===e.RGBA){let n=o?S.LinearTransfer:S.ColorManagement.getTransfer(i);a===e.FLOAT&&(l=e.RGBA32F),a===e.HALF_FLOAT&&(l=e.RGBA16F),a===e.UNSIGNED_BYTE&&(l=n===S.SRGBTransfer?e.SRGB8_ALPHA8:e.RGBA8),a===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),a===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)}return(l===e.R16F||l===e.R32F||l===e.RG16F||l===e.RG32F||l===e.RGBA16F||l===e.RGBA32F)&&n.get("EXT_color_buffer_float"),l}function E(n,t){let r;return n?null===t||t===S.UnsignedIntType||t===S.UnsignedInt248Type?r=e.DEPTH24_STENCIL8:t===S.FloatType?r=e.DEPTH32F_STENCIL8:t===S.UnsignedShortType&&(r=e.DEPTH24_STENCIL8,(0,S.warn)("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===t||t===S.UnsignedIntType||t===S.UnsignedInt248Type?r=e.DEPTH_COMPONENT24:t===S.FloatType?r=e.DEPTH_COMPONENT32F:t===S.UnsignedShortType&&(r=e.DEPTH_COMPONENT16),r}function T(e,n){return!0===g(e)||e.isFramebufferTexture&&e.minFilter!==S.NearestFilter&&e.minFilter!==S.LinearFilter?Math.log2(Math.max(n.width,n.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?n.mipmaps.length:1}function M(e){let n=e.target;n.removeEventListener("dispose",M),function(e){let n=r.get(e);if(void 0===n.__webglInit)return;let t=e.source,a=f.get(t);if(a){let r=a[n.__cacheKey];r.usedTimes--,0===r.usedTimes&&x(e),0===Object.keys(a).length&&f.delete(t)}r.remove(e)}(n),n.isVideoTexture&&d.delete(n)}function b(n){let t=n.target;t.removeEventListener("dispose",b),function(n){let t=r.get(n);if(n.depthTexture&&(n.depthTexture.dispose(),r.remove(n.depthTexture)),n.isWebGLCubeRenderTarget)for(let n=0;n<6;n++){if(Array.isArray(t.__webglFramebuffer[n]))for(let r=0;r0&&s.__version!==n.version){let e=n.image;if(null===e)(0,S.warn)("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void U(s,n,a);(0,S.warn)("WebGLRenderer: Texture marked for update but image is incomplete")}}else n.isExternalTexture&&(s.__webglTexture=n.sourceTexture?n.sourceTexture:null);t.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+a)}let y={[S.RepeatWrapping]:e.REPEAT,[S.ClampToEdgeWrapping]:e.CLAMP_TO_EDGE,[S.MirroredRepeatWrapping]:e.MIRRORED_REPEAT},A={[S.NearestFilter]:e.NEAREST,[S.NearestMipmapNearestFilter]:e.NEAREST_MIPMAP_NEAREST,[S.NearestMipmapLinearFilter]:e.NEAREST_MIPMAP_LINEAR,[S.LinearFilter]:e.LINEAR,[S.LinearMipmapNearestFilter]:e.LINEAR_MIPMAP_NEAREST,[S.LinearMipmapLinearFilter]:e.LINEAR_MIPMAP_LINEAR},P={[S.NeverCompare]:e.NEVER,[S.AlwaysCompare]:e.ALWAYS,[S.LessCompare]:e.LESS,[S.LessEqualCompare]:e.LEQUAL,[S.EqualCompare]:e.EQUAL,[S.GreaterEqualCompare]:e.GEQUAL,[S.GreaterCompare]:e.GREATER,[S.NotEqualCompare]:e.NOTEQUAL};function w(t,i){if((i.type===S.FloatType&&!1===n.has("OES_texture_float_linear")&&(i.magFilter===S.LinearFilter||i.magFilter===S.LinearMipmapNearestFilter||i.magFilter===S.NearestMipmapLinearFilter||i.magFilter===S.LinearMipmapLinearFilter||i.minFilter===S.LinearFilter||i.minFilter===S.LinearMipmapNearestFilter||i.minFilter===S.NearestMipmapLinearFilter||i.minFilter===S.LinearMipmapLinearFilter)&&(0,S.warn)("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(t,e.TEXTURE_WRAP_S,y[i.wrapS]),e.texParameteri(t,e.TEXTURE_WRAP_T,y[i.wrapT]),(t===e.TEXTURE_3D||t===e.TEXTURE_2D_ARRAY)&&e.texParameteri(t,e.TEXTURE_WRAP_R,y[i.wrapR]),e.texParameteri(t,e.TEXTURE_MAG_FILTER,A[i.magFilter]),e.texParameteri(t,e.TEXTURE_MIN_FILTER,A[i.minFilter]),i.compareFunction&&(e.texParameteri(t,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(t,e.TEXTURE_COMPARE_FUNC,P[i.compareFunction])),!0===n.has("EXT_texture_filter_anisotropic"))&&i.magFilter!==S.NearestFilter&&(i.minFilter===S.NearestMipmapLinearFilter||i.minFilter===S.LinearMipmapLinearFilter)&&(i.type!==S.FloatType||!1!==n.has("OES_texture_float_linear"))&&(i.anisotropy>1||r.get(i).__currentAnisotropy)){let o=n.get("EXT_texture_filter_anisotropic");e.texParameterf(t,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i.anisotropy,a.getMaxAnisotropy())),r.get(i).__currentAnisotropy=i.anisotropy}}function L(n,t){let r,a=!1;void 0===n.__webglInit&&(n.__webglInit=!0,t.addEventListener("dispose",M));let i=t.source,l=f.get(i);void 0===l&&(l={},f.set(i,l));let s=((r=[]).push(t.wrapS),r.push(t.wrapT),r.push(t.wrapR||0),r.push(t.magFilter),r.push(t.minFilter),r.push(t.anisotropy),r.push(t.internalFormat),r.push(t.format),r.push(t.type),r.push(t.generateMipmaps),r.push(t.premultiplyAlpha),r.push(t.flipY),r.push(t.unpackAlignment),r.push(t.colorSpace),r.join());if(s!==n.__cacheKey){void 0===l[s]&&(l[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,a=!0),l[s].usedTimes++;let r=l[n.__cacheKey];void 0!==r&&(l[n.__cacheKey].usedTimes--,0===r.usedTimes&&x(t)),n.__cacheKey=s,n.__webglTexture=l[s].texture}return a}function N(e,n,t){return Math.floor(Math.floor(e/t)/n)}function U(n,o,l){let s=e.TEXTURE_2D;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(s=e.TEXTURE_2D_ARRAY),o.isData3DTexture&&(s=e.TEXTURE_3D);let u=L(n,o),c=o.source;t.bindTexture(s,n.__webglTexture,e.TEXTURE0+l);let d=r.get(c);if(c.version!==d.__version||!0===u){let n;t.activeTexture(e.TEXTURE0+l);let r=S.ColorManagement.getPrimaries(S.ColorManagement.workingColorSpace),f=o.colorSpace===S.NoColorSpace?null:S.ColorManagement.getPrimaries(o.colorSpace),p=o.colorSpace===S.NoColorSpace||r===f?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let m=h(o.image,!1,a.maxTextureSize);m=V(o,m);let M=i.convert(o.format,o.colorSpace),b=i.convert(o.type),x=v(o.internalFormat,M,b,o.colorSpace,o.isVideoTexture);w(s,o);let R=o.mipmaps,C=!0!==o.isVideoTexture,y=void 0===d.__version||!0===u,A=c.dataReady,P=T(o,m);if(o.isDepthTexture)x=E(o.format===S.DepthStencilFormat,o.type),y&&(C?t.texStorage2D(e.TEXTURE_2D,1,x,m.width,m.height):t.texImage2D(e.TEXTURE_2D,0,x,m.width,m.height,0,M,b,null));else if(o.isDataTexture)if(R.length>0){C&&y&&t.texStorage2D(e.TEXTURE_2D,P,x,R[0].width,R[0].height);for(let r=0,a=R.length;re.start-n.start);let l=0;for(let e=1;e0){let a=(0,S.getByteLength)(n.width,n.height,o.format,o.type);for(let i of o.layerUpdates){let o=n.data.subarray(i*a/n.data.BYTES_PER_ELEMENT,(i+1)*a/n.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,i,n.width,n.height,1,M,o)}o.clearLayerUpdates()}else t.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,n.width,n.height,m.depth,M,n.data)}else t.compressedTexImage3D(e.TEXTURE_2D_ARRAY,r,x,n.width,n.height,m.depth,0,n.data,0,0);else(0,S.warn)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else C?A&&t.texSubImage3D(e.TEXTURE_2D_ARRAY,r,0,0,0,n.width,n.height,m.depth,M,b,n.data):t.texImage3D(e.TEXTURE_2D_ARRAY,r,x,n.width,n.height,m.depth,0,M,b,n.data)}else{C&&y&&t.texStorage2D(e.TEXTURE_2D,P,x,R[0].width,R[0].height);for(let r=0,a=R.length;r0){let n=(0,S.getByteLength)(m.width,m.height,o.format,o.type);for(let r of o.layerUpdates){let a=m.data.subarray(r*n/m.data.BYTES_PER_ELEMENT,(r+1)*n/m.data.BYTES_PER_ELEMENT);t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,r,m.width,m.height,1,M,b,a)}o.clearLayerUpdates()}else t.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,M,b,m.data)}else t.texImage3D(e.TEXTURE_2D_ARRAY,0,x,m.width,m.height,m.depth,0,M,b,m.data);else if(o.isData3DTexture)C?(y&&t.texStorage3D(e.TEXTURE_3D,P,x,m.width,m.height,m.depth),A&&t.texSubImage3D(e.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,M,b,m.data)):t.texImage3D(e.TEXTURE_3D,0,x,m.width,m.height,m.depth,0,M,b,m.data);else if(o.isFramebufferTexture){if(y)if(C)t.texStorage2D(e.TEXTURE_2D,P,x,m.width,m.height);else{let n=m.width,r=m.height;for(let a=0;a>=1,r>>=1}}else if(R.length>0){if(C&&y){let n=z(R[0]);t.texStorage2D(e.TEXTURE_2D,P,x,n.width,n.height)}for(let r=0,a=R.length;r>c),r=Math.max(1,a.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?t.texImage3D(u,c,p,n,r,a.depth,0,d,f,null):t.texImage2D(u,c,p,n,r,0,d,f,null)}t.bindFramebuffer(e.FRAMEBUFFER,n),k(a)?s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,l,u,h.__webglTexture,0,H(a)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,l,u,h.__webglTexture,c),t.bindFramebuffer(e.FRAMEBUFFER,null)}function I(n,t,r){if(e.bindRenderbuffer(e.RENDERBUFFER,n),t.depthBuffer){let a=t.depthTexture,i=a&&a.isDepthTexture?a.type:null,o=E(t.stencilBuffer,i),l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;k(t)?s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(t),o,t.width,t.height):r?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(t),o,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,o,t.width,t.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,l,e.RENDERBUFFER,n)}else{let n=t.textures;for(let a=0;a{delete a.__boundDepthTexture,delete a.__depthDisposeCallback,e.removeEventListener("dispose",n)};e.addEventListener("dispose",n),a.__depthDisposeCallback=n}a.__boundDepthTexture=e}if(n.depthTexture&&!a.__autoAllocateDepthBuffer)if(i)for(let e=0;e<6;e++)F(a.__webglFramebuffer[e],n,e);else{let e=n.texture.mipmaps;e&&e.length>0?F(a.__webglFramebuffer[0],n,0):F(a.__webglFramebuffer,n,0)}else if(i){a.__webglDepthbuffer=[];for(let r=0;r<6;r++)if(t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[r]),void 0===a.__webglDepthbuffer[r])a.__webglDepthbuffer[r]=e.createRenderbuffer(),I(a.__webglDepthbuffer[r],n,!1);else{let t=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=a.__webglDepthbuffer[r];e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,t,e.RENDERBUFFER,i)}}else{let r=n.texture.mipmaps;if(r&&r.length>0?t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[0]):t.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),void 0===a.__webglDepthbuffer)a.__webglDepthbuffer=e.createRenderbuffer(),I(a.__webglDepthbuffer,n,!1);else{let t=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,r=a.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,r),e.framebufferRenderbuffer(e.FRAMEBUFFER,t,e.RENDERBUFFER,r)}}t.bindFramebuffer(e.FRAMEBUFFER,null)}let B=[],G=[];function H(e){return Math.min(a.maxSamples,e.samples)}function k(e){let t=r.get(e);return e.samples>0&&!0===n.has("WEBGL_multisampled_render_to_texture")&&!1!==t.__useRenderToTexture}function V(e,n){let t=e.colorSpace,r=e.format,a=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||t!==S.LinearSRGBColorSpace&&t!==S.NoColorSpace&&(S.ColorManagement.getTransfer(t)===S.SRGBTransfer?(r!==S.RGBAFormat||a!==S.UnsignedByteType)&&(0,S.warn)("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):(0,S.error)("WebGLTextures: Unsupported texture color space:",t)),n}function z(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"u">typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){let e=R;return e>=a.maxTextures&&(0,S.warn)("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+a.maxTextures),R+=1,e},this.resetTextureUnits=function(){R=0},this.setTexture2D=C,this.setTexture2DArray=function(n,a){let i=r.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?U(i,n,a):(n.isExternalTexture&&(i.__webglTexture=n.sourceTexture?n.sourceTexture:null),t.bindTexture(e.TEXTURE_2D_ARRAY,i.__webglTexture,e.TEXTURE0+a))},this.setTexture3D=function(n,a){let i=r.get(n);!1===n.isRenderTargetTexture&&n.version>0&&i.__version!==n.version?U(i,n,a):t.bindTexture(e.TEXTURE_3D,i.__webglTexture,e.TEXTURE0+a)},this.setTextureCube=function(n,o){let l=r.get(n);!0!==n.isCubeDepthTexture&&n.version>0&&l.__version!==n.version?function(n,o,l){if(6!==o.image.length)return;let s=L(n,o),u=o.source;t.bindTexture(e.TEXTURE_CUBE_MAP,n.__webglTexture,e.TEXTURE0+l);let c=r.get(u);if(u.version!==c.__version||!0===s){let n;t.activeTexture(e.TEXTURE0+l);let r=S.ColorManagement.getPrimaries(S.ColorManagement.workingColorSpace),d=o.colorSpace===S.NoColorSpace?null:S.ColorManagement.getPrimaries(o.colorSpace),f=o.colorSpace===S.NoColorSpace||r===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,o.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,o.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,f);let p=o.isCompressedTexture||o.image[0].isCompressedTexture,m=o.image[0]&&o.image[0].isDataTexture,E=[];for(let e=0;e<6;e++)p||m?E[e]=m?o.image[e].image:o.image[e]:E[e]=h(o.image[e],!0,a.maxCubemapSize),E[e]=V(o,E[e]);let M=E[0],b=i.convert(o.format,o.colorSpace),x=i.convert(o.type),R=v(o.internalFormat,b,x,o.colorSpace),C=!0!==o.isVideoTexture,y=void 0===c.__version||!0===s,A=u.dataReady,P=T(o,M);if(w(e.TEXTURE_CUBE_MAP,o),p){C&&y&&t.texStorage2D(e.TEXTURE_CUBE_MAP,P,R,M.width,M.height);for(let r=0;r<6;r++){n=E[r].mipmaps;for(let a=0;a0&&P++;let r=z(E[0]);t.texStorage2D(e.TEXTURE_CUBE_MAP,P,R,r.width,r.height)}for(let r=0;r<6;r++)if(m){C?A&&t.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,0,0,E[r].width,E[r].height,b,x,E[r].data):t.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,R,E[r].width,E[r].height,0,b,x,E[r].data);for(let a=0;a1;if(!d&&(void 0===s.__webglTexture&&(s.__webglTexture=e.createTexture()),s.__version=a.version,o.memory.textures++),c){l.__webglFramebuffer=[];for(let n=0;n<6;n++)if(a.mipmaps&&a.mipmaps.length>0){l.__webglFramebuffer[n]=[];for(let t=0;t0){l.__webglFramebuffer=[];for(let n=0;n0&&!1===k(n)){l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],t.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(let t=0;t0)for(let r=0;r0)for(let t=0;t0){if(!1===k(n)){let a=n.textures,i=n.width,o=n.height,l=e.COLOR_BUFFER_BIT,s=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=r.get(n),d=a.length>1;if(d)for(let n=0;n0?t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):t.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let t=0;t= 1.0 ) { - - gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; - - } else { - - gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; - - } - -}`;class nj{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(null===this.texture){let t=new S.ExternalTexture(e.texture);(e.depthNear!==n.depthNear||e.depthFar!==n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=t}}getMesh(e){if(null!==this.texture&&null===this.mesh){let n=e.cameras[0].viewport,t=new S.ShaderMaterial({vertexShader:nW,fragmentShader:nX,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new S.Mesh(new S.PlaneGeometry(20,20),t)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class nq extends S.EventDispatcher{constructor(e,n){super();const t=this;let r=null,a=1,i=null,o="local-floor",l=1,s=null,u=null,c=null,d=null,f=null,p=null;const m="u">typeof XRWebGLBinding,h=new nj,g={},_=n.getContextAttributes();let v=null,T=null;const M=[],b=[],x=new S.Vector2;let R=null;const C=new S.PerspectiveCamera;C.viewport=new S.Vector4;const y=new S.PerspectiveCamera;y.viewport=new S.Vector4;const A=[C,y],P=new S.ArrayCamera;let w=null,L=null;function N(e){let n=b.indexOf(e.inputSource);if(-1===n)return;let t=M[n];void 0!==t&&(t.update(e.inputSource,e.frame,s||i),t.dispatchEvent({type:e.type,data:e.inputSource}))}function U(){r.removeEventListener("select",N),r.removeEventListener("selectstart",N),r.removeEventListener("selectend",N),r.removeEventListener("squeeze",N),r.removeEventListener("squeezestart",N),r.removeEventListener("squeezeend",N),r.removeEventListener("end",U),r.removeEventListener("inputsourceschange",D);for(let e=0;e=0&&(b[r]=null,M[r].disconnect(t))}for(let n=0;n=b.length){b.push(t),r=e;break}else if(null===b[e]){b[e]=t,r=e;break}if(-1===r)break}let a=M[r];a&&a.connect(t)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getTargetRaySpace()},this.getControllerGrip=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getGripSpace()},this.getHand=function(e){let n=M[e];return void 0===n&&(n=new S.WebXRController,M[e]=n),n.getHandSpace()},this.setFramebufferScaleFactor=function(e){a=e,!0===t.isPresenting&&(0,S.warn)("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){o=e,!0===t.isPresenting&&(0,S.warn)("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||i},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==d?d:f},this.getBinding=function(){return null===c&&m&&(c=new XRWebGLBinding(r,n)),c},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(u){if(null!==(r=u)){if(v=e.getRenderTarget(),r.addEventListener("select",N),r.addEventListener("selectstart",N),r.addEventListener("selectend",N),r.addEventListener("squeeze",N),r.addEventListener("squeezestart",N),r.addEventListener("squeezeend",N),r.addEventListener("end",U),r.addEventListener("inputsourceschange",D),!0!==_.xrCompatible&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(x),m&&"createProjectionLayer"in XRWebGLBinding.prototype){let t=null,i=null,o=null;_.depth&&(o=_.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,t=_.stencil?S.DepthStencilFormat:S.DepthFormat,i=_.stencil?S.UnsignedInt248Type:S.UnsignedIntType);let l={colorFormat:n.RGBA8,depthFormat:o,scaleFactor:a};d=(c=this.getBinding()).createProjectionLayer(l),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),T=new S.WebGLRenderTarget(d.textureWidth,d.textureHeight,{format:S.RGBAFormat,type:S.UnsignedByteType,depthTexture:new S.DepthTexture(d.textureWidth,d.textureHeight,i,void 0,void 0,void 0,void 0,void 0,void 0,t),stencilBuffer:_.stencil,colorSpace:e.outputColorSpace,samples:4*!!_.antialias,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}else{let t={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:a};f=new XRWebGLLayer(r,n,t),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),T=new S.WebGLRenderTarget(f.framebufferWidth,f.framebufferHeight,{format:S.RGBAFormat,type:S.UnsignedByteType,colorSpace:e.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:!1===f.ignoreDepthValues,resolveStencilBuffer:!1===f.ignoreDepthValues})}T.isXRRenderTarget=!0,this.setFoveation(l),s=null,i=await r.requestReferenceSpace(o),G.setContext(r),G.start(),t.isPresenting=!0,t.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==r)return r.environmentBlendMode},this.getDepthTexture=function(){return h.getDepthTexture()};const I=new S.Vector3,F=new S.Vector3;function O(e,n){null===n?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(n.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var n,t,a;if(null===r)return;let i=e.near,o=e.far;null!==h.texture&&(h.depthNear>0&&(i=h.depthNear),h.depthFar>0&&(o=h.depthFar)),P.near=y.near=C.near=i,P.far=y.far=C.far=o,(w!==P.near||L!==P.far)&&(r.updateRenderState({depthNear:P.near,depthFar:P.far}),w=P.near,L=P.far),P.layers.mask=6|e.layers.mask,C.layers.mask=3&P.layers.mask,y.layers.mask=5&P.layers.mask;let l=e.parent,s=P.cameras;O(P,l);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let a=n.get(r),i=a.envMap,o=a.envMapRotation;i&&(e.envMap.value=i,nY.copy(o),nY.x*=-1,nY.y*=-1,nY.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(nY.y*=-1,nY.z*=-1),e.envMapRotation.value.setFromMatrix4(nK.makeRotationFromEuler(nY)),e.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,t(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,t(r.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(n,t){t.color.getRGB(n.fogColor.value,(0,S.getUnlitUniformColorSpace)(e)),t.isFog?(n.fogNear.value=t.near,n.fogFar.value=t.far):t.isFogExp2&&(n.fogDensity.value=t.density)},refreshMaterialUniforms:function(e,a,i,o,l){var s,u,c,d,f,p,m,h,g,_,v,E,T,M,b,x,R,C,y,A,P,w,L;let N;a.isMeshBasicMaterial||a.isMeshLambertMaterial?r(e,a):a.isMeshToonMaterial?(r(e,a),s=e,(u=a).gradientMap&&(s.gradientMap.value=u.gradientMap)):a.isMeshPhongMaterial?(r(e,a),c=e,d=a,c.specular.value.copy(d.specular),c.shininess.value=Math.max(d.shininess,1e-4)):a.isMeshStandardMaterial?(r(e,a),f=e,p=a,f.metalness.value=p.metalness,p.metalnessMap&&(f.metalnessMap.value=p.metalnessMap,t(p.metalnessMap,f.metalnessMapTransform)),f.roughness.value=p.roughness,p.roughnessMap&&(f.roughnessMap.value=p.roughnessMap,t(p.roughnessMap,f.roughnessMapTransform)),p.envMap&&(f.envMapIntensity.value=p.envMapIntensity),a.isMeshPhysicalMaterial&&(m=e,h=a,g=l,m.ior.value=h.ior,h.sheen>0&&(m.sheenColor.value.copy(h.sheenColor).multiplyScalar(h.sheen),m.sheenRoughness.value=h.sheenRoughness,h.sheenColorMap&&(m.sheenColorMap.value=h.sheenColorMap,t(h.sheenColorMap,m.sheenColorMapTransform)),h.sheenRoughnessMap&&(m.sheenRoughnessMap.value=h.sheenRoughnessMap,t(h.sheenRoughnessMap,m.sheenRoughnessMapTransform))),h.clearcoat>0&&(m.clearcoat.value=h.clearcoat,m.clearcoatRoughness.value=h.clearcoatRoughness,h.clearcoatMap&&(m.clearcoatMap.value=h.clearcoatMap,t(h.clearcoatMap,m.clearcoatMapTransform)),h.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=h.clearcoatRoughnessMap,t(h.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),h.clearcoatNormalMap&&(m.clearcoatNormalMap.value=h.clearcoatNormalMap,t(h.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(h.clearcoatNormalScale),h.side===S.BackSide&&m.clearcoatNormalScale.value.negate())),h.dispersion>0&&(m.dispersion.value=h.dispersion),h.iridescence>0&&(m.iridescence.value=h.iridescence,m.iridescenceIOR.value=h.iridescenceIOR,m.iridescenceThicknessMinimum.value=h.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=h.iridescenceThicknessRange[1],h.iridescenceMap&&(m.iridescenceMap.value=h.iridescenceMap,t(h.iridescenceMap,m.iridescenceMapTransform)),h.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=h.iridescenceThicknessMap,t(h.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),h.transmission>0&&(m.transmission.value=h.transmission,m.transmissionSamplerMap.value=g.texture,m.transmissionSamplerSize.value.set(g.width,g.height),h.transmissionMap&&(m.transmissionMap.value=h.transmissionMap,t(h.transmissionMap,m.transmissionMapTransform)),m.thickness.value=h.thickness,h.thicknessMap&&(m.thicknessMap.value=h.thicknessMap,t(h.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=h.attenuationDistance,m.attenuationColor.value.copy(h.attenuationColor)),h.anisotropy>0&&(m.anisotropyVector.value.set(h.anisotropy*Math.cos(h.anisotropyRotation),h.anisotropy*Math.sin(h.anisotropyRotation)),h.anisotropyMap&&(m.anisotropyMap.value=h.anisotropyMap,t(h.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=h.specularIntensity,m.specularColor.value.copy(h.specularColor),h.specularColorMap&&(m.specularColorMap.value=h.specularColorMap,t(h.specularColorMap,m.specularColorMapTransform)),h.specularIntensityMap&&(m.specularIntensityMap.value=h.specularIntensityMap,t(h.specularIntensityMap,m.specularIntensityMapTransform)))):a.isMeshMatcapMaterial?(r(e,a),_=e,(v=a).matcap&&(_.matcap.value=v.matcap)):a.isMeshDepthMaterial?r(e,a):a.isMeshDistanceMaterial?(r(e,a),E=e,T=a,N=n.get(T).light,E.referencePosition.value.setFromMatrixPosition(N.matrixWorld),E.nearDistance.value=N.shadow.camera.near,E.farDistance.value=N.shadow.camera.far):a.isMeshNormalMaterial?r(e,a):a.isLineBasicMaterial?(M=e,b=a,M.diffuse.value.copy(b.color),M.opacity.value=b.opacity,b.map&&(M.map.value=b.map,t(b.map,M.mapTransform)),a.isLineDashedMaterial&&(x=e,R=a,x.dashSize.value=R.dashSize,x.totalSize.value=R.dashSize+R.gapSize,x.scale.value=R.scale)):a.isPointsMaterial?(C=e,y=a,A=i,P=o,C.diffuse.value.copy(y.color),C.opacity.value=y.opacity,C.size.value=y.size*A,C.scale.value=.5*P,y.map&&(C.map.value=y.map,t(y.map,C.uvTransform)),y.alphaMap&&(C.alphaMap.value=y.alphaMap,t(y.alphaMap,C.alphaMapTransform)),y.alphaTest>0&&(C.alphaTest.value=y.alphaTest)):a.isSpriteMaterial?(w=e,L=a,w.diffuse.value.copy(L.color),w.opacity.value=L.opacity,w.rotation.value=L.rotation,L.map&&(w.map.value=L.map,t(L.map,w.mapTransform)),L.alphaMap&&(w.alphaMap.value=L.alphaMap,t(L.alphaMap,w.alphaMapTransform)),L.alphaTest>0&&(w.alphaTest.value=L.alphaTest)):a.isShadowMaterial?(e.color.value.copy(a.color),e.opacity.value=a.opacity):a.isShaderMaterial&&(a.uniformsNeedUpdate=!1)}}}function nQ(e,n,t,r){let a={},i={},o=[],l=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function s(e){let n={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(n.boundary=4,n.storage=4):e.isVector2?(n.boundary=8,n.storage=8):e.isVector3||e.isColor?(n.boundary=16,n.storage=12):e.isVector4?(n.boundary=16,n.storage=16):e.isMatrix3?(n.boundary=48,n.storage=48):e.isMatrix4?(n.boundary=64,n.storage=64):e.isTexture?(0,S.warn)("WebGLRenderer: Texture samplers can not be part of an uniforms group."):(0,S.warn)("WebGLRenderer: Unsupported uniform value type.",e),n}function u(n){let t=n.target;t.removeEventListener("dispose",u);let r=o.indexOf(t.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(a[t.id]),delete a[t.id],delete i[t.id]}return{bind:function(e,n){let t=n.program;r.uniformBlockBinding(e,t)},update:function(t,c){var d;let f,p,m,h,g=a[t.id];void 0===g&&(function(e){let n=e.uniforms,t=0;for(let e=0,r=n.length;e0&&(t+=16-r),e.__size=t,e.__cache={}}(t),(d=t).__bindingPointIndex=f=function(){for(let e=0;etypeof WebGLRenderingContext&&F instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");n=F.getContextAttributes().alpha}else n=G;const q=new Set([S.RGBAIntegerFormat,S.RGIntegerFormat,S.RedIntegerFormat]),en=new Set([S.UnsignedByteType,S.UnsignedIntType,S.UnsignedShortType,S.UnsignedInt248Type,S.UnsignedShort4444Type,S.UnsignedShort5551Type]),er=new Uint32Array(4),ea=new Int32Array(4);let ei=null,eo=null;const el=[],es=[];let eu=null;this.domElement=I,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=S.NoToneMapping,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const ec=this;let ed=!1;this._outputColorSpace=S.SRGBColorSpace;let ef=0,ep=0,em=null,eh=-1,eg=null;const e_=new S.Vector4,ev=new S.Vector4;let eS=null;const eE=new S.Color(0);let eT=0,eM=I.width,eb=I.height,ex=1,eR=null,eC=null;const ey=new S.Vector4(0,0,eM,eb),eA=new S.Vector4(0,0,eM,eb);let eP=!1;const ew=new S.Frustum;let eL=!1,eN=!1;const eU=new S.Matrix4,eD=new S.Vector3,eI=new S.Vector4,eF={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let eO=!1;function eB(){return null===em?ex:1}let eG=F;function eH(e,n){return I.getContext(e,n)}try{if("setAttribute"in I&&I.setAttribute("data-engine",`three.js r${S.REVISION}`),I.addEventListener("webglcontextlost",ez,!1),I.addEventListener("webglcontextrestored",eW,!1),I.addEventListener("webglcontextcreationerror",eX,!1),null===eG){const e="webgl2";if(eG=eH(e,{alpha:!0,depth:O,stencil:B,antialias:H,premultipliedAlpha:k,preserveDrawingBuffer:V,powerPreference:z,failIfMajorPerformanceCaveat:W}),null===eG)if(eH(e))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(e){throw(0,S.error)("WebGLRenderer: "+e.message),e}function ek(){(t=new K(eG)).init(),C=new nz(eG,t),r=new L(eG,t,e,C),a=new nk(eG,t),r.reversedDepthBuffer&&X&&a.buffers.depth.setReversed(!0),i=new Z(eG),o=new nb,l=new nV(eG,t,a,o,r,C,i),s=new U(ec),u=new Y(ec),c=new T(eG),y=new P(eG,c),d=new $(eG,c,i,y),f=new ee(eG,d,c,i),b=new J(eG,r,l),_=new N(o),p=new nM(ec,s,u,t,r,y,_),m=new n$(ec,o),h=new ny,g=new nU(t),M=new A(ec,s,u,a,f,n,k),v=new nG(ec,f,r),D=new nQ(eG,i,r,a),x=new w(eG,t,i),R=new Q(eG,t,i),i.programs=p.programs,ec.capabilities=r,ec.extensions=t,ec.properties=o,ec.renderLists=h,ec.shadowMap=v,ec.state=a,ec.info=i}ek(),j!==S.UnsignedByteType&&(eu=new et(j,I.width,I.height,O,B));const eV=new nq(ec,eG);function ez(e){e.preventDefault(),(0,S.log)("WebGLRenderer: Context Lost."),ed=!0}function eW(){(0,S.log)("WebGLRenderer: Context Restored."),ed=!1;let e=i.autoReset,n=v.enabled,t=v.autoUpdate,r=v.needsUpdate,a=v.type;ek(),i.autoReset=e,v.enabled=n,v.autoUpdate=t,v.needsUpdate=r,v.type=a}function eX(e){(0,S.error)("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function ej(e){var n,t;let r,a=e.target;a.removeEventListener("dispose",ej),t=n=a,void 0!==(r=o.get(t).programs)&&(r.forEach(function(e){p.releaseProgram(e)}),t.isShaderMaterial&&p.releaseShaderCache(t)),o.remove(n)}function eq(e,n,t){!0===e.transparent&&e.side===S.DoubleSide&&!1===e.forceSinglePass?(e.side=S.BackSide,e.needsUpdate=!0,e2(e,n,t),e.side=S.FrontSide,e.needsUpdate=!0,e2(e,n,t),e.side=S.DoubleSide):e2(e,n,t)}this.xr=eV,this.getContext=function(){return eG},this.getContextAttributes=function(){return eG.getContextAttributes()},this.forceContextLoss=function(){let e=t.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=t.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return ex},this.setPixelRatio=function(e){void 0!==e&&(ex=e,this.setSize(eM,eb,!1))},this.getSize=function(e){return e.set(eM,eb)},this.setSize=function(e,n,t=!0){eV.isPresenting?(0,S.warn)("WebGLRenderer: Can't change size while VR device is presenting."):(eM=e,eb=n,I.width=Math.floor(e*ex),I.height=Math.floor(n*ex),!0===t&&(I.style.width=e+"px",I.style.height=n+"px"),null!==eu&&eu.setSize(I.width,I.height),this.setViewport(0,0,e,n))},this.getDrawingBufferSize=function(e){return e.set(eM*ex,eb*ex).floor()},this.setDrawingBufferSize=function(e,n,t){eM=e,eb=n,ex=t,I.width=Math.floor(e*t),I.height=Math.floor(n*t),this.setViewport(0,0,e,n)},this.setEffects=function(e){if(j===S.UnsignedByteType)return void console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");if(e){for(let n=0;np.matrixWorld.determinant(),E=function(e,n,t,i,c){var d,f;!0!==n.isScene&&(n=eF),l.resetTextureUnits();let p=n.fog,h=i.isMeshStandardMaterial?n.environment:null,g=null===em?ec.outputColorSpace:!0===em.isXRRenderTarget?em.texture.colorSpace:S.LinearSRGBColorSpace,v=(i.isMeshStandardMaterial?u:s).get(i.envMap||h),E=!0===i.vertexColors&&!!t.attributes.color&&4===t.attributes.color.itemSize,T=!!t.attributes.tangent&&(!!i.normalMap||i.anisotropy>0),M=!!t.morphAttributes.position,x=!!t.morphAttributes.normal,R=!!t.morphAttributes.color,C=S.NoToneMapping;i.toneMapped&&(null===em||!0===em.isXRRenderTarget)&&(C=ec.toneMapping);let y=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,A=void 0!==y?y.length:0,P=o.get(i),w=eo.state.lights;if(!0===eL&&(!0===eN||e!==eg)){let n=e===eg&&i.id===eh;_.setState(i,e,n)}let L=!1;i.version===P.__version?P.needsLights&&P.lightsStateVersion!==w.state.version||P.outputColorSpace!==g||c.isBatchedMesh&&!1===P.batching?L=!0:c.isBatchedMesh||!0!==P.batching?c.isBatchedMesh&&!0===P.batchingColor&&null===c.colorTexture||c.isBatchedMesh&&!1===P.batchingColor&&null!==c.colorTexture||c.isInstancedMesh&&!1===P.instancing?L=!0:c.isInstancedMesh||!0!==P.instancing?c.isSkinnedMesh&&!1===P.skinning?L=!0:c.isSkinnedMesh||!0!==P.skinning?c.isInstancedMesh&&!0===P.instancingColor&&null===c.instanceColor||c.isInstancedMesh&&!1===P.instancingColor&&null!==c.instanceColor||c.isInstancedMesh&&!0===P.instancingMorph&&null===c.morphTexture||c.isInstancedMesh&&!1===P.instancingMorph&&null!==c.morphTexture||P.envMap!==v||!0===i.fog&&P.fog!==p||void 0!==P.numClippingPlanes&&(P.numClippingPlanes!==_.numPlanes||P.numIntersection!==_.numIntersection)||P.vertexAlphas!==E||P.vertexTangents!==T||P.morphTargets!==M||P.morphNormals!==x||P.morphColors!==R||P.toneMapping!==C?L=!0:P.morphTargetsCount!==A&&(L=!0):L=!0:L=!0:L=!0:(L=!0,P.__version=i.version);let N=P.currentProgram;!0===L&&(N=e2(i,n,c));let U=!1,I=!1,F=!1,O=N.getUniforms(),B=P.uniforms;if(a.useProgram(N.program)&&(U=!0,I=!0,F=!0),i.id!==eh&&(eh=i.id,I=!0),U||eg!==e){a.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(eG,"projectionMatrix",e.projectionMatrix),O.setValue(eG,"viewMatrix",e.matrixWorldInverse);let n=O.map.cameraPosition;void 0!==n&&n.setValue(eG,eD.setFromMatrixPosition(e.matrixWorld)),r.logarithmicDepthBuffer&&O.setValue(eG,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&O.setValue(eG,"isOrthographic",!0===e.isOrthographicCamera),eg!==e&&(eg=e,I=!0,F=!0)}if(P.needsLights&&(w.state.directionalShadowMap.length>0&&O.setValue(eG,"directionalShadowMap",w.state.directionalShadowMap,l),w.state.spotShadowMap.length>0&&O.setValue(eG,"spotShadowMap",w.state.spotShadowMap,l),w.state.pointShadowMap.length>0&&O.setValue(eG,"pointShadowMap",w.state.pointShadowMap,l)),c.isSkinnedMesh){O.setOptional(eG,c,"bindMatrix"),O.setOptional(eG,c,"bindMatrixInverse");let e=c.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),O.setValue(eG,"boneTexture",e.boneTexture,l))}c.isBatchedMesh&&(O.setOptional(eG,c,"batchingTexture"),O.setValue(eG,"batchingTexture",c._matricesTexture,l),O.setOptional(eG,c,"batchingIdTexture"),O.setValue(eG,"batchingIdTexture",c._indirectTexture,l),O.setOptional(eG,c,"batchingColorTexture"),null!==c._colorsTexture&&O.setValue(eG,"batchingColorTexture",c._colorsTexture,l));let G=t.morphAttributes;if((void 0!==G.position||void 0!==G.normal||void 0!==G.color)&&b.update(c,t,N),(I||P.receiveShadow!==c.receiveShadow)&&(P.receiveShadow=c.receiveShadow,O.setValue(eG,"receiveShadow",c.receiveShadow)),i.isMeshGouraudMaterial&&null!==i.envMap&&(B.envMap.value=v,B.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1),i.isMeshStandardMaterial&&null===i.envMap&&null!==n.environment&&(B.envMapIntensity.value=n.environmentIntensity),void 0!==B.dfgLUT&&(B.dfgLUT.value=(null===nJ&&((nJ=new S.DataTexture(nZ,16,16,S.RGFormat,S.HalfFloatType)).name="DFG_LUT",nJ.minFilter=S.LinearFilter,nJ.magFilter=S.LinearFilter,nJ.wrapS=S.ClampToEdgeWrapping,nJ.wrapT=S.ClampToEdgeWrapping,nJ.generateMipmaps=!1,nJ.needsUpdate=!0),nJ)),I&&(O.setValue(eG,"toneMappingExposure",ec.toneMappingExposure),P.needsLights&&(d=B,f=F,d.ambientLightColor.needsUpdate=f,d.lightProbe.needsUpdate=f,d.directionalLights.needsUpdate=f,d.directionalLightShadows.needsUpdate=f,d.pointLights.needsUpdate=f,d.pointLightShadows.needsUpdate=f,d.spotLights.needsUpdate=f,d.spotLightShadows.needsUpdate=f,d.rectAreaLights.needsUpdate=f,d.hemisphereLights.needsUpdate=f),p&&!0===i.fog&&m.refreshFogUniforms(B,p),m.refreshMaterialUniforms(B,i,ex,eb,eo.state.transmissionRenderTarget[e.id]),e6.upload(eG,e4(P),B,l)),i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(e6.upload(eG,e4(P),B,l),i.uniformsNeedUpdate=!1),i.isSpriteMaterial&&O.setValue(eG,"center",c.center),O.setValue(eG,"modelViewMatrix",c.modelViewMatrix),O.setValue(eG,"normalMatrix",c.normalMatrix),O.setValue(eG,"modelMatrix",c.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){let e=i.uniformsGroups;for(let n=0,t=e.length;n{function r(){(a.forEach(function(e){o.get(e).currentProgram.isReady()&&a.delete(e)}),0===a.size)?n(e):setTimeout(r,10)}null!==t.get("KHR_parallel_shader_compile")?r():setTimeout(r,10)})};let eY=null;function eK(){eQ.stop()}function e$(){eQ.start()}const eQ=new E;function eZ(e,n,t,r){if(!1===e.visible)return;if(e.layers.test(n.layers)){if(e.isGroup)t=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(n);else if(e.isLight)eo.pushLight(e),e.castShadow&&eo.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||ew.intersectsSprite(e)){r&&eI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(eU);let n=f.update(e),a=e.material;a.visible&&ei.push(e,n,a,t,eI.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||ew.intersectsObject(e))){let n=f.update(e),a=e.material;if(r&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),eI.copy(e.boundingSphere.center)):(null===n.boundingSphere&&n.computeBoundingSphere(),eI.copy(n.boundingSphere.center)),eI.applyMatrix4(e.matrixWorld).applyMatrix4(eU)),Array.isArray(a)){let r=n.groups;for(let i=0,o=r.length;i0&&e1(i,n,t),o.length>0&&e1(o,n,t),l.length>0&&e1(l,n,t),a.buffers.depth.setTest(!0),a.buffers.depth.setMask(!0),a.buffers.color.setMask(!0),a.setPolygonOffset(!1)}function e0(e,n,a,i){if(null!==(!0===a.isScene?a.overrideMaterial:null))return;if(void 0===eo.state.transmissionRenderTarget[i.id]){let e=t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float");eo.state.transmissionRenderTarget[i.id]=new S.WebGLRenderTarget(1,1,{generateMipmaps:!0,type:e?S.HalfFloatType:S.UnsignedByteType,minFilter:S.LinearMipmapLinearFilter,samples:r.samples,stencilBuffer:B,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:S.ColorManagement.workingColorSpace})}let o=eo.state.transmissionRenderTarget[i.id],s=i.viewport||e_;o.setSize(s.z*ec.transmissionResolutionScale,s.w*ec.transmissionResolutionScale);let u=ec.getRenderTarget(),c=ec.getActiveCubeFace(),d=ec.getActiveMipmapLevel();ec.setRenderTarget(o),ec.getClearColor(eE),(eT=ec.getClearAlpha())<1&&ec.setClearColor(0xffffff,.5),ec.clear(),eO&&M.render(a);let f=ec.toneMapping;ec.toneMapping=S.NoToneMapping;let p=i.viewport;if(void 0!==i.viewport&&(i.viewport=void 0),eo.setupLightsView(i),!0===eL&&_.setGlobalState(ec.clippingPlanes,i),e1(e,a,i),l.updateMultisampleRenderTarget(o),l.updateRenderTargetMipmap(o),!1===t.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let t=0,r=n.length;ttypeof self&&eQ.setContext(self),this.setAnimationLoop=function(e){eY=e,eV.setAnimationLoop(e),null===e?eQ.stop():eQ.start()},eV.addEventListener("sessionstart",eK),eV.addEventListener("sessionend",e$),this.render=function(e,n){if(void 0!==n&&!0!==n.isCamera)return void(0,S.error)("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===ed)return;let t=!0===eV.enabled&&!0===eV.isPresenting,r=null!==eu&&(null===em||t)&&eu.begin(ec,em);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===n.parent&&!0===n.matrixWorldAutoUpdate&&n.updateMatrixWorld(),!0===eV.enabled&&!0===eV.isPresenting&&(null===eu||!1===eu.isCompositing())&&(!0===eV.cameraAutoUpdate&&eV.updateCamera(n),n=eV.getCamera()),!0===e.isScene&&e.onBeforeRender(ec,e,n,em),(eo=g.get(e,es.length)).init(n),es.push(eo),eU.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),ew.setFromProjectionMatrix(eU,S.WebGLCoordinateSystem,n.reversedDepth),eN=this.localClippingEnabled,eL=_.init(this.clippingPlanes,eN),(ei=h.get(e,el.length)).init(),el.push(ei),!0===eV.enabled&&!0===eV.isPresenting){let e=ec.xr.getDepthSensingMesh();null!==e&&eZ(e,n,-1/0,ec.sortObjects)}eZ(e,n,0,ec.sortObjects),ei.finish(),!0===ec.sortObjects&&ei.sort(eR,eC),(eO=!1===eV.enabled||!1===eV.isPresenting||!1===eV.hasDepthSensing())&&M.addToRenderList(ei,e),this.info.render.frame++,!0===eL&&_.beginShadows();let a=eo.state.shadowsArray;if(v.render(a,e,n),!0===eL&&_.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(r&&eu.hasRenderPass())){let t=ei.opaque,r=ei.transmissive;if(eo.setupLights(),n.isArrayCamera){let a=n.cameras;if(r.length>0)for(let n=0,i=a.length;n0&&e0(t,r,e,n),eO&&M.render(e),eJ(ei,e,n)}null!==em&&0===ep&&(l.updateMultisampleRenderTarget(em),l.updateRenderTargetMipmap(em)),r&&eu.end(ec),!0===e.isScene&&e.onAfterRender(ec,e,n),y.resetDefaultState(),eh=-1,eg=null,es.pop(),es.length>0?(eo=es[es.length-1],!0===eL&&_.setGlobalState(ec.clippingPlanes,eo.state.camera)):eo=null,el.pop(),ei=el.length>0?el[el.length-1]:null},this.getActiveCubeFace=function(){return ef},this.getActiveMipmapLevel=function(){return ep},this.getRenderTarget=function(){return em},this.setRenderTargetTextures=function(e,n,t){let r=o.get(e);r.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===r.__autoAllocateDepthBuffer&&(r.__useRenderToTexture=!1),o.get(e.texture).__webglTexture=n,o.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:t,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,n){let t=o.get(e);t.__webglFramebuffer=n,t.__useDefaultFramebuffer=void 0===n};const e8=eG.createFramebuffer();this.setRenderTarget=function(e,n=0,t=0){em=e,ef=n,ep=t;let r=null,i=!1,s=!1;if(e){let u=o.get(e);if(void 0!==u.__useDefaultFramebuffer){a.bindFramebuffer(eG.FRAMEBUFFER,u.__webglFramebuffer),e_.copy(e.viewport),ev.copy(e.scissor),eS=e.scissorTest,a.viewport(e_),a.scissor(ev),a.setScissorTest(eS),eh=-1;return}if(void 0===u.__webglFramebuffer)l.setupRenderTarget(e);else if(u.__hasExternalTextures)l.rebindTextures(e,o.get(e.texture).__webglTexture,o.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let n=e.depthTexture;if(u.__boundDepthTexture!==n){if(null!==n&&o.has(n)&&(e.width!==n.image.width||e.height!==n.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");l.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(s=!0);let d=o.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=Array.isArray(d[n])?d[n][t]:d[n],i=!0):r=e.samples>0&&!1===l.useMultisampledRTT(e)?o.get(e).__webglMultisampledFramebuffer:Array.isArray(d)?d[t]:d,e_.copy(e.viewport),ev.copy(e.scissor),eS=e.scissorTest}else e_.copy(ey).multiplyScalar(ex).floor(),ev.copy(eA).multiplyScalar(ex).floor(),eS=eP;if(0!==t&&(r=e8),a.bindFramebuffer(eG.FRAMEBUFFER,r)&&a.drawBuffers(e,r),a.viewport(e_),a.scissor(ev),a.setScissorTest(eS),i){let r=o.get(e.texture);eG.framebufferTexture2D(eG.FRAMEBUFFER,eG.COLOR_ATTACHMENT0,eG.TEXTURE_CUBE_MAP_POSITIVE_X+n,r.__webglTexture,t)}else if(s)for(let r=0;r=0&&n<=e.width-i&&t>=0&&t<=e.height-l&&(e.textures.length>1&&eG.readBuffer(eG.COLOR_ATTACHMENT0+c),eG.readPixels(n,t,i,l,C.convert(o),C.convert(u),s))}finally{let e=null!==em?o.get(em).__webglFramebuffer:null;a.bindFramebuffer(eG.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,n,t,i,l,s,u,c=0){if(!(e&&e.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let d=o.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(d=d[u]),d)if(n>=0&&n<=e.width-i&&t>=0&&t<=e.height-l){a.bindFramebuffer(eG.FRAMEBUFFER,d);let u=e.textures[c],f=u.format,p=u.type;if(!r.textureFormatReadable(f))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!r.textureTypeReadable(p))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let m=eG.createBuffer();eG.bindBuffer(eG.PIXEL_PACK_BUFFER,m),eG.bufferData(eG.PIXEL_PACK_BUFFER,s.byteLength,eG.STREAM_READ),e.textures.length>1&&eG.readBuffer(eG.COLOR_ATTACHMENT0+c),eG.readPixels(n,t,i,l,C.convert(f),C.convert(p),0);let h=null!==em?o.get(em).__webglFramebuffer:null;a.bindFramebuffer(eG.FRAMEBUFFER,h);let g=eG.fenceSync(eG.SYNC_GPU_COMMANDS_COMPLETE,0);return eG.flush(),await (0,S.probeAsync)(eG,g,4),eG.bindBuffer(eG.PIXEL_PACK_BUFFER,m),eG.getBufferSubData(eG.PIXEL_PACK_BUFFER,0,s),eG.deleteBuffer(m),eG.deleteSync(g),s}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(e,n=null,t=0){let r=Math.pow(2,-t),i=Math.floor(e.image.width*r),o=Math.floor(e.image.height*r),s=null!==n?n.x:0,u=null!==n?n.y:0;l.setTexture2D(e,0),eG.copyTexSubImage2D(eG.TEXTURE_2D,t,0,0,s,u,i,o),a.unbindTexture()};const e9=eG.createFramebuffer(),e7=eG.createFramebuffer();this.copyTextureToTexture=function(e,n,t=null,r=null,i=0,s=null){let u,c,d,f,p,m,h,g,_,v;null===s&&(0!==i?((0,S.warnOnce)("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),s=i,i=0):s=0);let E=e.isCompressedTexture?e.mipmaps[s]:e.image;if(null!==t)u=t.max.x-t.min.x,c=t.max.y-t.min.y,d=t.isBox3?t.max.z-t.min.z:1,f=t.min.x,p=t.min.y,m=t.isBox3?t.min.z:0;else{let n=Math.pow(2,-i);u=Math.floor(E.width*n),c=Math.floor(E.height*n),d=e.isDataArrayTexture?E.depth:e.isData3DTexture?Math.floor(E.depth*n):1,f=0,p=0,m=0}null!==r?(h=r.x,g=r.y,_=r.z):(h=0,g=0,_=0);let T=C.convert(n.format),M=C.convert(n.type);n.isData3DTexture?(l.setTexture3D(n,0),v=eG.TEXTURE_3D):n.isDataArrayTexture||n.isCompressedArrayTexture?(l.setTexture2DArray(n,0),v=eG.TEXTURE_2D_ARRAY):(l.setTexture2D(n,0),v=eG.TEXTURE_2D),eG.pixelStorei(eG.UNPACK_FLIP_Y_WEBGL,n.flipY),eG.pixelStorei(eG.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),eG.pixelStorei(eG.UNPACK_ALIGNMENT,n.unpackAlignment);let b=eG.getParameter(eG.UNPACK_ROW_LENGTH),x=eG.getParameter(eG.UNPACK_IMAGE_HEIGHT),R=eG.getParameter(eG.UNPACK_SKIP_PIXELS),y=eG.getParameter(eG.UNPACK_SKIP_ROWS),A=eG.getParameter(eG.UNPACK_SKIP_IMAGES);eG.pixelStorei(eG.UNPACK_ROW_LENGTH,E.width),eG.pixelStorei(eG.UNPACK_IMAGE_HEIGHT,E.height),eG.pixelStorei(eG.UNPACK_SKIP_PIXELS,f),eG.pixelStorei(eG.UNPACK_SKIP_ROWS,p),eG.pixelStorei(eG.UNPACK_SKIP_IMAGES,m);let P=e.isDataArrayTexture||e.isData3DTexture,w=n.isDataArrayTexture||n.isData3DTexture;if(e.isDepthTexture){let t=o.get(e),r=o.get(n),l=o.get(t.__renderTarget),v=o.get(r.__renderTarget);a.bindFramebuffer(eG.READ_FRAMEBUFFER,l.__webglFramebuffer),a.bindFramebuffer(eG.DRAW_FRAMEBUFFER,v.__webglFramebuffer);for(let t=0;ttypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return S.WebGLCoordinateSystem}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let n=this.getContext();n.drawingBufferColorSpace=S.ColorManagement._getDrawingBufferColorSpace(e),n.unpackColorSpace=S.ColorManagement._getUnpackColorSpace()}}e.s(["PMREMGenerator",()=>V,"ShaderChunk",()=>M,"ShaderLib",()=>x,"UniformsLib",()=>b,"WebGLRenderer",()=>n0,"WebGLUtils",()=>nz],8560);var n1=e.i(30224);let n3=e=>{let n,t=new Set,r=(e,r)=>{let a="function"==typeof e?e(n):e;if(!Object.is(a,n)){let e=n;n=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},n,a),t.forEach(t=>t(n,e))}},a=()=>n,i={setState:r,getState:a,getInitialState:()=>o,subscribe:e=>(t.add(e),()=>t.delete(e))},o=n=e(r,a,i);return i},n2=e=>e?n3(e):n3;e.s(["createStore",()=>n2],8155);let{useSyncExternalStoreWithSelector:n4}=n1.default,n5=e=>e;function n6(e,n=n5,t){let r=n4(e.subscribe,e.getState,e.getInitialState,n,t);return _.default.useDebugValue(r),r}let n8=(e,n)=>{let t=n2(e),r=(e,r=n)=>n6(t,e,r);return Object.assign(r,t),r},n9=(e,n)=>e?n8(e,n):n8;e.s(["createWithEqualityFn",()=>n9,"useStoreWithEqualityFn",()=>n6],66748);let n7=[];function te(e,n,t=(e,n)=>e===n){if(e===n)return!0;if(!e||!n)return!1;let r=e.length;if(n.length!==r)return!1;for(let a=0;a0&&(a.timeout&&clearTimeout(a.timeout),a.timeout=setTimeout(a.remove,r.lifespan)),a.response;if(!t)throw a.promise}let a={keys:n,equal:r.equal,remove:()=>{let e=n7.indexOf(a);-1!==e&&n7.splice(e,1)},promise:("object"==typeof e&&"function"==typeof e.then?e:e(...n)).then(e=>{a.response=e,r.lifespan&&r.lifespan>0&&(a.timeout=setTimeout(a.remove,r.lifespan))}).catch(e=>a.error=e)};if(n7.push(a),!t)throw a.promise}var tt=e.i(89499),tr=e.i(43476),ta=_;function ti(e,n,t){if(!e)return;if(!0===t(e))return e;let r=n?e.return:e.child;for(;r;){let e=ti(r,n,t);if(e)return e;r=n?null:r.sibling}}function to(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(n){return e}}"u">typeof window&&((null==(c=window.document)?void 0:c.createElement)||(null==(d=window.navigator)?void 0:d.product)==="ReactNative")?ta.useLayoutEffect:ta.useEffect;let tl=to(ta.createContext(null));class ts extends ta.Component{render(){return ta.createElement(tl.Provider,{value:this._reactInternals},this.props.children)}}function tu(){let e=ta.useContext(tl);if(null===e)throw Error("its-fine: useFiber must be called within a !");let n=ta.useId();return ta.useMemo(()=>{for(let t of[e,null==e?void 0:e.alternate]){if(!t)continue;let e=ti(t,!1,e=>{let t=e.memoizedState;for(;t;){if(t.memoizedState===n)return!0;t=t.next}});if(e)return e}},[e,n])}let tc=Symbol.for("react.context"),td=e=>null!==e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===tc;function tf(){let e=function(){let e=tu(),[n]=ta.useState(()=>new Map);n.clear();let t=e;for(;t;){let e=t.type;td(e)&&e!==tl&&!n.has(e)&&n.set(e,ta.use(to(e))),t=t.return}return n}();return ta.useMemo(()=>Array.from(e.keys()).reduce((n,t)=>r=>ta.createElement(n,null,ta.createElement(t.Provider,{...r,value:e.get(t)})),e=>ta.createElement(ts,{...e})),[e])}function tp(e){let n=e.root;for(;n.getState().previousRoot;)n=n.getState().previousRoot;return n}e.s(["FiberProvider",()=>ts,"traverseFiber",()=>ti,"useContextBridge",()=>tf,"useFiber",()=>tu],46791),_.act;let tm=e=>e&&e.hasOwnProperty("current"),th=e=>null!=e&&("string"==typeof e||"number"==typeof e||e.isColor),tg="u">typeof window&&((null==(o=window.document)?void 0:o.createElement)||(null==(l=window.navigator)?void 0:l.product)==="ReactNative")?_.useLayoutEffect:_.useEffect;function t_(e){let n=_.useRef(e);return tg(()=>void(n.current=e),[e]),n}function tv(){let e=tu(),n=tf();return _.useMemo(()=>({children:t})=>{let r=ti(e,!0,e=>e.type===_.StrictMode)?_.StrictMode:_.Fragment;return(0,tr.jsx)(r,{children:(0,tr.jsx)(n,{children:t})})},[e,n])}function tS({set:e}){return tg(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}let tE=((s=class extends _.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}).getDerivedStateFromError=()=>({error:!0}),s);function tT(e){var n;let t="u">typeof window?null!=(n=window.devicePixelRatio)?n:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],t),e[1]):e}function tM(e){var n;return null==(n=e.__r3f)?void 0:n.root.getState()}let tb={obj:e=>e===Object(e)&&!tb.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,boo:e=>"boolean"==typeof e,und:e=>void 0===e,nul:e=>null===e,arr:e=>Array.isArray(e),equ(e,n,{arrays:t="shallow",objects:r="reference",strict:a=!0}={}){let i;if(typeof e!=typeof n||!!e!=!!n)return!1;if(tb.str(e)||tb.num(e)||tb.boo(e))return e===n;let o=tb.obj(e);if(o&&"reference"===r)return e===n;let l=tb.arr(e);if(l&&"reference"===t)return e===n;if((l||o)&&e===n)return!0;for(i in e)if(!(i in n))return!1;if(o&&"shallow"===t&&"shallow"===r){for(i in a?n:e)if(!tb.equ(e[i],n[i],{strict:a,objects:"reference"}))return!1}else for(i in a?n:e)if(e[i]!==n[i])return!1;if(tb.und(i)){if(l&&0===e.length&&0===n.length||o&&0===Object.keys(e).length&&0===Object.keys(n).length)return!0;if(e!==n)return!1}return!0}},tx=["children","key","ref"];function tR(e,n,t,r){let a=null==e?void 0:e.__r3f;return!a&&(a={root:n,type:t,parent:null,children:[],props:function(e){let n={};for(let t in e)tx.includes(t)||(n[t]=e[t]);return n}(r),object:e,eventCount:0,handlers:{},isHidden:!1},e&&(e.__r3f=a)),a}function tC(e,n){if(!n.includes("-")||n in e)return{root:e,key:n,target:e[n]};let t=e,r=n.split("-");for(let a of r){if("object"!=typeof t||null===t){if(void 0!==t)return{root:t,key:r.slice(r.indexOf(a)).join("-"),target:void 0};return{root:e,key:n,target:void 0}}n=a,e=t,t=t[n]}return{root:e,key:n,target:t}}let ty=/-\d+$/;function tA(e,n){if(tb.str(n.props.attach)){if(ty.test(n.props.attach)){let t=n.props.attach.replace(ty,""),{root:r,key:a}=tC(e.object,t);Array.isArray(r[a])||(r[a]=[])}let{root:t,key:r}=tC(e.object,n.props.attach);n.previousAttach=t[r],t[r]=n.object}else tb.fun(n.props.attach)&&(n.previousAttach=n.props.attach(e.object,n.object))}function tP(e,n){if(tb.str(n.props.attach)){let{root:t,key:r}=tC(e.object,n.props.attach),a=n.previousAttach;void 0===a?delete t[r]:t[r]=a}else null==n.previousAttach||n.previousAttach(e.object,n.object);delete n.previousAttach}let tw=[...tx,"args","dispose","attach","object","onUpdate","dispose"],tL=new Map,tN=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],tU=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function tD(e,n){var t,r;let a=e.__r3f,i=a&&tp(a).getState(),o=null==a?void 0:a.eventCount;for(let t in n){let o=n[t];if(tw.includes(t))continue;if(a&&tU.test(t)){"function"==typeof o?a.handlers[t]=o:delete a.handlers[t],a.eventCount=Object.keys(a.handlers).length;continue}if(void 0===o)continue;let{root:l,key:s,target:u}=tC(e,t);if(void 0===u&&("object"!=typeof l||null===l))throw Error(`R3F: Cannot set "${t}". Ensure it is an object before setting "${s}".`);u instanceof v.Layers&&o instanceof v.Layers?u.mask=o.mask:u instanceof v.Color&&th(o)?u.set(o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"function"==typeof u.copy&&null!=o&&o.constructor&&u.constructor===o.constructor?u.copy(o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&Array.isArray(o)?"function"==typeof u.fromArray?u.fromArray(o):u.set(...o):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"number"==typeof o?"function"==typeof u.setScalar?u.setScalar(o):u.set(o):(l[s]=o,i&&!i.linear&&tN.includes(s)&&null!=(r=l[s])&&r.isTexture&&l[s].format===v.RGBAFormat&&l[s].type===v.UnsignedByteType&&(l[s].colorSpace=v.SRGBColorSpace))}if(null!=a&&a.parent&&null!=i&&i.internal&&null!=(t=a.object)&&t.isObject3D&&o!==a.eventCount){let e=a.object,n=i.internal.interaction.indexOf(e);n>-1&&i.internal.interaction.splice(n,1),a.eventCount&&null!==e.raycast&&i.internal.interaction.push(e)}return a&&void 0===a.props.attach&&(a.object.isBufferGeometry?a.props.attach="geometry":a.object.isMaterial&&(a.props.attach="material")),a&&tI(a),e}function tI(e){var n;if(!e.parent)return;null==e.props.onUpdate||e.props.onUpdate(e.object);let t=null==(n=e.root)||null==n.getState?void 0:n.getState();t&&0===t.internal.frames&&t.invalidate()}let tF=e=>null==e?void 0:e.isObject3D;function tO(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function tB(e,n,t,r){let a=t.get(n);a&&(t.delete(n),0===t.size&&(e.delete(r),a.target.releasePointerCapture(r)))}let tG=e=>!!(null!=e&&e.render),tH=_.createContext(null);function tk(){let e=_.useContext(tH);if(!e)throw Error("R3F: Hooks can only be used within the Canvas component!");return e}function tV(e=e=>e,n){return tk()(e,n)}function tz(e,n=0){let t=tk(),r=t.getState().internal.subscribe,a=t_(e);return tg(()=>r(a,n,t),[n,r,t]),null}let tW=new WeakMap;function tX(e,n){return function(t,...r){var a;let i;return"function"==typeof t&&(null==t||null==(a=t.prototype)?void 0:a.constructor)===t?(i=tW.get(t))||(i=new t,tW.set(t,i)):i=t,e&&e(i),Promise.all(r.map(e=>new Promise((t,r)=>i.load(e,e=>{var n;let r;tF(null==e?void 0:e.scene)&&Object.assign(e,(n=e.scene,r={nodes:{},materials:{},meshes:{}},n&&n.traverse(e=>{e.name&&(r.nodes[e.name]=e),e.material&&!r.materials[e.material.name]&&(r.materials[e.material.name]=e.material),e.isMesh&&!r.meshes[e.name]&&(r.meshes[e.name]=e)}),r)),t(e)},n,n=>r(Error(`Could not load ${e}: ${null==n?void 0:n.message}`))))))}}function tj(e,n,t,r){let a=Array.isArray(n)?n:[n],i=tn(tX(t,r),[e,...a],!1,{equal:tb.equ});return Array.isArray(n)?i:i[0]}tj.preload=function(e,n,t){let r,a=Array.isArray(n)?n:[n];tn(tX(t),[e,...a],!0,r)},tj.clear=function(e,n){var t=[e,...Array.isArray(n)?n:[n]];if(void 0===t||0===t.length)n7.splice(0,n7.length);else{let e=n7.find(e=>te(t,e.keys,e.equal));e&&e.remove()}};var tq={exports:{}},tY={exports:{}};tY.exports;let tK=(h||(h=1,m||(m=1,tY.exports=function(e){function n(e,n,t,r){return new rK(e,n,t,r)}function t(){}function r(e){var n="https://react.dev/errors/"+e;if(1oR||(e.current=ox[oR],ox[oR]=null,oR--)}function d(e,n){ox[++oR]=e.current,e.current=n}function f(e){var n=42&e;if(0!==n)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 0x1000000:case 0x2000000:return 0x3c00000&e;case 0x4000000:return 0x4000000;case 0x8000000:return 0x8000000;case 0x10000000:return 0x10000000;case 0x20000000:return 0x20000000;case 0x40000000:return 0;default:return e}}function p(e,n,t){var r=e.pendingLanes;if(0===r)return 0;var a=0,i=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var l=0x7ffffff&r;return 0!==l?0!=(r=l&~i)?a=f(r):0!=(o&=l)?a=f(o):t||0!=(t=l&~e)&&(a=f(t)):0!=(l=r&~i)?a=f(l):0!==o?a=f(o):t||0!=(t=r&~e)&&(a=f(t)),0===a?0:0!==n&&n!==a&&(n&i)==0&&((i=a&-a)>=(t=n&-n)||32===i&&(4194048&t)!=0)?n:a}function m(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)==0}function h(){var e=oN;return(0x3c00000&(oN<<=1))==0&&(oN=4194304),e}function v(e){for(var n=[],t=0;31>t;t++)n.push(e);return n}function S(e,n){e.pendingLanes|=n,0x10000000!==n&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function E(e,n,t){e.pendingLanes|=n,e.suspendedLanes&=~n;var r=31-oy(n);e.entangledLanes|=n,e.entanglements[r]=0x40000000|e.entanglements[r]|261930&t}function T(e,n){var t=e.entangledLanes|=n;for(e=e.entanglements;t;){var r=31-oy(t),a=1<)":-1a||s[r]!==u[a]){var c=` -`+s[r].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=r&&0<=a)break}}}finally{oK=!1,Error.prepareStackTrace=t}return(t=e?e.displayName||e.name:"")?C(t):""}function A(e){try{var n="",t=null;do n+=function(e,n){switch(e.tag){case 26:case 27:case 5:return C(e.type);case 16:return C("Lazy");case 13:return e.child!==n&&null!==n?C("Suspense Fallback"):C("Suspense");case 19:return C("SuspenseList");case 0:case 15:return y(e.type,!1);case 11:return y(e.type.render,!1);case 1:return y(e.type,!0);case 31:return C("Activity");default:return""}}(e,t),t=e,e=e.return;while(e)return n}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}function P(e,n){if("object"==typeof e&&null!==e){var t=o$.get(e);return void 0!==t?t:(n={value:e,source:n,stack:A(n)},o$.set(e,n),n)}return{value:e,source:n,stack:A(n)}}function w(e,n){oQ[oZ++]=o0,oQ[oZ++]=oJ,oJ=e,o0=n}function L(e,n,t){o1[o3++]=o4,o1[o3++]=o5,o1[o3++]=o2,o2=e;var r=o4;e=o5;var a=32-oy(r)-1;r&=~(1<>=o,a-=o,o4=1<<32-oy(n)+a|t<f?(p=d,d=null):p=d.sibling;var _=h(n,d,o[f],l);if(null===_){null===d&&(d=p);break}e&&d&&null===_.alternate&&t(n,d),r=s(_,r,f),null===c?u=_:c.sibling=_,c=_,d=p}if(f===o.length)return a(n,d),lt&&w(n,f),u;if(null===d){for(;fp?(_=f,f=null):_=f.sibling;var S=h(n,f,v.value,u);if(null===S){null===f&&(f=_);break}e&&f&&null===S.alternate&&t(n,f),o=s(S,o,p),null===d?c=S:d.sibling=S,d=S,f=_}if(v.done)return a(n,f),lt&&w(n,p),c;if(null===f){for(;!v.done;p++,v=l.next())null!==(v=m(n,v.value,u))&&(o=s(v,o,p),null===d?c=v:d.sibling=v,d=v);return lt&&w(n,p),c}for(f=i(f);!v.done;p++,v=l.next())null!==(v=g(f,n,p,v.value,u))&&(e&&null!==v.alternate&&f.delete(null===v.key?p:v.key),o=s(v,o,p),null===d?c=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return t(n,e)}),lt&&w(n,p),c}(c,d,f=_.call(f),p)}if("function"==typeof f.then)return n(c,d,eb(f),p);if(f.$$typeof===ad)return n(c,d,ee(c,f),p);eR(c,f)}return"string"==typeof f&&""!==f||"number"==typeof f||"bigint"==typeof f?(f=""+f,null!==d&&6===d.tag?(a(c,d.sibling),(p=o(d,f)).return=c):(a(c,d),(p=r1(f,c.mode,p)).return=c),u(c=p)):a(c,d)}(c,d,f,p);return lw=null,_}catch(e){if(e===lR||e===ly)throw e;var v=n(29,e,null,c.mode);return v.lanes=p,v.return=c,v}finally{}}}function ey(){for(var e=lI,n=lF=lI=0;ni?i:8);var o=aM.T,l={};aM.T=l,nZ(e,!1,n,t);try{var s=a(),u=aM.S;if(null!==u&&u(l,s),null!==s&&"object"==typeof s&&"function"==typeof s.then){var c,d,f=(c=[],d={status:"pending",value:null,reason:null,then:function(e){c.push(e)}},s.then(function(){d.status="fulfilled",d.value=r;for(var e=0;e";case sc:return":has("+(rf(e)||"")+")";case sd:return'[role="'+e.value+'"]';case sp:return'"'+e.value+'"';case sf:return'[data-testname="'+e.value+'"]';default:throw Error(r(365))}}function rp(e,n){var t=[];e=[e,0];for(var r=0;rsO&&(n.flags|=128,i=!0,tO(a,!1),n.lanes=4194304)}else{if(!i)if(null!==(e=eQ(o))){if(n.flags|=128,i=!0,n.updateQueue=e=e.updateQueue,tF(n,e),tO(a,!0),null===a.tail&&"hidden"===a.tailMode&&!o.alternate&&!lt)return tB(n),null}else 2*oO()-a.renderingStartTime>sO&&0x20000000!==t&&(n.flags|=128,i=!0,tO(a,!1),n.lanes=4194304);a.isBackwards?(o.sibling=n.child,n.child=o):(null!==(e=a.last)?e.sibling=o:n.child=o,a.last=o)}return null!==a.tail?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=oO(),e.sibling=null,t=lz.current,d(lz,i?1&t|2:1&t),lt&&w(n,a.treeForkCount),e):(tB(n),null);case 22:case 23:return e$(n),eX(),a=null!==n.memoizedState,null!==e?null!==e.memoizedState!==a&&(n.flags|=8192):a&&(n.flags|=8192),a?(0x20000000&t)!=0&&(128&n.flags)==0&&(tB(n),6&n.subtreeFlags&&(n.flags|=8192)):tB(n),null!==(t=n.updateQueue)&&tF(n,t.retryQueue),t=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(t=e.memoizedState.cachePool.pool),a=null,null!==n.memoizedState&&null!==n.memoizedState.cachePool&&(a=n.memoizedState.cachePool.pool),a!==t&&(n.flags|=2048),null!==e&&c(lx),null;case 24:return t=null,null!==e&&(t=e.memoizedState.cache),n.memoizedState.cache!==t&&(n.flags|=2048),q(lf),tB(n),null;case 25:case 30:return null}throw Error(r(156,n.tag))}(n.alternate,n,sR);if(null!==t){sv=t;return}if(null!==(n=n.sibling)){sv=n;return}sv=n=e}while(null!==n)0===sC&&(sC=5)}function rD(e,n){do{var t=function(e,n){switch(U(n),n.tag){case 1:return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 3:return q(lf),F(),(65536&(e=n.flags))!=0&&(128&e)==0?(n.flags=-65537&e|128,n):null;case 26:case 27:case 5:return B(n),null;case 31:if(null!==n.memoizedState){if(e$(n),null===n.alternate)throw Error(r(340));z()}return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 13:if(e$(n),null!==(e=n.memoizedState)&&null!==e.dehydrated){if(null===n.alternate)throw Error(r(340));z()}return 65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 19:return c(lz),null;case 4:return F(),null;case 10:return q(n.type),null;case 22:case 23:return e$(n),eX(),null!==e&&c(lx),65536&(e=n.flags)?(n.flags=-65537&e|128,n):null;case 24:return q(lf),null;default:return null}}(e.alternate,e);if(null!==t){t.flags&=32767,sv=t;return}if(null!==(t=e.return)&&(t.flags|=32768,t.subtreeFlags=0,t.deletions=null),!n&&null!==(e=e.sibling)){sv=e;return}sv=e=t}while(null!==e)sC=6,sv=null}function rI(e,n,t,a,i,o,l,s,u){e.cancelPendingCommit=null;do rH();while(0!==sH)if((6&sg)!=0)throw Error(r(327));if(null!==n){if(n===e.current)throw Error(r(177));if(function(e,n,t,r,a,i){var o=e.pendingLanes;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=t,e.entangledLanes&=t,e.errorRecoveryDisabledLanes&=t,e.shellSuspendCounter=0;var l=e.entanglements,s=e.expirationTimes,u=e.hiddenUpdates;for(t=o&~t;0t?32:t;t=aM.T;var i=aj();try{aX(a),aM.T=null,a=sX,sX=null;var o=sk,l=sz;if(sH=0,sV=sk=null,sz=0,(6&sg)!=0)throw Error(r(331));var s=sg;if(sg|=4,rs(o.current),rt(o,o.current,l,a),sg=s,eo(0,!1),oX&&"function"==typeof oX.onPostCommitFiberRoot)try{oX.onPostCommitFiberRoot(oW,o)}catch{}return!0}finally{aX(i),aM.T=t,rG(e,n)}}function rV(e,n,t){n=P(t,n),n=n9(e.stateNode,n,2),null!==(e=eF(e,n,2))&&(S(e,2),ei(e))}function rz(e,n,t){if(3===e.tag)rV(e,e,t);else for(;null!==n;){if(3===n.tag){rV(n,e,t);break}if(1===n.tag){var r=n.stateNode;if("function"==typeof n.type.getDerivedStateFromError||"function"==typeof r.componentDidCatch&&(null===sG||!sG.has(r))){e=P(t,e),null!==(r=eF(n,t=n7(2),2))&&(te(t,r,n,e),S(r,2),ei(r));break}}n=n.return}}function rW(e,n,t){var r=e.pingCache;if(null===r){r=e.pingCache=new sh;var a=new Set;r.set(n,a)}else void 0===(a=r.get(n))&&(a=new Set,r.set(n,a));a.has(t)||(sx=!0,a.add(t),e=rX.bind(null,e,n,t),n.then(e,e))}function rX(e,n,t){var r=e.pingCache;null!==r&&r.delete(n),e.pingedLanes|=e.suspendedLanes&t,e.warmLanes&=~t,s_===e&&(sS&t)===t&&(4===sC||3===sC&&(0x3c00000&sS)===sS&&300>oO()-sI?(2&sg)==0&&rb(e,0):sP|=t,sL===sS&&(sL=0)),ei(e)}function rj(e,n){0===n&&(n=h()),null!==(e=ew(e,n))&&(S(e,n),ei(e))}function rq(e){var n=e.memoizedState,t=0;null!==n&&(t=n.retryLane),rj(e,t)}function rY(e,n){var t=0;switch(e.tag){case 31:case 13:var a=e.stateNode,i=e.memoizedState;null!==i&&(t=i.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}null!==a&&a.delete(n),rj(e,t)}function rK(e,n,t,r){this.tag=e,this.key=t,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function r$(e){return!(!(e=e.prototype)||!e.isReactComponent)}function rQ(e,t){var r=e.alternate;return null===r?((r=n(e.tag,t,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=0x3e00000&e.flags,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function rZ(e,n){e.flags&=0x3e00002;var t=e.alternate;return null===t?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=t.childLanes,e.lanes=t.lanes,e.child=t.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=t.memoizedProps,e.memoizedState=t.memoizedState,e.updateQueue=t.updateQueue,e.type=t.type,e.dependencies=null===(n=t.dependencies)?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function rJ(e,t,a,i,o,l){var s=0;if(i=e,"function"==typeof e)r$(e)&&(s=1);else if("string"==typeof e)s=oa&&ov?oi(e,a,o6.current)?26:oM(e)?27:5:oa?oi(e,a,o6.current)?26:5:ov&&oM(e)?27:5;else t:switch(e){case a_:return(e=n(31,a,t,o)).elementType=a_,e.lanes=l,e;case al:return r0(a.children,o,l,t);case as:s=8,o|=24;break;case au:return(e=n(12,a,t,2|o)).elementType=au,e.lanes=l,e;case ap:return(e=n(13,a,t,o)).elementType=ap,e.lanes=l,e;case am:return(e=n(19,a,t,o)).elementType=am,e.lanes=l,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case ad:s=10;break t;case ac:s=9;break t;case af:s=11;break t;case ah:s=14;break t;case ag:s=16,i=null;break t}s=29,a=Error(r(130,null===e?"null":typeof e,"")),i=null}return(t=n(s,a,t,o)).elementType=e,t.type=i,t.lanes=l,t}function r0(e,t,r,a){return(e=n(7,e,a,t)).lanes=r,e}function r1(e,t,r){return(e=n(6,e,null,t)).lanes=r,e}function r3(e){var t=n(18,null,null,0);return t.stateNode=e,t}function r2(e,t,r){return(t=n(4,null!==e.children?e.children:[],e.key,t)).lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function r4(e,n,t,r,a,i,o,l,s){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=aB,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=v(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=v(0),this.hiddenUpdates=v(null),this.identifierPrefix=r,this.onUncaughtError=a,this.onCaughtError=i,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=s,this.incompleteTransitions=new Map}function r5(e,t,r,a,i,o,l,s,u,c,d,f){return e=new r4(e,t,r,l,u,c,d,f,s),t=1,!0===o&&(t|=24),o=n(3,null,null,t),e.current=o,o.stateNode=e,t=et(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:a,isDehydrated:r,cache:t},eU(o),e}function r6(e){var n=e._reactInternals;if(void 0===n)throw"function"==typeof e.render?Error(r(188)):Error(r(268,e=Object.keys(e).join(",")));return null===(e=null!==(e=o(n))?function e(n){var t=n.tag;if(5===t||26===t||27===t||6===t)return n;for(n=n.child;null!==n;){if(null!==(t=e(n)))return t;n=n.sibling}return null}(e):null)?null:aC(e.stateNode)}function r8(e,n,t,r,a,i){a=oC,null===r.context?r.context=a:r.pendingContext=a,(r=eI(n)).payload={element:t},null!==(i=void 0===i?null:i)&&(r.callback=i),null!==(t=eF(e,r,n))&&(r_(t,e,n),eO(t,e,n))}function r9(e,n){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var t=e.retryLane;e.retryLane=0!==t&&t>>=0)?32:31-(oA(e)/oP|0)|0},oA=Math.log,oP=Math.LN2,ow=256,oL=262144,oN=4194304,oU=at.unstable_scheduleCallback,oD=at.unstable_cancelCallback,oI=at.unstable_shouldYield,oF=at.unstable_requestPaint,oO=at.unstable_now,oB=at.unstable_ImmediatePriority,oG=at.unstable_UserBlockingPriority,oH=at.unstable_NormalPriority,ok=at.unstable_IdlePriority,oV=at.log,oz=at.unstable_setDisableYieldValue,oW=null,oX=null,oj="function"==typeof Object.is?Object.is:function(e,n){return e===n&&(0!==e||1/e==1/n)||e!=e&&n!=n},oq="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if("object"==typeof g.default&&"function"==typeof g.default.emit)return void g.default.emit("uncaughtException",e);console.error(e)},oY=Object.prototype.hasOwnProperty,oK=!1,o$=new WeakMap,oQ=[],oZ=0,oJ=null,o0=0,o1=[],o3=0,o2=null,o4=1,o5="",o6=u(null),o8=u(null),o9=u(null),o7=u(null),le=null,ln=null,lt=!1,lr=null,la=!1,li=Error(r(519)),lo=u(null),ll=null,ls=null,lu="u">typeof AbortController?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(n,t){e.push(t)}};this.abort=function(){n.aborted=!0,e.forEach(function(e){return e()})}},lc=at.unstable_scheduleCallback,ld=at.unstable_NormalPriority,lf={$$typeof:ad,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},lp=null,lm=null,lh=!1,lg=!1,l_=!1,lv=0,lS=null,lE=0,lT=0,lM=null,lb=aM.S;aM.S=function(e,n){sF=oO(),"object"==typeof n&&null!==n&&"function"==typeof n.then&&function(e,n){if(null===lS){var t=lS=[];lE=0,lT=ef(),lM={status:"pending",value:void 0,then:function(e){t.push(e)}}}lE++,n.then(ep,ep)}(0,n),null!==lb&&lb(e,n)};var lx=u(null),lR=Error(r(460)),lC=Error(r(474)),ly=Error(r(542)),lA={then:function(){}},lP=null,lw=null,lL=0,lN=eC(!0),lU=eC(!1),lD=[],lI=0,lF=0,lO=!1,lB=!1,lG=u(null),lH=u(0),lk=u(null),lV=null,lz=u(0),lW=0,lX=null,lj=null,lq=null,lY=!1,lK=!1,l$=!1,lQ=0,lZ=0,lJ=null,l0=0,l1={readContext:J,use:nn,useCallback:eZ,useContext:eZ,useEffect:eZ,useImperativeHandle:eZ,useLayoutEffect:eZ,useInsertionEffect:eZ,useMemo:eZ,useReducer:eZ,useRef:eZ,useState:eZ,useDebugValue:eZ,useDeferredValue:eZ,useTransition:eZ,useSyncExternalStore:eZ,useId:eZ,useHostTransitionStatus:eZ,useFormState:eZ,useActionState:eZ,useOptimistic:eZ,useMemoCache:eZ,useCacheRefresh:eZ};l1.useEffectEvent=eZ;var l3={readContext:J,use:nn,useCallback:function(e,n){return e8().memoizedState=[e,void 0===n?null:n],e},useContext:J,useEffect:nL,useImperativeHandle:function(e,n,t){t=null!=t?t.concat([e]):null,nP(4194308,4,nF.bind(null,n,e),t)},useLayoutEffect:function(e,n){return nP(4194308,4,e,n)},useInsertionEffect:function(e,n){nP(4,2,e,n)},useMemo:function(e,n){var t=e8();n=void 0===n?null:n;var r=e();return t.memoizedState=[r,n],r},useReducer:function(e,n,t){var r=e8();if(void 0!==t)var a=t(n);else a=n;return r.memoizedState=r.baseState=a,r.queue=e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:a},e=e.dispatch=nK.bind(null,lX,e),[r.memoizedState,e]},useRef:function(e){return e8().memoizedState={current:e}},useState:function(e){var n=(e=np(e)).queue,t=n$.bind(null,lX,n);return n.dispatch=t,[e.memoizedState,t]},useDebugValue:nB,useDeferredValue:function(e,n){return nk(e8(),e,n)},useTransition:function(){var e=np(!1);return e=nz.bind(null,lX,e.queue,!0,!1),e8().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,t){var a=lX,i=e8();if(lt){if(void 0===t)throw Error(r(407));t=t()}else{if(t=n(),null===s_)throw Error(r(349));(127&sS)!=0||ns(a,n,t)}i.memoizedState=t;var o={value:t,getSnapshot:n};return i.queue=o,nL(nc.bind(null,a,o,e),[e]),a.flags|=2048,ny(9,{destroy:void 0},nu.bind(null,a,o,t,n),null),t},useId:function(){var e=e8(),n=s_.identifierPrefix;if(lt){var t=o5,r=o4;n="_"+n+"R_"+(t=(r&~(1<<32-oy(r)-1)).toString(32)+t),0<(t=lQ++)&&(n+="H"+t.toString(32)),n+="_"}else n="_"+n+"r_"+(t=l0++).toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:nX,useFormState:nM,useActionState:nM,useOptimistic:function(e){var n=e8();n.memoizedState=n.baseState=e;var t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=t,n=nZ.bind(null,lX,!0,t),t.dispatch=n,[e,n]},useMemoCache:nt,useCacheRefresh:function(){return e8().memoizedState=nY.bind(null,lX)},useEffectEvent:function(e){var n=e8(),t={impl:e};return n.memoizedState=t,function(){if((2&sg)!=0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}},l2={readContext:J,use:nn,useCallback:nG,useContext:J,useEffect:nN,useImperativeHandle:nO,useInsertionEffect:nD,useLayoutEffect:nI,useMemo:nH,useReducer:na,useRef:nA,useState:function(){return na(nr)},useDebugValue:nB,useDeferredValue:function(e,n){return nV(e9(),lj.memoizedState,e,n)},useTransition:function(){var e=na(nr)[0],n=e9().memoizedState;return["boolean"==typeof e?e:ne(e),n]},useSyncExternalStore:nl,useId:nj,useHostTransitionStatus:nX,useFormState:nb,useActionState:nb,useOptimistic:function(e,n){return nm(e9(),lj,e,n)},useMemoCache:nt,useCacheRefresh:nq};l2.useEffectEvent=nU;var l4={readContext:J,use:nn,useCallback:nG,useContext:J,useEffect:nN,useImperativeHandle:nO,useInsertionEffect:nD,useLayoutEffect:nI,useMemo:nH,useReducer:no,useRef:nA,useState:function(){return no(nr)},useDebugValue:nB,useDeferredValue:function(e,n){var t=e9();return null===lj?nk(t,e,n):nV(t,lj.memoizedState,e,n)},useTransition:function(){var e=no(nr)[0],n=e9().memoizedState;return["boolean"==typeof e?e:ne(e),n]},useSyncExternalStore:nl,useId:nj,useHostTransitionStatus:nX,useFormState:nC,useActionState:nC,useOptimistic:function(e,n){var t=e9();return null!==lj?nm(t,lj,e,n):(t.baseState=e,[e,t.queue.dispatch])},useMemoCache:nt,useCacheRefresh:nq};l4.useEffectEvent=nU;var l5={enqueueSetState:function(e,n,t){e=e._reactInternals;var r=rh(),a=eI(r);a.payload=n,null!=t&&(a.callback=t),null!==(n=eF(e,a,r))&&(r_(n,e,r),eO(n,e,r))},enqueueReplaceState:function(e,n,t){e=e._reactInternals;var r=rh(),a=eI(r);a.tag=1,a.payload=n,null!=t&&(a.callback=t),null!==(n=eF(e,a,r))&&(r_(n,e,r),eO(n,e,r))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var t=rh(),r=eI(t);r.tag=2,null!=n&&(r.callback=n),null!==(n=eF(e,r,t))&&(r_(n,e,t),eO(n,e,t))}},l6=Error(r(461)),l8=!1,l9={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},l7=!1,se=!1,sn=!1,st="function"==typeof WeakSet?WeakSet:Set,sr=null,sa=null,si=!1,so=null,sl=8192,ss={getCacheForType:function(e){var n=J(lf),t=n.data.get(e);return void 0===t&&(t=e(),n.data.set(e,t)),t},cacheSignal:function(){return J(lf).controller.signal}},su=0,sc=1,sd=2,sf=3,sp=4;if("function"==typeof Symbol&&Symbol.for){var sm=Symbol.for;su=sm("selector.component"),sc=sm("selector.has_pseudo_class"),sd=sm("selector.role"),sf=sm("selector.test_id"),sp=sm("selector.text")}var sh="function"==typeof WeakMap?WeakMap:Map,sg=0,s_=null,sv=null,sS=0,sE=0,sT=null,sM=!1,sb=!1,sx=!1,sR=0,sC=0,sy=0,sA=0,sP=0,sw=0,sL=0,sN=null,sU=null,sD=!1,sI=0,sF=0,sO=1/0,sB=null,sG=null,sH=0,sk=null,sV=null,sz=0,sW=0,sX=null,sj=null,sq=0,sY=null;return ae.attemptContinuousHydration=function(e){if(13===e.tag||31===e.tag){var n=ew(e,0x4000000);null!==n&&r_(n,e,0x4000000),r7(e,0x4000000)}},ae.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag||31===e.tag){var n=rh(),t=ew(e,n=b(n));null!==t&&r_(t,e,n),r7(e,n)}},ae.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if((e=e.stateNode).current.memoizedState.isDehydrated){var n=f(e.pendingLanes);if(0!==n){for(e.pendingLanes|=2,e.entangledLanes|=2;n;){var t=1<<31-oy(n);e.entanglements[1]|=t,n&=~t}ei(e),(6&sg)==0&&(sO=oO()+500,eo(0,!1))}}break;case 31:case 13:null!==(n=ew(e,2))&&r_(n,e,2),rT(),r7(e,2)}},ae.batchedUpdates=function(e,n){return e(n)},ae.createComponentSelector=function(e){return{$$typeof:su,value:e}},ae.createContainer=function(e,n,t,r,a,i,o,l,s,u){return r5(e,n,!1,null,t,r,i,null,o,l,s,u)},ae.createHasPseudoClassSelector=function(e){return{$$typeof:sc,value:e}},ae.createHydrationContainer=function(e,n,t,r,a,i,o,l,s,u,c,d,f,p){var m;return(e=r5(t,r,!0,e,a,i,l,p,s,u,c,d)).context=oC,t=e.current,(a=eI(r=b(r=rh()))).callback=null!=(m=n)?m:null,eF(t,a,r),n=r,e.current.lanes=n,S(e,n),ei(e),e},ae.createPortal=function(e,n,t){var r=3=c&&o>=f&&i<=d&&l<=p){e.splice(n,1);break}if(a!==c||t.width!==u.width||pl){if(!(o!==f||t.height!==u.height||di)){c>a&&(u.width+=c-a,u.x=a),do&&(u.height+=f-o,u.y=o),pt&&(t=s)),s ")+` - -No matching component was found for: - `+e.join(" > ")}return null},ae.getPublicRootInstance=function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 27:case 5:return aC(e.child.stateNode);default:return e.child.stateNode}},ae.injectIntoDevTools=function(){var e={bundleType:0,version:ab,rendererPackageName:ax,currentDispatcherRef:aM,reconcilerVersion:"19.2.0"};if(null!==aR&&(e.rendererConfig=aR),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")e=!1;else{var n=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(n.isDisabled||!n.supportsFiber)e=!0;else{try{oW=n.inject(e),oX=n}catch{}e=!!n.checkDCE}}return e},ae.isAlreadyRendering=function(){return(6&sg)!=0},ae.observeVisibleRects=function(e,n,t,a){if(!a9)throw Error(r(363));var i=io(e=rm(e,n),t,a).disconnect;return{disconnect:function(){i()}}},ae.shouldError=function(){return null},ae.shouldSuspend=function(){return!1},ae.startHostTransition=function(e,n,a,i){if(5!==e.tag)throw Error(r(476));var o=nW(e).queue;nz(e,o,n,a2,null===a?t:function(){var n=nW(e);return null===n.next&&(n=e.alternate.memoizedState),nQ(e,n.next.queue,{},rh()),a(i)})},ae.updateContainer=function(e,n,t,r){var a=n.current,i=rh();return r8(a,i,e,n,t,r),i},ae.updateContainerSync=function(e,n,t,r){return r8(n.current,2,e,n,t,r),2},ae},tY.exports.default=tY.exports,Object.defineProperty(tY.exports,"__esModule",{value:!0})),tq.exports=tY.exports),(f=tq.exports)&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default"))?f.default:f,t$={},tQ=/^three(?=[A-Z])/,tZ=e=>`${e[0].toUpperCase()}${e.slice(1)}`,tJ=0;function t0(e){if("function"==typeof e){let n=`${tJ++}`;return t$[n]=e,n}Object.assign(t$,e)}function t1(e,n){let t=tZ(e),r=t$[t];if("primitive"!==e&&!r)throw Error(`R3F: ${t} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if("primitive"===e&&!n.object)throw Error("R3F: Primitives without 'object' are invalid!");if(void 0!==n.args&&!Array.isArray(n.args))throw Error("R3F: The args prop must be an array!")}function t3(e){if(e.isHidden){var n;e.props.attach&&null!=(n=e.parent)&&n.object?tA(e.parent,e):tF(e.object)&&!1!==e.props.visible&&(e.object.visible=!0),e.isHidden=!1,tI(e)}}function t2(e,n,t){let r=n.root.getState();if(e.parent||e.object===r.scene){if(!n.object){var a,i;let e=t$[tZ(n.type)];n.object=null!=(a=n.props.object)?a:new e(...null!=(i=n.props.args)?i:[]),n.object.__r3f=n}if(tD(n.object,n.props),n.props.attach)tA(e,n);else if(tF(n.object)&&tF(e.object)){let r=e.object.children.indexOf(null==t?void 0:t.object);if(t&&-1!==r){let t=e.object.children.indexOf(n.object);-1!==t?(e.object.children.splice(t,1),e.object.children.splice(t{try{e.dispose()}catch{}};"u">typeof IS_REACT_ACT_ENVIRONMENT?n():(0,tt.unstable_scheduleCallback)(tt.unstable_IdlePriority,n)}}function t8(e,n,t){if(!n)return;n.parent=null;let r=e.children.indexOf(n);-1!==r&&e.children.splice(r,1),n.props.attach?tP(e,n):tF(n.object)&&tF(e.object)&&(e.object.remove(n.object),function(e,n){let{internal:t}=e.getState();t.interaction=t.interaction.filter(e=>e!==n),t.initialHits=t.initialHits.filter(e=>e!==n),t.hovered.forEach((e,r)=>{(e.eventObject===n||e.object===n)&&t.hovered.delete(r)}),t.capturedMap.forEach((e,r)=>{tB(t.capturedMap,n,e,r)})}(tp(n),n.object));let a=null!==n.props.dispose&&!1!==t;for(let e=n.children.length-1;e>=0;e--){let t=n.children[e];t8(n,t,a)}n.children.length=0,delete n.object.__r3f,a&&"primitive"!==n.type&&"Scene"!==n.object.type&&t6(n.object),void 0===t&&tI(n)}let t9=[],t7=()=>{},re={},rn=0,rt=(p={isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:function(e,n,t){var r;return t1(e=tZ(e)in t$?e:e.replace(tQ,""),n),"primitive"===e&&null!=(r=n.object)&&r.__r3f&&delete n.object.__r3f,tR(n.object,t,e,n)},removeChild:t8,appendChild:t4,appendInitialChild:t4,insertBefore:t5,appendChildToContainer(e,n){let t=e.getState().scene.__r3f;n&&t&&t4(t,n)},removeChildFromContainer(e,n){let t=e.getState().scene.__r3f;n&&t&&t8(t,n)},insertInContainerBefore(e,n,t){let r=e.getState().scene.__r3f;n&&t&&r&&t5(r,n,t)},getRootHostContext:()=>re,getChildHostContext:()=>re,commitUpdate(e,n,t,r,a){var i,o,l;t1(n,r);let s=!1;if("primitive"===e.type&&t.object!==r.object||(null==(i=r.args)?void 0:i.length)!==(null==(o=t.args)?void 0:o.length)?s=!0:null!=(l=r.args)&&l.some((e,n)=>{var r;return e!==(null==(r=t.args)?void 0:r[n])})&&(s=!0),s)t9.push([e,{...r},a]);else{let n=function(e,n){let t={};for(let r in n)if(!tw.includes(r)&&!tb.equ(n[r],e.props[r]))for(let e in t[r]=n[r],n)e.startsWith(`${r}-`)&&(t[e]=n[e]);for(let r in e.props){if(tw.includes(r)||n.hasOwnProperty(r))continue;let{root:a,key:i}=tC(e.object,r);if(a.constructor&&0===a.constructor.length){let e=function(e){let n=tL.get(e.constructor);try{n||(n=new e.constructor,tL.set(e.constructor,n))}catch(e){}return n}(a);tb.und(e)||(t[i]=e[i])}else t[i]=0}return t}(e,r);Object.keys(n).length&&(Object.assign(e.props,n),tD(e.object,n))}(null===a.sibling||(4&a.flags)==0)&&function(){for(let[e]of t9){let n=e.parent;if(n)for(let t of(e.props.attach?tP(n,e):tF(e.object)&&tF(n.object)&&n.object.remove(e.object),e.children))t.props.attach?tP(e,t):tF(t.object)&&tF(e.object)&&e.object.remove(t.object);e.isHidden&&t3(e),e.object.__r3f&&delete e.object.__r3f,"primitive"!==e.type&&t6(e.object)}for(let[r,a,i]of t9){r.props=a;let o=r.parent;if(o){let a=t$[tZ(r.type)];r.object=null!=(e=r.props.object)?e:new a(...null!=(n=r.props.args)?n:[]),r.object.__r3f=r;var e,n,t=r.object;for(let e of[i,i.alternate])if(null!==e)if("function"==typeof e.ref){null==e.refCleanup||e.refCleanup();let n=e.ref(t);"function"==typeof n&&(e.refCleanup=n)}else e.ref&&(e.ref.current=t);for(let e of(tD(r.object,r.props),r.props.attach?tA(o,r):tF(r.object)&&tF(o.object)&&o.object.add(r.object),r.children))e.props.attach?tA(r,e):tF(e.object)&&tF(r.object)&&r.object.add(e.object);tI(r)}}t9.length=0}()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>null==e?void 0:e.object,prepareForCommit:()=>null,preparePortalMount:e=>tR(e.getState().scene,e,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:function(e){if(!e.isHidden){var n;e.props.attach&&null!=(n=e.parent)&&n.object?tP(e.parent,e):tF(e.object)&&(e.object.visible=!1),e.isHidden=!0,tI(e)}},unhideInstance:t3,createTextInstance:t7,hideTextInstance:t7,unhideTextInstance:t7,scheduleTimeout:"function"==typeof setTimeout?setTimeout:void 0,cancelTimeout:"function"==typeof clearTimeout?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:_.createContext(null),setCurrentUpdatePriority(e){rn=e},getCurrentUpdatePriority:()=>rn,resolveUpdatePriority(){var e;if(0!==rn)return rn;switch("u">typeof window&&(null==(e=window.event)?void 0:e.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return 2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return 8;default:return 32}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:"9.5.0",applyViewTransitionName(e,n,t){},restoreViewTransitionName(e,n){},cancelViewTransitionName(e,n,t){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,n)=>!1,hasInstanceAffectedParent:(e,n)=>!1,suspendOnActiveViewTransition(e,n){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance:(e,n)=>e,cloneMutableTextInstance:e=>e,cloneRootViewTransitionContainer(e){throw Error("Not implemented.")},removeRootViewTransitionClone(e,n){throw Error("Not implemented.")},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,n){},commitNewChildToFragmentInstance(e,n){},deleteChildFromFragmentInstance(e,n){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,n,t)=>!1,maySuspendCommitInSyncRender:(e,n)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,n)=>null},(u=tK(p)).injectIntoDevTools(),u),rr=new Map,ra={objects:"shallow",strict:!1};function ri(e){var n,t;let r,a,i,o,l,s,u,c=rr.get(e),d=null==c?void 0:c.fiber,f=null==c?void 0:c.store;c&&console.warn("R3F.createRoot should only be called once!");let p="function"==typeof reportError?reportError:console.error,m=f||(n=rE,t=rT,l=(o=(i=n9((e,r)=>{let a,i=new v.Vector3,o=new v.Vector3,l=new v.Vector3;function s(e=r().camera,n=o,t=r().size){let{width:a,height:u,top:c,left:d}=t,f=a/u;n.isVector3?l.copy(n):l.set(...n);let p=e.getWorldPosition(i).distanceTo(l);if(e&&e.isOrthographicCamera)return{width:a/e.zoom,height:u/e.zoom,top:c,left:d,factor:1,distance:p,aspect:f};{let n=2*Math.tan(e.fov*Math.PI/180/2)*p,t=a/u*n;return{width:t,height:n,top:c,left:d,factor:a/t,distance:p,aspect:f}}}let u=n=>e(e=>({performance:{...e.performance,current:n}})),c=new v.Vector2;return{set:e,get:r,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(e=1)=>n(r(),e),advance:(e,n)=>t(e,n,r()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new v.Clock,pointer:c,mouse:c,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=r();a&&clearTimeout(a),e.performance.current!==e.performance.min&&u(e.performance.min),a=setTimeout(()=>u(r().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:s},setEvents:n=>e(e=>({...e,events:{...e.events,...n}})),setSize:(n,t,a=0,i=0)=>{let l=r().camera,u={width:n,height:t,top:a,left:i};e(e=>({size:u,viewport:{...e.viewport,...s(l,o,u)}}))},setDpr:n=>e(e=>{let t=tT(n);return{viewport:{...e.viewport,dpr:t,initialDpr:e.viewport.initialDpr||t}}}),setFrameloop:(n="always")=>{let t=r().clock;t.stop(),t.elapsedTime=0,"never"!==n&&(t.start(),t.elapsedTime=0),e(()=>({frameloop:n}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:_.createRef(),active:!1,frames:0,priority:0,subscribe:(e,n,t)=>{let a=r().internal;return a.priority=a.priority+ +(n>0),a.subscribers.push({ref:e,priority:n,store:t}),a.subscribers=a.subscribers.sort((e,n)=>e.priority-n.priority),()=>{let t=r().internal;null!=t&&t.subscribers&&(t.priority=t.priority-(n>0),t.subscribers=t.subscribers.filter(n=>n.ref!==e))}}}}})).getState()).size,s=o.viewport.dpr,u=o.camera,i.subscribe(()=>{let{camera:e,size:n,viewport:t,gl:r,set:a}=i.getState();if(n.width!==l.width||n.height!==l.height||t.dpr!==s){l=n,s=t.dpr;!e.manual&&(e&&e.isOrthographicCamera?(e.left=-(n.width/2),e.right=n.width/2,e.top=n.height/2,e.bottom=-(n.height/2)):e.aspect=n.width/n.height,e.updateProjectionMatrix());t.dpr>0&&r.setPixelRatio(t.dpr);let a="u">typeof HTMLCanvasElement&&r.domElement instanceof HTMLCanvasElement;r.setSize(n.width,n.height,a)}e!==u&&(u=e,a(n=>({viewport:{...n.viewport,...n.viewport.getCurrentViewport(e)}})))}),i.subscribe(e=>n(e)),i),h=d||rt.createContainer(m,1,null,!1,null,"",p,p,p,null);c||rr.set(e,{fiber:h,store:m});let g=!1,S=null;return{async configure(n={}){var t,i;let o;S=new Promise(e=>o=e);let{gl:l,size:s,scene:u,events:c,onCreated:d,shadows:f=!1,linear:p=!1,flat:h=!1,legacy:_=!1,orthographic:E=!1,frameloop:T="always",dpr:M=[1,2],performance:b,raycaster:x,camera:R,onPointerMissed:C}=n,y=m.getState(),A=y.gl;if(!y.gl){let n={canvas:e,powerPreference:"high-performance",antialias:!0,alpha:!0},t="function"==typeof l?await l(n):l;A=tG(t)?t:new n0({...n,...l}),y.set({gl:A})}let P=y.raycaster;P||y.set({raycaster:P=new v.Raycaster});let{params:w,...L}=x||{};if(tb.equ(L,P,ra)||tD(P,{...L}),tb.equ(w,P.params,ra)||tD(P,{params:{...P.params,...w}}),!y.camera||y.camera===a&&!tb.equ(a,R,ra)){a=R;let e=null==R?void 0:R.isCamera,n=e?R:E?new v.OrthographicCamera(0,0,0,0,.1,1e3):new v.PerspectiveCamera(75,0,.1,1e3);!e&&(n.position.z=5,R&&(tD(n,R),!n.manual&&("aspect"in R||"left"in R||"right"in R||"bottom"in R||"top"in R)&&(n.manual=!0,n.updateProjectionMatrix())),y.camera||null!=R&&R.rotation||n.lookAt(0,0,0)),y.set({camera:n}),P.camera=n}if(!y.scene){let e;null!=u&&u.isScene?tR(e=u,m,"",{}):(tR(e=new v.Scene,m,"",{}),u&&tD(e,u)),y.set({scene:e})}c&&!y.events.handlers&&y.set({events:c(m)});let N=function(e,n){if(!n&&"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:n,height:t,top:r,left:a}=e.parentElement.getBoundingClientRect();return{width:n,height:t,top:r,left:a}}return!n&&"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...n}}(e,s);if(tb.equ(N,y.size,ra)||y.setSize(N.width,N.height,N.top,N.left),M&&y.viewport.dpr!==tT(M)&&y.setDpr(M),y.frameloop!==T&&y.setFrameloop(T),y.onPointerMissed||y.set({onPointerMissed:C}),b&&!tb.equ(b,y.performance,ra)&&y.set(e=>({performance:{...e.performance,...b}})),!y.xr){let e=(e,n)=>{let t=m.getState();"never"!==t.frameloop&&rT(e,!0,t,n)},n=()=>{let n=m.getState();n.gl.xr.enabled=n.gl.xr.isPresenting,n.gl.xr.setAnimationLoop(n.gl.xr.isPresenting?e:null),n.gl.xr.isPresenting||rE(n)},r={connect(){let e=m.getState().gl;e.xr.addEventListener("sessionstart",n),e.xr.addEventListener("sessionend",n)},disconnect(){let e=m.getState().gl;e.xr.removeEventListener("sessionstart",n),e.xr.removeEventListener("sessionend",n)}};"function"==typeof(null==(t=A.xr)?void 0:t.addEventListener)&&r.connect(),y.set({xr:r})}if(A.shadowMap){let e=A.shadowMap.enabled,n=A.shadowMap.type;if(A.shadowMap.enabled=!!f,tb.boo(f))A.shadowMap.type=v.PCFSoftShadowMap;else if(tb.str(f)){let e={basic:v.BasicShadowMap,percentage:v.PCFShadowMap,soft:v.PCFSoftShadowMap,variance:v.VSMShadowMap};A.shadowMap.type=null!=(i=e[f])?i:v.PCFSoftShadowMap}else tb.obj(f)&&Object.assign(A.shadowMap,f);(e!==A.shadowMap.enabled||n!==A.shadowMap.type)&&(A.shadowMap.needsUpdate=!0)}return v.ColorManagement.enabled=!_,g||(A.outputColorSpace=p?v.LinearSRGBColorSpace:v.SRGBColorSpace,A.toneMapping=h?v.NoToneMapping:v.ACESFilmicToneMapping),y.legacy!==_&&y.set(()=>({legacy:_})),y.linear!==p&&y.set(()=>({linear:p})),y.flat!==h&&y.set(()=>({flat:h})),!l||tb.fun(l)||tG(l)||tb.equ(l,A,ra)||tD(A,l),r=d,g=!0,o(),this},render(n){return g||S||this.configure(),S.then(()=>{rt.updateContainer((0,tr.jsx)(ro,{store:m,children:n,onCreated:r,rootElement:e}),h,null,()=>void 0)}),m},unmount(){rl(e)}}}function ro({store:e,children:n,onCreated:t,rootElement:r}){return tg(()=>{let n=e.getState();n.set(e=>({internal:{...e.internal,active:!0}})),t&&t(n),e.getState().events.connected||null==n.events.connect||n.events.connect(r)},[]),(0,tr.jsx)(tH.Provider,{value:e,children:n})}function rl(e,n){let t=rr.get(e),r=null==t?void 0:t.fiber;if(r){let a=null==t?void 0:t.store.getState();a&&(a.internal.active=!1),rt.updateContainer(null,r,null,()=>{a&&setTimeout(()=>{try{null==a.events.disconnect||a.events.disconnect(),null==(t=a.gl)||null==(r=t.renderLists)||null==r.dispose||r.dispose(),null==(i=a.gl)||null==i.forceContextLoss||i.forceContextLoss(),null!=(o=a.gl)&&o.xr&&a.xr.disconnect();var t,r,i,o,l=a.scene;for(let e in"Scene"!==l.type&&(null==l.dispose||l.dispose()),l){let n=l[e];(null==n?void 0:n.type)!=="Scene"&&(null==n||null==n.dispose||n.dispose())}rr.delete(e),n&&n(e)}catch(e){}},500)})}}function rs(e,n){let t={callback:e};return n.add(t),()=>void n.delete(t)}let ru=new Set,rc=new Set,rd=new Set,rf=e=>rs(e,ru),rp=e=>rs(e,rc);function rm(e,n){if(e.size)for(let{callback:t}of e.values())t(n)}function rh(e,n){switch(e){case"before":return rm(ru,n);case"after":return rm(rc,n);case"tail":return rm(rd,n)}}function rg(e,r,a){let i=r.clock.getDelta();"never"===r.frameloop&&"number"==typeof e&&(i=e-r.clock.elapsedTime,r.clock.oldTime=r.clock.elapsedTime,r.clock.elapsedTime=e),n=r.internal.subscribers;for(let e=0;e0)&&!(null!=(n=i.gl.xr)&&n.isPresenting)&&(r+=rg(e,i))}if(rv=!1,rh("after",e),0===r)return rh("tail",e),r_=!1,cancelAnimationFrame(a)}function rE(e,n=1){var t;if(!e)return rr.forEach(e=>rE(e.store.getState(),n));(null==(t=e.gl.xr)||!t.isPresenting)&&e.internal.active&&"never"!==e.frameloop&&(n>1?e.internal.frames=Math.min(60,e.internal.frames+n):rv?e.internal.frames=2:e.internal.frames=1,r_||(r_=!0,requestAnimationFrame(rS)))}function rT(e,n=!0,t,r){if(n&&rh("before",e),t)rg(e,t,r);else for(let n of rr.values())rg(e,n.store.getState());n&&rh("after",e)}let rM={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function rb(e){let{handlePointer:n}=function(e){function n(e){return e.filter(e=>["Move","Over","Enter","Out","Leave"].some(n=>{var t;return null==(t=e.__r3f)?void 0:t.handlers["onPointer"+n]}))}function t(n){let{internal:t}=e.getState();for(let e of t.hovered.values())if(!n.length||!n.find(n=>n.object===e.object&&n.index===e.index&&n.instanceId===e.instanceId)){let r=e.eventObject.__r3f;if(t.hovered.delete(tO(e)),null!=r&&r.eventCount){let t=r.handlers,a={...e,intersections:n};null==t.onPointerOut||t.onPointerOut(a),null==t.onPointerLeave||t.onPointerLeave(a)}}}function r(e,n){for(let t=0;tt([]);case"onLostPointerCapture":return n=>{let{internal:r}=e.getState();"pointerId"in n&&r.capturedMap.has(n.pointerId)&&requestAnimationFrame(()=>{r.capturedMap.has(n.pointerId)&&(r.capturedMap.delete(n.pointerId),t([]))})}}return function(i){let{onPointerMissed:o,internal:l}=e.getState();l.lastEvent.current=i;let s="onPointerMove"===a,u="onClick"===a||"onContextMenu"===a||"onDoubleClick"===a,c=function(n,t){let r=e.getState(),a=new Set,i=[],o=t?t(r.internal.interaction):r.internal.interaction;for(let e=0;e{let t=tM(e.object),r=tM(n.object);return t&&r&&r.events.priority-t.events.priority||e.distance-n.distance}).filter(e=>{let n=tO(e);return!a.has(n)&&(a.add(n),!0)});for(let e of(r.events.filter&&(l=r.events.filter(l,r)),l)){let n=e.object;for(;n;){var s;null!=(s=n.__r3f)&&s.eventCount&&i.push({...e,eventObject:n}),n=n.parent}}if("pointerId"in n&&r.internal.capturedMap.has(n.pointerId))for(let e of r.internal.capturedMap.get(n.pointerId).values())a.has(tO(e.intersection))||i.push(e.intersection);return i}(i,s?n:void 0),d=u?function(n){let{internal:t}=e.getState(),r=n.offsetX-t.initialClick[0],a=n.offsetY-t.initialClick[1];return Math.round(Math.sqrt(r*r+a*a))}(i):0;"onPointerDown"===a&&(l.initialClick=[i.offsetX,i.offsetY],l.initialHits=c.map(e=>e.eventObject)),u&&!c.length&&d<=2&&(r(i,l.interaction),o&&o(i)),s&&t(c),!function(e,n,r,a){if(e.length){let i={stopped:!1};for(let o of e){let l=tM(o.object);if(l||o.object.traverseAncestors(e=>{let n=tM(e);if(n)return l=n,!1}),l){let{raycaster:s,pointer:u,camera:c,internal:d}=l,f=new v.Vector3(u.x,u.y,0).unproject(c),p=e=>{var n,t;return null!=(n=null==(t=d.capturedMap.get(e))?void 0:t.has(o.eventObject))&&n},m=e=>{let t={intersection:o,target:n.target};d.capturedMap.has(e)?d.capturedMap.get(e).set(o.eventObject,t):d.capturedMap.set(e,new Map([[o.eventObject,t]])),n.target.setPointerCapture(e)},h=e=>{let n=d.capturedMap.get(e);n&&tB(d.capturedMap,o.eventObject,n,e)},g={};for(let e in n){let t=n[e];"function"!=typeof t&&(g[e]=t)}let _={...o,...g,pointer:u,intersections:e,stopped:i.stopped,delta:r,unprojectedPoint:f,ray:s.ray,camera:c,stopPropagation(){let r="pointerId"in n&&d.capturedMap.get(n.pointerId);(!r||r.has(o.eventObject))&&(_.stopped=i.stopped=!0,d.hovered.size&&Array.from(d.hovered.values()).find(e=>e.eventObject===o.eventObject)&&t([...e.slice(0,e.indexOf(o)),o]))},target:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},currentTarget:{hasPointerCapture:p,setPointerCapture:m,releasePointerCapture:h},nativeEvent:n};if(a(_),!0===i.stopped)break}}}}(c,i,d,function(e){let n=e.eventObject,t=n.__r3f;if(!(null!=t&&t.eventCount))return;let o=t.handlers;if(s){if(o.onPointerOver||o.onPointerEnter||o.onPointerOut||o.onPointerLeave){let n=tO(e),t=l.hovered.get(n);t?t.stopped&&e.stopPropagation():(l.hovered.set(n,e),null==o.onPointerOver||o.onPointerOver(e),null==o.onPointerEnter||o.onPointerEnter(e))}null==o.onPointerMove||o.onPointerMove(e)}else{let t=o[a];t?(!u||l.initialHits.includes(n))&&(r(i,l.interaction.filter(e=>!l.initialHits.includes(e))),t(e)):u&&l.initialHits.includes(n)&&r(i,l.interaction.filter(e=>!l.initialHits.includes(e)))}})}}}}(e);return{priority:1,enabled:!0,compute(e,n,t){n.pointer.set(e.offsetX/n.size.width*2-1,-(2*(e.offsetY/n.size.height))+1),n.raycaster.setFromCamera(n.pointer,n.camera)},connected:void 0,handlers:Object.keys(rM).reduce((e,t)=>({...e,[t]:n(t)}),{}),update:()=>{var n;let{events:t,internal:r}=e.getState();null!=(n=r.lastEvent)&&n.current&&t.handlers&&t.handlers.onPointerMove(r.lastEvent.current)},connect:n=>{let{set:t,events:r}=e.getState();if(null==r.disconnect||r.disconnect(),t(e=>({events:{...e.events,connected:n}})),r.handlers)for(let e in r.handlers){let t=r.handlers[e],[a,i]=rM[e];n.addEventListener(a,t,{passive:i})}},disconnect:()=>{let{set:n,events:t}=e.getState();if(t.connected){if(t.handlers)for(let e in t.handlers){let n=t.handlers[e],[r]=rM[e];t.connected.removeEventListener(r,n)}n(e=>({events:{...e.events,connected:void 0}}))}}}}e.s(["B",()=>tS,"C",()=>tV,"D",()=>tz,"E",()=>tE,"G",()=>tj,"a",()=>t_,"b",()=>tg,"c",()=>ri,"d",()=>rl,"e",()=>t0,"f",()=>rb,"i",()=>tm,"j",()=>rf,"k",()=>rp,"u",()=>tv],40859)},71753,e=>{"use strict";var n=e.i(40859);e.s(["useFrame",()=>n.D])},15080,e=>{"use strict";var n=e.i(40859);e.s(["useThree",()=>n.C])},79123,e=>{"use strict";var n=e.i(43476),t=e.i(71645);let r=(0,t.createContext)(null),a=(0,t.createContext)(null),i=(0,t.createContext)(null);function o(){return(0,t.useContext)(r)}function l(){return(0,t.useContext)(a)}function s(){return(0,t.useContext)(i)}function u({children:e,fogEnabledOverride:o,onClearFogEnabledOverride:l}){let[s,u]=(0,t.useState)(!0),[c,d]=(0,t.useState)(!1),[f,p]=(0,t.useState)(1),[m,h]=(0,t.useState)(90),[g,_]=(0,t.useState)(!1),[v,S]=(0,t.useState)(!0),[E,T]=(0,t.useState)(!1),[M,b]=(0,t.useState)("moveLookStick"),x=(0,t.useCallback)(e=>{u(e),l()},[l]),R=(0,t.useMemo)(()=>({fogEnabled:o??s,setFogEnabled:x,highQualityFog:c,setHighQualityFog:d,fov:m,setFov:h,audioEnabled:g,setAudioEnabled:_,animationEnabled:v,setAnimationEnabled:S}),[s,o,x,c,m,g,v]),C=(0,t.useMemo)(()=>({debugMode:E,setDebugMode:T}),[E,T]),y=(0,t.useMemo)(()=>({speedMultiplier:f,setSpeedMultiplier:p,touchMode:M,setTouchMode:b}),[f,p,M,b]);(0,t.useLayoutEffect)(()=>{let e={};try{e=JSON.parse(localStorage.getItem("settings"))||{}}catch(e){}null!=e.debugMode&&T(e.debugMode),null!=e.audioEnabled&&_(e.audioEnabled),null!=e.animationEnabled&&S(e.animationEnabled),null!=e.fogEnabled&&u(e.fogEnabled),null!=e.highQualityFog&&d(e.highQualityFog),null!=e.speedMultiplier&&p(e.speedMultiplier),null!=e.fov&&h(e.fov),null!=e.touchMode&&b(e.touchMode)},[]);let A=(0,t.useRef)(null);return(0,t.useEffect)(()=>(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{try{localStorage.setItem("settings",JSON.stringify({fogEnabled:s,highQualityFog:c,speedMultiplier:f,fov:m,audioEnabled:g,animationEnabled:v,debugMode:E,touchMode:M}))}catch(e){}},500),()=>{A.current&&clearTimeout(A.current)}),[s,c,f,m,g,v,E,M]),(0,n.jsx)(r.Provider,{value:R,children:(0,n.jsx)(a.Provider,{value:C,children:(0,n.jsx)(i.Provider,{value:y,children:e})})})}e.s(["SettingsProvider",()=>u,"useControls",()=>s,"useDebug",()=>l,"useSettings",()=>o])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/49bf5eb2ca42014f.js b/docs/_next/static/chunks/49bf5eb2ca42014f.js new file mode 100644 index 00000000..71a00783 --- /dev/null +++ b/docs/_next/static/chunks/49bf5eb2ca42014f.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,12631,e=>{"use strict";var t=e.i(71645),a=e.i(8155);let r=e=>{let r=(0,a.createStore)(e),n=e=>(function(e,a=e=>e){let r=t.default.useSyncExternalStore(e.subscribe,t.default.useCallback(()=>a(e.getState()),[e,a]),t.default.useCallback(()=>a(e.getInitialState()),[e,a]));return t.default.useDebugValue(r),r})(r,e);return Object.assign(n,r),n};var n=e.i(79473);let i=t.createContext(null);function o({map:e,children:a,onChange:o,domElement:s}){let l=e.map(e=>e.name+e.keys).join("-"),d=t.useMemo(()=>{let t;return(t=(0,n.subscribeWithSelector)(()=>e.reduce((e,t)=>({...e,[t.name]:!1}),{})))?r(t):r},[l]),c=t.useMemo(()=>[d.subscribe,d.getState,d],[l]),u=d.setState;return t.useEffect(()=>{let t=e.map(({name:e,keys:t,up:a})=>({keys:t,up:a,fn:t=>{u({[e]:t}),o&&o(e,t,c[1]())}})).reduce((e,{keys:t,fn:a,up:r=!0})=>(t.forEach(t=>e[t]={fn:a,pressed:!1,up:r}),e),{}),a=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,pressed:i,up:o}=r;r.pressed=!0,(o||!i)&&n(!0)},r=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,up:i}=r;r.pressed=!1,i&&n(!1)},n=s||window;return n.addEventListener("keydown",a,{passive:!0}),n.addEventListener("keyup",r,{passive:!0}),()=>{n.removeEventListener("keydown",a),n.removeEventListener("keyup",r)}},[s,l]),t.createElement(i.Provider,{value:c,children:a})}function s(e){let[a,r,n]=t.useContext(i);return e?n(e):[a,r]}e.s(["KeyboardControls",()=>o,"useKeyboardControls",()=>s],12631)},5729,e=>{"use strict";var t,a=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(90072),o=e.i(71753),s=e.i(15080),l=e.i(12631),d=e.i(85413),c=Object.defineProperty,u=(e,t,a)=>{let r;return(r="symbol"!=typeof t?t+"":t)in e?c(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,a};let h=new i.Euler(0,0,0,"YXZ"),g=new i.Vector3,p={type:"change"},m={type:"lock"},f={type:"unlock"},F=Math.PI/2;class v extends d.EventDispatcher{constructor(e,t){super(),u(this,"camera"),u(this,"domElement"),u(this,"isLocked"),u(this,"minPolarAngle"),u(this,"maxPolarAngle"),u(this,"pointerSpeed"),u(this,"onMouseMove",e=>{this.domElement&&!1!==this.isLocked&&(h.setFromQuaternion(this.camera.quaternion),h.y-=.002*e.movementX*this.pointerSpeed,h.x-=.002*e.movementY*this.pointerSpeed,h.x=Math.max(F-this.maxPolarAngle,Math.min(F-this.minPolarAngle,h.x)),this.camera.quaternion.setFromEuler(h),this.dispatchEvent(p))}),u(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(m),this.isLocked=!0):(this.dispatchEvent(f),this.isLocked=!1))}),u(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),u(this,"connect",e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),u(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),u(this,"dispose",()=>{this.disconnect()}),u(this,"getObject",()=>this.camera),u(this,"direction",new i.Vector3(0,0,-1)),u(this,"getDirection",e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion)),u(this,"moveForward",e=>{g.setFromMatrixColumn(this.camera.matrix,0),g.crossVectors(this.camera.up,g),this.camera.position.addScaledVector(g,e)}),u(this,"moveRight",e=>{g.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(g,e)}),u(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),u(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var y=e.i(79123),S=e.i(68294),k=e.i(93784);(t={}).forward="forward",t.backward="backward",t.left="left",t.right="right",t.up="up",t.down="down",t.lookUp="lookUp",t.lookDown="lookDown",t.lookLeft="lookLeft",t.lookRight="lookRight",t.camera1="camera1",t.camera2="camera2",t.camera3="camera3",t.camera4="camera4",t.camera5="camera5",t.camera6="camera6",t.camera7="camera7",t.camera8="camera8",t.camera9="camera9";let b=Math.PI/2-.01;function P(){let e,t,a,d,c,u,h,g,p,m,f,F,P,x=(0,r.c)(26),{speedMultiplier:I,setSpeedMultiplier:D}=(0,y.useControls)(),[C,E]=(0,l.useKeyboardControls)(),{camera:w,gl:M}=(0,s.useThree)(),{nextCamera:B,setCameraIndex:T,cameraCount:R}=(0,S.useCameras)(),N=(0,n.useRef)(null);x[0]===Symbol.for("react.memo_cache_sentinel")?(e=new i.Vector3,x[0]=e):e=x[0];let G=(0,n.useRef)(e);x[1]===Symbol.for("react.memo_cache_sentinel")?(t=new i.Vector3,x[1]=t):t=x[1];let A=(0,n.useRef)(t);x[2]===Symbol.for("react.memo_cache_sentinel")?(a=new i.Vector3,x[2]=a):a=x[2];let U=(0,n.useRef)(a);x[3]===Symbol.for("react.memo_cache_sentinel")?(d=new i.Euler(0,0,0,"YXZ"),x[3]=d):d=x[3];let j=(0,n.useRef)(d);return x[4]!==w||x[5]!==M.domElement?(c=()=>{let e=new v(w,M.domElement);return N.current=e,()=>{e.dispose()}},u=[w,M.domElement],x[4]=w,x[5]=M.domElement,x[6]=c,x[7]=u):(c=x[6],u=x[7]),(0,n.useEffect)(c,u),x[8]!==w||x[9]!==M.domElement||x[10]!==B?(h=()=>{let e=M.domElement,t=new i.Euler(0,0,0,"YXZ"),a=!1,r=!1,n=0,o=0,s=t=>{N.current?.isLocked||t.target===e&&(a=!0,r=!1,n=t.clientX,o=t.clientY)},l=e=>{!a||!r&&3>Math.abs(e.clientX-n)&&3>Math.abs(e.clientY-o)||(r=!0,t.setFromQuaternion(w.quaternion,"YXZ"),t.y=t.y-.003*e.movementX,t.x=t.x-.003*e.movementY,t.x=Math.max(-b,Math.min(b,t.x)),w.quaternion.setFromEuler(t))},d=()=>{a=!1},c=t=>{let a=N.current;!a||a.isLocked?B():t.target!==e||r||a.lock()};return e.addEventListener("mousedown",s),document.addEventListener("mousemove",l),document.addEventListener("mouseup",d),document.addEventListener("click",c),()=>{e.removeEventListener("mousedown",s),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",d),document.removeEventListener("click",c)}},g=[w,M.domElement,B],x[8]=w,x[9]=M.domElement,x[10]=B,x[11]=h,x[12]=g):(h=x[11],g=x[12]),(0,n.useEffect)(h,g),x[13]!==R||x[14]!==T||x[15]!==C?(p=()=>{let e=["camera1","camera2","camera3","camera4","camera5","camera6","camera7","camera8","camera9"];return C(t=>{for(let a=0;a{let e=e=>{e.preventDefault();let t=e.deltaY>0?-1:1,a=Math.max(.05,Math.min(.5,Math.abs(.01*e.deltaY)))*t;D(e=>Math.max(.1,Math.min(5,Math.round((e+a)*20)/20)))},t=M.domElement;return t.addEventListener("wheel",e,{passive:!1}),()=>{t.removeEventListener("wheel",e)}},F=[M.domElement,D],x[18]=M.domElement,x[19]=D,x[20]=f,x[21]=F):(f=x[20],F=x[21]),(0,n.useEffect)(f,F),x[22]!==w||x[23]!==E||x[24]!==I?(P=(e,t)=>{let a=k.streamPlaybackStore.getState();if(a.playback&&!a.freeFlyCamera)return;let{forward:r,backward:n,left:i,right:o,up:s,down:l,lookUp:d,lookDown:c,lookLeft:u,lookRight:h}=E();if((d||c||u||h)&&(j.current.setFromQuaternion(w.quaternion,"YXZ"),u&&(j.current.y=j.current.y+ +t),h&&(j.current.y=j.current.y-t),d&&(j.current.x=j.current.x+ +t),c&&(j.current.x=j.current.x-t),j.current.x=Math.max(-b,Math.min(b,j.current.x)),w.quaternion.setFromEuler(j.current)),!r&&!n&&!i&&!o&&!s&&!l)return;let g=80*I;w.getWorldDirection(G.current),G.current.normalize(),A.current.crossVectors(w.up,G.current).normalize(),U.current.set(0,0,0),r&&U.current.add(G.current),n&&U.current.sub(G.current),i&&U.current.add(A.current),o&&U.current.sub(A.current),s&&(U.current.y=U.current.y+1),l&&(U.current.y=U.current.y-1),U.current.lengthSq()>0&&(U.current.normalize().multiplyScalar(g*t),w.position.add(U.current))},x[22]=w,x[23]=E,x[24]=I,x[25]=P):P=x[25],(0,o.useFrame)(P),null}function x(){let e,t,i=(0,r.c)(2);return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],i[0]=e):e=i[0],(0,n.useEffect)(I,e),i[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(P,{}),i[1]=t):t=i[1],t}function I(){return window.addEventListener("keydown",D,{capture:!0}),window.addEventListener("keyup",D,{capture:!0}),()=>{window.removeEventListener("keydown",D,{capture:!0}),window.removeEventListener("keyup",D,{capture:!0})}}function D(e){(e.metaKey||e.ctrlKey)&&"k"===e.key||e.metaKey&&e.stopImmediatePropagation()}e.s(["ARROW_LOOK_SPEED",0,1,"KEYBOARD_CONTROLS",0,[{name:"forward",keys:["KeyW"]},{name:"backward",keys:["KeyS"]},{name:"left",keys:["KeyA"]},{name:"right",keys:["KeyD"]},{name:"up",keys:["Space"]},{name:"down",keys:["ShiftLeft","ShiftRight"]},{name:"lookUp",keys:["ArrowUp"]},{name:"lookDown",keys:["ArrowDown"]},{name:"lookLeft",keys:["ArrowLeft"]},{name:"lookRight",keys:["ArrowRight"]},{name:"camera1",keys:["Digit1"]},{name:"camera2",keys:["Digit2"]},{name:"camera3",keys:["Digit3"]},{name:"camera4",keys:["Digit4"]},{name:"camera5",keys:["Digit5"]},{name:"camera6",keys:["Digit6"]},{name:"camera7",keys:["Digit7"]},{name:"camera8",keys:["Digit8"]},{name:"camera9",keys:["Digit9"]}],"MOUSE_SENSITIVITY",0,.003,"ObserverControls",()=>x],5729)},76775,(e,t,a)=>{function r(e,t,a,r){return Math.round(e/a)+" "+r+(t>=1.5*a?"s":"")}t.exports=function(e,t){t=t||{};var a,n,i,o,s=typeof e;if("string"===s&&e.length>0){var l=e;if(!((l=String(l)).length>100)){var d=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(d){var c=parseFloat(d[1]);switch((d[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*c;case"weeks":case"week":case"w":return 6048e5*c;case"days":case"day":case"d":return 864e5*c;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*c;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*c;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*c;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:break}}}return}if("number"===s&&isFinite(e)){return t.long?(n=Math.abs(a=e))>=864e5?r(a,n,864e5,"day"):n>=36e5?r(a,n,36e5,"hour"):n>=6e4?r(a,n,6e4,"minute"):n>=1e3?r(a,n,1e3,"second"):a+" ms":(o=Math.abs(i=e))>=864e5?Math.round(i/864e5)+"d":o>=36e5?Math.round(i/36e5)+"h":o>=6e4?Math.round(i/6e4)+"m":o>=1e3?Math.round(i/1e3)+"s":i+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7003,(e,t,a)=>{t.exports=function(t){function a(e){let t,n,i,o=null;function s(...e){if(!s.enabled)return;let r=Number(new Date);s.diff=r-(t||r),s.prev=t,s.curr=r,t=r,e[0]=a.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let n=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return"%";n++;let i=a.formatters[r];if("function"==typeof i){let a=e[n];t=i.call(s,a),e.splice(n,1),n--}return t}),a.formatArgs.call(s,e),(s.log||a.log).apply(s,e)}return s.namespace=e,s.useColors=a.useColors(),s.color=a.selectColor(e),s.extend=r,s.destroy=a.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==a.namespaces&&(n=a.namespaces,i=a.enabled(e)),i),set:e=>{o=e}}),"function"==typeof a.init&&a.init(s),s}function r(e,t){let r=a(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function n(e,t){let a=0,r=0,n=-1,i=0;for(;a"-"+e)].join(",");return a.enable(""),e},a.enable=function(e){for(let t of(a.save(e),a.namespaces=e,a.names=[],a.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?a.skips.push(t.slice(1)):a.names.push(t)},a.enabled=function(e){for(let t of a.skips)if(n(e,t))return!1;for(let t of a.names)if(n(e,t))return!0;return!1},a.humanize=e.r(76775),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{a[e]=t[e]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(e){let t=0;for(let a=0;a{let r;var n=e.i(47167);a.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),e.splice(n,0,a)},a.save=function(e){try{e?a.storage.setItem("debug",e):a.storage.removeItem("debug")}catch(e){}},a.load=function(){let e;try{e=a.storage.getItem("debug")||a.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==n.default&&"env"in n.default&&(e=n.default.env.DEBUG),e},a.useColors=function(){let e;return"u">typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("u">typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"u">typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"u">typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch(e){}}(),r=!1,a.destroy=()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),t.exports=e.r(7003)(a);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},50593,17711,58281,45853,25311,89119,10244,e=>{"use strict";var t={},a=function(e,a,r,n,i){var o=new Worker(t[a]||(t[a]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(e){var t=e.data,a=t.$e$;if(a){var r=Error(a[0]);r.code=a[1],r.stack=a[2],i(r,null)}else i(null,t)},o.postMessage(r,n),o},r=Uint8Array,n=Uint16Array,i=Int32Array,o=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),s=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),l=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=function(e,t){for(var a=new n(31),r=0;r<31;++r)a[r]=t+=1<>1|(21845&F)<<1;v=(61680&(v=(52428&v)>>2|(13107&v)<<2))>>4|(3855&v)<<4,f[F]=((65280&v)>>8|(255&v)<<8)>>1}for(var y=function(e,t,a){for(var r,i=e.length,o=0,s=new n(t);o>d]=c}else for(o=0,r=new n(i);o>15-e[o]);return r},S=new r(288),F=0;F<144;++F)S[F]=8;for(var F=144;F<256;++F)S[F]=9;for(var F=256;F<280;++F)S[F]=7;for(var F=280;F<288;++F)S[F]=8;for(var k=new r(32),F=0;F<32;++F)k[F]=5;var b=y(S,9,0),P=y(S,9,1),x=y(k,5,0),I=y(k,5,1),D=function(e){for(var t=e[0],a=1;at&&(t=e[a]);return t},C=function(e,t,a){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&a},E=function(e,t){var a=t/8|0;return(e[a]|e[a+1]<<8|e[a+2]<<16)>>(7&t)},w=function(e){return(e+7)/8|0},M=function(e,t,a){return(null==t||t<0)&&(t=0),(null==a||a>e.length)&&(a=e.length),new r(e.subarray(t,a))},B=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],T=function(e,t,a){var r=Error(t||B[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,T),!a)throw r;return r},R=function(e,t,a,n){var i=e.length,d=n?n.length:0;if(!i||t.f&&!t.l)return a||new r(0);var c=!a,h=c||2!=t.i,g=t.i;c&&(a=new r(3*i));var m=function(e){var t=a.length;if(e>t){var n=new r(Math.max(2*t,e));n.set(a),a=n}},f=t.f||0,F=t.p||0,v=t.b||0,S=t.l,k=t.d,b=t.m,x=t.n,B=8*i;do{if(!S){f=C(e,F,1);var R=C(e,F+1,3);if(F+=3,R)if(1==R)S=P,k=I,b=9,x=5;else if(2==R){var N=C(e,F,31)+257,G=C(e,F+10,15)+4,A=N+C(e,F+5,31)+1;F+=14;for(var U=new r(A),j=new r(19),O=0;O>4;if(q<16)U[O++]=q;else{var $=0,H=0;for(16==q?(H=3+C(e,F,3),F+=2,$=U[O-1]):17==q?(H=3+C(e,F,7),F+=3):18==q&&(H=11+C(e,F,127),F+=7);H--;)U[O++]=$}}var W=U.subarray(0,N),X=U.subarray(N);b=D(W),x=D(X),S=y(W,b,1),k=y(X,x,1)}else T(1);else{var q=w(F)+4,Z=e[q-4]|e[q-3]<<8,Y=q+Z;if(Y>i){g&&T(0);break}h&&m(v+Z),a.set(e.subarray(q,Y),v),t.b=v+=Z,t.p=F=8*Y,t.f=f;continue}if(F>B){g&&T(0);break}}h&&m(v+131072);for(var J=(1<>4;if((F+=15&$)>B){g&&T(0);break}if($||T(2),ee<256)a[v++]=ee;else if(256==ee){Q=F,S=null;break}else{var et=ee-254;if(ee>264){var O=ee-257,ea=o[O];et=C(e,F,(1<>4;er||T(3),F+=15&er;var X=p[en];if(en>3){var ea=s[en];X+=E(e,F)&(1<B){g&&T(0);break}h&&m(v+131072);var ei=v+et;if(v>8},G=function(e,t,a){a<<=7&t;var r=t/8|0;e[r]|=a,e[r+1]|=a>>8,e[r+2]|=a>>16},A=function(e,t){for(var a=[],i=0;ip&&(p=s[i].s);var m=new n(p+1),f=U(a[h-1],m,0);if(f>t){var i=0,F=0,v=f-t,y=1<t)F+=y-(1<>=v;F>0;){var k=s[i].s;m[k]=0&&F;--i){var b=s[i].s;m[b]==t&&(--m[b],++F)}f=t}return{t:new r(m),l:f}},U=function(e,t,a){return -1==e.s?Math.max(U(e.l,t,a+1),U(e.r,t,a+1)):t[e.s]=a},j=function(e){for(var t=e.length;t&&!e[--t];);for(var a=new n(++t),r=0,i=e[0],o=1,s=function(e){a[r++]=e},l=1;l<=t;++l)if(e[l]==i&&l!=t)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=e[l]}return{c:a.subarray(0,r),n:t}},O=function(e,t){for(var a=0,r=0;r>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i4&&!$[l[W-1]];--W);var X=g+5<<3,Z=O(i,S)+O(d,k)+c,Y=O(i,I)+O(d,E)+c+14+3*W+O(V,$)+2*V[16]+3*V[17]+7*V[18];if(h>=0&&X<=Z&&X<=Y)return z(t,p,e.subarray(h,h+g));if(N(t,p,1+(Y15&&(N(t,p,ee[_]>>5&127),p+=ee[_]>>12)}}else m=b,f=S,F=x,v=k;for(var _=0;_255){var et=ea>>18&31;G(t,p,m[et+257]),p+=f[et+257],et>7&&(N(t,p,ea>>23&31),p+=o[et]);var er=31&ea;G(t,p,F[er]),p+=v[er],er>3&&(G(t,p,ea>>5&8191),p+=s[er])}else G(t,p,m[ea]),p+=f[ea]}return G(t,p,m[256]),p+f[256]},V=new i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),_=new r(0),q=function(e,t,a,l,d,c){var u=c.z||e.length,g=new r(l+u+5*(1+Math.ceil(u/7e3))+d),p=g.subarray(l,g.length-d),f=c.l,F=7&(c.r||0);if(t){F&&(p[0]=c.r>>3);for(var v=V[t-1],y=v>>13,S=8191&v,k=(1<7e3||G>24576)&&(q>423||!f)){F=L(e,p,0,C,E,B,R,G,U,N-U,F),G=T=R=0,U=N;for(var $=0;$<286;++$)E[$]=0;for(var $=0;$<30;++$)B[$]=0}var H=2,W=0,X=S,Z=O-_&32767;if(q>2&&j==D(N-Z))for(var Y=Math.min(y,q)-1,J=Math.min(32767,N),K=Math.min(258,q);Z<=J&&--X&&O!=_;){if(e[N+H]==e[N+H-Z]){for(var Q=0;QH){if(H=Q,W=Z,Q>Y)break;for(var ee=Math.min(Z,Q-2),et=0,$=0;$et&&(et=en,_=ea)}}}_=b[O=_],Z+=O-_&32767}if(W){C[G++]=0x10000000|h[H]<<18|m[W];var ei=31&h[H],eo=31&m[W];R+=o[ei]+s[eo],++E[257+ei],++B[eo],A=N+H,++T}else C[G++]=e[N],++E[e[N]]}}for(N=Math.max(N,A);N=u&&(p[F/8|0]=f,es=u),F=z(p,F+1,e.subarray(N,es))}c.i=u}return M(g,0,l+w(F)+d)},$=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var a=t,r=9;--r;)a=(1&a&&-0x12477ce0)^a>>>1;e[t]=a}return e}(),H=function(){var e=-1;return{p:function(t){for(var a=e,r=0;r>>8;e=a},d:function(){return~e}}},W=function(){var e=1,t=0;return{p:function(a){for(var r=e,n=t,i=0|a.length,o=0;o!=i;){for(var s=Math.min(o+2655,i);o>16),n=(65535&n)+15*(n>>16)}e=r,t=n},d:function(){return e%=65521,t%=65521,(255&e)<<24|(65280&e)<<8|(255&t)<<8|t>>8}}},X=function(e,t,a,n,i){if(!i&&(i={l:1},t.dictionary)){var o=t.dictionary.subarray(-32768),s=new r(o.length+e.length);s.set(o),s.set(e,o.length),e=s,i.w=o.length}return q(e,null==t.level?6:t.level,null==t.mem?i.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,a,n,i)},Z=function(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a},Y=function(e,t,a){for(var r=e(),n=e.toString(),i=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>0},eu=function(e,t){return ec(e,t)+0x100000000*ec(e,t+4)},eh=function(e,t,a){for(;a;++t)e[t]=a,a>>>=8},eg=function(e,t){var a=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:2*(9==t.level),e[9]=3,0!=t.mtime&&eh(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),a){e[3]=8;for(var r=0;r<=a.length;++r)e[r+10]=a.charCodeAt(r)}},ep=function(e){(31!=e[0]||139!=e[1]||8!=e[2])&&T(6,"invalid gzip data");var t=e[3],a=10;4&t&&(a+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[a++]);return a+(2&t)},em=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},ef=function(e){return 10+(e.filename?e.filename.length+1:0)},eF=function(e,t){var a=t.level;if(e[0]=120,e[1]=(0==a?0:a<6?1:9==a?3:2)<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=W();r.p(t.dictionary),eh(e,2,r.d())}},ev=function(e,t){return((15&e[0])!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&T(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&T(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function ey(e,t){return"function"==typeof e&&(t=e,e={}),this.ondata=t,e}var eS=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new r(98304),this.o.dictionary){var a=this.o.dictionary.subarray(-32768);this.b.set(a,32768-a.length),this.s.i=32768-a.length}}return e.prototype.p=function(e,t){this.ondata(X(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||T(5),this.s.l&&T(4);var a=e.length+this.s.z;if(a>this.b.length){if(a>2*this.b.length-32768){var n=new r(-32768&a);n.set(this.b.subarray(0,this.s.z)),this.b=n}var i=this.b.length-this.s.z;this.b.set(e.subarray(0,i),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(i),32768),this.s.z=e.length-i+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||T(5),this.s.l&&T(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e}(),ek=function(e,t){el([et,function(){return[es,eS]}],this,ey.call(this,e,t),function(e){onmessage=es(new eS(e.data))},6,1)};function eb(e,t){return X(e,t||{},0,0)}var eP=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var a=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:a?a.length:0},this.o=new r(32768),this.p=new r(0),a&&this.o.set(a)}return e.prototype.e=function(e){if(this.ondata||T(5),this.d&&T(4),this.p.length){if(e.length){var t=new r(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,a=R(this.p,this.s,this.o);this.ondata(M(a,t,this.s.b),this.d),this.o=M(a,this.s.b-32768),this.s.b=this.o.length,this.p=M(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ex=function(e,t){el([ee,function(){return[es,eP]}],this,ey.call(this,e,t),function(e){onmessage=es(new eP(e.data))},7,0)};function eI(e,t){return R(e,{i:2},t&&t.out,t&&t.dictionary)}(function(){function e(e,t){this.c=H(),this.l=0,this.v=1,eS.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,eS.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=X(e,this.o,this.v&&ef(this.o),t&&8,this.s);this.v&&(eg(a,this.o),this.v=0),t&&(eh(a,a.length-8,this.c.d()),eh(a,a.length-4,this.l)),this.ondata(a,t)},e.prototype.flush=function(){eS.prototype.flush.call(this)}})();var eD=function(){function e(e,t){this.v=1,this.r=0,eP.call(this,e,t)}return e.prototype.push=function(e,t){if(eP.prototype.e.call(this,e),this.r+=e.length,this.v){var a=this.p.subarray(this.v-1),n=a.length>3?ep(a):4;if(n>a.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-a.length);this.p=a.subarray(n),this.v=0}eP.prototype.c.call(this,t),!this.s.f||this.s.l||t||(this.v=w(this.s.p)+9,this.s={i:0},this.o=new r(0),this.push(new r(0),t))},e}(),eC=function(e,t){var a=this;el([ee,ea,function(){return[es,eP,eD]}],this,ey.call(this,e,t),function(e){var t=new eD(e.data);t.onmember=function(e){return postMessage(e)},onmessage=es(t)},9,0,function(e){return a.onmember&&a.onmember(e)})},eE=(function(){function e(e,t){this.c=W(),this.v=1,eS.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),eS.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=X(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(eF(a,this.o),this.v=0),t&&eh(a,a.length-4,this.c.d()),this.ondata(a,t)},e.prototype.flush=function(){eS.prototype.flush.call(this)}}(),function(){function e(e,t){eP.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(eP.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(ev(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&T(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),eP.prototype.c.call(this,t)},e}()),ew=function(e,t){el([ee,er,function(){return[es,eP,eE]}],this,ey.call(this,e,t),function(e){onmessage=es(new eE(e.data))},11,0)},eM=function(){function e(e,t){this.o=ey.call(this,e,t)||{},this.G=eD,this.I=eP,this.Z=eE}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,a){e.ondata(t,a)}},e.prototype.push=function(e,t){if(this.ondata||T(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var a=new r(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):(15&this.p[0])!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();function eB(e,t){eM.call(this,e,t),this.queuedSize=0,this.G=eC,this.I=ex,this.Z=ew}eB.prototype.i=function(){var e=this;this.s.ondata=function(t,a,r){e.ondata(t,a,r)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},eB.prototype.push=function(e,t){this.queuedSize+=e.length,eM.prototype.push.call(this,e,t)};var eT="u">typeof TextEncoder&&new TextEncoder,eR="u">typeof TextDecoder&&new TextDecoder,eN=0;try{eR.decode(_,{stream:!0}),eN=1}catch(e){}var eG=function(e){for(var t="",a=0;;){var r=e[a++],n=(r>127)+(r>223)+(r>239);if(a+n>e.length)return{s:t,r:M(e,a-1)};n?3==n?t+=String.fromCharCode(55296|(r=((15&r)<<18|(63&e[a++])<<12|(63&e[a++])<<6|63&e[a++])-65536)>>10,56320|1023&r):1&n?t+=String.fromCharCode((31&r)<<6|63&e[a++]):t+=String.fromCharCode((15&r)<<12|(63&e[a++])<<6|63&e[a++]):t+=String.fromCharCode(r)}};function eA(e,t){if(t){for(var a=new r(e.length),n=0;n>1)),s=0,l=function(e){o[s++]=e},n=0;no.length){var d=new r(s+8+(i-n<<1));d.set(o),o=d}var c=e.charCodeAt(n);c<128||t?l(c):(c<2048?l(192|c>>6):(c>55295&&c<57344?(l(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++n))>>18),l(128|c>>12&63)):l(224|c>>12),l(128|c>>6&63)),l(128|63&c))}return M(o,0,s)}(function(e){this.ondata=e,eN?this.t=new TextDecoder:this.p=_}).prototype.push=function(e,t){if(this.ondata||T(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&T(8),this.t=null);return}this.p||T(4);var a=new r(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length);var n=eG(a),i=n.s,o=n.r;t?(o.length&&T(8),this.p=null):this.p=o,this.ondata(i,t)},(function(e){this.ondata=e}).prototype.push=function(e,t){this.ondata||T(5),this.d&&T(4),this.ondata(eA(e),this.d=t||!1)};var eU=function(e){return 1==e?3:e<6?2:+(9==e)},ej=function(e,t){for(;1!=ed(e,t);t+=4+ed(e,t+2));return[eu(e,t+12),eu(e,t+4),eu(e,t+20)]},eO=function(e){var t=0;if(e)for(var a in e){var r=e[a].length;r>65535&&T(9),t+=r+4}return t},ez=function(e,t,a,r,n,i,o,s){var l=r.length,d=a.extra,c=s&&s.length,u=eO(d);eh(e,t,null!=o?0x2014b50:0x4034b50),t+=4,null!=o&&(e[t++]=20,e[t++]=a.os),e[t]=20,t+=2,e[t++]=a.flag<<1|(i<0&&8),e[t++]=n&&8,e[t++]=255&a.compression,e[t++]=a.compression>>8;var h=new Date(null==a.mtime?Date.now():a.mtime),g=h.getFullYear()-1980;if((g<0||g>119)&&T(10),eh(e,t,g<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,-1!=i&&(eh(e,t,a.crc),eh(e,t+4,i<0?-i-2:i),eh(e,t+8,a.size)),eh(e,t+12,l),eh(e,t+14,u),t+=16,null!=o&&(eh(e,t,c),eh(e,t+6,a.attrs),eh(e,t+10,o),t+=14),e.set(r,t),t+=l,u)for(var p in d){var m=d[p],f=m.length;eh(e,t,+p),eh(e,t+2,f),e.set(m,t+4),t+=4+f}return c&&(e.set(s,t),t+=c),t},eL=function(e,t,a,r,n){eh(e,t,0x6054b50),eh(e,t+8,a),eh(e,t+10,a),eh(e,t+12,r),eh(e,t+16,n)},eV=function(){function e(e){this.filename=e,this.c=H(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||T(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();function e_(e,t){var a=this;t||(t={}),eV.call(this,e),this.d=new eS(t,function(e,t){a.ondata(null,e,t)}),this.compression=8,this.flag=eU(t.level)}function eq(e,t){var a=this;t||(t={}),eV.call(this,e),this.d=new ek(t,function(e,t,r){a.ondata(e,t,r)}),this.compression=8,this.flag=eU(t.level),this.terminate=this.d.terminate}function e$(e){this.ondata=e,this.u=[],this.d=1}e_.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e_.prototype.push=function(e,t){eV.prototype.push.call(this,e,t)},eq.prototype.process=function(e,t){this.d.push(e,t)},eq.prototype.push=function(e,t){eV.prototype.push.call(this,e,t)},e$.prototype.add=function(e){var t=this;if(this.ondata||T(5),2&this.d)this.ondata(T(4+(1&this.d)*8,0,1),null,!1);else{var a=eA(e.filename),n=a.length,i=e.comment,o=i&&eA(i),s=n!=e.filename.length||o&&i.length!=o.length,l=n+eO(e.extra)+30;n>65535&&this.ondata(T(11,0,1),null,!1);var d=new r(l);ez(d,0,e,a,s,-1);var c=[d],u=function(){for(var e=0,a=c;e0){var n=Math.min(this.c,e.length),i=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(n)).length)return this.push(e,t)}else{var o=0,s=0,l=void 0,d=void 0;this.p.length?e.length?((d=new r(this.p.length+e.length)).set(this.p),d.set(e,this.p.length)):d=this.p:d=e;for(var c=d.length,u=this.c,h=u&&this.d,g=this;ss+30+i+h){var p,m,f=[];g.k.unshift(f),o=2;var F=ec(d,s+18),v=ec(d,s+22),y=function(e,t){if(t){for(var a="",r=0;r=0&&(S.size=F,S.originalSize=v),g.onfile(S)}return"break"}if(u){if(0x8074b50==e)return l=s+=12+(-2==u&&8),o=3,g.c=0,"break";else if(0x2014b50==e)return l=s-=4,o=3,g.c=0,"break"}}();++s);if(this.p=_,u<0){var p=o?d.subarray(0,l-12-(-2==u&&8)-(0x8074b50==ec(d,l-16)&&4)):d.subarray(0,s);h?h.push(p,!!o):this.k[+(2==o)].push(p)}if(2&o)return this.push(d.subarray(s),t);this.p=d.subarray(s)}t&&(this.c&&T(13),this.p=null)},eZ.prototype.register=function(e){this.o[e.compression]=e},"function"==typeof queueMicrotask&&queueMicrotask;var eY=e.i(48450);let eJ=[0,0,0,0,0,0,0,0,0,329,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2809,68,0,27,0,58,3,62,4,7,0,0,15,65,554,3,394,404,189,117,30,51,27,15,34,32,80,1,142,3,142,39,0,144,125,44,122,275,70,135,61,127,8,12,113,246,122,36,185,1,149,309,335,12,11,14,54,151,0,0,2,0,0,211,0,2090,344,736,993,2872,701,605,646,1552,328,305,1240,735,1533,1713,562,3,1775,1149,1469,979,407,553,59,279,31,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function eK(e){return e.node?e.node.pop:e.leaf.pop}let eQ=new class{nodes=[];leaves=[];tablesBuilt=!1;buildTables(){if(this.tablesBuilt)return;this.tablesBuilt=!0,this.leaves=[];for(let t=0;t<256;t++){var e;this.leaves.push({pop:eJ[t]+ +((e=t)>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)+1,symbol:t,numBits:0,code:0})}this.nodes=[{pop:0,index0:0,index1:0}];let t=256,a=[];for(let e=0;e<256;e++)a.push({node:null,leaf:this.leaves[e]});for(;1!==t;){let e=0xfffffffe,r=0xffffffff,n=-1,i=-1;for(let o=0;oi?n:i;a[s]={node:o,leaf:null},l!==t-1&&(a[l]=a[t-1]),t--}this.nodes[0]=a[0].node,this.generateCodes(0,0,0)}determineIndex(e){return null!==e.leaf?-(this.leaves.indexOf(e.leaf)+1):this.nodes.indexOf(e.node)}generateCodes(e,t,a){if(t<0){let r=this.leaves[-(t+1)];r.code=e,r.numBits=a}else{let r=this.nodes[t];this.generateCodes(e,r.index0,a+1),this.generateCodes(e|1<=0)t=e.readFlag()?this.nodes[t].index1:this.nodes[t].index0;else{a.push(this.leaves[-(t+1)].symbol);break}}return String.fromCharCode(...a)}{let t=e.readInt(8);return String.fromCharCode(...e.readBytes(t))}}};class e0{data;bitNum;maxReadBitNum;error;stringBuffer=null;constructor(e,t=0){this.data=e,this.bitNum=t,this.maxReadBitNum=e.length<<3,this.error=!1}getCurPos(){return this.bitNum}setCurPos(e){this.bitNum=e}getBytePosition(){return this.bitNum+7>>3}isError(){return this.error}isFull(){return this.bitNum>this.maxReadBitNum}getRemainingBits(){return this.maxReadBitNum-this.bitNum}getMaxPos(){return this.maxReadBitNum}readFlag(){if(this.bitNum>=this.maxReadBitNum)return this.error=!0,!1;let e=1<<(7&this.bitNum),t=(this.data[this.bitNum>>3]&e)!=0;return this.bitNum++,t}readInt(e){if(0===e)return 0;if(this.bitNum+e>this.maxReadBitNum)return this.error=!0,0;let t=this.bitNum>>3,a=7&this.bitNum;if(this.bitNum+=e,e+a<=32){let r=0,n=e+a+7>>3;for(let e=0;e>>=a,32===e)?r>>>0:r&(1<>3;for(let e=0;e>>0:r&(1<>3,a=new Uint8Array(t),r=this.bitNum>>3,n=7&this.bitNum,i=8-n;if(0===n)a.set(this.data.subarray(r,r+t));else{let e=this.data[r];for(let o=0;o>n|t<this.maxReadBitNum)return this.error=!0,0;let e=this.bitNum>>3,t=7&this.bitNum,a=e0.f32U8;if(0===t)a[0]=this.data[e],a[1]=this.data[e+1],a[2]=this.data[e+2],a[3]=this.data[e+3];else{let r=8-t;for(let n=0;n<4;n++){let i=this.data[e+n],o=e+n+1>t|o<>>0)}getCompressionPoint(){return this.compressionPoint}getDataBlockDataMap(){return this.dataBlockDataMap}getConnectionContext(){let e=this.dataBlockDataMap;return{compressionPoint:this.compressionPoint,ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e),getDataBlockData:e?t=>e.get(t):void 0,getGhostParser:e=>this.registry.getGhostParser(e)}}_setNextRecvEventSeq(e){this.nextRecvEventSeq=e>>>0}setConnectionProtocolState(e){for(this.lastSeqRecvdAtSend=e.lastSeqRecvdAtSend.slice(0,32);this.lastSeqRecvdAtSend.length<32;)this.lastSeqRecvdAtSend.push(0);this.lastSeqRecvd=e.lastSeqRecvd>>>0,this.highestAckedSeq=e.highestAckedSeq>>>0,this.lastSendSeq=e.lastSendSeq>>>0,this.recvAckMask=e.ackMask>>>0,this.connectSequence=e.connectSequence>>>0,this.lastRecvAckAck=e.lastRecvAckAck>>>0,this._connectionEstablished=e.connectionEstablished}onSendPacketTrigger(){this.lastSendSeq=this.lastSendSeq+1>>>0,this.lastSeqRecvdAtSend[31&this.lastSendSeq]=this.lastSeqRecvd>>>0}applyProtocolHeader(e){if(e.connectSeqBit!==(1&this.connectSequence)||e.ackByteCount>4||e.packetType>2)return{accepted:!1,dispatchData:!1};let t=(e.seqNumber|0xfffffe00&this.lastSeqRecvd)>>>0;if(t>>0),this.lastSeqRecvd+31>>0;if(a>>0),this.lastSendSeq>>0,0===e.packetType&&(this.recvAckMask=(1|this.recvAckMask)>>>0);for(let t=this.highestAckedSeq+1;t<=a;t++)(e.ackMask&1<<(a-t&31))!=0&&(this.lastRecvAckAck=this.lastSeqRecvdAtSend[31&t]>>>0);t-this.lastRecvAckAck>32&&(this.lastRecvAckAck=t-32),this.highestAckedSeq=a;let n=this.lastSeqRecvd!==t&&0===e.packetType;return this.lastSeqRecvd=t,{accepted:!0,dispatchData:n}}parsePacket(e){let t=new e0(e),a=this.readDnetHeader(t),r=this.applyProtocolHeader(a);if(this.packetsParsed++,!r.accepted)return this.protocolRejected++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};if(!r.dispatchData)return this.protocolNoDispatch++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};let n=this.readRateInfo(t);t.setStringBuffer(!0);let i=this.readGameState(t),o=void 0===i.controlObjectDataStart||void 0!==i.controlObjectData,s=o?this.readEvents(t):[],l=s[s.length-1],d=!l||l.dataBitsEnd!==l.dataBitsStart,c=o&&d?t.getCurPos():void 0,u=o&&d?this.readGhosts(t,a.seqNumber):[];return t.setStringBuffer(!1),{dnetHeader:a,rateInfo:n,gameState:i,events:s,ghosts:u,ghostSectionStart:c}}readDnetHeader(e){let t=e.readFlag(),a=e.readInt(1),r=e.readInt(9),n=e.readInt(9),i=e.readInt(2),o=e.readInt(3),s=o>0?e.readInt(8*o):0;return{gameFlag:t,connectSeqBit:a,seqNumber:r,highestAck:n,packetType:i,ackByteCount:o,ackMask:s}}readRateInfo(e){let t={};return e.readFlag()&&(t.updateDelay=e.readInt(10),t.packetSize=e.readInt(10)),e.readFlag()&&(t.maxUpdateDelay=e.readInt(10),t.maxPacketSize=e.readInt(10)),t}readGameState(e){let t,a,r,n,i,o,s,l,d,c,u,h,g,p,m,f=e.readInt(32);e.readFlag()&&(e.readFlag()&&(t=e.readFloat(7)),e.readFlag()&&(a=1.5*e.readFloat(7))),e.readFlag()&&(r=e.readFlag(),n=e.readFlag()),e.readFlag()&&((i=e.readFlag())&&(o={x:e.readF32(),y:e.readF32(),z:e.readF32()}),1===(s=e.readRangedU32(0,2))?e.readFlag()&&(l=e.readRangedU32(0,1023)):2===s&&(d={x:e.readF32(),y:e.readF32(),z:e.readF32()}));let F=e.readFlag(),v=e.readFlag();if(e.readFlag())if(e.readFlag()){let m=e.readInt(10);c=m,u=e.getCurPos();let y=e.savePos(),S=this.ghostTracker.getGhost(m),k=S?this.registry.getGhostParser(S.classId):void 0,b=this.controlParserByGhostIndex.get(m),P=this.registry.getGhostParser(25),x=this.registry.getGhostParser(4),I=[],D=new Set,C=e=>{!e?.readPacketData||D.has(e.name)||(D.add(e.name),I.push(e))};C(k),C(b),C(P),C(x);let E=!1;for(let t of I){e.restorePos(y);try{let a=this.getConnectionContext(),r=t.readPacketData(e,a);if(e.getCurPos()-u<=0||e.isError())continue;g=r,h=e.getCurPos(),this.controlParserByGhostIndex.set(m,t),a.compressionPoint!==this.compressionPoint&&(this.compressionPoint=a.compressionPoint,p=this.compressionPoint),this.controlObjectParsed++,E=!0;break}catch{}}if(!E)return e.restorePos(y),h=u,this.controlObjectFailed++,{lastMoveAck:f,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:d,pinged:F,jammed:v,controlObjectGhostIndex:c,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:g,targetVisibility:[]}}else p={x:e.readF32(),y:e.readF32(),z:e.readF32()},this.compressionPoint=p;let y=[];for(;e.readFlag();)y.push({index:e.readInt(4),mask:e.readInt(32)});return e.readFlag()&&(m=e.readInt(8)),{lastMoveAck:f,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:d,pinged:F,jammed:v,controlObjectGhostIndex:c,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:g,compressionPoint:p,targetVisibility:y.length>0?y:void 0,cameraFov:m}}readEvents(e){let t=[],a=!0,r=-2;for(;;){let n,i,o,s=e.readFlag();if(a&&!s){if(a=!1,!e.readFlag()){this.dispatchGuaranteedEvents(t);break}}else if(a||s){if(!s)break}else{this.dispatchGuaranteedEvents(t);break}!a&&(r=n=e.readFlag()?r+1&127:e.readInt(7),(i=n|0xffffff80&this.nextRecvEventSeq)0&&this.pendingGuaranteedEvents[0].absoluteSequenceNumber===this.nextRecvEventSeq;){let t=this.pendingGuaranteedEvents.shift();if(!t)break;this.nextRecvEventSeq=this.nextRecvEventSeq+1>>>0,e.push(t.event),t.event.parsedData&&this.applyEventSideEffects(t.event.parsedData)}}applyEventSideEffects(e){let t=e.type;if("GhostingMessageEvent"===t){let t=e.message;"number"==typeof t&&2===t&&this.ghostTracker.clear();return}if("GhostAlwaysObjectEvent"===t){let t=e.ghostIndex,a=e.classId;if("number"==typeof t&&"number"==typeof a){let e=this.registry.getGhostParser(a);this.ghostTracker.createGhost(t,a,e?.name??`unknown_${a}`)}}"SimDataBlockEvent"===t&&this.dataBlockDataMap&&e.dataBlockData&&"number"==typeof e.objectId&&this.dataBlockDataMap.set(e.objectId,e.dataBlockData)}readGhosts(e,t){let a=[];if(!e.readFlag())return a;let r=e.readInt(3)+3;for(;e.readFlag();){let n;if(e.isError())break;let i=e.readInt(r);if(e.isError())break;if(e.readFlag()){this.ghostTracker.deleteGhost(i),this.ghostDeletes++,a.push({index:i,type:"delete",updateBitsStart:e.getCurPos(),updateBitsEnd:e.getCurPos()});continue}let o=!this.ghostTracker.hasGhost(i);n=o?e.readInt(7)+0:this.ghostTracker.getGhost(i)?.classId;let s=e.getCurPos(),l=void 0!==n?this.registry.getGhostParser(n):void 0;if(o&&!l){this.ghostsTrackerDiverged++,e5("DIVERGED pkt=%d seq=%d idx=%d classId=%d bit=%d/%d trackerSize=%d (server sent UPDATE for ghost not in our tracker; 7-bit classId is actually update data)",this.packetsParsed,t,i,n,s,e.getMaxPos(),this.ghostTracker.size()),a.push({index:i,type:"create",classId:n,updateBitsStart:s,updateBitsEnd:s});break}let d=!1;if(l)try{let t=this.getConnectionContext();t.currentGhostIndex=i;let r=l.unpackUpdate(e,o,t),c=e.getCurPos();o&&void 0!==n?(this.ghostTracker.createGhost(i,n,l.name),this.ghostCreatesParsed++):this.ghostUpdatesParsed++,a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:c,parsedData:r}),d=!0}catch(c){this.ghostsFailed++;let r=o?"create":"update",d=c instanceof Error?c.message:String(c);e5("FAIL pkt=%d seq=%d #%d idx=%d op=%s classId=%d parser=%s bit=%d/%d trackerSize=%d err=%s",this.packetsParsed,t,a.length,i,r,n,l.name,s,e.getMaxPos(),this.ghostTracker.size(),d)}if(!d){e5("STOP pkt=%d seq=%d idx=%d op=%s classId=%d parser=%s bit=%d/%d",this.packetsParsed,t,i,o?"create":"update",n,l?.name??"NONE",s,e.getMaxPos()),a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:s});break}}return a}emptyGameState(){return{lastMoveAck:0,pinged:!1,jammed:!1}}}class e8{eventParsers=new Map;ghostParsers=new Map;dataBlockParsers=new Map;eventCatalog=new Map;ghostCatalog=new Map;dataBlockCatalog=new Map;catalogEvent(e){this.eventCatalog.set(e.name,e)}catalogGhost(e){this.ghostCatalog.set(e.name,e)}catalogDataBlock(e){this.dataBlockCatalog.set(e.name,e)}bindDeterministicDataBlocks(e,t){let a=0,r=[];for(let n=0;n0&&(r.sounds=t)}if(e.readFlag()){let t=[];for(let a=0;a<4;a++)e.readFlag()&&t.push({index:a,sequence:e.readInt(5),state:e.readInt(2),forward:e.readFlag(),atEnd:e.readFlag()});t.length>0&&(r.threads=t)}let n=!1;if(e.readFlag()){let a=[];for(let r=0;r<8;r++)if(e.readFlag()){let i={index:r};e.readFlag()?i.dataBlockId=e9(e):i.dataBlockId=0,e.readFlag()&&(e.readFlag()?i.skinTagIndex=e.readInt(10):i.skinName=e.readString(),n=!0),i.triggerDown=e.readFlag(),i.loaded=e.readFlag(),i.ammo=e.readFlag(),i.wet=e.readFlag(),i.target=e.readFlag(),i.fireCount=e.readInt(3),t&&(i.imageExtraFlag=e.readFlag()),a.push(i)}a.length>0&&(r.images=a)}if(e.readFlag()){if(e.readFlag()){r.stateAEnabled=e.readFlag(),r.stateB=e.readFlag();let t=e.readFlag();r.hasInvulnerability=t,t?(r.invulnerabilityVisual=e.readFlag(),r.invulnerabilityTicks=e.readU32()):r.binaryCloak=e.readFlag()}if(e.readFlag())if(e.readFlag()){let t=e.readFlag();r.stateBMode=t,t?r.energyPackOn=!0:r.energyPackOn=!1}else r.shieldNormal=e.readNormalVector(8),r.energyPercent=e.readFloat(5);e.readFlag()&&(r.stateValue1=e.readU32(),r.stateValue2=e.readU32())}return n&&(r.imageSkinDirty=!0),e.readFlag()&&(e.readFlag()?(r.mountObject=e.readInt(10),r.mountNode=e.readInt(5)):r.mountObject=-1),r}function ta(e,t,a){let r=tt(e,t,a);if(e.readFlag()&&(r.impactSound=e.readInt(3)),e.readFlag()&&(r.action=e.readInt(8),r.actionHoldAtEnd=e.readFlag(),r.actionAtEnd=e.readFlag(),r.actionFirstPerson=e.readFlag(),!r.actionAtEnd&&e.readFlag()&&(r.actionAnimPos=e.readSignedFloat(6))),e.readFlag()&&(r.armAction=e.readInt(8)),e.readFlag())return r;if(e.readFlag()){if(r.actionState=e.readInt(3),e.readFlag()&&(r.recoverTicks=e.readInt(7)),r.moveFlag0=e.readFlag(),r.moveFlag1=e.readFlag(),r.position=e.readCompressedPoint(a.compressionPoint),e.readFlag()){let t=e.readInt(13)/32,a=e.readNormalVector(10);r.velocity={x:a.x*t,y:a.y*t,z:a.z*t}}else r.velocity={x:0,y:0,z:0};r.headX=e.readSignedFloat(6),r.headZ=e.readSignedFloat(6),r.rotationZ=2*e.readFloat(7)*Math.PI,r.move=e7(e),r.allowWarp=e.readFlag()}return r.energy=e.readFloat(5),r}function tr(e,t){let a={};if(a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.actionState=e.readInt(3),e.readFlag()&&(a.recoverTicks=e.readInt(7)),e.readFlag()&&(a.jumpDelay=e.readInt(7)),e.readFlag()){let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};a.position=r,t.compressionPoint=r,a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.jumpSurfaceLastContact=e.readInt(4)}if(a.headX=e.readF32(),a.headZ=e.readF32(),a.rotationZ=e.readF32(),e.readFlag()){let r=e.readInt(10);a.controlObjectGhost=r;let n=t.ghostTracker.getGhost(r),i=n?t.getGhostParser?.(n.classId):void 0;if(i?.readPacketData){let n=t.currentGhostIndex;t.currentGhostIndex=r,a.controlObjectData=i.readPacketData(e,t),t.currentGhostIndex=n}}return a.disableMove=e.readFlag(),a.pilot=e.readFlag(),a}function tn(e,t,a){let r=tt(e,t,a);return(r.jetting=e.readFlag(),e.readFlag())?r._controlledEarlyReturn=!0:(r.steeringYaw=e.readFloat(9),r.steeringPitch=e.readFloat(9),r.move=e7(e),r.frozen=e.readFlag(),e.readFlag()&&(r.position=e.readCompressedPoint(a.compressionPoint),r.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},r.linMomentum=e.readPoint3F(),r.angMomentum=e.readPoint3F()),e.readFlag()&&(r.energy=e.readFloat(8))),r}function ti(e,t){let a={};a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.steering={x:e.readF32(),y:e.readF32()};let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};return a.linPosition=r,a.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},a.linMomentum=e.readPoint3F(),a.angMomentum=e.readPoint3F(),a.disableMove=e.readFlag(),a.frozen=e.readFlag(),t.compressionPoint=r,a}function to(e,t){let a=ti(e,t);a.braking=e.readFlag();let r=4,n=t.currentGhostIndex;if(void 0!==n){let e=tX.get(n);void 0!==e&&(r=e)}let i=[];for(let t=0;t64)throw Error(`Invalid Sky fogVolumeCount: ${t}`);r.fogVolumeCount=t,r.useSkyTextures=e.readBool(),r.renderBottomTexture=e.readBool(),r.skySolidColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},r.windEffectPrecipitation=e.readBool();let a=[];for(let r=0;r3)throw Error(`Invalid precipitation colorCount: ${t}`);let a=[];for(let r=0;rMath.floor(e.getRemainingBits()/96))throw Error(`Invalid physicalZone point count: ${t}`);let a=[];for(let r=0;rMath.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone plane count: ${n}`);let i=[];for(let t=0;tMath.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone edge count: ${o}`);let s=[];for(let t=0;t0&&(a.audioData=e.readBitsBuffer(8*r)),a}function ad(e,t){return{type:"GhostingMessageEvent",sequence:e.readU32(),message:e.readInt(3),ghostCount:e.readInt(11)}}function ac(e,t){let a={type:"GhostAlwaysObjectEvent"};a.ghostIndex=e.readInt(10);let r=e.readFlag();if(a._hasObjectData=r,r){let r=e.readInt(7);a.classId=r;let n=t.getGhostParser?.(r);if(!n)throw Error(`No ghost parser for GhostAlwaysObjectEvent classId=${r}`);a.objectData=n.unpackUpdate(e,!0,t)}return a}function au(e,t){let a={type:"PathManagerEvent"};if(e.readFlag()){a.messageType="NewPaths";let t=e.readU32(),r=[];for(let a=0;a0&&(t.hudImages=a),t}function aE(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),t.mountPoint=e.readU32(),e.readFlag()||(t.offset=e.readAffineTransform()),t.firstPerson=e.readFlag(),t.mass=e.readF32(),t.usesEnergy=e.readFlag(),t.minEnergy=e.readF32(),t.hasFlash=e.readFlag(),t.projectile=ab(e),t.muzzleFlash=ab(e),t.isSeeker=e.readFlag(),t.isSeeker&&(t.seekerRadius=e.readF32(),t.maxSeekAngle=e.readF32(),t.seekerLockTime=e.readF32(),t.seekerFreeTime=e.readF32(),t.isTargetLockRequired=e.readFlag(),t.maxLockRange=e.readF32()),t.cloakable=e.readFlag(),t.lightType=e.readRangedU32(0,3),0!==t.lightType&&(t.lightRadius=e.readF32(),t.lightTime=e.readS32(),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)}),t.shellExitDir={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.shellExitVariance=e.readF32(),t.shellVelocity=e.readF32(),t.casing=ab(e),t.accuFire=e.readFlag();let a=[];for(let t=0;t<31;t++){if(!e.readFlag())continue;let t={};t.name=e.readString(),t.transitionOnAmmo=e.readInt(5),t.transitionOnNoAmmo=e.readInt(5),t.transitionOnTarget=e.readInt(5),t.transitionOnNoTarget=e.readInt(5),t.transitionOnWet=e.readInt(5),t.transitionOnNotWet=e.readInt(5),t.transitionOnTriggerUp=e.readInt(5),t.transitionOnTriggerDown=e.readInt(5),t.transitionOnTimeout=e.readInt(5),t.transitionGeneric0In=e.readInt(5),t.transitionGeneric0Out=e.readInt(5),e.readFlag()&&(t.timeoutValue=e.readF32()),t.waitForTimeout=e.readFlag(),t.fire=e.readFlag(),t.ejectShell=e.readFlag(),t.scaleAnimation=e.readFlag(),t.direction=e.readFlag(),t.reload=e.readFlag(),e.readFlag()&&(t.energyDrain=e.readF32()),t.loaded=e.readInt(3),t.spin=e.readInt(3),t.recoil=e.readInt(3),e.readFlag()&&(t.sequence=e.readSignedInt(16)),e.readFlag()&&(t.sequenceVis=e.readSignedInt(16)),t.flashSequence=e.readFlag(),t.ignoreLoadedForReady=e.readFlag(),t.emitter=ab(e),null!==t.emitter&&(t.emitterTime=e.readF32(),t.emitterNode=e.readS32()),t.sound=ab(e),a.push(t)}return t.states=a,t}function aw(e){let t=aC(e);t.renderFirstPerson=e.readFlag(),t.minLookAngle=e.readF32(),t.maxLookAngle=e.readF32(),t.maxFreelookAngle=e.readF32(),t.maxTimeScale=e.readF32(),t.maxStepHeight=e.readF32(),t.runForce=e.readF32(),t.runEnergyDrain=e.readF32(),t.minRunEnergy=e.readF32(),t.maxForwardSpeed=e.readF32(),t.maxBackwardSpeed=e.readF32(),t.maxSideSpeed=e.readF32(),t.maxUnderwaterForwardSpeed=e.readF32(),t.maxUnderwaterBackwardSpeed=e.readF32(),t.maxUnderwaterSideSpeedRef=ab(e),e.readFlag()&&(t.runSurfaceAngleRef=e.readInt(11)),t.runSurfaceAngle=e.readF32(),t.recoverDelay=e.readF32(),t.recoverRunForceScale=e.readF32(),t.jumpForce=e.readF32(),t.jumpEnergyDrain=e.readF32(),t.minJumpEnergy=e.readF32(),t.minJumpSpeed=e.readF32(),t.maxJumpSpeed=e.readF32(),t.jumpSurfaceAngle=e.readF32(),t.minJetEnergy=e.readF32(),t.splashVelocity=e.readF32(),t.splashAngle=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.bubbleEmitTime=e.readF32(),t.medSplashSoundVel=e.readF32(),t.hardSplashSoundVel=e.readF32(),t.exitSplashSoundVel=e.readF32(),t.jumpDelay=e.readInt(7),t.horizMaxSpeed=e.readF32(),t.horizResistSpeed=e.readF32(),t.horizResistFactor=e.readF32(),t.upMaxSpeed=e.readF32(),t.upResistSpeed=e.readF32(),t.upResistFactor=e.readF32(),t.jetEnergyDrain=e.readF32(),t.canJet=e.readF32(),t.maxJetHorizontalPercentage=e.readF32(),t.maxJetForwardSpeed=e.readF32(),t.jetForce=e.readF32(),t.minJetSpeed=e.readF32(),t.maxDamage=e.readF32(),t.minImpactDamageSpeed=e.readF32(),t.impactDamageScale=e.readF32(),t.footSplashHeight=e.readF32();let a=[];for(let t=0;t<32;t++)e.readFlag()?a.push(e.readInt(11)):a.push(null);t.sounds=a,t.boxSize={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.footPuffEmitter=ab(e),t.footPuffNumParts=e.readF32(),t.footPuffRadius=e.readF32(),t.decalData=ab(e),t.decalOffset=e.readF32(),t.dustEmitter=ab(e),t.splash=ab(e);let r=[];for(let t=0;t<3;t++)r.push(ab(e));return t.splashEmitters=r,t.groundImpactMinSpeed=e.readF32(),t.groundImpactShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeDuration=e.readF32(),t.groundImpactShakeFalloff=e.readF32(),t.boundingRadius=e.readF32(),t.moveBubbleSize=e.readF32(),t}function aM(e){let t=aC(e);t.bodyRestitution=e.readF32(),t.bodyFriction=e.readF32();let a=[];for(let t=0;t<2;t++)a.push(ab(e));t.impactSounds=a,t.minImpactSpeed=e.readF32(),t.softImpactSpeed=e.readF32(),t.hardImpactSpeed=e.readF32(),t.minRollSpeed=e.readF32(),t.maxSteeringAngle=e.readF32(),t.maxDrag=e.readF32(),t.minDrag=e.readF32(),t.cameraOffset=e.readF32(),t.cameraLag=e.readF32(),t.jetForce=e.readF32(),t.jetEnergyDrain=e.readF32(),t.minJetEnergy=e.readF32(),t.integration=e.readF32(),t.collisionTol=e.readF32(),t.massCenter=e.readF32(),t.exitSplashSoundVelocity=e.readF32(),t.softSplashSoundVelocity=e.readF32(),t.mediumSplashSoundVelocity=e.readF32(),t.hardSplashSoundVelocity=e.readF32();let r=[];for(let t=0;t<5;t++)r.push(ab(e));t.waterSounds=r,t.dustEmitter=ab(e);let n=[];for(let t=0;t<3;t++)n.push(ab(e));t.damageEmitters=n;let i=[];for(let t=0;t<2;t++)i.push(ab(e));return t.splashEmitters=i,t.damageEmitterOffset0={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageEmitterOffset1={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageLevelTolerance0=e.readF32(),t.damageLevelTolerance1=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.collDamageThresholdVel=e.readF32(),t.collDamageMultiplier=e.readF32(),t}function aB(e){let t=aM(e);t.jetActivateSound=ab(e),t.jetDeactivateSound=ab(e);let a=[];for(let t=0;t<4;t++)a.push(ab(e));return t.jetEmitters=a,t.maneuveringForce=e.readF32(),t.horizontalSurfaceForce=e.readF32(),t.verticalSurfaceForce=e.readF32(),t.autoInputDamping=e.readF32(),t.steeringForce=e.readF32(),t.steeringRollForce=e.readF32(),t.rollForce=e.readF32(),t.autoAngularForce=e.readF32(),t.rotationalDrag=e.readF32(),t.maxAutoSpeed=e.readF32(),t.autoLinearForce=e.readF32(),t.hoverHeight=e.readF32(),t.createHoverHeight=e.readF32(),t.minTrailSpeed=e.readF32(),t.vertThrustMultiple=e.readF32(),t.maxForwardSpeed=e.readF32(),t}function aT(e){let t=aM(e);t.dragForce=e.readF32(),t.mainThrustForce=e.readF32(),t.reverseThrustForce=e.readF32(),t.strafeThrustForce=e.readF32(),t.turboFactor=e.readF32(),t.stabLenMin=e.readF32(),t.stabLenMax=e.readF32(),t.stabSpringConstant=e.readF32(),t.stabDampingConstant=e.readF32(),t.gyroDrag=e.readF32(),t.normalForce=e.readF32(),t.restorativeForce=e.readF32(),t.steeringForce=e.readF32(),t.rollForce=e.readF32(),t.pitchForce=e.readF32(),t.floatingThrustFactor=e.readF32(),t.brakingForce=e.readF32(),t.dustTrailOffset={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.dustTrailFreqMod=e.readF32(),t.triggerTrailHeight=e.readF32(),t.floatSound=ab(e),t.thrustSound=ab(e),t.turboSound=ab(e);let a=[];for(let t=0;t<3;t++)a.push(ab(e));return t.jetEmitters=a,t.dustTrailEmitter=ab(e),t.mainThrustEmitterFactor=e.readF32(),t.strafeThrustEmitterFactor=e.readF32(),t.reverseThrustEmitterFactor=e.readF32(),t}function aR(e){let t=aM(e);return t.tireRadius=e.readF32(),t.tireStaticFriction=e.readF32(),t.tireKineticFriction=e.readF32(),t.tireRestitution=e.readF32(),t.tireLateralForce=e.readF32(),t.tireLateralDamping=e.readF32(),t.tireLateralRelaxation=e.readF32(),t.tireLongitudinalForce=e.readF32(),t.tireLongitudinalDamping=e.readF32(),t.tireEmitter=ab(e),t.jetSound=ab(e),t.engineSound=ab(e),t.squealSound=ab(e),t.wadeSound=ab(e),t.spring=e.readF32(),t.springDamping=e.readF32(),t.springLength=e.readF32(),t.brakeTorque=e.readF32(),t.engineTorque=e.readF32(),t.engineBrake=e.readF32(),t.maxWheelSpeed=e.readF32(),t.steeringAngle=e.readF32(),t.steeringReturn=e.readF32(),t.steeringDamping=e.readF32(),t.powerSteeringFactor=e.readF32(),t}function aN(e){let t=aC(e);return t.noIndividualDamage=e.readFlag(),t.dynamicTypeField=e.readS32(),t}function aG(e){let t=aN(e);return t.thetaMin=e.readF32(),t.thetaMax=e.readF32(),t.thetaNull=e.readF32(),t.neverUpdateControl=e.readFlag(),t.primaryAxis=e.readRangedU32(0,3),t.maxCapacitorEnergy=e.readF32(),t.capacitorRechargeRate=e.readF32(),t}function aA(e){let t=aE(e);return t.activationMS=e.readInt(8),t.deactivateDelayMS=e.readInt(8),t.degPerSecTheta=e.readRangedU32(0,1080),t.degPerSecPhi=e.readRangedU32(0,1080),t.dontFireInsideDamageRadius=e.readFlag(),t.damageRadius=e.readF32(),t.useCapacitor=e.readFlag(),t}function aU(e){let t=aC(e);return t.friction=e.readFloat(10),t.elasticity=e.readFloat(10),t.sticky=e.readFlag(),e.readFlag()&&(t.gravityMod=e.readFloat(10)),e.readFlag()&&(t.maxVelocity=e.readF32()),e.readFlag()&&(t.lightType=e.readInt(2),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)},t.lightTime=e.readS32(),t.lightRadius=e.readF32(),t.lightOnlyStatic=e.readFlag()),t}function aj(e){let t={};t.projectileShapeName=e.readString(),t.faceViewerLinkTime=e.readS32(),t.lifetime=e.readS32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()}),t.baseEmitter=ab(e),t.delayEmitter=ab(e),t.bubbleEmitter=ab(e),t.explosion=ab(e),t.underwaterExplosion=ab(e),t.splash=ab(e),t.sound=ab(e),t.wetFireSound=ab(e),t.fireSound=ab(e);let a=[];for(let t=0;t<6;t++)a.push(ab(e));return t.decals=a,e.readFlag()&&(t.lightRadius=e.readFloat(8),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),e.readFlag()&&(t.underwaterLightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),t.explodeOnWaterImpact=aI(e),t.depthTolerance=e.readF32(),t}function aO(e){let t=aj(e);return t.dryVelocity=e.readF32(),t.wetVelocity=e.readF32(),t.fizzleTime=e.readU32(),t.fizzleType=e.readU32(),t.hardRetarget=e.readFlag(),t.inheritedVelocityScale=e.readRangedU32(0,90),t.lifetimeMS=e.readRangedU32(0,90),t.collideWithOwnerTimeMS=e.readU32(),t.proximityRadius=e.readU32(),t.tracerProjectile=e.readFlag(),t}function az(e){let t=aj(e);return t.armingDelayMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.grenadeElasticity=e.readF32(),t.grenadeFriction=e.readF32(),t.drag=e.readF32(),t.density=e.readF32(),t.gravityMod=e.readF32(),t.lifetimeMS=e.readS32(),t}function aL(e){let t=aj(e);return t.lifetimeMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.turningSpeed=e.readF32(),t.proximityRadius=e.readF32(),t.terrainAvoidanceSpeed=e.readF32(),t.terrainScanAhead=e.readF32(),t.terrainHeightFail=e.readF32(),t.terrainAvoidanceRadius=e.readF32(),t.flareDistance=e.readF32(),t.flareAngle=e.readF32(),t.useFlechette=aI(e),t.maxVelocity=e.readF32(),t.acceleration=e.readF32(),t.flechetteDelayMs=e.readS32(),t.exhaustTimeMs=e.readS32(),t.exhaustNodeName=e.readString(),t.casingShapeName=e.readString(),t.casingDebris=ab(e),t.puffEmitter=ab(e),t.exhaustEmitter=ab(e),t}function aV(e){let t=aj(e);t.maxRifleRange=e.readF32(),t.rifleHeadMultiplier=e.readF32(),t.beamColor=ax(e),t.fadeTime=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32(),t.lightColor=ax(e),t.lightRadius=e.readF32();let a=[];for(let t=0;t<12;t++)a.push(e.readString());return t.textures=a,t}function a_(e){let t=aj(e);t.zapDuration=e.readF32(),t.boltLength=e.readF32(),t.numParts=e.readF32(),t.lightningFreq=e.readF32(),t.lightningDensity=e.readF32(),t.lightningAmp=e.readF32(),t.lightningWidth=e.readF32(),t.shockwave=ab(e);let a=[],r=[],n=[],i=[];for(let t=0;t<2;t++)a.push(e.readF32()),r.push(e.readF32()),n.push(e.readF32()),i.push(e.readF32());t.startWidth=a,t.endWidth=r,t.boltSpeed=n,t.texWrap=i;let o=[];for(let t=0;t<4;t++)o.push(e.readString());return t.textures=o,t.emitter=ab(e),t}function aq(e){let t=aj(e);return t.beamRange=e.readF32(),t.beamDrainRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t.flareTexture=e.readString(),t.hitEmitter=ab(e),t}function a$(e){let t=aj(e);return t.beamRange=e.readF32(),t.beamRepairRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t}function aH(e){let t=aj(e);t.maxRifleRange=e.readF32(),t.beamColor=ax(e),t.startBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32();let a=[];for(let t=0;t<4;t++)a.push(e.readString());return t.textures=a,t}function aW(e){let t=aO(e);return t.tracerLength=e.readF32(),t.tracerAlpha=e.readF32(),t.tracerMinPixels=e.readF32(),t.crossViewFraction=aI(e),t.tracerColor=ax(e),t.tracerWidth=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=aI(e),t.textureName0=e.readString(),t.textureName1=e.readString(),t}function aX(e){let t=az(e);return t.energyDrainPerSecond=e.readF32(),t.energyMinDrain=e.readF32(),t.beamWidth=e.readF32(),t.beamRange=e.readF32(),t.numSegments=e.readF32(),t.texRepeat=e.readF32(),t.beamFlareAngle=e.readF32(),t.beamTexture=e.readString(),t.flareTexture=e.readString(),t}function aZ(e){let t=aO(e);return t.numFlares=e.readF32(),t.flareColor=ax(e),t.flareTexture=e.readString(),t.smokeTexture=e.readString(),t.size=e.readF32(),t.flareModTexture=e.readF32(),t.smokeSize=e.readF32(),t}function aY(e){let t=az(e);return t.smokeDist=e.readF32(),t.noSmoke=e.readF32(),t.boomTime=e.readF32(),t.casingDist=e.readF32(),t.smokeCushion=e.readF32(),t.noSmokeCounter=e.readF32(),t.smokeTexture=e.readString(),t.bombTexture=e.readString(),t}function aJ(e){let t=az(e);return t.size=e.readF32(),t.useLensFlare=aI(e),t.flareTexture=e.readString(),t.lensFlareTexture=e.readString(),t}function aK(e){let t={};t.dtsFileName=e.readString(),t.soundProfile=ab(e),t.particleEmitter=ab(e),t.particleDensity=e.readInt(14),t.particleRadius=e.readF32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.explosionScale={x:e.readInt(16),y:e.readInt(16),z:e.readInt(16)}),t.playSpeed=e.readInt(14),t.debrisThetaMin=e.readRangedU32(0,180),t.debrisThetaMax=e.readRangedU32(0,180),t.debrisPhiMin=e.readRangedU32(0,360),t.debrisPhiMax=e.readRangedU32(0,360),t.debrisMinVelocity=e.readRangedU32(0,1e3),t.debrisMaxVelocity=e.readRangedU32(0,1e3),t.debrisNum=e.readInt(14),t.debrisVariance=e.readRangedU32(0,1e4),t.delayMS=e.readInt(16),t.delayVariance=e.readInt(16),t.lifetimeMS=e.readInt(16),t.lifetimeVariance=e.readInt(16),t.offset=e.readF32(),t.shakeCamera=e.readFlag(),t.hasLight=e.readFlag(),t.camShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeDuration=e.readF32(),t.camShakeRadius=e.readF32(),t.camShakeFalloff=e.readF32(),t.shockwave=ab(e),t.debris=ab(e);let a=[];for(let t=0;t<4;t++)a.push(ab(e));t.emitters=a;let r=[];for(let t=0;t<5;t++)r.push(ab(e));t.subExplosions=r;let n=e.readRangedU32(0,4),i=[];for(let t=0;t0&&ry("DataBlock binding: %d/%d bound, missing parsers: %s",t,e2.length,a.join(", "));const{bound:r,missing:n}=this.registry.bindDeterministicGhosts(e3,0);n.length>0&&ry("Ghost binding: %d/%d bound, missing parsers: %s",r,e3.length,n.join(", "));const{bound:i,missing:o}=this.registry.bindDeterministicEvents(e1,255);o.length>0&&ry("Event binding: %d/%d bound, missing parsers: %s",i,e1.length,o.join(", ")),this.packetParser=new e6(this.registry,this.ghostTracker)}getRegistry(){return this.registry}getGhostTracker(){return this.ghostTracker}getPacketParser(){return this.packetParser}get loaded(){return this._loaded}get header(){if(!this._loaded)throw Error("must call load() first");return this._header}get initialBlock(){if(!this._loaded)throw Error("must call load() first");return this._initialBlock}get blockCount(){if(!this._loaded)throw Error("must call load() first");if(void 0===this._blockCount){let e=this._decompressedData,t=this._decompressedView,a=0,r=0;for(;r+2<=e.length;){let n=4095&t.getUint16(r,!0);if((r+=2+n)>e.length)break;a++}this._blockCount=a}return this._blockCount}get blockCursor(){if(!this._loaded)throw Error("must call load() first");return this._blockCursor}async load(){if(this._loaded)return{header:this._header,initialBlock:this._initialBlock};let e=this.readHeader();ry('header: "%s" version=0x%s length=%dms (%smin) initialBlockSize=%d',e.identString,e.protocolVersion.toString(16),e.demoLengthMs,(e.demoLengthMs/1e3/60).toFixed(1),e.initialBlockSize);let t=this.buffer.subarray(this.offset,this.offset+e.initialBlockSize),a=this.readInitialBlock(t);this.offset+=e.initialBlockSize;let r=this.buffer.subarray(this.offset);ry("compressed block stream: %d bytes",r.length);let n=await new Promise((e,t)=>{var a,n;a=(a,r)=>{a?t(a):e(r)},n||(n=a,a={}),"function"!=typeof n&&T(7),eo(r,a,[ee],function(e){return en(eI(e.data[0],ei(e.data[1])))},1,n)});return ry("decompressed block stream: %d bytes",n.length),this._decompressedData=n,this._decompressedView=new DataView(n.buffer,n.byteOffset,n.byteLength),this.setupPacketParser(a),this._header=e,this._initialBlock=a,this._blockStreamOffset=0,this._blockCursor=0,this._loaded=!0,{header:e,initialBlock:a}}nextBlock(){if(!this._loaded)throw Error("must call load() first");let e=this._decompressedData,t=this._decompressedView,a=this._blockStreamOffset;if(a+2>e.length)return;let r=t.getUint16(a,!0),n=r>>12,i=4095&r;if(a+2+i>e.length)return void rk("block %d: size %d would exceed decompressed data (offset=%d remaining=%d), stopping",this._blockCursor,i,a+2,e.length-a-2);let o=e.subarray(a+2,a+2+i);this._blockStreamOffset=a+2+i;let s={index:this._blockCursor,type:n,size:i,data:o};if(this._blockCursor++,0===n)try{s.parsed=this.packetParser.parsePacket(o)}catch{}else if(1===n)this.packetParser.onSendPacketTrigger();else if(2===n&&64===i)try{s.parsed=this.readRawMove(o)}catch{}else if(3===n&&8===i)try{s.parsed=this.readInfoBlock(o)}catch{}return s}reset(){if(!this._loaded)throw Error("must call load() first");this._blockStreamOffset=0,this._blockCursor=0,this._blockCount=void 0,this.setupPacketParser(this._initialBlock)}processBlocks(e){if(!this._loaded)throw Error("must call load() first");let t=0;for(let a=0;a=128&&t<128+e2.length?e2[t-128]:`unknown(${t})`;throw Error(`No parser for DataBlock classId ${t} (${e}) at bit ${i}`)}}ry("all %d/%d DataBlocks parsed (%d payloads), bit position after DataBlocks: %d",l,i,s.size,r.getCurPos());let d=r.readU8(),c=[];for(let e=0;e<6;e++)c.push(r.readU32());let u=[];for(let e=0;e<16;e++)u.push(r.readU32());let h=r.readU32(),g=[];for(let e=0;e>3<<3),this.readSimpleTargetManager(r),this.readSimpleTargetManager(r),rS('after sequential tail bit=%d mission="%s" CRC=0x%s',r.getCurPos(),M,B.toString(16))}catch(e){a=e instanceof Error?e.message:String(e)}finally{this.ghostTracker=x}let T=b-r.getCurPos(),R=M.length>0?M.split("").filter(e=>{let t=e.charCodeAt(0);return t>=32&&t<=126}).length/M.length:1,N=M.length>0&&R>=.8&&void 0===a;return ry('initial block: events=%d ghosts=%d ghostingSeq=%d controlObj=%d mission="%s" CRC=0x%s valid=%s%s',I.length,E.length,C,w,M,B.toString(16),N,a?` error=${a}`:""),{taggedStrings:n,dataBlockHeaders:o,dataBlockCount:l,dataBlocks:s,demoSetting:d,connectionFields:c,stateArray:u,scoreEntries:g,demoValues:p,sensorGroupColors:m,targetEntries:f,connectionState:F,roundTripTime:v,packetLoss:y,pathManager:S,notifyCount:k,nextRecvEventSeq:D,ghostingSequence:C,initialGhosts:E,initialEvents:I,controlObjectGhostIndex:w,controlObjectData:t,missionName:M,missionCRC:B,phase2TrailingBits:T,phase2Valid:N,phase2Error:a}}readScoreEntry(e){let t=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{clientId:t,teamId:a,score:r,field0:n,field1:i,field2:o,isBot:s,triggerFlags:l}}readDemoValues(e){let t=[];for(;e.readFlag();)t.push(e.readString());return t}readComplexTargetManager(e){e.readU8(),e.readU8(),e.readU8(),e.readU8();let t=[];for(let a=0;a<32;a++)for(let r=0;r<32;r++)e.readFlag()&&t.push({group:a,targetGroup:r,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()});let a=[];for(let t=0;t<512;t++){if(!e.readFlag())continue;let r={targetId:t,sensorGroup:0,targetData:0,damageLevel:0};e.readFlag()&&(r.sensorData=e.readU32()),e.readFlag()&&(r.voiceMapData=e.readU32()),e.readFlag()&&(r.name=e.readString()),e.readFlag()&&(r.skin=e.readString()),e.readFlag()&&(r.skinPref=e.readString()),e.readFlag()&&(r.voice=e.readString()),e.readFlag()&&(r.typeDescription=e.readString()),r.sensorGroup=e.readInt(5),r.targetData=e.readInt(9),t>=32&&e.readFlag()&&(r.dataBlockRef=e.readInt(11)),r.damageLevel=e.readFloat(7),a.push(r)}return{sensorGroupColors:t,targets:a}}readPathManager(e){let t=[],a=e.readU32();for(let r=0;rthis.registry.getDataBlockParser(e)};t=i.unpack(e,a)}catch{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}else{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:e.getCurPos(),parsedData:t}),rS(" event classId=%d bits=%d",r,e.getCurPos()-n)}return{nextRecvEventSeq:t,events:a}}readGhostStartBlock(e,t){let a=e.readU32(),r=[];rS("ghost block: seq=%d bit=%d",a,e.getCurPos());let n=this.registry.getGhostCatalog(),i=8*e.getBuffer().length,o=new Map;for(let[e,a]of t)o.set(e,a.data);for(;e.readFlag()&&!e.isError();){let a=e.readInt(10),s=e.readInt(7)+0,l=e.getCurPos(),d=[],c=new Set,{entry:u}=this.identifyGhostViaDataBlock(e,t,n),h=this.registry.getGhostParser(s);h&&(d.push({entry:h,method:"registry"}),c.add(h)),u&&!c.has(u)&&(d.push({entry:u,method:"datablock"}),c.add(u));let g={getDataBlockData:e=>o.get(e),getDataBlockParser:e=>this.registry.getDataBlockParser(e)},p=!1;for(let{entry:t,method:n}of d){let o="registry"===n,d=this.tryGhostParser(e,t,l,i,!1,g,o);if(!1!==d){this.ghostTracker.createGhost(a,s,t.name),rS(" ghost idx=%d classId=%d parser=%s bits=%d via=%s",a,s,t.name,e.getCurPos()-l,n),r.push({index:a,type:"create",classId:s,updateBitsStart:l,updateBitsEnd:e.getCurPos(),parsedData:d}),p=!0;break}}if(!p){rS(" ghost idx=%d classId=%d NO PARSER (stopping at bit=%d, remaining=%d)",a,s,l,i-l);break}}return rS("ghost loop ended at bit=%d remaining=%d count=%d",e.getCurPos(),i-e.getCurPos(),r.length),{ghostingSequence:a,ghosts:r}}tryGhostParser(e,t,a,r,n=!1,i,o=!1){let s=e.savePos();n||rS(" try %s: startBit=%d",t.name,a);try{let l=t.unpackUpdate(e,!0,{compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,...i}),d=e.getCurPos()-a,c=r-e.getCurPos();if(e.isError()||!o&&d<3)return n||rS(" reject %s: bits=%d isError=%s",t.name,d,e.isError()),e.restorePos(s),!1;if(c>1e3){let a=e.getCurPos(),r=e.readFlag();if(e.setCurPos(a),!r)return n||rS(" reject %s: bits=%d misaligned (remaining=%d)",t.name,d,c),e.restorePos(s),!1}return l??{}}catch(a){return n||rS(" reject %s: error at bit=%d: %s",t.name,e.getCurPos(),a instanceof Error?a.message:String(a)),e.restorePos(s),!1}}identifyGhostViaDataBlock(e,t,a){let r;if(!t)return{entry:void 0,dbFlag:!1};let n=e.savePos(),i=!1;try{if(i=e.readFlag()){let n=e.readInt(11),i=t.get(n);if(i){let e=i.className.replace(/Data$/,"");(r=a.get(e))||rS(" identifyGhostViaDataBlock: dbId=%d className=%s ghostName=%s (no ghost parser)",n,i.className,e)}else rS(" identifyGhostViaDataBlock: dbId=%d (no DataBlock found)",n)}else rS(" identifyGhostViaDataBlock: DataBlock flag=0")}catch{}return e.restorePos(n),{entry:r,dbFlag:i}}readRawMove(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getInt32(0,!0),r=t.getInt32(4,!0),n=t.getInt32(8,!0),i=t.getUint32(12,!0),o=t.getUint32(16,!0),s=t.getUint32(20,!0),l=t.getFloat32(24,!0),d=t.getFloat32(28,!0),c=t.getFloat32(32,!0),u=t.getFloat32(36,!0),h=t.getFloat32(40,!0),g=t.getFloat32(44,!0),p=t.getUint32(48,!0),m=t.getUint32(52,!0),f=0!==e[56],F=[];for(let t=0;t<6;t++)F.push(0!==e[57+t]);return{px:a,py:r,pz:n,pyaw:i,ppitch:o,proll:s,x:l,y:d,z:c,yaw:u,pitch:h,roll:g,id:p,sendCount:m,freeLook:f,trigger:F}}readInfoBlock(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{value1:t.getUint32(0,!0),value2:t.getFloat32(4,!0)}}}function rP(){let e=new e8,t=new e4;ak(e),t2(e),rv(e),e.bindDeterministicDataBlocks(e2,128),e.bindDeterministicGhosts(e3,0),e.bindDeterministicEvents(e1,255);let a=new e6(e,t,{dataBlockDataMap:new Map});return{registry:e,ghostTracker:t,packetParser:a}}e.s(["DemoParser",()=>rb],58281),e.s(["createLiveParser",()=>rP],45853),e.s([],50593);var rx=e.i(90072);let rI=new Set(["FlyingVehicle","HoverVehicle","WheeledVehicle"]),rD=new Set(["BombProjectile","EnergyProjectile","FlareProjectile","GrenadeProjectile","LinearFlareProjectile","LinearProjectile","Projectile","SeekerProjectile","TracerProjectile"]),rC=new Set(["LinearProjectile","TracerProjectile","LinearFlareProjectile","Projectile"]),rE=new Set(["GrenadeProjectile","EnergyProjectile","FlareProjectile","BombProjectile"]),rw=new Set(["SeekerProjectile"]),rM=new Set(["StaticShape","ScopeAlwaysShape","Turret","BeaconObject","ForceFieldBare"]);function rB(e){return"Player"===e?"Player":rI.has(e)?"Vehicle":"Item"===e?"Item":rD.has(e)?"Projectile":rM.has(e)?"Deployable":"Ghost"}function rT(e,t){return`${e}_${t}`}let rR=Object.freeze({r:0,g:255,b:0}),rN=Object.freeze({r:255,g:0,b:0});e.s(["IFF_GREEN",0,rR,"IFF_RED",0,rN,"TICK_DURATION_MS",0,32,"ballisticProjectileClassNames",0,rE,"linearProjectileClassNames",0,rC,"projectileClassNames",0,rD,"seekerProjectileClassNames",0,rw,"toEntityId",()=>rT,"toEntityType",()=>rB],25311);let rG=new rx.Matrix4,rA=new rx.Quaternion;function rU(e,t,a){return ea?a:e}let rj=.494*Math.PI;function rO(e,t){let a=Math.sin(t),r=Math.cos(t),n=Math.sin(e),i=Math.cos(e);return rG.set(-n,i*a,-i*r,0,0,r,a,0,i,n*a,-n*r,0,0,0,0,1),rA.setFromRotationMatrix(rG),[rA.x,rA.y,rA.z,rA.w]}function rz(e){let t=-e/2;return[0,Math.sin(t),0,Math.cos(t)]}function rL(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)||!Number.isFinite(e.w))return null;let t=-e.y,a=-e.z,r=-e.x,n=e.w,i=t*t+a*a+r*r+n*n;if(i<=1e-12)return null;let o=1/Math.sqrt(i);return[t*o,a*o,r*o,n*o]}function rV(e){return null!=e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}function r_(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z}function rq(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z&&"number"==typeof e.w}function r$(e,t){let a;if(t)return"string"==typeof(a=rD.has(e)||e.endsWith("ProjectileData")?t.projectileShapeName:"DebrisData"===e?t.shapeFileName:t.shapeName)&&a.length>0?a:void 0}function rH(e,t){if(e)for(let a of t){let t=e[a];if("number"==typeof t&&Number.isFinite(t))return t}}function rW(e,t){if(e)for(let a of t){let t=e[a];if("string"==typeof t&&t.length>0)return t}}function rX(e,t){if(!t)return;let a=rW(t,["tracerTex0","textureName0","texture0"])??"";if(!("TracerProjectile"===e||a.length>0&&null!=rH(t,["tracerLength"]))||!a)return;let r=rW(t,["tracerTex1","textureName1","texture1"]),n=rH(t,["tracerLength"])??10,i=rH(t,["tracerWidth"]),o=rH(t,["tracerAlpha"]),s=null!=i&&(null!=rH(t,["crossViewAng"])||i<=.7)?i:o??i??.5,l=rH(t,["crossViewAng","crossViewFraction"])??("number"==typeof t.tracerWidth&&t.tracerWidth>.7?t.tracerWidth:.98);return{kind:"tracer",texture:a,crossTexture:r,tracerLength:n,tracerWidth:s,crossViewAng:l,crossSize:rH(t,["crossSize","muzzleVelocity"])??.45,renderCross:function(e,t){if(e)for(let a of t){let t=e[a];if("boolean"==typeof t)return t}}(t,["renderCross","proximityRadius"])??!0}}function rZ(e,t){if(t){if("LinearFlareProjectile"===e){let e=rW(t,["smokeTexture","flareTexture"]);if(!e)return;let a=t.flareColor,r=rH(t,["size"])??.5;return{kind:"sprite",texture:e,color:a?{r:a.r,g:a.g,b:a.b}:{r:1,g:1,b:1},size:r}}if("FlareProjectile"===e){let e=rW(t,["flareTexture"]);if(!e)return;return{kind:"sprite",texture:e,color:{r:1,g:.9,b:.5},size:rH(t,["size"])??4}}}}function rY(e){let t=e.states;if(Array.isArray(t)&&0!==t.length)return t.map(e=>{let t=e=>null==e?-1:e-1;return{name:e.name??"",transitionOnNotLoaded:t(e.transitionOnAmmo),transitionOnLoaded:t(e.transitionOnNoAmmo),transitionOnNoAmmo:t(e.transitionOnTarget),transitionOnAmmo:t(e.transitionOnNoTarget),transitionOnNoTarget:t(e.transitionOnWet),transitionOnTarget:t(e.transitionOnNotWet),transitionOnNotWet:t(e.transitionOnTriggerUp),transitionOnWet:t(e.transitionOnTriggerDown),transitionOnTriggerUp:t(e.transitionOnTimeout),transitionOnTriggerDown:t(e.transitionGeneric0In),transitionOnTimeout:t(e.transitionGeneric0Out),timeoutValue:e.timeoutValue,waitForTimeout:e.waitForTimeout??!1,fire:e.fire??!1,sequence:e.sequence,spin:e.spin??0,direction:e.direction??!0,scaleAnimation:e.scaleAnimation??!1,loaded:e.loaded??0,soundDataBlockId:e.sound??-1}})}function rJ(e){let t="";for(let a=0;a=32&&(t+=e[a]);return t}let rK={2:0,3:1,4:2,5:3,6:4,7:5,8:6,11:7,12:8,14:9};function rQ(e){for(let t=0;t=32)break}}function r0(e){let t=[],a=0,r="",n=!1;for(let i=0;i=32&&(r+=e[i]);continue}let s=rK[o];void 0!==s?(r&&(t.push({text:r,colorCode:a}),r=""),a=s):15===o?(r&&(t.push({text:r,colorCode:a}),r=""),a=0):o>=32&&(r+=e[i])}return r&&t.push({text:r,colorCode:a}),t}function r2(e){let t=e.indexOf("~w");return -1===t?{text:e,wavPath:null}:{text:e.substring(0,t),wavPath:e.substring(t+2)}}function r3(e){return e?"number"==typeof e.cameraMode?"camera":"number"==typeof e.rotationZ?"player":null:null}let r1=new Map([["gui/hud_new_packammo",0],["gui/hud_new_packcloak",1],["gui/hud_new_packenergy",2],["gui/hud_new_packrepair",3],["gui/hud_new_packsatchel",4],["gui/hud_new_packshield",5],["gui/hud_new_packinventory",6],["gui/hud_new_packmotionsens",7],["gui/hud_new_packradar",8],["gui/hud_new_packturretout",9],["gui/hud_new_packturretin",10],["gui/hud_new_packsensjam",11],["gui/hud_new_packturret",12],["gui/hud_satchel_unarmed",18]]);function r5(e){let t=e.toLowerCase();for(let[e,a]of r1)if(e===t)return a;return -1}e.s(["CameraMode_OrbitObject",0,3,"MAX_PITCH",0,rj,"backpackBitmapToIndex",()=>r5,"clamp",()=>rU,"detectColorCode",()=>rQ,"detectControlObjectType",()=>r3,"extractWavTag",()=>r2,"getNumberField",()=>rH,"isQuatLike",()=>rq,"isValidPosition",()=>rV,"isVec3Like",()=>r_,"parseColorSegments",()=>r0,"parseWeaponImageStates",()=>rY,"playerYawToQuaternion",()=>rz,"resolveShapeName",()=>r$,"resolveSpriteVisual",()=>rZ,"resolveTracerVisual",()=>rX,"stripTaggedStringMarkup",()=>rJ,"torqueQuatToThreeJS",()=>rL,"yawPitchToQuaternion",()=>rO],89119),e.i(70847);var r6=e.i(47566),r8=e.i(8328);class r4{registry;ghostTracker;entities=new Map;entityIdByGhostIndex=new Map;tickCount=0;camera=null;chatMessages=[];audioEvents=[];netStrings=new Map;targetNames=new Map;targetTeams=new Map;targetRenderFlags=new Map;pendingNameTags=new Map;sensorGroupColors=new Map;playerSensorGroup=0;lastStatus={health:1,energy:1};latestControl={ghostIndex:-1};controlPlayerGhostId;lastControlType="camera";isPiloting=!1;lastCameraMode;lastOrbitGhostIndex;lastOrbitDistance;latestFov=90;weaponsHud={slots:new Map,activeIndex:-1};backpackHud={packIndex:-1,active:!1,text:""};inventoryHud={slots:new Map,activeSlot:-1};teamScores=[];playerRoster=new Map;nextExplosionId=0;resolveGhostClassName(e,t){if("number"==typeof t){let e=this.registry.getGhostParser(t)?.name;if(e)return e}let a=this.entityIdByGhostIndex.get(e);if(a){let e=this.entities.get(a);if(e?.className)return e.className}let r=this.ghostTracker.getGhost(e);if(r?.className)return r.className}resolveEntityIdForGhostIndex(e){let t=this.entityIdByGhostIndex.get(e);if(t)return t;let a=this.ghostTracker.getGhost(e);if(a)return rT(a.className,e)}resetSharedState(){this.entities.clear(),this.entityIdByGhostIndex.clear(),this.tickCount=0,this.camera=null,this.chatMessages=[],this.audioEvents=[],this.netStrings.clear(),this.targetNames.clear(),this.targetTeams.clear(),this.targetRenderFlags.clear(),this.sensorGroupColors.clear(),this.playerSensorGroup=0,this.lastStatus={health:1,energy:1},this.latestControl={ghostIndex:-1},this.controlPlayerGhostId=void 0,this.lastControlType="camera",this.isPiloting=!1,this.lastCameraMode=void 0,this.lastOrbitGhostIndex=void 0,this.lastOrbitDistance=void 0,this.latestFov=90,this.weaponsHud={slots:new Map,activeIndex:-1},this.backpackHud={packIndex:-1,active:!1,text:""},this.inventoryHud={slots:new Map,activeSlot:-1},this.teamScores=[],this.playerRoster.clear(),this.nextExplosionId=0}resolveNetString(e){if(e.length>=2&&1===e.charCodeAt(0)){let t=parseInt(e.slice(1),10);if(Number.isFinite(t))return this.netStrings.get(t)??e}return e}formatRemoteArgs(e,t){let a=this.resolveNetString(e);for(let e=0;e0&&(this.playerSensorGroup=t.sensorGroup)}if(t){let e=r3(t);if(e&&(this.lastControlType=e),"player"===this.lastControlType)this.isPiloting=!!(t.pilot||null!=t.controlObjectGhost);else if(this.isPiloting=!1,"number"==typeof t.cameraMode)if(this.lastCameraMode=t.cameraMode,3===t.cameraMode){"number"==typeof t.orbitObjectGhostIndex&&(this.lastOrbitGhostIndex=t.orbitObjectGhostIndex);let e=t.minOrbitDist,a=t.maxOrbitDist,r=t.curOrbitDist;"number"==typeof e&&"number"==typeof a&&Number.isFinite(e)&&Number.isFinite(a)?this.lastOrbitDistance=Math.max(0,a-e):"number"==typeof r&&Number.isFinite(r)&&(this.lastOrbitDistance=Math.max(0,r))}else this.lastOrbitGhostIndex=void 0,this.lastOrbitDistance=void 0}void 0!==e.cameraFov&&(this.latestFov=e.cameraFov)}processEvent(e,t){let a=e.parsedData;if(!a)return;let r=a.type;if("GhostAlwaysObjectEvent"===r){let e=a.ghostIndex,t=a.classId,r=a.objectData;null!=e&&null!=t&&this.processGhostUpdate({index:e,type:"create",classId:t,parsedData:r});return}if("NetStringEvent"===r||"NetStringEvent"===t){let e=a.id,t=a.value;if(null!=e&&"string"==typeof t){this.netStrings.set(e,t);let a=this.pendingNameTags.get(e);if(null!=a){this.pendingNameTags.delete(e);let r=rJ(t);for(let e of(this.targetNames.set(a,r),this.entities.values()))e.targetId===a&&(e.playerName=r)}}return}if("TargetInfoEvent"===r||"TargetInfoEvent"===t){let e=a.targetId,t=a.nameTag;if(null!=e&&null!=t){let a=this.netStrings.get(t);a?this.targetNames.set(e,rJ(a)):this.pendingNameTags.set(t,e)}let r=a.sensorGroup;null!=e&&null!=r&&this.targetTeams.set(e,r);let n=a.renderFlags;if(null!=e&&null!=n&&this.targetRenderFlags.set(e,n),null!=e){let t=this.targetNames.get(e),a=this.targetTeams.get(e),r=this.targetRenderFlags.get(e);for(let n of this.entities.values())n.targetId===e&&(t&&(n.playerName=t),null!=a&&(n.sensorGroup=a),null!=r&&(n.targetRenderFlags=r))}return}if("SetSensorGroupEvent"===r||"SetSensorGroupEvent"===t){let e=a.sensorGroup;null!=e&&(this.playerSensorGroup=e);return}if("SensorGroupColorEvent"===r||"SensorGroupColorEvent"===t){let e=a.sensorGroup,t=a.colors;if(t){let a=this.sensorGroupColors.get(e);for(let r of(a||(a=new Map,this.sensorGroupColors.set(e,a)),t))r.default?a.delete(r.index):a.set(r.index,{r:r.r??0,g:r.g??0,b:r.b??0})}return}if("RemoteCommandEvent"===r||"RemoteCommandEvent"===t){let e=this.resolveNetString(a.funcName),t=a.args,r=this.getTimeSec();if("ChatMessage"===e&&t.length>=4){let e=rQ(this.resolveNetString(t[3])),a=t[4]?rJ(this.resolveNetString(t[4])):"",n=this.formatRemoteArgs(t[3],t.slice(4));if(n){let i,o,s=n.indexOf(": "),{text:l,wavPath:d}=r2(s>=0?n.slice(s+2):n);if(d){let e=this.resolveNetString(t[1]);i=e?`voice/${e}/${d}.wav`:d;let a=this.resolveNetString(t[2]);if(a){let e=parseFloat(a);Number.isFinite(e)&&(o=Math.max(.5,Math.min(2,e)))}}let c=e??0;this.pushChatMessage({timeSec:r,sender:a,text:l,kind:"chat",colorCode:c,segments:[{text:a?`${a}: ${l}`:l,colorCode:c}],soundPath:i,soundPitch:o})}}else if("CannedChatMessage"===e&&t.length>=6){let e=rQ(this.resolveNetString(t[1])),a=rJ(this.resolveNetString(t[2])),n=rJ(this.resolveNetString(t[4])),i=this.formatRemoteArgs(t[1],t.slice(2));if(i){let o,s,{wavPath:l}=r2(i),d=r2(rJ(this.resolveNetString(t[3]))).text;if(l){let e=this.resolveNetString(t[5]);if(o=e?`voice/${e}/${l}.wav`:l,t[6]){let e=parseFloat(this.resolveNetString(t[6]));Number.isFinite(e)&&(s=Math.max(.5,Math.min(2,e)))}}let c=e??0,u=[];n&&u.push({text:`[${n}] `,colorCode:0}),u.push({text:a?`${a}: ${d}`:d,colorCode:c}),this.pushChatMessage({timeSec:r,sender:a,text:d,kind:"chat",colorCode:c,segments:u,soundPath:o,soundPitch:s})}}else if("ServerMessage"===e&&t.length>=2){this.handleServerMessage(t);let e=rQ(this.resolveNetString(t[1])),a=this.formatRemoteArgs(t[1],t.slice(2));if(a){let{text:t,wavPath:n}=r2(a),i=e??0;this.pushChatMessage({timeSec:r,sender:"",text:t,kind:"server",colorCode:i,segments:[{text:t,colorCode:i}],soundPath:n??void 0})}}else this.handleHudRemoteCommand(e,t);return}if("Sim3DAudioEvent"===r||"Sim2DAudioEvent"===r||"Sim3DAudioEvent"===t||"Sim2DAudioEvent"===t){let e=a.profileId;if("number"==typeof e){let n=this.getTimeSec(),i="Sim3DAudioEvent"===r||"Sim3DAudioEvent"===t?a.position:void 0;this.audioEvents.push({profileId:e,position:i,timeSec:n}),this.audioEvents.length>100&&this.audioEvents.splice(0,this.audioEvents.length-100)}}}processGhostUpdate(e){let t,a=e.index,r=this.entityIdByGhostIndex.get(a);if(r){let t=this.entities.get(r);t&&"Projectile"===t.type&&!t.hasExploded&&null!=t.explosionDataBlockId&&t.position&&("delete"===e.type||"create"===e.type)&&this.spawnExplosion(t,[...t.position])}if("delete"===e.type){r&&(this.removeSoundSlotEntities(r),this.entities.delete(r),this.entityIdByGhostIndex.delete(a));return}let n=this.resolveGhostClassName(a,e.classId);if(!n){if("create"===e.type)throw Error(`No ghost parser for classId ${e.classId} (ghost index ${a})`);return}let i=rT(n,a);r&&r!==i&&(this.removeSoundSlotEntities(r),this.entities.delete(r));let o=this.entities.get(i);if(o&&"create"===e.type?(this.removeSoundSlotEntities(i),o.spawnTick=this.tickCount,this.resetEntity(o),t=o):o?t=o:(t={id:i,ghostIndex:a,className:n,spawnTick:this.tickCount,type:rB(n),rotation:[0,0,0,1]},this.entities.set(i,t)),t.ghostIndex=a,t.className=n,t.type=rB(n),this.entityIdByGhostIndex.set(a,i),this.applyGhostData(t,e.parsedData),"create"===e.type&&e.parsedData){let r=(0,r6.ghostToSceneObject)(n,a,e.parsedData);r&&(t.sceneData=r)}}resetEntity(e){e.rotation=[0,0,0,1],e.hasExploded=void 0,e.explosionShape=void 0,e.explosionLifetimeTicks=void 0,e.faceViewer=void 0,e.simulatedVelocity=void 0,e.projectilePhysics=void 0,e.gravityMod=void 0,e.direction=void 0,e.velocity=void 0,e.position=void 0,e.dataBlock=void 0,e.dataBlockId=void 0,e.shapeHint=void 0,e.visual=void 0,e.targetId=void 0,e.targetRenderFlags=void 0,e.carryingFlag=void 0,e.sensorGroup=void 0,e.playerName=void 0,e.weaponShape=void 0,e.weaponImageState=void 0,e.weaponImageStates=void 0,e.weaponImageStatesDbId=void 0,e.itemPhysics=void 0,e.threads=void 0,e.headPitch=void 0,e.headYaw=void 0,e.health=void 0,e.energy=void 0,e.maxEnergy=void 0,e.damageState=void 0,e.actionAnim=void 0,e.actionAtEnd=void 0,e.explosionDataBlockId=void 0,e.maintainEmitterId=void 0}applyGhostData(e,t){if(!t)return;let a=t.dataBlockId;if(null!=a){e.dataBlockId=a;let t=this.getDataBlockData(a),r=r$(e.className,t);if(e.visual=rX(e.className,t)??rZ(e.className,t),"string"==typeof r&&(e.shapeHint=r,e.dataBlock=r),"Player"===e.type&&"number"==typeof t?.maxEnergy&&(e.maxEnergy=t.maxEnergy),"Projectile"===e.type&&(rC.has(e.className)?e.projectilePhysics="linear":rE.has(e.className)?(e.projectilePhysics="ballistic",e.gravityMod=rH(t,["gravityMod"])??1):rw.has(e.className)&&(e.projectilePhysics="seeker")),"Projectile"===e.type&&null==e.explosionDataBlockId){let t=this.resolveExplosionInfo(a);t&&(e.explosionShape=t.shape,e.faceViewer=t.faceViewer,e.explosionLifetimeTicks=t.lifetimeTicks,e.explosionDataBlockId=t.explosionDataBlockId)}if("Projectile"===e.type&&null==e.maintainEmitterId){let a=t?.baseEmitter;"number"==typeof a&&a>0&&(e.maintainEmitterId=a)}}if("Player"===e.type){let a=t.images;if(Array.isArray(a)&&a.length>0){let t=a.find(e=>0===e.index);if(t?.dataBlockId&&t.dataBlockId>0){let a=this.getDataBlockData(t.dataBlockId),r=r$("ShapeBaseImageData",a);if(r){let t=a?.mountPoint;(null==t||t<=0)&&!/pack_/i.test(r)&&(e.weaponShape=r)}let n=e.weaponImageState;e.weaponImageState={dataBlockId:t.dataBlockId,triggerDown:t.triggerDown??n?.triggerDown??!1,ammo:t.ammo??n?.ammo??!0,loaded:t.loaded??n?.loaded??!0,target:t.target??n?.target??!1,wet:t.wet??n?.wet??!1,fireCount:t.fireCount??n?.fireCount??0},a&&e.weaponImageStatesDbId!==t.dataBlockId&&(e.weaponImageStates=rY(a),e.weaponImageStatesDbId=t.dataBlockId)}else t&&!t.dataBlockId&&(e.weaponShape=void 0,e.weaponImageState=void 0,e.weaponImageStates=void 0);let r=a.find(e=>3===e.index);if(r){let t=!!r.dataBlockId&&r.dataBlockId>0;if(e.carryingFlag=t,null!=e.targetId&&e.targetId>=0){let a=this.targetRenderFlags.get(e.targetId)??0,r=t?2|a:-3&a;r!==a&&(this.targetRenderFlags.set(e.targetId,r),e.targetRenderFlags=r)}}}}let r=rV(t.position)?t.position:rV(t.initialPosition)?t.initialPosition:rV(t.explodePosition)?t.explodePosition:rV(t.endPoint)?t.endPoint:rV(t.transform?.position)?t.transform.position:void 0;r&&(e.position=[r.x,r.y,r.z],this.updateSoundSlotPositions(e));let n=r_(t.direction)?t.direction:void 0;if(n&&(e.direction=[n.x,n.y,n.z]),"Player"===e.type&&"number"==typeof t.rotationZ&&(e.rotation=rz(t.rotationZ)),"Player"===e.type&&("number"==typeof t.headX&&(e.headPitch=t.headX),"number"==typeof t.headZ&&(e.headYaw=t.headZ)),rq(t.angPosition)){let a=rL(t.angPosition);a&&(e.rotation=a)}else if(rq(t.transform?.rotation)){let a=rL(t.transform.rotation);a&&(e.rotation=a)}else if("Item"===e.type&&"number"==typeof t.rotation?.angle){let a=t.rotation;e.rotation=rz((a.zSign??1)*a.angle)}else if("Projectile"===e.type){let a=t.velocity??t.direction??(rV(t.initialPosition)&&rV(t.endPos)?{x:t.endPos.x-t.initialPosition.x,y:t.endPos.y-t.initialPosition.y,z:t.endPos.z-t.initialPosition.z}:void 0);r_(a)&&(0!==a.x||0!==a.y)&&(e.rotation=rz(Math.atan2(a.x,a.y)))}if(r_(t.velocity)&&(e.velocity=[t.velocity.x,t.velocity.y,t.velocity.z],e.direction||(e.direction=[t.velocity.x,t.velocity.y,t.velocity.z])),"Item"===e.type){let a=t.atRest;if(!1===a&&r_(t.velocity)){let a=null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0;e.itemPhysics={velocity:[t.velocity.x,t.velocity.y,t.velocity.z],atRest:!1,elasticity:rH(a,["elasticity"])??.2,friction:rH(a,["friction"])??.6,gravityMod:rH(a,["gravityMod"])??1}}else!0===a&&(e.itemPhysics=void 0)}if(e.projectilePhysics){if("linear"===e.projectilePhysics){let a=rH(null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0,["dryVelocity","muzzleVelocity","bulletVelocity"])??80,r=e.direction??[0,1,0],n=r[0]*a,i=r[1]*a,o=r[2]*a,s=t.excessVel,l=t.excessDir;"number"==typeof s&&s>0&&r_(l)&&(n+=l.x*s,i+=l.y*s,o+=l.z*s),e.simulatedVelocity=[n,i,o]}else r_(t.velocity)&&(e.simulatedVelocity=[t.velocity.x,t.velocity.y,t.velocity.z]);let a=t.currTick;if("number"==typeof a&&a>0&&e.simulatedVelocity&&e.position){let t=.032*a,r=e.simulatedVelocity;if(e.position[0]+=r[0]*t,e.position[1]+=r[1]*t,e.position[2]+=r[2]*t,"ballistic"===e.projectilePhysics){let a=-9.81*(e.gravityMod??1);e.position[2]+=.5*a*t*t,r[2]+=a*t}}}let i=rV(t.explodePosition)?t.explodePosition:rV(t.explodePoint)?t.explodePoint:void 0;if("Projectile"===e.type&&!e.hasExploded&&i&&null!=e.explosionDataBlockId&&this.spawnExplosion(e,[i.x,i.y,i.z]),"number"==typeof t.damageLevel&&(e.health=rU(1-t.damageLevel,0,1)),"number"==typeof t.damageState&&(e.damageState=t.damageState),"number"==typeof t.action&&(e.actionAnim=t.action,e.actionAtEnd=!!t.actionAtEnd),Array.isArray(t.threads)){let a=t.threads;if(e.threads){let t=[...e.threads];for(let e of a){let a=t.findIndex(t=>t.index===e.index);a>=0?t[a]=e:t.push(e)}e.threads=t}else e.threads=a}if("number"==typeof t.energy&&(e.energy=rU(t.energy,0,1)),"number"==typeof t.targetId){e.targetId=t.targetId;let a=this.targetNames.get(t.targetId);a&&(e.playerName=a);let r=this.targetTeams.get(t.targetId);null!=r&&(e.sensorGroup=r,e.ghostIndex===this.latestControl.ghostIndex&&"player"===this.lastControlType&&(this.playerSensorGroup=r));let n=this.targetRenderFlags.get(t.targetId);null!=n&&(e.targetRenderFlags=n)}let o=t.sounds;Array.isArray(o)&&this.syncSoundSlotEntities(e,o),"WayPoint"===e.className&&"string"==typeof t.name&&(e.label=t.name),"AudioEmitter"===e.className&&("string"==typeof t.filename&&(e.audioFileName=t.filename),"number"==typeof t.volume&&(e.audioVolume=t.volume),"boolean"==typeof t.is3D&&(e.audioIs3D=t.is3D),"boolean"==typeof t.isLooping&&(e.audioIsLooping=t.isLooping),"number"==typeof t.minDistance&&(e.audioMinDistance=t.minDistance),"number"==typeof t.maxDistance&&(e.audioMaxDistance=t.maxDistance),"number"==typeof t.minLoopGap&&(e.audioMinLoopGap=t.minLoopGap),"number"==typeof t.maxLoopGap&&(e.audioMaxLoopGap=t.maxLoopGap))}syncSoundSlotEntities(e,t){for(let a of t){let t=`${e.id}:sound:${a.index}`;if(a.playing&&"number"==typeof a.profileId){let r=this.getDataBlockData(a.profileId),n=r?.filename;if(!n)continue;let i=n.endsWith(".wav")?n:`${n}.wav`,o=r.description,s=null!=o?this.getDataBlockData(o):void 0,l=this.entities.get(t);l?l.position=e.position:this.entities.set(t,{id:t,ghostIndex:e.ghostIndex,className:"AudioEmitter",type:"AudioEmitter",spawnTick:this.tickCount,position:e.position,rotation:[0,0,0,1],audioFileName:i,audioVolume:s?.volume??1,audioIs3D:s?.is3D??!0,audioIsLooping:s?.isLooping??!1,audioMinDistance:s?.referenceDistance??20,audioMaxDistance:s?.maxDistance??100,audioMinLoopGap:s?.minLoopGap??0,audioMaxLoopGap:s?.maxLoopGap??0})}else this.entities.delete(t)}}updateSoundSlotPositions(e){for(let t=0;t<4;t++){let a=this.entities.get(`${e.id}:sound:${t}`);a&&(a.position=e.position)}}removeSoundSlotEntities(e){for(let t=0;t<4;t++)this.entities.delete(`${e}:sound:${t}`)}resolveExplosionInfo(e){let t=this.getDataBlockData(e);if(!t)return;let a=t.explosion;if(null==a)return;let r=this.getDataBlockData(a);if(!r)return;let n=r.dtsFileName||void 0,i=r.lifetimeMS??31;return{shape:n,faceViewer:!1!==r.faceViewer&&0!==r.faceViewer,lifetimeTicks:i,explosionDataBlockId:a}}spawnExplosion(e,t){e.hasExploded=!0;let a=e.explosionLifetimeTicks??31,r=`fx_${this.nextExplosionId++}`,n={id:r,ghostIndex:-1,className:"Explosion",spawnTick:this.tickCount,type:"Explosion",dataBlock:e.explosionShape,explosionDataBlockId:e.explosionDataBlockId,position:t,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==e.faceViewer,expiryTick:this.tickCount+a};if(this.entities.set(r,n),null!=e.explosionDataBlockId){let a=this.getDataBlockData(e.explosionDataBlockId),r=a?.subExplosions;if(Array.isArray(r))for(let e of r){if(null==e)continue;let a=this.getDataBlockData(e);if(!a)continue;let r=a.dtsFileName||void 0;if(!r)continue;let n=a.lifetimeMS??31,i=a.offset??0,o=Math.random()*Math.PI*2,s=[t[0]+Math.cos(o)*i,t[1]+Math.sin(o)*i,t[2]],l=`fx_${this.nextExplosionId++}`,d={id:l,ghostIndex:-1,className:"Explosion",spawnTick:this.tickCount,type:"Explosion",dataBlock:r,explosionDataBlockId:e,position:s,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==a.faceViewer&&0!==a.faceViewer,expiryTick:this.tickCount+n};this.entities.set(l,d)}}e.position=void 0,e.simulatedVelocity=void 0}advanceProjectiles(){for(let e of this.entities.values()){if(!e.simulatedVelocity||!e.position)continue;let t=e.simulatedVelocity,a=e.position;"ballistic"===e.projectilePhysics&&(t[2]+=-9.81*(e.gravityMod??1)*.032),a[0]+=.032*t[0],a[1]+=.032*t[1],a[2]+=.032*t[2],(0!==t[0]||0!==t[1])&&(e.rotation=rz(Math.atan2(t[0],t[1])))}}advanceItems(){for(let e of this.entities.values()){let t=e.itemPhysics;if(!t||t.atRest||!e.position)continue;let a=t.velocity,r=e.position;a[2]+=-20*t.gravityMod*.032,r[0]+=.032*a[0],r[1]+=.032*a[1],r[2]+=.032*a[2];let n=(0,r8.getTerrainHeightAt)(r[0],r[1]);if(null!=n&&r[2]0){let e=Math.max(0,1-i/o);a[0]*=e,a[1]*=e}.15>Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])&&(a[0]=a[1]=a[2]=0,t.atRest=!0)}}}removeExpiredExplosions(){for(let[e,t]of this.entities)t.isExplosion&&null!=t.expiryTick&&this.tickCount>=t.expiryTick&&this.entities.delete(e)}updateCameraAndHud(){let e=this.latestControl,t=this.getTimeSec(),a=e.data,r=this.lastControlType;if(this.removeExpiredExplosions(),e.position){let{yaw:n,pitch:i}=this.getCameraYawPitch(a);if(this.camera={time:t,position:[e.position.x,e.position.y,e.position.z],rotation:rO(n,rU(i,-rj,rj)),fov:this.latestFov,mode:"observer",yaw:n,pitch:i},"camera"===r)if(("number"==typeof a?.cameraMode?a.cameraMode:this.lastCameraMode)===3){this.camera.mode="third-person","number"==typeof this.lastOrbitDistance&&(this.camera.orbitDistance=this.lastOrbitDistance);let e="number"==typeof a?.orbitObjectGhostIndex?a.orbitObjectGhostIndex:this.lastOrbitGhostIndex;"number"==typeof e&&e>=0&&(this.camera.orbitTargetId=this.resolveEntityIdForGhostIndex(e))}else this.camera.mode="observer";else this.camera.mode="first-person",e.ghostIndex>=0&&(this.controlPlayerGhostId=this.resolveEntityIdForGhostIndex(e.ghostIndex)),this.controlPlayerGhostId&&(this.camera.controlEntityId=this.controlPlayerGhostId);if("player"===r&&!this.isPiloting&&this.controlPlayerGhostId&&e.position){let t=this.entities.get(this.controlPlayerGhostId);t&&(t.position=[e.position.x,e.position.y,e.position.z],t.rotation=rz(n),t.headPitch=this.getControlPlayerHeadPitch(i))}}else this.camera&&(this.camera={...this.camera,time:t,fov:this.latestFov});let n={health:1,energy:1};if(this.camera?.mode==="first-person"){let e=this.controlPlayerGhostId,t=e?this.entities.get(e):void 0;n.health=t?.health??1;let r=a?.energyLevel;if("number"==typeof r){let e=t?.maxEnergy??60;e>0&&(n.energy=rU(r/e,0,1))}else n.energy=t?.energy??1}else if(this.camera?.mode==="third-person"&&this.camera.orbitTargetId){let e=this.entities.get(this.camera.orbitTargetId);n.health=e?.health??1,n.energy=e?.energy??1}this.lastStatus=n}getControlPlayerHeadPitch(e){return rU(e/rj,-1,1)}getAbsoluteRotation(e){return e?"number"==typeof e.rotationZ&&"number"==typeof e.headX?{yaw:e.rotationZ,pitch:e.headX}:"number"==typeof e.rotZ&&"number"==typeof e.rotX?{yaw:e.rotZ,pitch:e.rotX}:null:null}resolveIffColor(e){if(0===this.playerSensorGroup)return;let t=this.sensorGroupColors.get(this.playerSensorGroup);if(t){let a=t.get(e);if(a)return a}return e===this.playerSensorGroup?rR:0!==e?rN:void 0}pushChatMessage(e){this.chatMessages.push(e),this.chatMessages.length>200&&this.chatMessages.splice(0,this.chatMessages.length-200)}handleServerMessage(e){if(e.length<2)return;let t=this.resolveNetString(e[0]);if("MsgTeamScoreIs"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.teamScores.find(e=>e.teamId===t);e&&(e.score=a,this.onTeamScoresChanged())}}else if("MsgCTFAddTeam"===t&&e.length>=6){let t=parseInt(this.resolveNetString(e[2]),10),a=rJ(this.resolveNetString(e[3])),r=parseInt(this.resolveNetString(e[5]),10);if(!isNaN(t)){let e=t+1,n=this.teamScores.find(t=>t.teamId===e);n?(n.name=a,n.score=isNaN(r)?n.score:r):this.teamScores.push({teamId:e,name:a,score:isNaN(r)?0:r,playerCount:0}),this.onTeamScoresChanged()}}else if("MsgClientJoin"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=rJ(this.resolveNetString(e[3]));if(!isNaN(t)){let e=this.playerRoster.get(t);this.playerRoster.set(t,{name:a,teamId:e?.teamId??0}),this.onRosterChanged()}}else if("MsgClientDrop"===t&&e.length>=3){let t=parseInt(this.resolveNetString(e[2]),10);isNaN(t)||(this.playerRoster.delete(t),this.onRosterChanged())}else if("MsgClientJoinTeam"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.playerRoster.get(t);e?e.teamId=a:this.playerRoster.set(t,{name:"",teamId:a}),this.onRosterChanged()}}}onTeamScoresChanged(){}onRosterChanged(){}handleHudRemoteCommand(e,t){if("setWeaponsHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];isNaN(e)||(r?this.weaponsHud.slots.set(e,isNaN(a)?-1:a):this.weaponsHud.slots.delete(e),this.onWeaponsHudChanged())}else if("setWeaponsHudAmmo"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);isNaN(e)||(this.weaponsHud.slots.set(e,isNaN(a)?-1:a),this.onWeaponsHudChanged())}else if("setWeaponsHudActive"===e&&t.length>=1){let e=parseInt(t[0],10);this.weaponsHud.activeIndex=isNaN(e)?-1:e,isNaN(e)||!(e>=0)||this.weaponsHud.slots.has(e)||this.weaponsHud.slots.set(e,-1),this.onWeaponsHudChanged()}else if("setWeaponsHudClearAll"===e)this.weaponsHud.slots.clear(),this.weaponsHud.activeIndex=-1,this.onWeaponsHudChanged();else if("setBackpackHudItem"===e&&t.length>=2){let e=parseInt(t[0],10);"1"!==t[1]&&"true"!==t[1]||isNaN(e)?this.backpackHud.packIndex=-1:this.backpackHud.packIndex=e,this.backpackHud.active=!1,this.backpackHud.text=""}else if("setSatchelArmed"===e)this.backpackHud.active=!0;else if("setCloakIconOn"===e||"setRepairPackIconOn"===e||"setShieldIconOn"===e||"setSenJamIconOn"===e)this.backpackHud.active=!0;else if("setCloakIconOff"===e||"setRepairPackIconOff"===e||"setShieldIconOff"===e||"setSenJamIconOff"===e)this.backpackHud.active=!1;else if("updatePackText"===e&&t.length>=1)this.backpackHud.text=t[0]??"";else if("setInventoryHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];isNaN(e)||(r&&!isNaN(a)?this.inventoryHud.slots.set(e,a):this.inventoryHud.slots.delete(e),this.onInventoryHudChanged())}else if("setInventoryHudAmount"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);isNaN(e)||isNaN(a)||(this.inventoryHud.slots.set(e,a),this.onInventoryHudChanged())}else"setInventoryHudClearAll"===e&&(this.inventoryHud.slots.clear(),this.inventoryHud.activeSlot=-1,this.onInventoryHudChanged())}onWeaponsHudChanged(){}onInventoryHudChanged(){}buildEntityList(e){let t=[];for(let a of this.entities.values()){if(e&&!e(a))continue;let r=null!=a.targetId&&a.targetId>=0?this.targetRenderFlags.get(a.targetId)??a.targetRenderFlags:a.targetRenderFlags;"Player"!==a.type||a.carryingFlag||(r=null!=r?-3&r:r),t.push({id:a.id,type:a.type,visual:a.visual,direction:a.direction,ghostIndex:a.ghostIndex,className:a.className,dataBlockId:a.dataBlockId,shapeHint:a.shapeHint,dataBlock:a.dataBlock,weaponShape:a.weaponShape,playerName:a.playerName,targetRenderFlags:r,iffColor:("Player"===a.type||((r??0)&2)!=0)&&null!=a.sensorGroup?this.resolveIffColor(a.sensorGroup):void 0,position:a.position&&(a.simulatedVelocity||a.itemPhysics&&!a.itemPhysics.atRest)?[...a.position]:a.position,rotation:a.rotation,velocity:a.velocity,health:a.health,energy:a.energy,actionAnim:a.actionAnim,actionAtEnd:a.actionAtEnd,damageState:a.damageState,faceViewer:a.faceViewer,threads:a.threads,explosionDataBlockId:a.explosionDataBlockId,maintainEmitterId:a.maintainEmitterId,weaponImageState:a.weaponImageState,weaponImageStates:a.weaponImageStates,headPitch:a.headPitch,headYaw:a.headYaw,label:a.label,audioFileName:a.audioFileName,audioVolume:a.audioVolume,audioIs3D:a.audioIs3D,audioIsLooping:a.audioIsLooping,audioMinDistance:a.audioMinDistance,audioMaxDistance:a.audioMaxDistance,audioMinLoopGap:a.audioMinLoopGap,audioMaxLoopGap:a.audioMaxLoopGap,sceneData:a.sceneData})}return t}buildHudState(){let e={slots:Array.from(this.weaponsHud.slots.entries()).map(([e,t])=>({index:e,ammo:t})),activeIndex:this.weaponsHud.activeIndex},t={slots:Array.from(this.inventoryHud.slots.entries()).map(([e,t])=>({slot:e,count:t})),activeSlot:this.inventoryHud.activeSlot},a=this.backpackHud.packIndex>=0?{...this.backpackHud}:null,r=this.teamScores.map(e=>({...e})),n=new Map;for(let{teamId:e}of this.playerRoster.values())e>0&&n.set(e,(n.get(e)??0)+1);for(let e of r)e.playerCount=n.get(e.teamId)??0;return{weaponsHud:e,inventoryHud:t,backpackHud:a,teamScores:r}}buildTimeFilteredEvents(e){return{chatMessages:this.chatMessages.filter(t=>t.timeSec>e-15),audioEvents:this.audioEvents.filter(t=>t.timeSec>e-.5&&t.timeSec<=e)}}}e.s(["StreamEngine",()=>r4],10244)},71051,e=>{"use strict";class t{ws=null;handlers;url;_connected=!1;wsPingInterval=null;smoothedWsPing=0;constructor(e,t){this.url=e,this.handlers=t}get connected(){return this._connected}connect(){this.ws=new WebSocket(this.url),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{console.log("[relay] WebSocket connected to",this.url),this._connected=!0,this.startWsPing(),this.handlers.onOpen?.()},this.ws.onmessage=e=>{if(e.data instanceof ArrayBuffer)this.handlers.onGamePacket?.(new Uint8Array(e.data));else try{let t=JSON.parse(e.data);this.handleMessage(t)}catch(e){console.error("Failed to parse relay message:",e)}},this.ws.onclose=()=>{console.log("[relay] WebSocket disconnected"),this._connected=!1,this.stopWsPing(),this.handlers.onClose?.()},this.ws.onerror=()=>{console.error("[relay] WebSocket error"),this.handlers.onError?.("WebSocket connection error")}}handleMessage(e){switch(e.type){case"serverList":this.handlers.onServerList?.(e.servers);break;case"status":this.handlers.onStatus?.(e.status,e.message,e.connectSequence,e.mapName);break;case"ping":this.handlers.onPing?.(e.ms);break;case"wsPong":{let t=Date.now()-e.ts;this.smoothedWsPing=0===this.smoothedWsPing?t:.5*this.smoothedWsPing+.5*t,this.handlers.onWsPing?.(Math.round(this.smoothedWsPing));break}case"error":this.handlers.onError?.(e.message)}}listServers(){this.send({type:"listServers"})}sendWsPing(){this.send({type:"wsPing",ts:Date.now()})}joinServer(e){console.log("[relay] Joining server:",e),this.send({type:"joinServer",address:e})}disconnectServer(){this.send({type:"disconnect"})}sendAuthEvent(e,t){this.send({type:"sendCommand",command:e,args:t})}sendCommand(e,t){this.send({type:"sendCommand",command:e,args:t})}sendCRCResponse(e,t,a){this.send({type:"sendCRCResponse",crcValue:e,field1:t,field2:a})}sendCRCCompute(e,t,a,r){this.send({type:"sendCRCCompute",seed:e,field2:t,includeTextures:r,datablocks:a})}sendGhostAck(e,t){this.send({type:"sendGhostAck",sequence:e,ghostCount:t})}sendMove(e){this.send({type:"sendMove",move:e})}close(){this.stopWsPing(),this.ws&&(this.ws.close(),this.ws=null),this._connected=!1}startWsPing(){this.smoothedWsPing=0,this.send({type:"wsPing",ts:Date.now()}),this.wsPingInterval=setInterval(()=>{this.send({type:"wsPing",ts:Date.now()})},7e3)}stopWsPing(){null!=this.wsPingInterval&&(clearInterval(this.wsPingInterval),this.wsPingInterval=null)}send(e){this.ws?.readyState===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):console.warn("[relay] send dropped (ws not open):",e.type)}}e.s(["RelayClient",()=>t])},12781,e=>{"use strict";e.i(47167);var t=e.i(43476),a=e.i(932),r=e.i(71645),n=e.i(71051);e.i(50593);var i=e.i(45853),o=e.i(89119),s=e.i(10244);class l extends s.StreamEngine{packetParser;relay;currentTimeSec=0;connectSynced=!1;_snapshot=null;_snapshotTick=-1;_ready=!1;dataBlockClassNames=new Map;onReady;constructor(e){super(),this.relay=e;const{registry:t,ghostTracker:a,packetParser:r}=(0,i.createLiveParser)();this.packetParser=r,this.ghostTracker=a,this.registry=t}getDataBlockData(e){return this.packetParser.getDataBlockDataMap()?.get(e)}_shapeConstructorCache=null;getShapeConstructorSequences(e){this._shapeConstructorCache=new Map;let t=this.packetParser.getDataBlockDataMap();if(t){for(let[,e]of t){let t=e.shape,a=e.sequences;t&&a&&this._shapeConstructorCache.set(t.toLowerCase(),a)}return this._shapeConstructorCache.get(e.toLowerCase())}}getTimeSec(){return this.currentTimeSec}getCameraYawPitch(e){return this.getAbsoluteRotation(e)??{yaw:0,pitch:0}}getEffectShapes(){let e=new Set,t=this.packetParser.getDataBlockDataMap();if(!t)return[];for(let[,a]of t){let r=a.explosion;if(null==r)continue;let n=t.get(r);n?.dtsFileName&&e.add(n.dtsFileName)}return[...e]}reset(){this.resetSharedState(),this.ghostTracker.clear?.(),this.currentTimeSec=0,this._snapshot=null,this._snapshotTick=-1,this.dataBlockClassNames.clear(),this.observerMode="fly"}getSnapshot(){return this._snapshot&&this._snapshotTick===this.tickCount?this._snapshot:this.buildSnapshot()}stepToTime(e,t){return this.currentTimeSec=e,this.getSnapshot()}syncConnectSequence(e){if(this.connectSynced||e.length<1)return;this.connectSynced=!0;let t=e[0]>>1&1;this.packetParser.setConnectionProtocolState({lastSeqRecvdAtSend:Array(32).fill(0),lastSeqRecvd:0,highestAckedSeq:0,lastSendSeq:0x1fffffff,ackMask:0,connectSequence:t,lastRecvAckAck:0,connectionEstablished:!0})}feedPacket(e){this.syncConnectSequence(e),this.processPacket(e)}handleRelayCommands(e){if("RemoteCommandEvent"!==e.type)return;let t=e.funcName;if(!t)return;let a=this.resolveNetString(t);if(["t2csri_pokeClient","t2csri_getChallengeChunk","t2csri_decryptChallenge"].includes(a)){let t=(e.args??[]).map(e=>this.resolveNetString(e)).filter(e=>""!==e);console.log(`[live] auth event: ${a}`,t),this.relay.sendAuthEvent(a,t);return}let r=(e.args??[]).map(e=>this.resolveNetString(e));if("MissionStartPhase1"===a){let e=r[0]??"";console.log(`[live] mission phase 1, seq=${e}`),this.relay.sendCommand("MissionStartPhase1Done",[e])}else if("MissionStartPhase2"===a){let e=r[0]??"";console.log(`[live] mission phase 2 (datablocks), seq=${e}`),this.relay.sendCommand("MissionStartPhase2Done",[e])}else if("MissionStartPhase3"===a){let e=r[0]??"";console.log(`[live] mission phase 3 (ghosting), seq=${e}`),this.relay.sendCommand("setClientFav",[""]),this.relay.sendCommand("MissionStartPhase3Done",[e])}}handleCRCChallenge(e){if("CRCChallengeEvent"!==e.type)return;let t=e.crcValue,a=e.field1,r=e.field2,n=(1&a)!=0;console.log(`[live] CRC challenge: seed=0x${(t>>>0).toString(16)} f1=0x${(a>>>0).toString(16)} f2=0x${(r>>>0).toString(16)} includeTextures=${n}`);let i=this.packetParser.getDataBlockDataMap(),s=[];if(i)for(let[e,t]of i){let a=this.dataBlockClassNames.get(e);if(!a)continue;let r=(0,o.resolveShapeName)(a,t);s.push({objectId:e,className:a,shapeName:r??""})}console.log(`[live] CRC: sending ${s.length} datablocks for computation`),this.relay.sendCRCCompute(t,r,s,n)}handleGhostingMessage(e){if("GhostingMessageEvent"!==e.type)return;let t=e.message,a=e.sequence,r=e.ghostCount;console.log(`[live] GhostingMessageEvent: message=${t} sequence=${a} ghostCount=${r}`),0===t&&(console.log(`[live] Sending ghost ack (type 1) for sequence ${a}`),this.relay.sendGhostAck(a,r))}observerMode="fly";cycleObserveNext(){"fly"===this.observerMode?(console.log("[live] observer: fly → follow (jump trigger)"),this.sendTrigger(2),this.observerMode="follow"):(console.log("[live] observer: cycle next (fire trigger)"),this.sendTrigger(0))}toggleObserverMode(){"fly"===this.observerMode?(console.log("[live] observer: fly → follow (jump trigger)"),this.sendTrigger(2),this.observerMode="follow"):(console.log("[live] observer: follow → fly (jump trigger)"),this.sendTrigger(2),this.observerMode="fly")}sendTrigger(e){let t=[!1,!1,!1,!1,!1,!1];t[e]=!0,this.relay.sendMove({x:0,y:0,z:0,yaw:0,pitch:0,roll:0,trigger:t,freeLook:!1})}getPlayerList(){let e=[];for(let[t,a]of this.targetNames){let r=this.targetTeams.get(t)??0;e.push({targetId:t,name:a,sensorGroup:r})}return e}processPacket(e){try{let t=this.packetParser.protocolRejected,a=this.packetParser.protocolNoDispatch,r=this.packetParser.parsePacket(e),n=this.packetParser.protocolRejected>t,i=this.packetParser.protocolNoDispatch>a;(n||i)&&console.warn(`[live] packet #${this.tickCount} ${n?"REJECTED":"no-dispatch"}: ${e.length} bytes (total rejected=${this.packetParser.protocolRejected}, noDispatch=${this.packetParser.protocolNoDispatch})`);let s=this.tickCount<20,l=this.tickCount%100==0,d=s||l;for(let t of(d&&console.log(`[live] packet #${this.tickCount}: ${r.events.length} events, ${r.ghosts.length} ghosts, ${e.length} bytes`+(void 0!==r.gameState.controlObjectGhostIndex?`, control=${r.gameState.controlObjectGhostIndex}`:"")+(void 0!==r.gameState.cameraFov?`, fov=${r.gameState.cameraFov}`:"")),this.processControlObject(r.gameState),r.events))if(t.parsedData){this.handleRelayCommands(t.parsedData),this.handleCRCChallenge(t.parsedData),this.handleGhostingMessage(t.parsedData);let e=t.parsedData.type;if(s&&"NetStringEvent"!==e&&console.log(`[live] event: ${e}`,"RemoteCommandEvent"===e?{funcName:this.resolveNetString(t.parsedData.funcName??"")}:"SimDataBlockEvent"===e?{id:t.parsedData.objectId,className:t.parsedData.dataBlockClassName}:void 0),"SimDataBlockEvent"===e){let e=t.parsedData.objectId,a=t.parsedData.dataBlockClassName;if(null!=e&&a&&this.dataBlockClassNames.set(e,a),d){let r=t.parsedData.dataBlockData,n=(0,o.resolveShapeName)(a??"",r);console.log(`[live] datablock: id=${e} class=${a??"?"}`+(n?` shape=${n}`:""))}}let a=this.registry.getEventParser(t.classId)?.name;if(this.processEvent(t,a),s&&"NetStringEvent"===e){let e=t.parsedData.id,a=t.parsedData.value;null!=e&&"string"==typeof a&&console.log(`[live] netString #${e} = "${a.length>60?a.slice(0,60)+"…":a}"`)}if("TargetInfoEvent"===e){let e=t.parsedData.targetId,a=t.parsedData.nameTag;if(null!=e&&null!=a){let r=this.netStrings.get(a);if(r){let a=(0,o.stripTaggedStringMarkup)(r);console.log(`[live] target #${e}: "${a}" team=${t.parsedData.sensorGroup??"?"}`)}}}if("SetSensorGroupEvent"===e){let e=t.parsedData.sensorGroup;null!=e&&console.log(`[live] sensor group changed: → ${e}`)}if("SensorGroupColorEvent"===e){let e=t.parsedData.sensorGroup,a=t.parsedData.colors;a&&console.log(`[live] sensor group colors: group=${e}, ${a.length} entries`)}}for(let e of r.ghosts){if("create"===e.type){let t=e.parsedData?.position,a=t&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.z,r=this.resolveGhostClassName(e.index,e.classId);console.log(`[live] ghost create: #${e.index} ${r??"?"}`+(a?` at (${t.x.toFixed(1)}, ${t.y.toFixed(1)}, ${t.z.toFixed(1)})`:"")+` (${this.entities.size+1} entities total)`),this._ready||(this._ready=!0,this.onReady?.())}else if("delete"===e.type){let t=this.entityIdByGhostIndex.get(e.index),a=t?this.entities.get(t):void 0;(this.tickCount<50||this.tickCount%200==0)&&console.log(`[live] ghost delete: #${e.index} ${a?.className??"?"} (${this.entities.size-1} entities remaining)`)}this.processGhostUpdate(e)}if(this.tickCount++,this.advanceProjectiles(),this.advanceItems(),l&&this.tickCount>1){let e=this.packetParser.getDataBlockDataMap();console.log(`[live] status @ tick ${this.tickCount}: ${this.entities.size} entities, ${e?.size??0} datablocks, rejected=${this.packetParser.protocolRejected}, noDispatch=${this.packetParser.protocolNoDispatch}`)}let c=this.entities.size;if(1===this.tickCount||c>0&&c%25==0&&this.tickCount<100){let e=new Map;for(let t of this.entities.values())e.set(t.type,(e.get(t.type)??0)+1);let t=[...e.entries()].map(([e,t])=>`${e}=${t}`).join(" ");console.log(`[live] entity count: ${c} (${t})`)}if(this.updateCameraAndHud(),this.tickCount<=5&&this.camera){let[e,t,a]=this.camera.position;console.log(`[live] camera: mode=${this.camera.mode} pos=(${e.toFixed(1)}, ${t.toFixed(1)}, ${a.toFixed(1)}) fov=${this.camera.fov}`)}}catch(t){console.error("Failed to process live packet:",t,{tickCount:this.tickCount,entityCount:this.entities.size,dataLength:e.length,controlGhost:this.latestControl.ghostIndex,connectSynced:this.connectSynced})}}buildSnapshot(){let e=this.buildEntityList(),t=this.currentTimeSec,{chatMessages:a,audioEvents:r}=this.buildTimeFilteredEvents(t),{weaponsHud:n,inventoryHud:i,backpackHud:o,teamScores:s}=this.buildHudState();this.camera||(this.camera={time:t,position:[0,0,200],rotation:[0,0,0,1],fov:90,mode:"observer"});let l={timeSec:t,exhausted:!1,camera:this.camera,entities:e,controlPlayerGhostId:this.controlPlayerGhostId,playerSensorGroup:this.playerSensorGroup,status:this.lastStatus,chatMessages:a,audioEvents:r,weaponsHud:n,backpackHud:o,inventoryHud:i,teamScores:s};return this._snapshot=l,this._snapshotTick=this.tickCount,l}}let d=(0,r.createContext)(null);function c(){let e=(0,r.useContext)(d);if(!e)throw Error("useLiveConnection must be used within LiveConnectionProvider");return e}function u(){return(0,r.useContext)(d)}function h(e){let i,o,s,c,u,h,g,p,m,f,F,v,y,S=(0,a.c)(27),{children:k}=e,b=(0,r.useRef)(null),P=(0,r.useRef)(null);S[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],S[0]=i):i=S[0];let x=(0,r.useRef)(i),I=(0,r.useRef)(!1),[D,C]=(0,r.useState)(!1),[E,w]=(0,r.useState)(null),[M,B]=(0,r.useState)(),[T,R]=(0,r.useState)();S[1]===Symbol.for("react.memo_cache_sentinel")?(o=[],S[1]=o):o=S[1];let[N,G]=(0,r.useState)(o),[A,U]=(0,r.useState)(!1),[j,O]=(0,r.useState)(null),[z,L]=(0,r.useState)(!1),[V,_]=(0,r.useState)(null),[q,$]=(0,r.useState)(null);S[2]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{b.current&&(b.current.close(),b.current=null);let t=new n.RelayClient(void 0===e?"wss://t2-relay.fly.dev":e,{onOpen(){for(let e of(C(!0),x.current))e();x.current=[]},onStatus(e,t,a,r){console.log(`[relay] game status: ${e}${t?` — ${t}`:""}${r?` map=${r}`:""}`),w(e),B(t),r&&R(r)},onServerList(e){G(e),U(!1),I.current=!1},onGamePacket(e){P.current||console.warn("[relay] received game packet but no adapter is active"),P.current?.feedPacket(e)},onPing(e){_(e)},onWsPing(e){$(e)},onError(e){console.error("Relay error:",e),U(!1),I.current=!1},onClose(){b.current===t&&(b.current=null,C(!1),w(null),R(void 0),_(null),$(null),O(null),L(!1),P.current=null,x.current=[],I.current=!1)}});t.connect(),b.current=t},S[2]=s):s=S[2];let H=s;S[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{b.current?.close(),b.current=null,P.current=null,x.current=[],C(!1),w(null),R(void 0),O(null),L(!1)},S[3]=c):c=S[3];let W=c;S[4]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{if(I.current)return;I.current=!0;let e=()=>{b.current?.sendWsPing(),b.current?.listServers()};U(!0),b.current?.connected?e():(x.current.push(e),b.current||H())},S[4]=u):u=S[4];let X=u;S[5]!==N?(h=e=>{if(!b.current)return;let t=N.find(t=>t.address===e);t?.mapName&&R(t.mapName);let a=new l(b.current);a.onReady=()=>L(!0),P.current=a,L(!1),w(null),O(a),b.current.joinServer(e)},S[5]=N,S[6]=h):h=S[6];let Z=h;S[7]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{b.current?.disconnectServer(),P.current?.reset(),P.current=null,O(null),L(!1),w(null),R(void 0),_(null)},S[7]=g):g=S[7];let Y=g;S[8]===Symbol.for("react.memo_cache_sentinel")?(p=e=>{b.current?.sendMove(e)},S[8]=p):p=S[8];let J=p;S[9]===Symbol.for("react.memo_cache_sentinel")?(m=(e,...t)=>{b.current?.sendCommand(e,t)},S[9]=m):m=S[9];let K=m;S[10]===Symbol.for("react.memo_cache_sentinel")?(f=()=>()=>{b.current?.close()},F=[],S[10]=f,S[11]=F):(f=S[10],F=S[11]),(0,r.useEffect)(f,F);let Q=null!=V&&null!=q?V+q:V??null;S[12]!==j||S[13]!==E||S[14]!==M||S[15]!==Z||S[16]!==z||S[17]!==T||S[18]!==Q||S[19]!==D||S[20]!==N||S[21]!==A||S[22]!==q?(v={relayConnected:D,gameStatus:E,gameStatusMessage:M,mapName:T,ping:Q,wsPing:q,servers:N,serversLoading:A,adapter:j,liveReady:z,connectRelay:H,disconnectRelay:W,listServers:X,joinServer:Z,disconnectServer:Y,sendMove:J,sendCommand:K},S[12]=j,S[13]=E,S[14]=M,S[15]=Z,S[16]=z,S[17]=T,S[18]=Q,S[19]=D,S[20]=N,S[21]=A,S[22]=q,S[23]=v):v=S[23];let ee=v;return S[24]!==k||S[25]!==ee?(y=(0,t.jsx)(d.Provider,{value:ee,children:k}),S[24]=k,S[25]=ee,S[26]=y):y=S[26],y}e.s(["LiveConnectionProvider",()=>h,"useLiveConnection",()=>c,"useLiveConnectionOptional",()=>u],12781)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/53a9c1169e187e33.js b/docs/_next/static/chunks/53a9c1169e187e33.js deleted file mode 100644 index 6216c2b8..00000000 --- a/docs/_next/static/chunks/53a9c1169e187e33.js +++ /dev/null @@ -1,52 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,79474,(t,e,i)=>{"use strict";var s=t.r(71645).__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;i.c=function(t){return s.H.useMemoCache(t)}},932,(t,e,i)=>{"use strict";e.exports=t.r(79474)},90072,t=>{"use strict";let e,i,s,r,n,a,o,h,l,u={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},c={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},p="attached",d="detached",m="srgb",f="srgb-linear",g="linear",y="srgb",x={COMPUTE:"compute",RENDER:"render"},b={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},v={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function w(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}let M={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function S(t,e){return new M[t](e)}function A(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function _(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function C(){let t=_("canvas");return t.style.display="block",t}let T={},I=null;function z(t){I=t}function k(){return I}function B(...t){let e="THREE."+t.shift();I?I("log",e,...t):console.log(e,...t)}function R(...t){let e="THREE."+t.shift();I?I("warn",e,...t):console.warn(e,...t)}function O(...t){let e="THREE."+t.shift();I?I("error",e,...t):console.error(e,...t)}function E(...t){let e=t.join(" ");e in T||(T[e]=!0,R(...t))}function P(t,e,i){return new Promise(function(s,r){setTimeout(function n(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(n,i);break;default:s()}},i)})}class L{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){let i=this._listeners;return void 0!==i&&void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){let i=this._listeners;if(void 0===i)return;let s=i[t];if(void 0!==s){let t=s.indexOf(e);-1!==t&&s.splice(t,1)}}dispatchEvent(t){let e=this._listeners;if(void 0===e)return;let i=e[t.type];if(void 0!==i){t.target=this;let e=i.slice(0);for(let i=0,s=e.length;i>8&255]+N[t>>16&255]+N[t>>24&255]+"-"+N[255&e]+N[e>>8&255]+"-"+N[e>>16&15|64]+N[e>>24&255]+"-"+N[63&i|128]+N[i>>8&255]+"-"+N[i>>16&255]+N[i>>24&255]+N[255&s]+N[s>>8&255]+N[s>>16&255]+N[s>>24&255]).toLowerCase()}function j(t,e,i){return Math.max(e,Math.min(i,t))}function U(t,e){return(t%e+e)%e}function W(t,e,i){return(1-i)*t+i*e}function G(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/0xffffffff;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/0x7fffffff,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function q(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(0xffffffff*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(0x7fffffff*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw Error("Invalid component type.")}}let H={DEG2RAD:$,RAD2DEG:V,generateUUID:D,clamp:j,euclideanModulo:U,mapLinear:function(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:W,damp:function(t,e,i,s){return W(t,e,1-Math.exp(-i*s))},pingpong:function(t,e=1){return e-Math.abs(U(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(F=t);let e=F+=0x6d2b79f5;return e=Math.imul(e^e>>>15,1|e),(((e^=e+Math.imul(e^e>>>7,61|e))^e>>>14)>>>0)/0x100000000},degToRad:function(t){return t*$},radToDeg:function(t){return t*V},isPowerOfTwo:function(t){return(t&t-1)==0&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,s,r){let n=Math.cos,a=Math.sin,o=n(i/2),h=a(i/2),l=n((e+s)/2),u=a((e+s)/2),c=n((e-s)/2),p=a((e-s)/2),d=n((s-e)/2),m=a((s-e)/2);switch(r){case"XYX":t.set(o*u,h*c,h*p,o*l);break;case"YZY":t.set(h*p,o*u,h*c,o*l);break;case"ZXZ":t.set(h*c,h*p,o*u,o*l);break;case"XZX":t.set(o*u,h*m,h*d,o*l);break;case"YXY":t.set(h*d,o*u,h*m,o*l);break;case"ZYZ":t.set(h*m,h*d,o*u,o*l);break;default:R("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:q,denormalize:G};class J{constructor(t=0,e=0){J.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());return 0===e?Math.PI/2:Math.acos(j(this.dot(t)/e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let i=Math.cos(e),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class X{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,a){let o=i[s+0],h=i[s+1],l=i[s+2],u=i[s+3],c=r[n+0],p=r[n+1],d=r[n+2],m=r[n+3];if(a<=0){t[e+0]=o,t[e+1]=h,t[e+2]=l,t[e+3]=u;return}if(a>=1){t[e+0]=c,t[e+1]=p,t[e+2]=d,t[e+3]=m;return}if(u!==m||o!==c||h!==p||l!==d){let t=o*c+h*p+l*d+u*m;t<0&&(c=-c,p=-p,d=-d,m=-m,t=-t);let e=1-a;if(t<.9995){let i=Math.acos(t),s=Math.sin(i);o=o*(e=Math.sin(e*i)/s)+c*(a=Math.sin(a*i)/s),h=h*e+p*a,l=l*e+d*a,u=u*e+m*a}else{let t=1/Math.sqrt((o=o*e+c*a)*o+(h=h*e+p*a)*h+(l=l*e+d*a)*l+(u=u*e+m*a)*u);o*=t,h*=t,l*=t,u*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,r,n){let a=i[s],o=i[s+1],h=i[s+2],l=i[s+3],u=r[n],c=r[n+1],p=r[n+2],d=r[n+3];return t[e]=a*d+l*u+o*p-h*c,t[e+1]=o*d+l*c+h*u-a*p,t[e+2]=h*d+l*p+a*c-o*u,t[e+3]=l*d-a*u-o*c-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let i=t._x,s=t._y,r=t._z,n=t._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(s/2),u=a(r/2),c=o(i/2),p=o(s/2),d=o(r/2);switch(n){case"XYZ":this._x=c*l*u+h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u-c*p*d;break;case"YXZ":this._x=c*l*u+h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u+c*p*d;break;case"ZXY":this._x=c*l*u-h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u-c*p*d;break;case"ZYX":this._x=c*l*u-h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u+c*p*d;break;case"YZX":this._x=c*l*u+h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u-c*p*d;break;case"XZY":this._x=c*l*u-h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u+c*p*d;break;default:R("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],a=e[5],o=e[9],h=e[2],l=e[6],u=e[10],c=i+a+u;if(c>0){let t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>a&&i>u){let t=2*Math.sqrt(1+i-a-u);this._w=(l-o)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(a>u){let t=2*Math.sqrt(1+a-i-u);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(o+l)/t}else{let t=2*Math.sqrt(1+u-i-a);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0):(this._x=0,this._y=-t.z,this._z=t.y)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x),this._w=i,this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(j(this.dot(t),-1,1)))}rotateTowards(t,e){let i=this.angleTo(t);if(0===i)return this;let s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let i=t._x,s=t._y,r=t._z,n=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+n*a+s*h-r*o,this._y=s*l+n*o+r*a-i*h,this._z=r*l+n*h+i*o-s*a,this._w=n*l-i*a-s*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let i=t._x,s=t._y,r=t._z,n=t._w,a=this.dot(t);a<0&&(i=-i,s=-s,r=-r,n=-n,a=-a);let o=1-e;if(a<.9995){let t=Math.acos(a),h=Math.sin(t);o=Math.sin(o*t)/h,e=Math.sin(e*t)/h,this._x=this._x*o+i*e,this._y=this._y*o+s*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this._onChangeCallback()}else this._x=this._x*o+i*e,this._y=this._y*o+s*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Z{constructor(t=0,e=0,i=0){Z.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Q.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Q.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){let e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,a=t.z,o=t.w,h=2*(n*s-a*i),l=2*(a*e-r*s),u=2*(r*i-n*e);return this.x=e+o*h+n*u-a*l,this.y=i+o*l+a*h-r*u,this.z=s+o*u+r*l-n*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let i=t.x,s=t.y,r=t.z,n=e.x,a=e.y,o=e.z;return this.x=s*o-r*a,this.y=r*n-i*o,this.z=i*a-s*n,this}projectOnVector(t){let e=t.lengthSq();if(0===e)return this.set(0,0,0);let i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Y.copy(this).projectOnVector(t),this.sub(Y)}reflect(t){return this.sub(Y.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());return 0===e?Math.PI/2:Math.acos(j(this.dot(t)/e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){let s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let Y=new Z,Q=new X;class K{constructor(t,e,i,s,r,n,a,o,h){K.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h)}set(t,e,i,s,r,n,a,o,h){let l=this.elements;return l[0]=t,l[1]=s,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[3],o=i[6],h=i[1],l=i[4],u=i[7],c=i[2],p=i[5],d=i[8],m=s[0],f=s[3],g=s[6],y=s[1],x=s[4],b=s[7],v=s[2],w=s[5],M=s[8];return r[0]=n*m+a*y+o*v,r[3]=n*f+a*x+o*w,r[6]=n*g+a*b+o*M,r[1]=h*m+l*y+u*v,r[4]=h*f+l*x+u*w,r[7]=h*g+l*b+u*M,r[2]=c*m+p*y+d*v,r[5]=c*f+p*x+d*w,r[8]=c*g+p*b+d*M,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*n*l-e*a*h-i*r*l+i*a*o+s*r*h-s*n*o}invert(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],u=l*n-a*h,c=a*o-l*r,p=h*r-n*o,d=e*u+i*c+s*p;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);let m=1/d;return t[0]=u*m,t[1]=(s*h-l*i)*m,t[2]=(a*i-s*n)*m,t[3]=c*m,t[4]=(l*e-s*o)*m,t[5]=(s*r-a*e)*m,t[6]=p*m,t[7]=(i*o-h*e)*m,t[8]=(n*e-i*r)*m,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,r,n,a){let o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*n+h*a)+n+t,-s*h,s*o,-s*(-h*n+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(tt.makeScale(t,e)),this}rotate(t){return this.premultiply(tt.makeRotation(-t)),this}translate(t,e){return this.premultiply(tt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}let tt=new K,te=new K().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ti=new K().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),ts=(o=[.64,.33,.3,.6,.15,.06],h=[.2126,.7152,.0722],l=[.3127,.329],(a={enabled:!0,workingColorSpace:f,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i&&(this.spaces[e].transfer===y&&(t.r=tr(t.r),t.g=tr(t.g),t.b=tr(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===y&&(t.r=tn(t.r),t.g=tn(t.g),t.b=tn(t.b))),t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?g:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,e){return E("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(t,e)},toWorkingColorSpace:function(t,e){return E("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(t,e)}}).define({[f]:{primaries:o,whitePoint:l,transfer:g,toXYZ:te,fromXYZ:ti,luminanceCoefficients:h,workingColorSpaceConfig:{unpackColorSpace:m},outputColorSpaceConfig:{drawingBufferColorSpace:m}},[m]:{primaries:o,whitePoint:l,transfer:y,toXYZ:te,fromXYZ:ti,luminanceCoefficients:h,outputColorSpaceConfig:{drawingBufferColorSpace:m}}}),a);function tr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function tn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class ta{static getDataURL(t,i="image/png"){let s;if(/^data:/i.test(t.src)||"u"typeof HTMLImageElement&&t instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&t instanceof ImageBitmap){let e=_("canvas");e.width=t.width,e.height=t.height;let i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);let s=i.getImageData(0,0,t.width,t.height),r=s.data;for(let t=0;ttypeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"u">typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];let i={uuid:this.uuid,url:""},s=this.data;if(null!==s){let t;if(Array.isArray(s)){t=[];for(let e=0,i=s.length;etypeof HTMLImageElement&&t instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&t instanceof ImageBitmap?ta.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(R("Texture: Unable to serialize Texture."),{})}let tu=0,tc=new Z;class tp extends L{constructor(t=tp.DEFAULT_IMAGE,e=tp.DEFAULT_MAPPING,i=1001,s=1001,r=1006,n=1008,a=1023,o=1009,h=tp.DEFAULT_ANISOTROPY,l=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tu++}),this.uuid=D(),this.name="",this.source=new th(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=n,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new K,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!t&&!!t.depth&&t.depth>1,this.pmremVersion=0}get width(){return this.source.getSize(tc).x}get height(){return this.source.getSize(tc).y}get depth(){return this.source.getSize(tc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let i=t[e];if(void 0===i){R(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(void 0===s){R(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[e]=i}}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}tp.DEFAULT_IMAGE=null,tp.DEFAULT_MAPPING=300,tp.DEFAULT_ANISOTROPY=1;class td{constructor(t=0,e=0,i=0,s=1){td.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,i=this.y,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,r,n=t.elements,a=n[0],o=n[4],h=n[8],l=n[1],u=n[5],c=n[9],p=n[2],d=n[6],m=n[10];if(.01>Math.abs(o-l)&&.01>Math.abs(h-p)&&.01>Math.abs(c-d)){if(.1>Math.abs(o+l)&&.1>Math.abs(h+p)&&.1>Math.abs(c+d)&&.1>Math.abs(a+u+m-3))return this.set(1,0,0,0),this;e=Math.PI;let t=(a+1)/2,n=(u+1)/2,f=(m+1)/2,g=(o+l)/4,y=(h+p)/4,x=(c+d)/4;return t>n&&t>f?t<.01?(i=0,s=.707106781,r=.707106781):(s=g/(i=Math.sqrt(t)),r=y/i):n>f?n<.01?(i=.707106781,s=0,r=.707106781):(i=g/(s=Math.sqrt(n)),r=x/s):f<.01?(i=.707106781,s=.707106781,r=0):(i=y/(r=Math.sqrt(f)),s=x/r),this.set(i,s,r,e),this}let f=Math.sqrt((d-c)*(d-c)+(h-p)*(h-p)+(l-o)*(l-o));return .001>Math.abs(f)&&(f=1),this.x=(d-c)/f,this.y=(h-p)/f,this.z=(l-o)/f,this.w=Math.acos((a+u+m-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this.w=j(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this.w=j(this.w,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tm extends L{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new td(0,0,t,e),this.scissorTest=!1,this.viewport=new td(0,0,t,e);const s=new tp({width:t,height:e,depth:i.depth});this.textures=[];const r=i.count;for(let t=0;t1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,tM),tM.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(tk),tB.subVectors(this.max,tk),tA.subVectors(t.a,tk),t_.subVectors(t.b,tk),tC.subVectors(t.c,tk),tT.subVectors(t_,tA),tI.subVectors(tC,t_),tz.subVectors(tA,tC);let e=[0,-tT.z,tT.y,0,-tI.z,tI.y,0,-tz.z,tz.y,tT.z,0,-tT.x,tI.z,0,-tI.x,tz.z,0,-tz.x,-tT.y,tT.x,0,-tI.y,tI.x,0,-tz.y,tz.x,0];return!!tE(e,tA,t_,tC,tB)&&!!tE(e=[1,0,0,0,1,0,0,0,1],tA,t_,tC,tB)&&(tR.crossVectors(tT,tI),tE(e=[tR.x,tR.y,tR.z],tA,t_,tC,tB))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tM).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(tM).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(tw[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),tw[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),tw[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),tw[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),tw[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),tw[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),tw[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),tw[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(tw)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}let tw=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],tM=new Z,tS=new tv,tA=new Z,t_=new Z,tC=new Z,tT=new Z,tI=new Z,tz=new Z,tk=new Z,tB=new Z,tR=new Z,tO=new Z;function tE(t,e,i,s,r){for(let n=0,a=t.length-3;n<=a;n+=3){tO.fromArray(t,n);let a=r.x*Math.abs(tO.x)+r.y*Math.abs(tO.y)+r.z*Math.abs(tO.z),o=e.dot(tO),h=i.dot(tO),l=s.dot(tO);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>a)return!1}return!0}let tP=new tv,tL=new Z,tN=new Z;class tF{constructor(t=new Z,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let i=this.center;void 0!==e?i.copy(e):tP.setFromPoints(t).getCenter(i);let s=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?t.makeEmpty():(t.set(this.center,this.center),t.expandByScalar(this.radius)),t}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;tL.subVectors(t,this.center);let e=tL.lengthSq();if(e>this.radius*this.radius){let t=Math.sqrt(e),i=(t-this.radius)*.5;this.center.addScaledVector(tL,i/t),this.radius+=i}return this}union(t){return t.isEmpty()||(this.isEmpty()?this.copy(t):!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(tN.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(tL.copy(t.center).add(tN)),this.expandByPoint(tL.copy(t.center).sub(tN)))),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let t$=new Z,tV=new Z,tD=new Z,tj=new Z,tU=new Z,tW=new Z,tG=new Z;class tq{constructor(t=new Z,e=new Z(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,t$)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=t$.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(t$.copy(this.origin).addScaledVector(this.direction,e),t$.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){let r,n,a,o;tV.copy(t).add(e).multiplyScalar(.5),tD.copy(e).sub(t).normalize(),tj.copy(this.origin).sub(tV);let h=.5*t.distanceTo(e),l=-this.direction.dot(tD),u=tj.dot(this.direction),c=-tj.dot(tD),p=tj.lengthSq(),d=Math.abs(1-l*l);if(d>0)if(r=l*c-u,n=l*u-c,o=h*d,r>=0)if(n>=-o)if(n<=o){let t=1/d;r*=t,n*=t,a=r*(r+l*n+2*u)+n*(l*r+n+2*c)+p}else a=-(r=Math.max(0,-(l*(n=h)+u)))*r+n*(n+2*c)+p;else a=-(r=Math.max(0,-(l*(n=-h)+u)))*r+n*(n+2*c)+p;else n<=-o?(n=(r=Math.max(0,-(-l*h+u)))>0?-h:Math.min(Math.max(-h,-c),h),a=-r*r+n*(n+2*c)+p):n<=o?(r=0,a=(n=Math.min(Math.max(-h,-c),h))*(n+2*c)+p):(n=(r=Math.max(0,-(l*h+u)))>0?h:Math.min(Math.max(-h,-c),h),a=-r*r+n*(n+2*c)+p);else n=l>0?-h:h,a=-(r=Math.max(0,-(l*n+u)))*r+n*(n+2*c)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,r),s&&s.copy(tV).addScaledVector(tD,n),a}intersectSphere(t,e){t$.subVectors(t.center,this.origin);let i=t$.dot(this.direction),s=t$.dot(t$)-i*i,r=t.radius*t.radius;if(s>r)return null;let n=Math.sqrt(r-s),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){let i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return!!(0===e||t.normal.dot(this.direction)*e<0)}intersectBox(t,e){let i,s,r,n,a,o,h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return(h>=0?(i=(t.min.x-c.x)*h,s=(t.max.x-c.x)*h):(i=(t.max.x-c.x)*h,s=(t.min.x-c.x)*h),l>=0?(r=(t.min.y-c.y)*l,n=(t.max.y-c.y)*l):(r=(t.max.y-c.y)*l,n=(t.min.y-c.y)*l),i>n||r>s||((r>i||isNaN(i))&&(i=r),(n=0?(a=(t.min.z-c.z)*u,o=(t.max.z-c.z)*u):(a=(t.max.z-c.z)*u,o=(t.min.z-c.z)*u),i>o||a>s||((a>i||i!=i)&&(i=a),(o=0?i:s,e)}intersectsBox(t){return null!==this.intersectBox(t,t$)}intersectTriangle(t,e,i,s,r){let n;tU.subVectors(e,t),tW.subVectors(i,t),tG.crossVectors(tU,tW);let a=this.direction.dot(tG);if(a>0){if(s)return null;n=1}else{if(!(a<0))return null;n=-1,a=-a}tj.subVectors(this.origin,t);let o=n*this.direction.dot(tW.crossVectors(tj,tW));if(o<0)return null;let h=n*this.direction.dot(tU.cross(tj));if(h<0||o+h>a)return null;let l=-n*tj.dot(tG);return l<0?null:this.at(l/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class tH{constructor(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f){tH.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f)}set(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f){let g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=r,g[5]=n,g[9]=a,g[13]=o,g[2]=h,g[6]=l,g[10]=u,g[14]=c,g[3]=p,g[7]=d,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new tH().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){let e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1)):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2)),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();let e=this.elements,i=t.elements,s=1/tJ.setFromMatrixColumn(t,0).length(),r=1/tJ.setFromMatrixColumn(t,1).length(),n=1/tJ.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,i=t.x,s=t.y,r=t.z,n=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),l=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){let t=n*l,i=n*u,s=a*l,r=a*u;e[0]=o*l,e[4]=-o*u,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-a*o,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*o}else if("YXZ"===t.order){let t=o*l,i=o*u,s=h*l,r=h*u;e[0]=t+r*a,e[4]=s*a-i,e[8]=n*h,e[1]=n*u,e[5]=n*l,e[9]=-a,e[2]=i*a-s,e[6]=r+t*a,e[10]=n*o}else if("ZXY"===t.order){let t=o*l,i=o*u,s=h*l,r=h*u;e[0]=t-r*a,e[4]=-n*u,e[8]=s+i*a,e[1]=i+s*a,e[5]=n*l,e[9]=r-t*a,e[2]=-n*h,e[6]=a,e[10]=n*o}else if("ZYX"===t.order){let t=n*l,i=n*u,s=a*l,r=a*u;e[0]=o*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=o*u,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=a*o,e[10]=n*o}else if("YZX"===t.order){let t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=r-t*u,e[8]=s*u+i,e[1]=u,e[5]=n*l,e[9]=-a*l,e[2]=-h*l,e[6]=i*u+s,e[10]=t-r*u}else if("XZY"===t.order){let t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=-u,e[8]=h*l,e[1]=t*u+r,e[5]=n*l,e[9]=i*u-s,e[2]=s*u-i,e[6]=a*l,e[10]=r*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(tZ,t,tY)}lookAt(t,e,i){let s=this.elements;return t0.subVectors(t,e),0===t0.lengthSq()&&(t0.z=1),t0.normalize(),tQ.crossVectors(i,t0),0===tQ.lengthSq()&&(1===Math.abs(i.z)?t0.x+=1e-4:t0.z+=1e-4,t0.normalize(),tQ.crossVectors(i,t0)),tQ.normalize(),tK.crossVectors(t0,tQ),s[0]=tQ.x,s[4]=tK.x,s[8]=t0.x,s[1]=tQ.y,s[5]=tK.y,s[9]=t0.y,s[2]=tQ.z,s[6]=tK.z,s[10]=t0.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[4],o=i[8],h=i[12],l=i[1],u=i[5],c=i[9],p=i[13],d=i[2],m=i[6],f=i[10],g=i[14],y=i[3],x=i[7],b=i[11],v=i[15],w=s[0],M=s[4],S=s[8],A=s[12],_=s[1],C=s[5],T=s[9],I=s[13],z=s[2],k=s[6],B=s[10],R=s[14],O=s[3],E=s[7],P=s[11],L=s[15];return r[0]=n*w+a*_+o*z+h*O,r[4]=n*M+a*C+o*k+h*E,r[8]=n*S+a*T+o*B+h*P,r[12]=n*A+a*I+o*R+h*L,r[1]=l*w+u*_+c*z+p*O,r[5]=l*M+u*C+c*k+p*E,r[9]=l*S+u*T+c*B+p*P,r[13]=l*A+u*I+c*R+p*L,r[2]=d*w+m*_+f*z+g*O,r[6]=d*M+m*C+f*k+g*E,r[10]=d*S+m*T+f*B+g*P,r[14]=d*A+m*I+f*R+g*L,r[3]=y*w+x*_+b*z+v*O,r[7]=y*M+x*C+b*k+v*E,r[11]=y*S+x*T+b*B+v*P,r[15]=y*A+x*I+b*R+v*L,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],i=t[4],s=t[8],r=t[12],n=t[1],a=t[5],o=t[9],h=t[13],l=t[2],u=t[6],c=t[10],p=t[14],d=t[3],m=t[7],f=t[11],g=t[15],y=o*p-h*c,x=a*p-h*u,b=a*c-o*u,v=n*p-h*l,w=n*c-o*l,M=n*u-a*l;return e*(m*y-f*x+g*b)-i*(d*y-f*v+g*w)+s*(d*x-m*v+g*M)-r*(d*b-m*w+f*M)}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(t,e,i){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],u=t[9],c=t[10],p=t[11],d=t[12],m=t[13],f=t[14],g=t[15],y=u*f*h-m*c*h+m*o*p-a*f*p-u*o*g+a*c*g,x=d*c*h-l*f*h-d*o*p+n*f*p+l*o*g-n*c*g,b=l*m*h-d*u*h+d*a*p-n*m*p-l*a*g+n*u*g,v=d*u*o-l*m*o-d*a*c+n*m*c+l*a*f-n*u*f,w=e*y+i*x+s*b+r*v;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/w;return t[0]=y*M,t[1]=(m*c*r-u*f*r-m*s*p+i*f*p+u*s*g-i*c*g)*M,t[2]=(a*f*r-m*o*r+m*s*h-i*f*h-a*s*g+i*o*g)*M,t[3]=(u*o*r-a*c*r-u*s*h+i*c*h+a*s*p-i*o*p)*M,t[4]=x*M,t[5]=(l*f*r-d*c*r+d*s*p-e*f*p-l*s*g+e*c*g)*M,t[6]=(d*o*r-n*f*r-d*s*h+e*f*h+n*s*g-e*o*g)*M,t[7]=(n*c*r-l*o*r+l*s*h-e*c*h-n*s*p+e*o*p)*M,t[8]=b*M,t[9]=(d*u*r-l*m*r-d*i*p+e*m*p+l*i*g-e*u*g)*M,t[10]=(n*m*r-d*a*r+d*i*h-e*m*h-n*i*g+e*a*g)*M,t[11]=(l*a*r-n*u*r-l*i*h+e*u*h+n*i*p-e*a*p)*M,t[12]=v*M,t[13]=(l*m*s-d*u*s+d*i*c-e*m*c-l*i*f+e*u*f)*M,t[14]=(d*a*s-n*m*s-d*i*o+e*m*o+n*i*f-e*a*f)*M,t[15]=(n*u*s-l*a*s+l*i*o-e*u*o-n*i*c+e*a*c)*M,this}scale(t){let e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements;return Math.sqrt(Math.max(t[0]*t[0]+t[1]*t[1]+t[2]*t[2],t[4]*t[4]+t[5]*t[5]+t[6]*t[6],t[8]*t[8]+t[9]*t[9]+t[10]*t[10]))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let i=Math.cos(e),s=Math.sin(e),r=1-i,n=t.x,a=t.y,o=t.z,h=r*n,l=r*a;return this.set(h*n+i,h*a-s*o,h*o+s*a,0,h*a+s*o,l*a+i,l*o-s*n,0,h*o-s*a,l*o+s*n,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){let s=this.elements,r=e._x,n=e._y,a=e._z,o=e._w,h=r+r,l=n+n,u=a+a,c=r*h,p=r*l,d=r*u,m=n*l,f=n*u,g=a*u,y=o*h,x=o*l,b=o*u,v=i.x,w=i.y,M=i.z;return s[0]=(1-(m+g))*v,s[1]=(p+b)*v,s[2]=(d-x)*v,s[3]=0,s[4]=(p-b)*w,s[5]=(1-(c+g))*w,s[6]=(f+y)*w,s[7]=0,s[8]=(d+x)*M,s[9]=(f-y)*M,s[10]=(1-(c+m))*M,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){let s=this.elements;if(t.x=s[12],t.y=s[13],t.z=s[14],0===this.determinant())return i.set(1,1,1),e.identity(),this;let r=tJ.set(s[0],s[1],s[2]).length(),n=tJ.set(s[4],s[5],s[6]).length(),a=tJ.set(s[8],s[9],s[10]).length();0>this.determinant()&&(r=-r),tX.copy(this);let o=1/r,h=1/n,l=1/a;return tX.elements[0]*=o,tX.elements[1]*=o,tX.elements[2]*=o,tX.elements[4]*=h,tX.elements[5]*=h,tX.elements[6]*=h,tX.elements[8]*=l,tX.elements[9]*=l,tX.elements[10]*=l,e.setFromRotationMatrix(tX),i.x=r,i.y=n,i.z=a,this}makePerspective(t,e,i,s,r,n,a=2e3,o=!1){let h,l,u=this.elements;if(o)h=r/(n-r),l=n*r/(n-r);else if(2e3===a)h=-(n+r)/(n-r),l=-2*n*r/(n-r);else if(2001===a)h=-n/(n-r),l=-n*r/(n-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return u[0]=2*r/(e-t),u[4]=0,u[8]=(e+t)/(e-t),u[12]=0,u[1]=0,u[5]=2*r/(i-s),u[9]=(i+s)/(i-s),u[13]=0,u[2]=0,u[6]=0,u[10]=h,u[14]=l,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(t,e,i,s,r,n,a=2e3,o=!1){let h,l,u=this.elements;if(o)h=1/(n-r),l=n/(n-r);else if(2e3===a)h=-2/(n-r),l=-(n+r)/(n-r);else if(2001===a)h=-1/(n-r),l=-r/(n-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return u[0]=2/(e-t),u[4]=0,u[8]=0,u[12]=-(e+t)/(e-t),u[1]=0,u[5]=2/(i-s),u[9]=0,u[13]=-(i+s)/(i-s),u[2]=0,u[6]=0,u[10]=h,u[14]=l,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(t){let e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}let tJ=new Z,tX=new tH,tZ=new Z(0,0,0),tY=new Z(1,1,1),tQ=new Z,tK=new Z,t0=new Z,t1=new tH,t2=new X;class t3{constructor(t=0,e=0,i=0,s=t3.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){let s=t.elements,r=s[0],n=s[4],a=s[8],o=s[1],h=s[5],l=s[9],u=s[2],c=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(j(a,-1,1)),.9999999>Math.abs(a)?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(c,h),this._z=0);break;case"YXZ":this._x=Math.asin(-j(l,-1,1)),.9999999>Math.abs(l)?(this._y=Math.atan2(a,p),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(j(c,-1,1)),.9999999>Math.abs(c)?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-j(u,-1,1)),.9999999>Math.abs(u)?(this._x=Math.atan2(c,p),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(j(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-j(n,-1,1)),.9999999>Math.abs(n)?(this._x=Math.atan2(c,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,p),this._y=0);break;default:R("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return t1.makeRotationFromQuaternion(t),this.setFromRotationMatrix(t1,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return t2.setFromEuler(this),this.setFromQuaternion(t2,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}t3.DEFAULT_ORDER="XYZ";class t5{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(t=>({...t})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(s.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){let i=e.shapes;if(Array.isArray(i))for(let e=0,s=i.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(i.geometries=e),s.length>0&&(i.materials=s),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l),u.length>0&&(i.nodes=u)}return i.object=s,i;function n(t){let e=[];for(let i in t){let s=t[i];delete s.metadata,e.push(s)}return e}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,i,s,r){ec.subVectors(s,e),ep.subVectors(i,e),ed.subVectors(t,e);let n=ec.dot(ec),a=ec.dot(ep),o=ec.dot(ed),h=ep.dot(ep),l=ep.dot(ed),u=n*h-a*a;if(0===u)return r.set(0,0,0),null;let c=1/u,p=(h*o-a*l)*c,d=(n*l-a*o)*c;return r.set(1-p-d,d,p)}static containsPoint(t,e,i,s){return null!==this.getBarycoord(t,e,i,s,em)&&em.x>=0&&em.y>=0&&em.x+em.y<=1}static getInterpolation(t,e,i,s,r,n,a,o){return null===this.getBarycoord(t,e,i,s,em)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,em.x),o.addScaledVector(n,em.y),o.addScaledVector(a,em.z),o)}static getInterpolatedAttribute(t,e,i,s,r,n){return ew.setScalar(0),eM.setScalar(0),eS.setScalar(0),ew.fromBufferAttribute(t,e),eM.fromBufferAttribute(t,i),eS.fromBufferAttribute(t,s),n.setScalar(0),n.addScaledVector(ew,r.x),n.addScaledVector(eM,r.y),n.addScaledVector(eS,r.z),n}static isFrontFacing(t,e,i,s){return ec.subVectors(i,e),ep.subVectors(t,e),0>ec.cross(ep).dot(s)}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ec.subVectors(this.c,this.b),ep.subVectors(this.a,this.b),.5*ec.cross(ep).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return eA.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return eA.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,r){return eA.getInterpolation(t,this.a,this.b,this.c,e,i,s,r)}containsPoint(t){return eA.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return eA.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let i,s,r=this.a,n=this.b,a=this.c;ef.subVectors(n,r),eg.subVectors(a,r),ex.subVectors(t,r);let o=ef.dot(ex),h=eg.dot(ex);if(o<=0&&h<=0)return e.copy(r);eb.subVectors(t,n);let l=ef.dot(eb),u=eg.dot(eb);if(l>=0&&u<=l)return e.copy(n);let c=o*u-l*h;if(c<=0&&o>=0&&l<=0)return i=o/(o-l),e.copy(r).addScaledVector(ef,i);ev.subVectors(t,a);let p=ef.dot(ev),d=eg.dot(ev);if(d>=0&&p<=d)return e.copy(a);let m=p*h-o*d;if(m<=0&&h>=0&&d<=0)return s=h/(h-d),e.copy(r).addScaledVector(eg,s);let f=l*d-p*u;if(f<=0&&u-l>=0&&p-d>=0)return ey.subVectors(a,n),s=(u-l)/(u-l+(p-d)),e.copy(n).addScaledVector(ey,s);let g=1/(f+m+c);return i=m*g,s=c*g,e.copy(r).addScaledVector(ef,i).addScaledVector(eg,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let e_={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},eC={h:0,s:0,l:0},eT={h:0,s:0,l:0};function eI(t,e,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?t+(e-t)*6*i:i<.5?e:i<2/3?t+(e-t)*6*(2/3-i):t}class ez{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){return void 0===e&&void 0===i?t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t):this.setRGB(t,e,i),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=m){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ts.colorSpaceToWorking(this,e),this}setRGB(t,e,i,s=ts.workingColorSpace){return this.r=t,this.g=e,this.b=i,ts.colorSpaceToWorking(this,s),this}setHSL(t,e,i,s=ts.workingColorSpace){if(t=U(t,1),e=j(e,0,1),i=j(i,0,1),0===e)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=eI(r,s,t+1/3),this.g=eI(r,s,t),this.b=eI(r,s,t-1/3)}return ts.colorSpaceToWorking(this,s),this}setStyle(t,e=m){let i;function s(e){void 0!==e&&1>parseFloat(e)&&R("Color: Alpha component of "+t+" will be ignored.")}if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,n=i[1],a=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:R("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],r=s.length;if(3===r)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(s,16),e);R("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=m){let i=e_[t.toLowerCase()];return void 0!==i?this.setHex(i,e):R("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=tr(t.r),this.g=tr(t.g),this.b=tr(t.b),this}copyLinearToSRGB(t){return this.r=tn(t.r),this.g=tn(t.g),this.b=tn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=m){return ts.workingToColorSpace(ek.copy(this),t),65536*Math.round(j(255*ek.r,0,255))+256*Math.round(j(255*ek.g,0,255))+Math.round(j(255*ek.b,0,255))}getHexString(t=m){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ts.workingColorSpace){let i,s;ts.workingToColorSpace(ek.copy(this),e);let r=ek.r,n=ek.g,a=ek.b,o=Math.max(r,n,a),h=Math.min(r,n,a),l=(h+o)/2;if(h===o)i=0,s=0;else{let t=o-h;switch(s=l<=.5?t/(o+h):t/(2-o-h),o){case r:i=(n-a)/t+6*(n0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(let e in t){let i=t[e];if(void 0===i){R(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(void 0===s){R(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){let e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function s(t){let e=[];for(let i in t){let s=t[i];delete s.metadata,e.push(s)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(i.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(i.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){let e=s(t.textures),r=s(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,i=null;if(null!==e){let t=e.length;i=Array(t);for(let s=0;s!==t;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class eO extends eR{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ez(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}let eE=function(){let t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),s=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){let e=t-127;e<-27?(s[t]=0,s[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(s[t]=1024>>-e-14,s[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(s[t]=e+15<<10,s[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(s[t]=31744,s[256|t]=64512,r[t]=24,r[256|t]=24):(s[t]=31744,s[256|t]=64512,r[t]=13,r[256|t]=13)}let n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;(8388608&e)==0;)e<<=1,i-=8388608;e&=-8388609,i+=0x38800000,n[t]=e|i}for(let t=1024;t<2048;++t)n[t]=0x38000000+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=0x47800000,a[32]=0x80000000;for(let t=33;t<63;++t)a[t]=0x80000000+(t-32<<23);a[63]=0xc7800000;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:s,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}();function eP(t){Math.abs(t)>65504&&R("DataUtils.toHalfFloat(): Value out of range."),t=j(t,-65504,65504),eE.floatView[0]=t;let e=eE.uint32View[0],i=e>>23&511;return eE.baseTable[i]+((8388607&e)>>eE.shiftTable[i])}function eL(t){let e=t>>10;return eE.uint32View[0]=eE.mantissaTable[eE.offsetTable[e]+(1023&t)]+eE.exponentTable[e],eE.floatView[0]}class eN{static toHalfFloat(t){return eP(t)}static fromHalfFloat(t){return eL(t)}}let eF=new Z,e$=new J,eV=0;class eD{constructor(t,e,i=!1){if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eV++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,r=this.itemSize;se.count&&R("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tv);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){O("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Z(-1/0,-1/0,-1/0),new Z(Infinity,Infinity,Infinity));return}if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){let e=this.parameters;for(let i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};let e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let i=this.attributes;for(let e in i){let s=i[e];t.data.attributes[e]=s.toJSON(t.data)}let s={},r=!1;for(let e in this.morphAttributes){let i=this.morphAttributes[e],n=[];for(let e=0,s=i.length;e0&&(s[e]=n,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let n=this.groups;n.length>0&&(t.data.groups=JSON.parse(JSON.stringify(n)));let a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let i=t.index;null!==i&&this.setIndex(i.clone());let s=t.attributes;for(let t in s){let i=s[t];this.setAttribute(t,i.clone(e))}let r=t.morphAttributes;for(let t in r){let i=[],s=r[t];for(let t=0,r=s.length;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)||(e4.copy(r).invert(),e6.copy(t.ray).applyMatrix4(e4),(null===i.boundingBox||!1!==e6.intersectsBox(i.boundingBox))&&this._computeIntersections(t,e,e6)))}_computeIntersections(t,e,i){let s,r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,c=r.groups,p=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,o=c.length;ri.far?null:{distance:h,point:ia.clone(),object:t}}(t,e,i,s,e7,it,ie,ir);if(u){let t=new Z;eA.getBarycoord(ir,e7,it,ie,t),r&&(u.uv=eA.getInterpolatedAttribute(r,o,h,l,t,new J)),n&&(u.uv1=eA.getInterpolatedAttribute(n,o,h,l,t,new J)),a&&(u.normal=eA.getInterpolatedAttribute(a,o,h,l,t,new Z),u.normal.dot(s.direction)>0&&u.normal.multiplyScalar(-1));let e={a:o,b:h,c:l,normal:new Z,materialIndex:0};eA.getNormal(e7,it,ie,e.normal),u.face=e,u.barycoord=t}return u}class il extends e5{constructor(t=1,e=1,i=1,s=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:r,depthSegments:n};const a=this;s=Math.floor(s),r=Math.floor(r);const o=[],h=[],l=[],u=[];let c=0,p=0;function d(t,e,i,s,r,n,d,m,f,g,y){let x=n/f,b=d/g,v=n/2,w=d/2,M=m/2,S=f+1,A=g+1,_=0,C=0,T=new Z;for(let n=0;n0?1:-1,l.push(T.x,T.y,T.z),u.push(o/f),u.push(1-n/g),_+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let i={};for(let t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class ig extends eu{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tH,this.projectionMatrix=new tH,this.projectionMatrixInverse=new tH,this.coordinateSystem=2e3,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}let iy=new Z,ix=new J,ib=new J;class iv extends ig{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=2*V*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(.5*$*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*V*Math.atan(Math.tan(.5*$*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){iy.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(iy.x,iy.y).multiplyScalar(-t/iy.z),iy.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(iy.x,iy.y).multiplyScalar(-t/iy.z)}getViewSize(t,e){return this.getViewBounds(t,ix,ib),e.subVectors(ib,ix)}setViewOffset(t,e,i,s,r,n){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(.5*$*this.fov)/this.zoom,i=2*e,s=this.aspect*i,r=-.5*s,n=this.view;if(null!==this.view&&this.view.enabled){let t=n.fullWidth,a=n.fullHeight;r+=n.offsetX*s/t,e-=n.offsetY*i/a,s*=n.width/t,i*=n.height/a}let a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-i,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class iw extends eu{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new iv(-90,1,t,e);s.layers=this.layers,this.add(s);const r=new iv(-90,1,t,e);r.layers=this.layers,this.add(r);const n=new iv(-90,1,t,e);n.layers=this.layers,this.add(n);const a=new iv(-90,1,t,e);a.layers=this.layers,this.add(a);const o=new iv(-90,1,t,e);o.layers=this.layers,this.add(o);const h=new iv(-90,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[i,s,r,n,a,o]=e;for(let t of e)this.remove(t);if(2e3===t)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===t)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,n,a,o,h,l]=this.children,u=t.getRenderTarget(),c=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),d=t.xr.enabled;t.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,r),t.setRenderTarget(i,1,s),t.render(e,n),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,l),t.setRenderTarget(u,c,p),t.xr.enabled=d,i.texture.needsPMREMUpdate=!0}}class iM extends tp{constructor(t=[],e=301,i,s,r,n,a,o,h,l){super(t,e,i,s,r,n,a,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class iS extends tf{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1};this.texture=new iM([i,i,i,i,i,i]),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `,fragmentShader:` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - `},s=new il(5,5,5),r=new im({name:"CubemapFromEquirect",uniforms:iu(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;let n=new io(s,r),a=e.minFilter;return 1008===e.minFilter&&(e.minFilter=1006),new iw(1,10,this).update(t,n),e.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(t,e=!0,i=!0,s=!0){let r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(r)}}class iA extends eu{constructor(){super(),this.isGroup=!0,this.type="Group"}}let i_={type:"move"};class iC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new iA,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new iA,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Z),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new iA,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Z),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let s=null,r=null,n=null,a=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){for(let s of(n=!0,t.hand.values())){let t=e.getJointPose(s,i),r=this._getHandJoint(h,s);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}let s=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=s.position.distanceTo(r.position);h.inputState.pinching&&a>.025?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&a<=.015&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&null!==(r=e.getPose(t.gripSpace,i))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1);null!==a&&(null===(s=e.getPose(t.targetRaySpace,i))&&null!==r&&(s=r),null!==s&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(i_)))}return null!==a&&(a.visible=null!==s),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==n),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){let i=new iA;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class iT{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ez(t),this.density=e}clone(){return new iT(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class iI{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new ez(t),this.near=e,this.far=i}clone(){return new iI(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class iz extends eu{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new t3,this.environmentIntensity=1,this.environmentRotation=new t3,this.overrideMaterial=null,"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ik{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=D()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let s=0,r=this.stride;st.far||e.push({distance:o,point:iE.clone(),uv:eA.getInterpolation(iE,iV,iD,ij,iU,iW,iG,new J),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function iH(t,e,i,s,r,n){iN.subVectors(t,i).addScalar(.5).multiply(s),void 0!==r?(iF.x=n*iN.x-r*iN.y,iF.y=r*iN.x+n*iN.y):iF.copy(iN),t.copy(e),t.x+=iF.x,t.y+=iF.y,t.applyMatrix4(i$)}let iJ=new Z,iX=new Z;class iZ extends eu{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let t=0,i=e.length;t0){let i,s;for(i=1,s=e.length;i0){iJ.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(iJ);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){let i,s;iJ.setFromMatrixPosition(t.matrixWorld),iX.setFromMatrixPosition(this.matrixWorld);let r=iJ.distanceTo(iX)/t.zoom;for(i=1,e[0].object.visible=!0,s=e.length;i=t)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let i=e||sd.getNormalMatrix(t),s=this.coplanarPoint(sc).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}let sf=new tF,sg=new J(.5,.5),sy=new Z;class sx{constructor(t=new sm,e=new sm,i=new sm,s=new sm,r=new sm,n=new sm){this.planes=[t,e,i,s,r,n]}set(t,e,i,s,r,n){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(n),this}copy(t){let e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3,i=!1){let s=this.planes,r=t.elements,n=r[0],a=r[1],o=r[2],h=r[3],l=r[4],u=r[5],c=r[6],p=r[7],d=r[8],m=r[9],f=r[10],g=r[11],y=r[12],x=r[13],b=r[14],v=r[15];if(s[0].setComponents(h-n,p-l,g-d,v-y).normalize(),s[1].setComponents(h+n,p+l,g+d,v+y).normalize(),s[2].setComponents(h+a,p+u,g+m,v+x).normalize(),s[3].setComponents(h-a,p-u,g-m,v-x).normalize(),i)s[4].setComponents(o,c,f,b).normalize(),s[5].setComponents(h-o,p-c,g-f,v-b).normalize();else if(s[4].setComponents(h-o,p-c,g-f,v-b).normalize(),2e3===e)s[5].setComponents(h+o,p+c,g+f,v+b).normalize();else if(2001===e)s[5].setComponents(o,c,f,b).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),sf.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),sf.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(sf)}intersectsSprite(t){return sf.center.set(0,0,0),sf.radius=.7071067811865476+sg.distanceTo(t.center),sf.applyMatrix4(t.matrixWorld),this.intersectsSphere(sf)}intersectsSphere(t){let e=this.planes,i=t.center,s=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,sy.y=s.normal.y>0?t.max.y:t.min.y,sy.z=s.normal.z>0?t.max.z:t.min.z,0>s.distanceToPoint(sy))return!1}return!0}containsPoint(t){let e=this.planes;for(let i=0;i<6;i++)if(0>e[i].distanceToPoint(t))return!1;return!0}clone(){return new this.constructor().copy(this)}}let sb=new tH,sv=new sx;class sw{constructor(){this.coordinateSystem=2e3}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];n.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}},sP=new io,sL=[];function sN(t,e){if(t.constructor!==e.constructor){let i=Math.min(t.length,e.length);for(let s=0;s65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new eD(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let i in e.attributes){if(!t.hasAttribute(i))throw Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let s=t.getAttribute(i),r=e.getAttribute(i);if(s.itemSize!==r.itemSize||s.normalized!==r.normalized)throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){let e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){let e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tv);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw Error("THREE.BatchedMesh: Maximum item count reached.");let e={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(sM),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=e):(i=this._instanceInfo.length,this._instanceInfo.push(e));let s=this._matricesTexture;s_.identity().toArray(s.image.data,16*i),s.needsUpdate=!0;let r=this._colorsTexture;return r&&(sC.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,i=-1){let s;this._initializeGeometry(t),this._validateGeometry(t);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=-1===e?t.getAttribute("position").count:e;let a=t.getIndex();if(null!==a&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=-1===i?a.count:i),-1!==r.indexStart&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(sM),n[s=this._availableGeometryIds.shift()]=r):(s=this._geometryCount,this._geometryCount++,n.push(r)),this.setGeometryAt(s,t),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,s}setGeometryAt(t,e){if(t>=this._geometryCount)throw Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let i=this.geometry,s=null!==i.getIndex(),r=i.getIndex(),n=e.getIndex(),a=this._geometryInfo[t];if(s&&n.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let o=a.vertexStart,h=a.reservedVertexCount;for(let t in a.vertexCount=e.getAttribute("position").count,i.attributes){let s=e.getAttribute(t),r=i.getAttribute(t);!function(t,e,i=0){let s=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){let r=t.count;for(let n=0;n=e.length||!1===e[t].active)return this;let i=this._instanceInfo;for(let e=0,s=i.length;ee).sort((t,e)=>i[t].vertexStart-i[e].vertexStart),r=this.geometry;for(let n=0,a=i.length;n=this._geometryCount)return null;let i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingBox){let t=new tv,e=i.index,r=i.attributes.position;for(let i=s.start,n=s.start+s.count;i=this._geometryCount)return null;let i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingSphere){let e=new tF;this.getBoundingBoxAt(t,sz),sz.getCenter(e.center);let r=i.index,n=i.attributes.position,a=0;for(let t=s.start,i=s.start+s.count;tt.active);if(Math.max(...i.map(t=>t.vertexStart+t.reservedVertexCount))>t)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(t=>t.indexStart+t.reservedIndexCount))>e)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new e5,this._initializeGeometry(s));let r=this.geometry;for(let t in s.index&&sN(s.index.array,r.index.array),s.attributes)sN(s.attributes[t].array,r.attributes[t].array)}raycast(t,e){let i=this._instanceInfo,s=this._geometryInfo,r=this.matrixWorld,n=this.geometry;sP.material=this.material,sP.geometry.index=n.index,sP.geometry.attributes=n.attributes,null===sP.geometry.boundingBox&&(sP.geometry.boundingBox=new tv),null===sP.geometry.boundingSphere&&(sP.geometry.boundingSphere=new tF);for(let n=0,a=i.length;n({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(t=>({...t})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,i,s,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let n=s.getIndex(),a=null===n?1:n.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,u=this._geometryInfo,c=this.perObjectFrustumCulled,p=this._indirectTexture,d=p.image.data,m=i.isArrayCamera?sI:sT;c&&!i.isArrayCamera&&(s_.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),sT.setFromProjectionMatrix(s_,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){s_.copy(this.matrixWorld).invert(),sB.setFromMatrixPosition(i.matrixWorld).applyMatrix4(s_),sR.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(s_);for(let t=0,e=o.length;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ts)return;sG.applyMatrix4(t.matrixWorld);let h=e.ray.origin.distanceTo(sG);if(!(he.far))return{distance:h,point:sq.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}let sX=new Z,sZ=new Z;class sY extends sH{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(null===t.index){let e=t.attributes.position,i=[];for(let t=0,s=e.count;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class s6 extends tp{constructor(t,e,i,s,r=1006,n=1006,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const l=this;"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(function e(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class s8 extends s6{constructor(t,e,i,s,r,n,a,o){super({},t,e,i,s,r,n,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class s9 extends tp{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class s7 extends tp{constructor(t,e,i,s,r,n,a,o,h,l,u,c){super(null,n,a,o,h,l,s,r,u,c),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rt extends s7{constructor(t,e,i,s,r,n){super(t,e,i,r,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class re extends s7{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ri extends tp{constructor(t,e,i,s,r,n,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rs extends tp{constructor(t,e,i=1014,s,r,n,a=1003,o=1003,h,l=1026,u=1){if(1026!==l&&1027!==l)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:u},s,r,n,a,o,l,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new th(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class rr extends rs{constructor(t,e=1014,i=301,s,r,n=1003,a=1003,o,h=1026){const l={width:t,height:t,depth:1};super(t,t,e,i,s,r,n,a,o,h),this.image=[l,l,l,l,l,l],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class rn extends tp{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class ra extends e5{constructor(t=1,e=1,i=4,s=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:i,radialSegments:s,heightSegments:r},e=Math.max(0,e),i=Math.max(1,Math.floor(i)),s=Math.max(3,Math.floor(s));const n=[],a=[],o=[],h=[],l=e/2,u=Math.PI/2*t,c=e,p=2*u+c,d=2*i+(r=Math.max(1,Math.floor(r))),m=s+1,f=new Z,g=new Z;for(let y=0;y<=d;y++){let x=0,b=0,v=0,w=0;if(y<=i){const e=y/i,s=e*Math.PI/2;b=-l-t*Math.cos(s),v=t*Math.sin(s),w=-t*Math.cos(s),x=e*u}else if(y<=i+r){const s=(y-i)/r;b=-l+s*e,v=t,w=0,x=u+s*c}else{const e=(y-i-r)/i,s=e*Math.PI/2;b=l+t*Math.sin(s),v=t*Math.cos(s),w=t*Math.sin(s),x=u+c+e*u}const M=Math.max(0,Math.min(1,x/p));let S=0;0===y?S=.5/s:y===d&&(S=-.5/s);for(let t=0;t<=s;t++){const e=t/s,i=e*Math.PI*2,r=Math.sin(i),n=Math.cos(i);g.x=-v*n,g.y=b,g.z=v*r,a.push(g.x,g.y,g.z),f.set(-v*n,w,v*r),f.normalize(),o.push(f.x,f.y,f.z),h.push(e+S,M)}if(y>0){const t=(y-1)*m;for(let e=0;e0||0!==s)&&(l.push(n,a,h),x+=3),(e>0||s!==r-1)&&(l.push(a,o,h),x+=3)}h.addGroup(g,x,0),g+=x})(),!1===n&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(l),this.setAttribute("position",new eZ(u,3)),this.setAttribute("normal",new eZ(c,3)),this.setAttribute("uv",new eZ(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rl extends rh{constructor(t=1,e=1,i=32,s=1,r=!1,n=0,a=2*Math.PI){super(0,t,e,i,s,r,n,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:n,thetaLength:a}}static fromJSON(t){return new rl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ru extends e5{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const r=[],n=[];function a(t){r.push(t.x,t.y,t.z)}function o(e,i){let s=3*e;i.x=t[s+0],i.y=t[s+1],i.z=t[s+2]}function h(t,e,i,s){s<0&&1===t.x&&(n[e]=t.x-1),0===i.x&&0===i.z&&(n[e]=s/2/Math.PI+.5)}function l(t){return Math.atan2(t.z,-t.x)}(function(t){let i=new Z,s=new Z,r=new Z;for(let n=0;n.9&&a<.1&&(e<.2&&(n[t+0]+=1),i<.2&&(n[t+2]+=1),s<.2&&(n[t+4]+=1))}}()}(),this.setAttribute("position",new eZ(r,3)),this.setAttribute("normal",new eZ(r.slice(),3)),this.setAttribute("uv",new eZ(n,2)),0===s?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ru(t.vertices,t.indices,t.radius,t.detail)}}class rc extends ru{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new rc(t.radius,t.detail)}}let rp=new Z,rd=new Z,rm=new Z,rf=new eA;class rg extends e5{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=Math.cos($*e),s=t.getIndex(),r=t.getAttribute("position"),n=s?s.count:r.count,a=[0,0,0],o=["a","b","c"],h=[,,,],l={},u=[];for(let t=0;t0)o=r-1;else{o=r;break}if(s[r=o]===i)return r/(n-1);let l=s[r],u=s[r+1];return(r+(i-l)/(u-l))/(n-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let r=this.getPoint(i),n=this.getPoint(s),a=e||(r.isVector2?new J:new Z);return a.copy(n).sub(r).normalize(),a}getTangentAt(t,e){let i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){let i=new Z,s=[],r=[],n=[],a=new Z,o=new tH;for(let e=0;e<=t;e++){let i=e/t;s[e]=this.getTangentAt(i,new Z)}r[0]=new Z,n[0]=new Z;let h=Number.MAX_VALUE,l=Math.abs(s[0].x),u=Math.abs(s[0].y),c=Math.abs(s[0].z);l<=h&&(h=l,i.set(1,0,0)),u<=h&&(h=u,i.set(0,1,0)),c<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],a),n[0].crossVectors(s[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),n[e]=n[e-1].clone(),a.crossVectors(s[e-1],s[e]),a.length()>Number.EPSILON){a.normalize();let t=Math.acos(j(s[e-1].dot(s[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}n[e].crossVectors(s[e],r[e])}if(!0===e){let e=Math.acos(j(r[0].dot(r[t]),-1,1));e/=t,s[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(s[i],e*i)),n[i].crossVectors(s[i],r[i])}return{tangents:s,normals:r,binormals:n}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class rx extends ry{constructor(t=0,e=0,i=1,s=1,r=0,n=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new J){let i=2*Math.PI,s=this.aEndAngle-this.aStartAngle,r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/n)+1)*n:0===h&&o===n-1&&(o=n-2,h=1),this.closed||o>0?i=r[(o-1)%n]:(rw.subVectors(r[0],r[1]).add(r[0]),i=rw);let l=r[o%n],u=r[(o+1)%n];if(this.closed||o+2i.length-2?i.length-1:r+1],l=i[r>i.length-3?i.length-1:r+2];return e.set(rC(n,a.x,o.x,h.x,l.x),rC(n,a.y,o.y,h.y,l.y)),e}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){let t=s[r]-i,n=this.curves[r],a=n.getLength(),o=0===a?0:1-t/a;return n.getPointAt(o,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let i=0,s=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){let t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);let l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class r$ extends rF{constructor(t){super(t),this.uuid=D(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let i=0,s=this.holes.length;i0)for(let r=e;r=e;r-=s)n=rK(r/s|0,t[r],t[r+1],n);return n&&rH(n,n.next)&&(r0(n),n=n.next),n}function rD(t,e){if(!t)return t;e||(e=t);let i=t,s;do if(s=!1,!i.steiner&&(rH(i,i.next)||0===rq(i.prev,i,i.next))){if(r0(i),(i=e=i.prev)===i.next)break;s=!0}else i=i.next;while(s||i!==e)return e}function rj(t,e){let i=t.x-e.x;return 0===i&&0==(i=t.y-e.y)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function rU(t,e,i,s,r){return(t=((t=((t=((t=((t=(t-i)*r|0)|t<<8)&0xff00ff)|t<<4)&0xf0f0f0f)|t<<2)&0x33333333)|t<<1)&0x55555555)|(e=((e=((e=((e=((e=(e-s)*r|0)|e<<8)&0xff00ff)|e<<4)&0xf0f0f0f)|e<<2)&0x33333333)|e<<1)&0x55555555)<<1}function rW(t,e,i,s,r,n,a,o){return(r-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(s-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(r-a)*(s-o)}function rG(t,e,i,s,r,n,a,o){return(t!==a||e!==o)&&rW(t,e,i,s,r,n,a,o)}function rq(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function rH(t,e){return t.x===e.x&&t.y===e.y}function rJ(t,e,i,s){let r=rZ(rq(t,e,i)),n=rZ(rq(t,e,s)),a=rZ(rq(i,s,t)),o=rZ(rq(i,s,e));return!!(r!==n&&a!==o||0===r&&rX(t,i,e)||0===n&&rX(t,s,e)||0===a&&rX(i,t,s)||0===o&&rX(i,e,s))}function rX(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function rZ(t){return t>0?1:t<0?-1:0}function rY(t,e){return 0>rq(t.prev,t,t.next)?rq(t,e,t.next)>=0&&rq(t,t.prev,e)>=0:0>rq(t,e,t.prev)||0>rq(t,t.next,e)}function rQ(t,e){let i=r1(t.i,t.x,t.y),s=r1(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function rK(t,e,i,s){let r=r1(t,e,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function r0(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function r1(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class r2{static triangulate(t,e,i=2){return function(t,e,i=2){let s,r,n,a=e&&e.length,o=a?e[0]*i:t.length,h=rV(t,0,o,i,!0),l=[];if(!h||h.next===h.prev)return l;if(a&&(h=function(t,e,i,s){let r=[];for(let i=0,n=e.length;i=s.next.y&&s.next.y!==s.y){let t=s.x+(n-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=r&&t>a&&(a=t,i=s.x=s.x&&s.x>=h&&r!==s.x&&rW(ni.x||s.x===i.x&&(c=i,p=s,0>rq(c.prev,c,p.prev)&&0>rq(p.next,c,c.next))))&&(i=s,u=e)}s=s.next}while(s!==o)return i}(t,e);if(!i)return e;let s=rQ(i,t);return rD(s,s.next),rD(i,i.next)}(r[t],i);return i}(t,e,h,i)),t.length>80*i){s=t[0],r=t[1];let e=s,a=r;for(let n=i;ne&&(e=i),o>a&&(a=o)}n=0!==(n=Math.max(e-s,a-r))?32767/n:0}return function t(e,i,s,r,n,a,o){if(!e)return;!o&&a&&function(t,e,i,s){let r=t;do 0===r.z&&(r.z=rU(r.x,r.y,e,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==t)r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let s,r=t;t=null;let n=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t0||h>0&&a;)0!==o&&(0===h||!a||r.z<=a.z)?(s=r,r=r.nextZ,o--):(s=a,a=a.nextZ,h--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=a}n.nextZ=null,i*=2}while(e>1)}(r)}(e,r,n,a);let h=e;for(;e.prev!==e.next;){let l=e.prev,u=e.next;if(a?function(t,e,i,s){let r=t.prev,n=t.next;if(rq(r,t,n)>=0)return!1;let a=r.x,o=t.x,h=n.x,l=r.y,u=t.y,c=n.y,p=Math.min(a,o,h),d=Math.min(l,u,c),m=Math.max(a,o,h),f=Math.max(l,u,c),g=rU(p,d,e,i,s),y=rU(m,f,e,i,s),x=t.prevZ,b=t.nextZ;for(;x&&x.z>=g&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=f&&x!==r&&x!==n&&rG(a,l,o,u,h,c,x.x,x.y)&&rq(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=d&&b.y<=f&&b!==r&&b!==n&&rG(a,l,o,u,h,c,b.x,b.y)&&rq(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=f&&x!==r&&x!==n&&rG(a,l,o,u,h,c,x.x,x.y)&&rq(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=d&&b.y<=f&&b!==r&&b!==n&&rG(a,l,o,u,h,c,b.x,b.y)&&rq(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}(e,r,n,a):function(t){let e=t.prev,i=t.next;if(rq(e,t,i)>=0)return!1;let s=e.x,r=t.x,n=i.x,a=e.y,o=t.y,h=i.y,l=Math.min(s,r,n),u=Math.min(a,o,h),c=Math.max(s,r,n),p=Math.max(a,o,h),d=i.next;for(;d!==e;){if(d.x>=l&&d.x<=c&&d.y>=u&&d.y<=p&&rG(s,a,r,o,n,h,d.x,d.y)&&rq(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}(e)){i.push(l.i,e.i,u.i),r0(e),e=u.next,h=u.next;continue}if((e=u)===h){o?1===o?t(e=function(t,e){let i=t;do{let s=i.prev,r=i.next.next;!rH(s,r)&&rJ(s,i,i.next,r)&&rY(s,r)&&rY(r,s)&&(e.push(s.i,i.i,r.i),r0(i),r0(i.next),i=t=r),i=i.next}while(i!==t)return rD(i)}(rD(e),i),i,s,r,n,a,2):2===o&&function(e,i,s,r,n,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){var h,l;if(o.i!==e.i&&(h=o,l=e,h.next.i!==l.i&&h.prev.i!==l.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&rJ(i,i.next,t,e))return!0;i=i.next}while(i!==t)return!1}(h,l)&&(rY(h,l)&&rY(l,h)&&function(t,e){let i=t,s=!1,r=(t.x+e.x)/2,n=(t.y+e.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next;while(i!==t)return s}(h,l)&&(rq(h.prev,h,l.prev)||rq(h,l.prev,l))||rH(h,l)&&rq(h.prev,h,h.next)>0&&rq(l.prev,l,l.next)>0))){let h=rQ(o,e);o=rD(o,o.next),h=rD(h,h.next),t(o,i,s,r,n,a,0),t(h,i,s,r,n,a,0);return}e=e.next}o=o.next}while(o!==e)}(e,i,s,r,n,a):t(rD(e),i,s,r,n,a,1);break}}}(h,l,i,s,r,n,0),l}(t,e,i)}}class r3{static area(t){let e=t.length,i=0;for(let s=e-1,r=0;rr3.area(t)}static triangulateShape(t,e){let i=[],s=[],r=[];r5(t),r4(i,t);let n=t.length;e.forEach(r5);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function r4(t,e){for(let i=0;iNumber.EPSILON){let c=Math.sqrt(u),p=Math.sqrt(h*h+l*l),d=e.x-o/c,m=e.y+a/c,f=((i.x-l/p-d)*l-(i.y+h/p-m)*h)/(a*l-o*h),g=(s=d+a*f-t.x)*s+(r=m+o*f-t.y)*r;if(g<=2)return new J(s,r);n=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?h>Number.EPSILON&&(t=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(l)&&(t=!0),t?(s=-o,r=a,n=Math.sqrt(u)):(s=a,r=o,n=Math.sqrt(u/2))}return new J(s/n,r/n)}let R=[];for(let t=0,e=I.length,i=e-1,s=t+1;t=0;t--){let e=t/x,i=f*Math.cos(e*Math.PI/2),s=g*Math.sin(e*Math.PI/2)+y;for(let t=0,e=I.length;t=0;){let n=r,a=r-1;a<0&&(a=t.length-1);for(let t=0,r=p+2*x;t0)&&p.push(e,r,h),(t!==i-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class ng extends eR{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ez(0xffffff),this.specular=new ez(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ny extends eR{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ez(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class nx extends eR{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class nb extends eR{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ez(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nv extends eR{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class nw extends eR{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class nM extends eR{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ez(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nS extends s${constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function nA(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function n_(t){let e=t.length,i=Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort(function(e,i){return t[e]-t[i]}),i}function nC(t,e,i){let s=t.length,r=new t.constructor(s);for(let n=0,a=0;a!==s;++n){let s=i[n]*e;for(let i=0;i!==e;++i)r[a++]=t[s+i]}return r}function nT(t,e,i,s){let r=1,n=t[0];for(;void 0!==n&&void 0===n[s];)n=t[r++];if(void 0===n)return;let a=n[s];if(void 0!==a)if(Array.isArray(a))do void 0!==(a=n[s])&&(e.push(n.time),i.push(...a)),n=t[r++];while(void 0!==n)else if(void 0!==a.toArray)do void 0!==(a=n[s])&&(e.push(n.time),a.toArray(i,i.length)),n=t[r++];while(void 0!==n)else do void 0!==(a=n[s])&&(e.push(n.time),i.push(a)),n=t[r++];while(void 0!==n)}class nI{static convertArray(t,e){return nA(t,e)}static isTypedArray(t){return A(t)}static getKeyframeOrder(t){return n_(t)}static sortedArray(t,e,i){return nC(t,e,i)}static flattenJSON(t,e,i,s){nT(t,e,i,s)}static subclip(t,e,i,s,r=30){return function(t,e,i,s,r=30){let n=t.clone();n.name=e;let a=[];for(let t=0;t=s)){h.push(e.times[t]);for(let i=0;in.tracks[t].times[0]&&(o=n.tracks[t].times[0]);for(let t=0;t=r.times[p]){let t=p*l+h,e=t+l-h;s=r.values.slice(t,e)}else{let t=r.createInterpolant(),e=h,i=l-h;t.evaluate(n),s=t.resultBuffer.slice(e,i)}"quaternion"===a&&new X().fromArray(s).normalize().conjugate().toArray(s);let d=o.times.length;for(let t=0;t=r)){let a=e[1];t=(r=e[--i-1]))break e}n=i,i=0;break i}break t}for(;i>>1;te;)--n;if(++n,0!==r||n!==s){r>=n&&(r=(n=Math.max(n,1))-1);let t=this.getValueSize();this.times=i.slice(r,n),this.values=this.values.slice(r*t,n*t)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(O("KeyframeTrack: Invalid value size in track.",this),t=!1);let i=this.times,s=this.values,r=i.length;0===r&&(O("KeyframeTrack: Track is empty.",this),t=!1);let n=null;for(let e=0;e!==r;e++){let s=i[e];if("number"==typeof s&&isNaN(s)){O("KeyframeTrack: Time is not a valid number.",this,e,s),t=!1;break}if(null!==n&&n>s){O("KeyframeTrack: Out of order keys.",this,e,s,n),t=!1;break}n=s}if(void 0!==s&&A(s))for(let e=0,i=s.length;e!==i;++e){let i=s[e];if(isNaN(i)){O("KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=2302===this.getInterpolation(),r=t.length-1,n=1;for(let a=1;a0){t[n]=t[r];for(let t=r*i,s=n*i,a=0;a!==i;++a)e[s+a]=e[t+a];++n}return n!==t.length?(this.times=t.slice(0,n),this.values=e.slice(0,n*i)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),i=new this.constructor(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}nO.prototype.ValueTypeName="",nO.prototype.TimeBufferType=Float32Array,nO.prototype.ValueBufferType=Float32Array,nO.prototype.DefaultInterpolation=2301;class nE extends nO{constructor(t,e,i){super(t,e,i)}}nE.prototype.ValueTypeName="bool",nE.prototype.ValueBufferType=Array,nE.prototype.DefaultInterpolation=2300,nE.prototype.InterpolantFactoryMethodLinear=void 0,nE.prototype.InterpolantFactoryMethodSmooth=void 0;class nP extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nP.prototype.ValueTypeName="color";class nL extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nL.prototype.ValueTypeName="number";class nN extends nz{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){let r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e),h=t*a;for(let t=h+a;h!==t;h+=4)X.slerpFlat(r,0,n,h-a,n,h,o);return r}}class nF extends nO{constructor(t,e,i,s){super(t,e,i,s)}InterpolantFactoryMethodLinear(t){return new nN(this.times,this.values,this.getValueSize(),t)}}nF.prototype.ValueTypeName="quaternion",nF.prototype.InterpolantFactoryMethodSmooth=void 0;class n$ extends nO{constructor(t,e,i){super(t,e,i)}}n$.prototype.ValueTypeName="string",n$.prototype.ValueBufferType=Array,n$.prototype.DefaultInterpolation=2300,n$.prototype.InterpolantFactoryMethodLinear=void 0,n$.prototype.InterpolantFactoryMethodSmooth=void 0;class nV extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nV.prototype.ValueTypeName="vector";class nD{constructor(t="",e=-1,i=[],s=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=D(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){let e=[],i=t.tracks,s=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push((function(t){if(void 0===t.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return nL;case"vector":case"vector2":case"vector3":case"vector4":return nV;case"color":return nP;case"quaternion":return nF;case"bool":case"boolean":return nE;case"string":return n$}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){let e=[],i=[];nT(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)})(i[t]).scale(s));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){let e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,s=i.length;t!==s;++t)e.push(nO.toJSON(i[t]));return s}static CreateFromMorphTargetSequence(t,e,i,s){let r=e.length,n=[];for(let t=0;t1){let t=n[1],e=s[t];e||(s[t]=e=[]),e.push(i)}}let n=[];for(let t in s)n.push(this.CreateFromMorphTargetSequence(t,s[t],e,i));return n}static parseAnimation(t,e){if(R("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return O("AnimationClip: No animation in JSONLoader data."),null;let i=function(t,e,i,s,r){if(0!==i.length){let n=[],a=[];nT(i,n,a,s),0!==n.length&&r.push(new t(e,n,a))}},s=[],r=t.name||"default",n=t.fps||30,a=t.blendMode,o=t.length||-1,h=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)},0),r;if(void 0!==nq[t])return void nq[t].push({onLoad:e,onProgress:i,onError:s});nq[t]=[],nq[t].push({onLoad:e,onProgress:i,onError:s});let n=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(n).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&R("FileLoader: HTTP Status 0 received."),"u"{if(s)t.close();else{let s=new ProgressEvent("progress",{lengthComputable:a,loaded:o+=r.byteLength,total:n});for(let t=0,e=i.length;t{t.error(e)})}()}}))}throw new nH(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>new DOMParser().parseFromString(t,a));case"json":return t.json();default:if(""===a)return t.text();{let e=/charset="?([^;"\s]*)"?/i.exec(a),i=new TextDecoder(e&&e[1]?e[1].toLowerCase():void 0);return t.arrayBuffer().then(t=>i.decode(t))}}}).then(e=>{nj.add(`file:${t}`,e);let i=nq[t];delete nq[t];for(let t=0,s=i.length;t{let i=nq[t];if(void 0===i)throw this.manager.itemError(t),e;delete nq[t];for(let t=0,s=i.length;t{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class nX extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):O(e),r.manager.itemError(t)}},i,s)}parse(t){let e=[];for(let i=0;i0:s.vertexColors=t.vertexColors),void 0!==t.uniforms)for(let e in t.uniforms){let r=t.uniforms[e];switch(s.uniforms[e]={},r.type){case"t":s.uniforms[e].value=i(r.value);break;case"c":s.uniforms[e].value=new ez().setHex(r.value);break;case"v2":s.uniforms[e].value=new J().fromArray(r.value);break;case"v3":s.uniforms[e].value=new Z().fromArray(r.value);break;case"v4":s.uniforms[e].value=new td().fromArray(r.value);break;case"m3":s.uniforms[e].value=new K().fromArray(r.value);break;case"m4":s.uniforms[e].value=new tH().fromArray(r.value);break;default:s.uniforms[e].value=r.value}}if(void 0!==t.defines&&(s.defines=t.defines),void 0!==t.vertexShader&&(s.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(s.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(s.glslVersion=t.glslVersion),void 0!==t.extensions)for(let e in t.extensions)s.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(s.lights=t.lights),void 0!==t.clipping&&(s.clipping=t.clipping),void 0!==t.size&&(s.size=t.size),void 0!==t.sizeAttenuation&&(s.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(s.map=i(t.map)),void 0!==t.matcap&&(s.matcap=i(t.matcap)),void 0!==t.alphaMap&&(s.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(s.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(s.bumpScale=t.bumpScale),void 0!==t.normalMap&&(s.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(s.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),s.normalScale=new J().fromArray(e)}return void 0!==t.displacementMap&&(s.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(s.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(s.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(s.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(s.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(s.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(s.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(s.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(s.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(s.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(s.envMap=i(t.envMap)),void 0!==t.envMapRotation&&s.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(s.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(s.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(s.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(s.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(s.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(s.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(s.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(s.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(s.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(s.clearcoatNormalScale=new J().fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(s.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(s.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(s.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(s.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(s.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return al.createMaterialFromType(t)}static createMaterialFromType(t){return new({ShadowMaterial:np,SpriteMaterial:iO,RawShaderMaterial:nd,ShaderMaterial:im,PointsMaterial:sK,MeshPhysicalMaterial:nf,MeshStandardMaterial:nm,MeshPhongMaterial:ng,MeshToonMaterial:ny,MeshNormalMaterial:nx,MeshLambertMaterial:nb,MeshDepthMaterial:nv,MeshDistanceMaterial:nw,MeshBasicMaterial:eO,MeshMatcapMaterial:nM,LineDashedMaterial:nS,LineBasicMaterial:s$,Material:eR})[t]}}class au{static extractUrlBase(t){let e=t.lastIndexOf("/");return -1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t))?t:e+t}}class ac extends e5{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class ap extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):O(e),r.manager.itemError(t)}},i,s)}parse(t){let e={},i={};function s(t,s){if(void 0!==e[s])return e[s];let r=t.interleavedBuffers[s],n=function(t,e){if(void 0!==i[e])return i[e];let s=new Uint32Array(t.arrayBuffers[e]).buffer;return i[e]=s,s}(t,r.buffer),a=new ik(S(r.type,n),r.stride);return a.uuid=r.uuid,e[s]=a,a}let r=t.isInstancedBufferGeometry?new ac:new e5,n=t.data.index;if(void 0!==n){let t=S(n.type,n.array);r.setIndex(new eD(t,1))}let a=t.data.attributes;for(let e in a){let i,n=a[e];if(n.isInterleavedBufferAttribute)i=new iR(s(t.data,n.data),n.itemSize,n.offset,n.normalized);else{let t=S(n.type,n.array);i=new(n.isInstancedBufferAttribute?si:eD)(t,n.itemSize,n.normalized)}void 0!==n.name&&(i.name=n.name),void 0!==n.usage&&i.setUsage(n.usage),r.setAttribute(e,i)}let o=t.data.morphAttributes;if(o)for(let e in o){let i=o[e],n=[];for(let e=0,r=i.length;e0){(i=new nQ(new nU(e))).setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){(e=new nQ(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{let e=null,i=null;return void 0!==t.boundingBox&&(e=new tv().fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=new tF().fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),n._instanceInfo=t.instanceInfo,n._availableInstanceIds=t._availableInstanceIds,n._availableGeometryIds=t._availableGeometryIds,n._nextIndexStart=t.nextIndexStart,n._nextVertexStart=t.nextVertexStart,n._geometryCount=t.geometryCount,n._maxInstanceCount=t.maxInstanceCount,n._maxVertexCount=t.maxVertexCount,n._maxIndexCount=t.maxIndexCount,n._geometryInitialized=t.geometryInitialized,n._matricesTexture=u(t.matricesTexture.uuid),n._indirectTexture=u(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(n._colorsTexture=u(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(n.boundingSphere=new tF().fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(n.boundingBox=new tv().fromJSON(t.boundingBox));break;case"LOD":n=new iZ;break;case"Line":n=new sH(h(t.geometry),l(t.material));break;case"LineLoop":n=new sQ(h(t.geometry),l(t.material));break;case"LineSegments":n=new sY(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":n=new s5(h(t.geometry),l(t.material));break;case"Sprite":n=new iq(l(t.material));break;case"Group":n=new iA;break;case"Bone":n=new i8;break;default:n=new eu}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.up&&n.up.fromArray(t.up),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(n.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(n.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children){let a=t.children;for(let t=0;t{if(!0!==ay.has(n))return e&&e(i),r.manager.itemEnd(t),i;s&&s(ay.get(n)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(n),r.manager.itemEnd(t)},0),n);let a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){return nj.add(`image-bitmap:${t}`,i),e&&e(i),r.manager.itemEnd(t),i}).catch(function(e){s&&s(e),ay.set(o,e),nj.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});nj.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ab{static getContext(){return void 0===s&&(s=new(window.AudioContext||window.webkitAudioContext)),s}static setContext(t){s=t}}class av extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(this.manager);function a(e){s?s(e):O(e),r.manager.itemError(t)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(t){try{let i=t.slice(0);ab.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,s)}}let aw=new tH,aM=new tH,aS=new tH;class aA{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new iv,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new iv,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){let i,s;e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,aS.copy(t.projectionMatrix);let r=e.eyeSep/2,n=r*e.near/e.focus,a=e.near*Math.tan($*e.fov*.5)/e.zoom;aM.elements[12]=-r,aw.elements[12]=r,i=-a*e.aspect+n,s=a*e.aspect+n,aS.elements[0]=2*e.near/(s-i),aS.elements[8]=(s+i)/(s-i),this.cameraL.projectionMatrix.copy(aS),i=-a*e.aspect-n,s=a*e.aspect-n,aS.elements[0]=2*e.near/(s-i),aS.elements[8]=(s+i)/(s-i),this.cameraR.projectionMatrix.copy(aS)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(aM),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(aw)}}class a_ extends iv{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class aC{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}let aT=new Z,aI=new X,az=new Z,ak=new Z,aB=new Z;class aR extends eu{constructor(){super(),this.type="AudioListener",this.context=ab.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new aC}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(aT,aI,az),ak.set(0,0,-1).applyQuaternion(aI),aB.set(0,1,0).applyQuaternion(aI),e.positionX){let t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(aT.x,t),e.positionY.linearRampToValueAtTime(aT.y,t),e.positionZ.linearRampToValueAtTime(aT.z,t),e.forwardX.linearRampToValueAtTime(ak.x,t),e.forwardY.linearRampToValueAtTime(ak.y,t),e.forwardZ.linearRampToValueAtTime(ak.z,t),e.upX.linearRampToValueAtTime(aB.x,t),e.upY.linearRampToValueAtTime(aB.y,t),e.upZ.linearRampToValueAtTime(aB.z,t)}else e.setPosition(aT.x,aT.y,aT.z),e.setOrientation(ak.x,ak.y,ak.z,aB.x,aB.y,aB.z)}}class aO extends eu{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void R("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void R("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){return!1===this.hasPlaybackControl?void R("Audio: this Audio has no playback control."):(!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this)}stop(t=0){return!1===this.hasPlaybackControl?void R("Audio: this Audio has no playback control."):(this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this)}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,s);break}}saveOriginalState(){let t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let t=i;t!==s;++t)e[t]=e[s+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let s=0;s!==r;++s)t[e+s]=t[i+s]}_slerp(t,e,i,s){X.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,r){let n=this._workIndex*r;X.multiplyQuaternionsFlat(t,n,t,e,t,i),X.slerpFlat(t,e,t,e,t,n,s)}_lerp(t,e,i,s,r){let n=1-s;for(let a=0;a!==r;++a){let r=e+a;t[r]=t[r]*n+t[i+a]*s}}_lerpAdditive(t,e,i,s,r){for(let n=0;n!==r;++n){let r=e+n;t[r]=t[r]+t[i+n]*s}}}let aD="\\[\\]\\.:\\/",aj=RegExp("["+aD+"]","g"),aU="[^"+aD+"]",aW="[^"+aD.replace("\\.","")+"]",aG=RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",aU)+/(WCOD+)?/.source.replace("WCOD",aW)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",aU)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",aU)+"$"),aq=["material","materials","bones","map"];class aH{constructor(t,e,i){this.path=e,this.parsedPath=i||aH.parseTrackName(e),this.node=aH.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new aH.Composite(t,e,i):new aH(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(aj,"")}static parseTrackName(t){let e=aG.exec(t);if(null===e)throw Error("PropertyBinding: Cannot parse trackName: "+t);let i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){let t=i.nodeName.substring(s+1);-1!==aq.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){let i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){let i=function(t){for(let s=0;s=r){let n=r++,l=t[n];e[l.uuid]=h,t[h]=l,e[o]=n,t[n]=a;for(let t=0;t!==s;++t){let e=i[t],s=e[n],r=e[h];e[h]=s,e[n]=r}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length,r=this.nCachedObjects_,n=t.length;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],h=o.uuid,l=e[h];if(void 0!==l)if(delete e[h],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0;t!==s;++t){let e=i[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let i=this._bindingsIndicesByPath,s=i[t],r=this._bindings;if(void 0!==s)return r[s];let n=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,u=Array(h);s=r.length,i[t]=s,n.push(t),a.push(e),r.push(u);for(let i=l,s=o.length;i!==s;++i){let s=o[i];u[i]=new aH(s,t,e)}return u}unsubscribe_(t){let e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){let s=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length-1,o=n[a];e[t[a]]=i,n[i]=o,n.pop(),r[i]=r[a],r.pop(),s[i]=s[a],s.pop()}}}class aX{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const r=e.tracks,n=r.length,a=Array(n),o={endingStart:2400,endingEnd:2400};for(let t=0;t!==n;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),!0===i){let i=this._clip.duration,s=t._clip.duration;t.warp(1,s/i,e),this.warp(i/s,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){let t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){let s=this._mixer,r=s.time,n=this.timeScale,a=this._timeScaleInterpolant;null===a&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=t/n,h[1]=e/n,this}stopWarping(){let t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled)return void this._updateWeight(t);let r=this._startTime;if(null!==r){let s=(t-r)*i;s<0||0===i?e=0:(this._startTime=null,e=i*s)}e*=this._updateTimeScale(t);let n=this._updateTime(e),a=this._updateWeight(t);if(a>0){let t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(n),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(n),e[i].accumulate(s,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let i=this._weightInterpolant;if(null!==i){let s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,i=this.loop,s=this.time+t,r=this._loopCount,n=2202===i;if(0===t)return -1===r?s:n&&(1&r)==1?e-s:s;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));r:{if(s>=e)s=e;else if(s<0)s=0;else{this.time=s;break r}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),s>=e||s<0){let i=Math.floor(s/e);s-=e*i,r+=Math.abs(i);let a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){let e=t<0;this._setEndings(e,!e,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=s;if(n&&(1&r)==1)return e-s}return s}_setEndings(t,e,i){let s=this._interpolantSettings;i?(s.endingStart=2401,s.endingEnd=2401):(t?s.endingStart=this.zeroSlopeAtStart?2401:2400:s.endingStart=2402,e?s.endingEnd=this.zeroSlopeAtEnd?2401:2400:s.endingEnd=2402)}_scheduleFading(t,e,i){let s=this._mixer,r=s.time,n=this._weightInterpolant;null===n&&(n=s._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}let aZ=new Float32Array(1);class aY extends L{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let i=t._localRoot||this._root,s=t._clip.tracks,r=s.length,n=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName,l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){let r=s[t],h=r.name,u=l[h];if(void 0!==u)++u.referenceCount,n[t]=u;else{if(void 0!==(u=n[t])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,o,h));continue}let s=e&&e._propertyBindings[t].binding.parsedPath;u=new aV(aH.create(i,h,s),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,o,h),n[t]=u}a[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){let e=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,e)}let e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){let i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){let i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return null!==e&&e=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;let e=this._actions,i=this._nActiveActions,s=this.time+=t,r=Math.sign(t),n=this._accuIndex^=1;for(let a=0;a!==i;++a)e[a]._update(s,t,r,n);let a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(n);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,os).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}let on=new Z,oa=new Z,oo=new Z,oh=new Z,ol=new Z,ou=new Z,oc=new Z;class op{constructor(t=new Z,e=new Z){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){on.subVectors(t,this.start),oa.subVectors(this.end,this.start);let i=oa.dot(oa),s=oa.dot(on)/i;return e&&(s=j(s,0,1)),s}closestPointToPoint(t,e,i){let s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}distanceSqToLine3(t,e=ou,i=oc){let s,r,n=1e-8*1e-8,a=this.start,o=t.start,h=this.end,l=t.end;oo.subVectors(h,a),oh.subVectors(l,o),ol.subVectors(a,o);let u=oo.dot(oo),c=oh.dot(oh),p=oh.dot(ol);if(u<=n&&c<=n)return e.copy(a),i.copy(o),e.sub(i),e.dot(e);if(u<=n)s=0,r=j(r=p/c,0,1);else{let t=oo.dot(ol);if(c<=n)r=0,s=j(-t/u,0,1);else{let e=oo.dot(oh),i=u*c-e*e;s=0!==i?j((e*p-t*c)/i,0,1):0,(r=(e*s+p)/c)<0?(r=0,s=j(-t/u,0,1)):r>1&&(r=1,s=j((e-t)/u,0,1))}}return e.copy(a).add(oo.multiplyScalar(s)),i.copy(o).add(oh.multiplyScalar(r)),e.sub(i),e.dot(e)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}let od=new Z;class om extends eu{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new e5,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1;t<32;t++,e++){const i=t/32*Math.PI*2,r=e/32*Math.PI*2;s.push(Math.cos(i),Math.sin(i),1,Math.cos(r),Math.sin(r),1)}i.setAttribute("position",new eZ(s,3));const r=new s$({fog:!1,toneMapped:!1});this.cone=new sY(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),od.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(od),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}let of=new Z,og=new tH,oy=new tH;class ox extends sY{constructor(t){const e=function t(e){let i=[];!0===e.isBone&&i.push(e);for(let s=0;s1)for(let i=0;i.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{oF.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(oF,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class oV extends sY{constructor(t=1){const e=new e5;e.setAttribute("position",new eZ([0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],3)),e.setAttribute("color",new eZ([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(e,new s$({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){let s=new ez,r=this.geometry.attributes.color.array;return s.set(t),s.toArray(r,0),s.toArray(r,3),s.set(e),s.toArray(r,6),s.toArray(r,9),s.set(i),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class oD{constructor(){this.type="ShapePath",this.color=new ez,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new rF,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,r,n){return this.currentPath.bezierCurveTo(t,e,i,s,r,n),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){let e,i,s,r,n,a=r3.isClockWise,o=this.subPaths;if(0===o.length)return[];let h=[];if(1===o.length)return i=o[0],(s=new r$).curves=i.curves,h.push(s),h;let l=!a(o[0].getPoints());l=t?!l:l;let u=[],c=[],p=[],d=0;c[0]=void 0,p[d]=[];for(let s=0,n=o.length;s1){let t=!1,e=0;for(let t=0,e=c.length;tNumber.EPSILON){if(h<0&&(i=e[n],o=-o,a=e[r],h=-h),t.ya.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{let e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;s=!s}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return s})(n.p,c[s].p)&&(i!==s&&e++,a?(a=!1,u[s].push(n)):t=!0);a&&u[i].push(n)}}e>0&&!1===t&&(p=u)}for(let t=0,e=c.length;te?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}static cover(t,e){let i;return(i=t.image&&t.image.width?t.image.width/t.image.height:1)>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}static fill(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}static getByteLength(t,e,i,s){return oU(t,e,i,s)}}"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}})),"u">typeof window&&(window.__THREE__?R("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182"),t.s(["ACESFilmicToneMapping",()=>4,"AddEquation",()=>100,"AddOperation",()=>2,"AdditiveAnimationBlendMode",()=>2501,"AdditiveBlending",()=>2,"AgXToneMapping",()=>6,"AlphaFormat",()=>1021,"AlwaysCompare",()=>519,"AlwaysDepth",()=>1,"AlwaysStencilFunc",()=>519,"AmbientLight",()=>an,"AnimationAction",()=>aX,"AnimationClip",()=>nD,"AnimationLoader",()=>nX,"AnimationMixer",()=>aY,"AnimationObjectGroup",()=>aJ,"AnimationUtils",()=>nI,"ArcCurve",()=>rb,"ArrayCamera",()=>a_,"ArrowHelper",()=>o$,"AttachedBindMode",()=>p,"Audio",()=>aO,"AudioAnalyser",()=>a$,"AudioContext",()=>ab,"AudioListener",()=>aR,"AudioLoader",()=>av,"AxesHelper",()=>oV,"BackSide",()=>1,"BasicDepthPacking",()=>3200,"BasicShadowMap",()=>0,"BatchedMesh",()=>sF,"Bone",()=>i8,"BooleanKeyframeTrack",()=>nE,"Box2",()=>or,"Box3",()=>tv,"Box3Helper",()=>oL,"BoxGeometry",()=>il,"BoxHelper",()=>oP,"BufferAttribute",()=>eD,"BufferGeometry",()=>e5,"BufferGeometryLoader",()=>ap,"ByteType",()=>1010,"Cache",()=>nj,"Camera",()=>ig,"CameraHelper",()=>oR,"CanvasTexture",()=>ri,"CapsuleGeometry",()=>ra,"CatmullRomCurve3",()=>r_,"CineonToneMapping",()=>3,"CircleGeometry",()=>ro,"ClampToEdgeWrapping",()=>1001,"Clock",()=>aC,"Color",()=>ez,"ColorKeyframeTrack",()=>nP,"ColorManagement",()=>ts,"CompressedArrayTexture",()=>rt,"CompressedCubeTexture",()=>re,"CompressedTexture",()=>s7,"CompressedTextureLoader",()=>nZ,"ConeGeometry",()=>rl,"ConstantAlphaFactor",()=>213,"ConstantColorFactor",()=>211,"Controls",()=>oj,"CubeCamera",()=>iw,"CubeDepthTexture",()=>rr,"CubeReflectionMapping",()=>301,"CubeRefractionMapping",()=>302,"CubeTexture",()=>iM,"CubeTextureLoader",()=>nK,"CubeUVReflectionMapping",()=>306,"CubicBezierCurve",()=>rz,"CubicBezierCurve3",()=>rk,"CubicInterpolant",()=>nk,"CullFaceBack",()=>1,"CullFaceFront",()=>2,"CullFaceFrontBack",()=>3,"CullFaceNone",()=>0,"Curve",()=>ry,"CurvePath",()=>rN,"CustomBlending",()=>5,"CustomToneMapping",()=>5,"CylinderGeometry",()=>rh,"Cylindrical",()=>oe,"Data3DTexture",()=>tx,"DataArrayTexture",()=>tg,"DataTexture",()=>i9,"DataTextureLoader",()=>n0,"DataUtils",()=>eN,"DecrementStencilOp",()=>7683,"DecrementWrapStencilOp",()=>34056,"DefaultLoadingManager",()=>nW,"DepthFormat",()=>1026,"DepthStencilFormat",()=>1027,"DepthTexture",()=>rs,"DetachedBindMode",()=>d,"DirectionalLight",()=>ar,"DirectionalLightHelper",()=>oz,"DiscreteInterpolant",()=>nR,"DodecahedronGeometry",()=>rc,"DoubleSide",()=>2,"DstAlphaFactor",()=>206,"DstColorFactor",()=>208,"DynamicCopyUsage",()=>35050,"DynamicDrawUsage",()=>35048,"DynamicReadUsage",()=>35049,"EdgesGeometry",()=>rg,"EllipseCurve",()=>rx,"EqualCompare",()=>514,"EqualDepth",()=>4,"EqualStencilFunc",()=>514,"EquirectangularReflectionMapping",()=>303,"EquirectangularRefractionMapping",()=>304,"Euler",()=>t3,"EventDispatcher",()=>L,"ExternalTexture",()=>rn,"ExtrudeGeometry",()=>r6,"FileLoader",()=>nJ,"Float16BufferAttribute",()=>eX,"Float32BufferAttribute",()=>eZ,"FloatType",()=>1015,"Fog",()=>iI,"FogExp2",()=>iT,"FramebufferTexture",()=>s9,"FrontSide",()=>0,"Frustum",()=>sx,"FrustumArray",()=>sw,"GLBufferAttribute",()=>a3,"GLSL1",()=>"100","GLSL3",()=>"300 es","GreaterCompare",()=>516,"GreaterDepth",()=>6,"GreaterEqualCompare",()=>518,"GreaterEqualDepth",()=>5,"GreaterEqualStencilFunc",()=>518,"GreaterStencilFunc",()=>516,"GridHelper",()=>oA,"Group",()=>iA,"HalfFloatType",()=>1016,"HemisphereLight",()=>n3,"HemisphereLightHelper",()=>oS,"IcosahedronGeometry",()=>r9,"ImageBitmapLoader",()=>ax,"ImageLoader",()=>nQ,"ImageUtils",()=>ta,"IncrementStencilOp",()=>7682,"IncrementWrapStencilOp",()=>34055,"InstancedBufferAttribute",()=>si,"InstancedBufferGeometry",()=>ac,"InstancedInterleavedBuffer",()=>a2,"InstancedMesh",()=>su,"Int16BufferAttribute",()=>eG,"Int32BufferAttribute",()=>eH,"Int8BufferAttribute",()=>ej,"IntType",()=>1013,"InterleavedBuffer",()=>ik,"InterleavedBufferAttribute",()=>iR,"Interpolant",()=>nz,"InterpolateDiscrete",()=>2300,"InterpolateLinear",()=>2301,"InterpolateSmooth",()=>2302,"InterpolationSamplingMode",()=>v,"InterpolationSamplingType",()=>b,"InvertStencilOp",()=>5386,"KeepStencilOp",()=>7680,"KeyframeTrack",()=>nO,"LOD",()=>iZ,"LatheGeometry",()=>r7,"Layers",()=>t5,"LessCompare",()=>513,"LessDepth",()=>2,"LessEqualCompare",()=>515,"LessEqualDepth",()=>3,"LessEqualStencilFunc",()=>515,"LessStencilFunc",()=>513,"Light",()=>n2,"LightProbe",()=>ah,"Line",()=>sH,"Line3",()=>op,"LineBasicMaterial",()=>s$,"LineCurve",()=>rB,"LineCurve3",()=>rR,"LineDashedMaterial",()=>nS,"LineLoop",()=>sQ,"LineSegments",()=>sY,"LinearFilter",()=>1006,"LinearInterpolant",()=>nB,"LinearMipMapLinearFilter",()=>1008,"LinearMipMapNearestFilter",()=>1007,"LinearMipmapLinearFilter",()=>1008,"LinearMipmapNearestFilter",()=>1007,"LinearSRGBColorSpace",()=>f,"LinearToneMapping",()=>1,"LinearTransfer",()=>g,"Loader",()=>nG,"LoaderUtils",()=>au,"LoadingManager",()=>nU,"LoopOnce",()=>2200,"LoopPingPong",()=>2202,"LoopRepeat",()=>2201,"MOUSE",()=>u,"Material",()=>eR,"MaterialLoader",()=>al,"MathUtils",()=>H,"Matrix2",()=>oi,"Matrix3",()=>K,"Matrix4",()=>tH,"MaxEquation",()=>104,"Mesh",()=>io,"MeshBasicMaterial",()=>eO,"MeshDepthMaterial",()=>nv,"MeshDistanceMaterial",()=>nw,"MeshLambertMaterial",()=>nb,"MeshMatcapMaterial",()=>nM,"MeshNormalMaterial",()=>nx,"MeshPhongMaterial",()=>ng,"MeshPhysicalMaterial",()=>nf,"MeshStandardMaterial",()=>nm,"MeshToonMaterial",()=>ny,"MinEquation",()=>103,"MirroredRepeatWrapping",()=>1002,"MixOperation",()=>1,"MultiplyBlending",()=>4,"MultiplyOperation",()=>0,"NearestFilter",()=>1003,"NearestMipMapLinearFilter",()=>1005,"NearestMipMapNearestFilter",()=>1004,"NearestMipmapLinearFilter",()=>1005,"NearestMipmapNearestFilter",()=>1004,"NeutralToneMapping",()=>7,"NeverCompare",()=>512,"NeverDepth",()=>0,"NeverStencilFunc",()=>512,"NoBlending",()=>0,"NoColorSpace",()=>"","NoNormalPacking",()=>"","NoToneMapping",()=>0,"NormalAnimationBlendMode",()=>2500,"NormalBlending",()=>1,"NormalGAPacking",()=>"ga","NormalRGPacking",()=>"rg","NotEqualCompare",()=>517,"NotEqualDepth",()=>7,"NotEqualStencilFunc",()=>517,"NumberKeyframeTrack",()=>nL,"Object3D",()=>eu,"ObjectLoader",()=>ad,"ObjectSpaceNormalMap",()=>1,"OctahedronGeometry",()=>nt,"OneFactor",()=>201,"OneMinusConstantAlphaFactor",()=>214,"OneMinusConstantColorFactor",()=>212,"OneMinusDstAlphaFactor",()=>207,"OneMinusDstColorFactor",()=>209,"OneMinusSrcAlphaFactor",()=>205,"OneMinusSrcColorFactor",()=>203,"OrthographicCamera",()=>ai,"PCFShadowMap",()=>1,"PCFSoftShadowMap",()=>2,"Path",()=>rF,"PerspectiveCamera",()=>iv,"Plane",()=>sm,"PlaneGeometry",()=>ne,"PlaneHelper",()=>oN,"PointLight",()=>ae,"PointLightHelper",()=>ob,"Points",()=>s5,"PointsMaterial",()=>sK,"PolarGridHelper",()=>o_,"PolyhedronGeometry",()=>ru,"PositionalAudio",()=>aF,"PropertyBinding",()=>aH,"PropertyMixer",()=>aV,"QuadraticBezierCurve",()=>rO,"QuadraticBezierCurve3",()=>rE,"Quaternion",()=>X,"QuaternionKeyframeTrack",()=>nF,"QuaternionLinearInterpolant",()=>nN,"R11_EAC_Format",()=>37488,"RAD2DEG",()=>V,"RED_GREEN_RGTC2_Format",()=>36285,"RED_RGTC1_Format",()=>36283,"REVISION",()=>"182","RG11_EAC_Format",()=>37490,"RGBADepthPacking",()=>3201,"RGBAFormat",()=>1023,"RGBAIntegerFormat",()=>1033,"RGBA_ASTC_10x10_Format",()=>37819,"RGBA_ASTC_10x5_Format",()=>37816,"RGBA_ASTC_10x6_Format",()=>37817,"RGBA_ASTC_10x8_Format",()=>37818,"RGBA_ASTC_12x10_Format",()=>37820,"RGBA_ASTC_12x12_Format",()=>37821,"RGBA_ASTC_4x4_Format",()=>37808,"RGBA_ASTC_5x4_Format",()=>37809,"RGBA_ASTC_5x5_Format",()=>37810,"RGBA_ASTC_6x5_Format",()=>37811,"RGBA_ASTC_6x6_Format",()=>37812,"RGBA_ASTC_8x5_Format",()=>37813,"RGBA_ASTC_8x6_Format",()=>37814,"RGBA_ASTC_8x8_Format",()=>37815,"RGBA_BPTC_Format",()=>36492,"RGBA_ETC2_EAC_Format",()=>37496,"RGBA_PVRTC_2BPPV1_Format",()=>35843,"RGBA_PVRTC_4BPPV1_Format",()=>35842,"RGBA_S3TC_DXT1_Format",()=>33777,"RGBA_S3TC_DXT3_Format",()=>33778,"RGBA_S3TC_DXT5_Format",()=>33779,"RGBDepthPacking",()=>3202,"RGBFormat",()=>1022,"RGBIntegerFormat",()=>1032,"RGB_BPTC_SIGNED_Format",()=>36494,"RGB_BPTC_UNSIGNED_Format",()=>36495,"RGB_ETC1_Format",()=>36196,"RGB_ETC2_Format",()=>37492,"RGB_PVRTC_2BPPV1_Format",()=>35841,"RGB_PVRTC_4BPPV1_Format",()=>35840,"RGB_S3TC_DXT1_Format",()=>33776,"RGDepthPacking",()=>3203,"RGFormat",()=>1030,"RGIntegerFormat",()=>1031,"RawShaderMaterial",()=>nd,"Ray",()=>tq,"Raycaster",()=>a4,"RectAreaLight",()=>aa,"RedFormat",()=>1028,"RedIntegerFormat",()=>1029,"ReinhardToneMapping",()=>2,"RenderTarget",()=>tm,"RenderTarget3D",()=>aQ,"RepeatWrapping",()=>1e3,"ReplaceStencilOp",()=>7681,"ReverseSubtractEquation",()=>102,"RingGeometry",()=>ni,"SIGNED_R11_EAC_Format",()=>37489,"SIGNED_RED_GREEN_RGTC2_Format",()=>36286,"SIGNED_RED_RGTC1_Format",()=>36284,"SIGNED_RG11_EAC_Format",()=>37491,"SRGBColorSpace",()=>m,"SRGBTransfer",()=>y,"Scene",()=>iz,"ShaderMaterial",()=>im,"ShadowMaterial",()=>np,"Shape",()=>r$,"ShapeGeometry",()=>ns,"ShapePath",()=>oD,"ShapeUtils",()=>r3,"ShortType",()=>1011,"Skeleton",()=>se,"SkeletonHelper",()=>ox,"SkinnedMesh",()=>i6,"Source",()=>th,"Sphere",()=>tF,"SphereGeometry",()=>nr,"Spherical",()=>ot,"SphericalHarmonics3",()=>ao,"SplineCurve",()=>rP,"SpotLight",()=>n7,"SpotLightHelper",()=>om,"Sprite",()=>iq,"SpriteMaterial",()=>iO,"SrcAlphaFactor",()=>204,"SrcAlphaSaturateFactor",()=>210,"SrcColorFactor",()=>202,"StaticCopyUsage",()=>35046,"StaticDrawUsage",()=>35044,"StaticReadUsage",()=>35045,"StereoCamera",()=>aA,"StreamCopyUsage",()=>35042,"StreamDrawUsage",()=>35040,"StreamReadUsage",()=>35041,"StringKeyframeTrack",()=>n$,"SubtractEquation",()=>101,"SubtractiveBlending",()=>3,"TOUCH",()=>c,"TangentSpaceNormalMap",()=>0,"TetrahedronGeometry",()=>nn,"Texture",()=>tp,"TextureLoader",()=>n1,"TextureUtils",()=>oW,"Timer",()=>a9,"TimestampQuery",()=>x,"TorusGeometry",()=>na,"TorusKnotGeometry",()=>no,"Triangle",()=>eA,"TriangleFanDrawMode",()=>2,"TriangleStripDrawMode",()=>1,"TrianglesDrawMode",()=>0,"TubeGeometry",()=>nh,"UVMapping",()=>300,"Uint16BufferAttribute",()=>eq,"Uint32BufferAttribute",()=>eJ,"Uint8BufferAttribute",()=>eU,"Uint8ClampedBufferAttribute",()=>eW,"Uniform",()=>aK,"UniformsGroup",()=>a1,"UniformsUtils",()=>id,"UnsignedByteType",()=>1009,"UnsignedInt101111Type",()=>35899,"UnsignedInt248Type",()=>1020,"UnsignedInt5999Type",()=>35902,"UnsignedIntType",()=>1014,"UnsignedShort4444Type",()=>1017,"UnsignedShort5551Type",()=>1018,"UnsignedShortType",()=>1012,"VSMShadowMap",()=>3,"Vector2",()=>J,"Vector3",()=>Z,"Vector4",()=>td,"VectorKeyframeTrack",()=>nV,"VideoFrameTexture",()=>s8,"VideoTexture",()=>s6,"WebGL3DRenderTarget",()=>tb,"WebGLArrayRenderTarget",()=>ty,"WebGLCoordinateSystem",()=>2e3,"WebGLCubeRenderTarget",()=>iS,"WebGLRenderTarget",()=>tf,"WebGPUCoordinateSystem",()=>2001,"WebXRController",()=>iC,"WireframeGeometry",()=>nl,"WrapAroundEnding",()=>2402,"ZeroCurvatureEnding",()=>2400,"ZeroFactor",()=>200,"ZeroSlopeEnding",()=>2401,"ZeroStencilOp",()=>0,"arrayNeedsUint32",()=>w,"cloneUniforms",()=>iu,"createCanvasElement",()=>C,"createElementNS",()=>_,"error",()=>O,"getByteLength",()=>oU,"getConsoleFunction",()=>k,"getUnlitUniformColorSpace",()=>ip,"log",()=>B,"mergeUniforms",()=>ic,"probeAsync",()=>P,"setConsoleFunction",()=>z,"warn",()=>R,"warnOnce",()=>E])},98223,71726,91996,t=>{"use strict";function e(t){return t.split(/(?:\r\n|\r|\n)/g).map(t=>t.trim()).filter(Boolean).filter(t=>!t.startsWith(";")).map(t=>{let e=t.match(/^(.+)\s(\d+)$/);if(!e)return{name:t,frameCount:1};{let t=parseInt(e[2],10);return{name:e[1],frameCount:t}}})}t.s(["parseImageFileList",()=>e],98223);var i=t.i(87447);function s(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/")}t.s(["normalizePath",()=>s],71726);let r=i.default;function n(t){return s(t).toLowerCase()}function a(){return r.resources}function o(t){let[e,...i]=r.resources[t],[s,n]=i[i.length-1];return[s,n??e]}function h(t){let e=n(t);if(r.resources[e])return e;let i=e.replace(/\d+(\.(png))$/i,"$1");if(r.resources[i])return i;throw Error(`Resource not found in manifest: ${t}`)}function l(){return Object.keys(r.resources)}let u=["",".jpg",".png",".gif",".bmp"];function c(t){let e=n(t);for(let t of u){let i=`${e}${t}`;if(r.resources[i])return i}return e}function p(t){let e=r.missions[t];if(!e)throw Error(`Mission not found: ${t}`);return e}function d(){return Object.keys(r.missions)}let m=new Map(Object.keys(r.missions).map(t=>[t.toLowerCase(),t]));function f(t){let e=t.replace(/-/g,"_").toLowerCase();return m.get(e)??null}t.s(["findMissionByDemoName",()=>f,"getActualResourceKey",()=>h,"getMissionInfo",()=>p,"getMissionList",()=>d,"getResourceKey",()=>n,"getResourceList",()=>l,"getResourceMap",()=>a,"getSourceAndPath",()=>o,"getStandardTextureResourceKey",()=>c],91996)},92552,(t,e,i)=>{"use strict";let s,r;function n(t,e){return e.reduce((t,[e,i])=>({type:"BinaryExpression",operator:e,left:t,right:i}),t)}function a(t,e){return{type:"UnaryExpression",operator:t,argument:e}}class o extends SyntaxError{constructor(t,e,i,s){super(t),this.expected=e,this.found=i,this.location=s,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let i=null,s=t.find(t=>t.source===this.location.source);s&&(i=s.text.split(/\r\n|\n|\r/g));let r=this.location.start,n=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(r):r,a=this.location.source+":"+n.line+":"+n.column;if(i){let t=this.location.end,s="".padEnd(n.line.toString().length," "),o=i[r.line-1],h=(r.line===t.line?t.column:o.length+1)-r.column||1;e+="\n --> "+a+"\n"+s+" |\n"+n.line+" | "+o+"\n"+s+" | "+"".padEnd(r.column-1," ")+"".padEnd(h,"^")}else e+="\n at "+a}return e}static buildMessage(t,e){function i(t){return t.codePointAt(0).toString(16).toUpperCase()}let s=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function r(t){return s?t.replace(s,t=>"\\u{"+i(t)+"}"):t}function n(t){return r(t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+i(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+i(t)))}function a(t){return r(t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+i(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+i(t)))}let o={literal:t=>'"'+n(t.text)+'"',class(t){let e=t.parts.map(t=>Array.isArray(t)?a(t[0])+"-"+a(t[1]):a(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function h(t){return o[t.type](t)}return"Expected "+function(t){let e=t.map(h);if(e.sort(),e.length>0){let t=1;for(let i=1;i]/,I=/^[+\-]/,z=/^[%*\/]/,k=/^[!\-~]/,B=/^[a-zA-Z_]/,R=/^[a-zA-Z0-9_]/,O=/^[ \t]/,E=/^[^"\\\n\r]/,P=/^[^'\\\n\r]/,L=/^[0-9a-fA-F]/,N=/^[0-9]/,F=/^[xX]/,$=/^[^\n\r]/,V=/^[\n\r]/,D=/^[ \t\n\r]/,j=eC(";",!1),U=eC("package",!1),W=eC("{",!1),G=eC("}",!1),q=eC("function",!1),H=eC("(",!1),J=eC(")",!1),X=eC("::",!1),Z=eC(",",!1),Y=eC("datablock",!1),Q=eC(":",!1),K=eC("new",!1),tt=eC("[",!1),te=eC("]",!1),ti=eC("=",!1),ts=eC(".",!1),tr=eC("if",!1),tn=eC("else",!1),ta=eC("for",!1),to=eC("while",!1),th=eC("do",!1),tl=eC("switch$",!1),tu=eC("switch",!1),tc=eC("case",!1),tp=eC("default",!1),td=eC("or",!1),tm=eC("return",!1),tf=eC("break",!1),tg=eC("continue",!1),ty=eC("+=",!1),tx=eC("-=",!1),tb=eC("*=",!1),tv=eC("/=",!1),tw=eC("%=",!1),tM=eC("<<=",!1),tS=eC(">>=",!1),tA=eC("&=",!1),t_=eC("|=",!1),tC=eC("^=",!1),tT=eC("?",!1),tI=eC("||",!1),tz=eC("&&",!1),tk=eC("|",!1),tB=eC("^",!1),tR=eC("&",!1),tO=eC("==",!1),tE=eC("!=",!1),tP=eC("<=",!1),tL=eC(">=",!1),tN=eT(["<",">"],!1,!1,!1),tF=eC("$=",!1),t$=eC("!$=",!1),tV=eC("@",!1),tD=eC("NL",!1),tj=eC("TAB",!1),tU=eC("SPC",!1),tW=eC("<<",!1),tG=eC(">>",!1),tq=eT(["+","-"],!1,!1,!1),tH=eT(["%","*","/"],!1,!1,!1),tJ=eT(["!","-","~"],!1,!1,!1),tX=eC("++",!1),tZ=eC("--",!1),tY=eC("*",!1),tQ=eC("%",!1),tK=eT([["a","z"],["A","Z"],"_"],!1,!1,!1),t0=eT([["a","z"],["A","Z"],["0","9"],"_"],!1,!1,!1),t1=eC("$",!1),t2=eC("parent",!1),t3=eT([" "," "],!1,!1,!1),t5=eC('"',!1),t4=eC("'",!1),t6=eC("\\",!1),t8=eT(['"',"\\","\n","\r"],!0,!1,!1),t9=eT(["'","\\","\n","\r"],!0,!1,!1),t7=eC("n",!1),et=eC("r",!1),ee=eC("t",!1),ei=eC("x",!1),es=eT([["0","9"],["a","f"],["A","F"]],!1,!1,!1),er=eC("cr",!1),en=eC("cp",!1),ea=eC("co",!1),eo=eC("c",!1),eh=eT([["0","9"]],!1,!1,!1),el={type:"any"},eu=eC("0",!1),ec=eT(["x","X"],!1,!1,!1),ep=eC("-",!1),ed=eC("true",!1),em=eC("false",!1),ef=eC("//",!1),eg=eT(["\n","\r"],!0,!1,!1),ey=eT(["\n","\r"],!1,!1,!1),ex=eC("/*",!1),eb=eC("*/",!1),ev=eT([" "," ","\n","\r"],!1,!1,!1),ew=0|e.peg$currPos,eM=[{line:1,column:1}],eS=ew,eA=e.peg$maxFailExpected||[],e_=0|e.peg$silentFails;if(e.startRule){if(!(e.startRule in u))throw Error("Can't start parsing from rule \""+e.startRule+'".');c=u[e.startRule]}function eC(t,e){return{type:"literal",text:t,ignoreCase:e}}function eT(t,e,i,s){return{type:"class",parts:t,inverted:e,ignoreCase:i,unicode:s}}function eI(e){let i,s=eM[e];if(s)return s;if(e>=eM.length)i=eM.length-1;else for(i=e;!eM[--i];);for(s={line:(s=eM[i]).line,column:s.column};ieS&&(eS=ew,eA=[]),eA.push(t))}function eB(){let t,e,i;for(ip(),t=[],e=ew,(i=il())===h&&(i=eR()),i!==h?e=i=[i,ip()]:(ew=e,e=h);e!==h;)t.push(e),e=ew,(i=il())===h&&(i=eR()),i!==h?e=i=[i,ip()]:(ew=e,e=h);return{type:"Program",body:t.map(([t])=>t).filter(Boolean),execScriptPaths:Array.from(s),hasDynamicExec:r}}function eR(){let e,i,s,r,n,a,o,l,u,c,m,b,v,A,_,C,T;return(e=function(){let e,i,s,r,n,a,o,l;if(e=ew,t.substr(ew,7)===p?(i=p,ew+=7):(i=h,0===e_&&ek(U)),i!==h)if(ic()!==h)if((s=is())!==h)if(iu(),123===t.charCodeAt(ew)?(r="{",ew++):(r=h,0===e_&&ek(W)),r!==h){for(ip(),n=[],a=ew,(o=il())===h&&(o=eR()),o!==h?a=o=[o,l=ip()]:(ew=a,a=h);a!==h;)n.push(a),a=ew,(o=il())===h&&(o=eR()),o!==h?a=o=[o,l=ip()]:(ew=a,a=h);(125===t.charCodeAt(ew)?(a="}",ew++):(a=h,0===e_&&ek(G)),a!==h)?(o=iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),e={type:"PackageDeclaration",name:s,body:n.map(([t])=>t).filter(Boolean)}):(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o;if(e=ew,t.substr(ew,8)===d?(i=d,ew+=8):(i=h,0===e_&&ek(q)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r;if(e=ew,(i=is())!==h)if("::"===t.substr(ew,2)?(s="::",ew+=2):(s=h,0===e_&&ek(X)),s!==h)if((r=is())!==h)e={type:"MethodName",namespace:i,method:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=is()),e}())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=function(){let e,i,s,r,n,a,o,l;if(e=ew,(i=is())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=is())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=is())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=[i,...s.map(([,,,t])=>t)]}else ew=e,e=h;return e}())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h)if(iu(),(o=eD())!==h)e={type:"FunctionDeclaration",name:s,params:n||[],body:o};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&((s=ew,(r=eO())!==h)?(iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n===h&&(n=null),iu(),s=r):(ew=s,s=h),(e=s)===h&&((a=ew,(o=eE())!==h)?(iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),iu(),a=o):(ew=a,a=h),(e=a)===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c,p;if(e=ew,"if"===t.substr(ew,2)?(i="if",ew+=2):(i=h,0===e_&&ek(tr)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),(a=eR())!==h){var d;o=ew,l=iu(),t.substr(ew,4)===f?(u=f,ew+=4):(u=h,0===e_&&ek(tn)),u!==h?(c=iu(),(p=eR())!==h?o=l=[l,u,c,p]:(ew=o,o=h)):(ew=o,o=h),o===h&&(o=null),e={type:"IfStatement",test:r,consequent:a,alternate:(d=o)?d[3]:null}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c;if(e=ew,"for"===t.substr(ew,3)?(i="for",ew+=3):(i=h,0===e_&&ek(ta)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())===h&&(r=null),iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n!==h)if(iu(),(a=ej())===h&&(a=null),iu(),59===t.charCodeAt(ew)?(o=";",ew++):(o=h,0===e_&&ek(j)),o!==h)if(iu(),(l=ej())===h&&(l=null),iu(),41===t.charCodeAt(ew)?(u=")",ew++):(u=h,0===e_&&ek(J)),u!==h)if(iu(),(c=eR())!==h){var p,d;p=r,d=a,e={type:"ForStatement",init:p,test:d,update:l,body:c}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l;if(e=ew,"do"===t.substr(ew,2)?(i="do",ew+=2):(i=h,0===e_&&ek(th)),i!==h)if(iu(),(s=eR())!==h)if(iu(),t.substr(ew,5)===g?(r=g,ew+=5):(r=h,0===e_&&ek(to)),r!==h)if(iu(),40===t.charCodeAt(ew)?(n="(",ew++):(n=h,0===e_&&ek(H)),n!==h)if(iu(),(a=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(o=")",ew++):(o=h,0===e_&&ek(J)),o!==h)iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),e={type:"DoWhileStatement",test:a,body:s};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a;if(e=ew,t.substr(ew,5)===g?(i=g,ew+=5):(i=h,0===e_&&ek(to)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),(a=eR())!==h)e={type:"WhileStatement",test:r,body:a};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c;if(e=ew,t.substr(ew,7)===y?(i=y,ew+=7):(i=h,0===e_&&ek(tl)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),123===t.charCodeAt(ew)?(a="{",ew++):(a=h,0===e_&&ek(W)),a!==h){for(ip(),o=[],l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);l!==h;)o.push(l),l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);(125===t.charCodeAt(ew)?(l="}",ew++):(l=h,0===e_&&ek(G)),l!==h)?e={type:"SwitchStatement",stringMode:!0,discriminant:r,cases:o.map(([t])=>t).filter(t=>t&&"SwitchCase"===t.type)}:(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;if(e===h)if(e=ew,t.substr(ew,6)===x?(i=x,ew+=6):(i=h,0===e_&&ek(tu)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),123===t.charCodeAt(ew)?(a="{",ew++):(a=h,0===e_&&ek(W)),a!==h){for(ip(),o=[],l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);l!==h;)o.push(l),l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);(125===t.charCodeAt(ew)?(l="}",ew++):(l=h,0===e_&&ek(G)),l!==h)?e={type:"SwitchStatement",stringMode:!1,discriminant:r,cases:o.map(([t])=>t).filter(t=>t&&"SwitchCase"===t.type)}:(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n;if(e=ew,t.substr(ew,6)===w?(i=w,ew+=6):(i=h,0===e_&&ek(tm)),i!==h)if(s=ew,(r=ic())!==h&&(n=ej())!==h?s=r=[r,n]:(ew=s,s=h),s===h&&(s=null),r=iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n!==h){var a;e={type:"ReturnStatement",value:(a=s)?a[1]:null}}else ew=e,e=h;else ew=e,e=h;return e}())===h&&(u=ew,t.substr(ew,5)===M?(c=M,ew+=5):(c=h,0===e_&&ek(tf)),c!==h?(iu(),59===t.charCodeAt(ew)?(m=";",ew++):(m=h,0===e_&&ek(j)),m!==h?u={type:"BreakStatement"}:(ew=u,u=h)):(ew=u,u=h),(e=u)===h&&(b=ew,t.substr(ew,8)===S?(v=S,ew+=8):(v=h,0===e_&&ek(tg)),v!==h?(iu(),59===t.charCodeAt(ew)?(A=";",ew++):(A=h,0===e_&&ek(j)),A!==h?b={type:"ContinueStatement"}:(ew=b,b=h)):(ew=b,b=h),(e=b)===h&&((_=ew,(C=ej())!==h&&(iu(),59===t.charCodeAt(ew)?(T=";",ew++):(T=h,0===e_&&ek(j)),T!==h))?_={type:"ExpressionStatement",expression:C}:(ew=_,_=h),(e=_)===h&&(e=eD())===h&&(e=il())===h)))))&&(e=ew,iu(),59===t.charCodeAt(ew)?(i=";",ew++):(i=h,0===e_&&ek(j)),i!==h?(iu(),e=null):(ew=e,e=h)),e}function eO(){let e,i,s,r,n,a,o,l,u,c,p,d,f,g;if(e=ew,t.substr(ew,9)===m?(i=m,ew+=9):(i=h,0===e_&&ek(Y)),i!==h)if(ic()!==h)if((s=is())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=eL())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h){var y,x,b;if(iu(),o=ew,58===t.charCodeAt(ew)?(l=":",ew++):(l=h,0===e_&&ek(Q)),l!==h?(u=iu(),(c=is())!==h?o=l=[l,u,c]:(ew=o,o=h)):(ew=o,o=h),o===h&&(o=null),l=iu(),u=ew,123===t.charCodeAt(ew)?(c="{",ew++):(c=h,0===e_&&ek(W)),c!==h){for(p=iu(),d=[],f=eP();f!==h;)d.push(f),f=eP();f=iu(),125===t.charCodeAt(ew)?(g="}",ew++):(g=h,0===e_&&ek(G)),g!==h?u=c=[c,p,d,f,g,iu()]:(ew=u,u=h)}else ew=u,u=h;u===h&&(u=null),y=n,x=o,b=u,e={type:"DatablockDeclaration",className:s,instanceName:y,parent:x?x[2]:null,body:b?b[2].filter(Boolean):[]}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}function eE(){let e,i,s,r,n,a,o,l,u,c,p,d;if(e=ew,"new"===t.substr(ew,3)?(i="new",ew+=3):(i=h,0===e_&&ek(K)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r,n,a,o,l,u,c;if((e=ew,40===t.charCodeAt(ew)?(i="(",ew++):(i=h,0===e_&&ek(H)),i!==h&&(s=iu(),(r=ej())!==h&&(n=iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h)))?e=r:(ew=e,e=h),e===h)if(e=ew,(i=is())!==h){var p;for(s=[],r=ew,n=iu(),91===t.charCodeAt(ew)?(a="[",ew++):(a=h,0===e_&&ek(tt)),a!==h?(o=iu(),(l=e$())!==h?(u=iu(),93===t.charCodeAt(ew)?(c="]",ew++):(c=h,0===e_&&ek(te)),c!==h?r=n=[n,a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),91===t.charCodeAt(ew)?(a="[",ew++):(a=h,0===e_&&ek(tt)),a!==h?(o=iu(),(l=e$())!==h?(u=iu(),93===t.charCodeAt(ew)?(c="]",ew++):(c=h,0===e_&&ek(te)),c!==h?r=n=[n,a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);p=i,e=s.reduce((t,[,,,e])=>({type:"IndexExpression",object:t,index:e}),p)}else ew=e,e=h;return e}())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=eL())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h){var m;if(iu(),o=ew,123===t.charCodeAt(ew)?(l="{",ew++):(l=h,0===e_&&ek(W)),l!==h){for(u=iu(),c=[],p=eP();p!==h;)c.push(p),p=eP();p=iu(),125===t.charCodeAt(ew)?(d="}",ew++):(d=h,0===e_&&ek(G)),d!==h?o=l=[l,u,c,p,d,iu()]:(ew=o,o=h)}else ew=o,o=h;o===h&&(o=null),e={type:"ObjectDeclaration",className:s,instanceName:n,body:(m=o)?m[2].filter(Boolean):[]}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}function eP(){let e,i,s;return(e=ew,(i=eE())!==h)?(iu(),59===t.charCodeAt(ew)?(s=";",ew++):(s=h,0===e_&&ek(j)),s===h&&(s=null),iu(),e=i):(ew=e,e=h),e===h&&((e=ew,(i=eO())!==h)?(iu(),59===t.charCodeAt(ew)?(s=";",ew++):(s=h,0===e_&&ek(j)),s===h&&(s=null),iu(),e=i):(ew=e,e=h),e===h&&(e=function(){let e,i,s,r,n;if(e=ew,iu(),(i=eN())!==h)if(iu(),61===t.charCodeAt(ew)?(s="=",ew++):(s=h,0===e_&&ek(ti)),s!==h)if(iu(),(r=ej())!==h)iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n===h&&(n=null),iu(),e={type:"Assignment",target:i,value:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=il())===h&&(e=function(){let e,i;if(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i!==h)for(;i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));else e=h;return e!==h&&(e=null),e}())),e}function eL(){let t;return(t=eK())===h&&(t=is())===h&&(t=ih()),t}function eN(){let t,e,i,s;if(t=ew,(e=e9())!==h){for(i=[],s=eF();s!==h;)i.push(s),s=eF();t=i.reduce((t,e)=>"property"===e.type?{type:"MemberExpression",object:t,property:e.value}:{type:"IndexExpression",object:t,index:e.value},e)}else ew=t,t=h;return t}function eF(){let e,i,s,r;return(e=ew,46===t.charCodeAt(ew)?(i=".",ew++):(i=h,0===e_&&ek(ts)),i!==h&&(iu(),(s=is())!==h))?e={type:"property",value:s}:(ew=e,e=h),e===h&&((e=ew,91===t.charCodeAt(ew)?(i="[",ew++):(i=h,0===e_&&ek(tt)),i!==h&&(iu(),(s=e$())!==h&&(iu(),93===t.charCodeAt(ew)?(r="]",ew++):(r=h,0===e_&&ek(te)),r!==h)))?e={type:"index",value:s}:(ew=e,e=h)),e}function e$(){let e,i,s,r,n,a,o,l;if(e=ew,(i=ej())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=s.length>0?[i,...s.map(([,,,t])=>t)]:i}else ew=e,e=h;return e}function eV(){let e,i,s,r,n,a,o,l,u;if(e=ew,t.substr(ew,4)===b?(i=b,ew+=4):(i=h,0===e_&&ek(tc)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r,n,a,o,l;if(e=ew,(i=e5())!==h){for(s=[],r=ew,n=iu(),"or"===t.substr(ew,2)?(a="or",ew+=2):(a=h,0===e_&&ek(td)),a!==h&&(o=ic())!==h&&(l=e5())!==h?r=n=[n,a,o,l]:(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),"or"===t.substr(ew,2)?(a="or",ew+=2):(a=h,0===e_&&ek(td)),a!==h&&(o=ic())!==h&&(l=e5())!==h?r=n=[n,a,o,l]:(ew=r,r=h);e=s.length>0?[i,...s.map(([,,,t])=>t)]:i}else ew=e,e=h;return e}())!==h)if(iu(),58===t.charCodeAt(ew)?(r=":",ew++):(r=h,0===e_&&ek(Q)),r!==h){for(n=ip(),a=[],o=ew,(l=il())===h&&(l=eR()),l!==h?o=l=[l,u=ip()]:(ew=o,o=h);o!==h;)a.push(o),o=ew,(l=il())===h&&(l=eR()),l!==h?o=l=[l,u=ip()]:(ew=o,o=h);e={type:"SwitchCase",test:s,consequent:a.map(([t])=>t).filter(Boolean)}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;if(e===h)if(e=ew,t.substr(ew,7)===v?(i=v,ew+=7):(i=h,0===e_&&ek(tp)),i!==h)if(iu(),58===t.charCodeAt(ew)?(s=":",ew++):(s=h,0===e_&&ek(Q)),s!==h){for(ip(),r=[],n=ew,(a=il())===h&&(a=eR()),a!==h?n=a=[a,o=ip()]:(ew=n,n=h);n!==h;)r.push(n),n=ew,(a=il())===h&&(a=eR()),a!==h?n=a=[a,o=ip()]:(ew=n,n=h);e={type:"SwitchCase",test:null,consequent:r.map(([t])=>t).filter(Boolean)}}else ew=e,e=h;else ew=e,e=h;return e}function eD(){let e,i,s,r,n,a;if(e=ew,123===t.charCodeAt(ew)?(i="{",ew++):(i=h,0===e_&&ek(W)),i!==h){for(ip(),s=[],r=ew,(n=il())===h&&(n=eR()),n!==h?r=n=[n,a=ip()]:(ew=r,r=h);r!==h;)s.push(r),r=ew,(n=il())===h&&(n=eR()),n!==h?r=n=[n,a=ip()]:(ew=r,r=h);(125===t.charCodeAt(ew)?(r="}",ew++):(r=h,0===e_&&ek(G)),r!==h)?e={type:"BlockStatement",body:s.map(([t])=>t).filter(Boolean)}:(ew=e,e=h)}else ew=e,e=h;return e}function ej(){let e,i,s,r;if(e=ew,(i=eN())!==h)if(iu(),(s=eU())!==h)if(iu(),(r=ej())!==h)e={type:"AssignmentExpression",operator:s,target:i,value:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=function(){let e,i,s,r,n,a;if(e=ew,(i=eW())!==h)if(iu(),63===t.charCodeAt(ew)?(s="?",ew++):(s=h,0===e_&&ek(tT)),s!==h)if(iu(),(r=ej())!==h)if(iu(),58===t.charCodeAt(ew)?(n=":",ew++):(n=h,0===e_&&ek(Q)),n!==h)if(iu(),(a=ej())!==h)e={type:"ConditionalExpression",test:i,consequent:r,alternate:a};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=eW()),e}()),e}function eU(){let e;return 61===t.charCodeAt(ew)?(e="=",ew++):(e=h,0===e_&&ek(ti)),e===h&&("+="===t.substr(ew,2)?(e="+=",ew+=2):(e=h,0===e_&&ek(ty)),e===h&&("-="===t.substr(ew,2)?(e="-=",ew+=2):(e=h,0===e_&&ek(tx)),e===h&&("*="===t.substr(ew,2)?(e="*=",ew+=2):(e=h,0===e_&&ek(tb)),e===h&&("/="===t.substr(ew,2)?(e="/=",ew+=2):(e=h,0===e_&&ek(tv)),e===h&&("%="===t.substr(ew,2)?(e="%=",ew+=2):(e=h,0===e_&&ek(tw)),e===h&&("<<="===t.substr(ew,3)?(e="<<=",ew+=3):(e=h,0===e_&&ek(tM)),e===h&&(">>="===t.substr(ew,3)?(e=">>=",ew+=3):(e=h,0===e_&&ek(tS)),e===h&&("&="===t.substr(ew,2)?(e="&=",ew+=2):(e=h,0===e_&&ek(tA)),e===h&&("|="===t.substr(ew,2)?(e="|=",ew+=2):(e=h,0===e_&&ek(t_)),e===h&&("^="===t.substr(ew,2)?(e="^=",ew+=2):(e=h,0===e_&&ek(tC)))))))))))),e}function eW(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eG())!==h){for(s=[],r=ew,a=iu(),"||"===t.substr(ew,2)?(o="||",ew+=2):(o=h,0===e_&&ek(tI)),o!==h?(l=iu(),(u=eG())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),"||"===t.substr(ew,2)?(o="||",ew+=2):(o=h,0===e_&&ek(tI)),o!==h?(l=iu(),(u=eG())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eG(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eq())!==h){for(s=[],r=ew,a=iu(),"&&"===t.substr(ew,2)?(o="&&",ew+=2):(o=h,0===e_&&ek(tz)),o!==h?(l=iu(),(u=eq())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),"&&"===t.substr(ew,2)?(o="&&",ew+=2):(o=h,0===e_&&ek(tz)),o!==h?(l=iu(),(u=eq())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eq(){let e,i,s,r,a,o,l,u,c;if(e=ew,(i=eH())!==h){for(s=[],r=ew,a=iu(),124===t.charCodeAt(ew)?(o="|",ew++):(o=h,0===e_&&ek(tk)),o!==h?(l=ew,e_++,124===t.charCodeAt(ew)?(u="|",ew++):(u=h,0===e_&&ek(tk)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eH())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),124===t.charCodeAt(ew)?(o="|",ew++):(o=h,0===e_&&ek(tk)),o!==h?(l=ew,e_++,124===t.charCodeAt(ew)?(u="|",ew++):(u=h,0===e_&&ek(tk)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eH())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,,e])=>[t,e]))}else ew=e,e=h;return e}function eH(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eJ())!==h){for(s=[],r=ew,a=iu(),94===t.charCodeAt(ew)?(o="^",ew++):(o=h,0===e_&&ek(tB)),o!==h?(l=iu(),(u=eJ())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),94===t.charCodeAt(ew)?(o="^",ew++):(o=h,0===e_&&ek(tB)),o!==h?(l=iu(),(u=eJ())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eJ(){let e,i,s,r,a,o,l,u,c;if(e=ew,(i=eX())!==h){for(s=[],r=ew,a=iu(),38===t.charCodeAt(ew)?(o="&",ew++):(o=h,0===e_&&ek(tR)),o!==h?(l=ew,e_++,38===t.charCodeAt(ew)?(u="&",ew++):(u=h,0===e_&&ek(tR)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eX())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),38===t.charCodeAt(ew)?(o="&",ew++):(o=h,0===e_&&ek(tR)),o!==h?(l=ew,e_++,38===t.charCodeAt(ew)?(u="&",ew++):(u=h,0===e_&&ek(tR)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eX())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,,e])=>[t,e]))}else ew=e,e=h;return e}function eX(){let t,e,i,s,r,a,o,l;if(t=ew,(e=eY())!==h){for(i=[],s=ew,r=iu(),(a=eZ())!==h?(o=iu(),(l=eY())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=eZ())!==h?(o=iu(),(l=eY())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function eZ(){let e;return"=="===t.substr(ew,2)?(e="==",ew+=2):(e=h,0===e_&&ek(tO)),e===h&&("!="===t.substr(ew,2)?(e="!=",ew+=2):(e=h,0===e_&&ek(tE))),e}function eY(){let t,e,i,s,r,a,o,l;if(t=ew,(e=eK())!==h){for(i=[],s=ew,r=iu(),(a=eQ())!==h?(o=iu(),(l=eK())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=eQ())!==h?(o=iu(),(l=eK())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function eQ(){let e;return"<="===t.substr(ew,2)?(e="<=",ew+=2):(e=h,0===e_&&ek(tP)),e===h&&(">="===t.substr(ew,2)?(e=">=",ew+=2):(e=h,0===e_&&ek(tL)),e===h&&(e=t.charAt(ew),T.test(e)?ew++:(e=h,0===e_&&ek(tN)))),e}function eK(){let t,e,i,s,r,a,o,l;if(t=ew,(e=e2())!==h){for(i=[],s=ew,r=iu(),(a=e1())!==h?(o=iu(),(l=e0())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=e1())!==h?(o=iu(),(l=e0())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function e0(){let t,e,i,s;if(t=ew,(e=eN())!==h)if(iu(),(i=eU())!==h)if(iu(),(s=ej())!==h)t={type:"AssignmentExpression",operator:i,target:e,value:s};else ew=t,t=h;else ew=t,t=h;else ew=t,t=h;return t===h&&(t=e2()),t}function e1(){let e;return"$="===t.substr(ew,2)?(e="$=",ew+=2):(e=h,0===e_&&ek(tF)),e===h&&("!$="===t.substr(ew,3)?(e="!$=",ew+=3):(e=h,0===e_&&ek(t$)),e===h&&(64===t.charCodeAt(ew)?(e="@",ew++):(e=h,0===e_&&ek(tV)),e===h&&("NL"===t.substr(ew,2)?(e="NL",ew+=2):(e=h,0===e_&&ek(tD)),e===h&&("TAB"===t.substr(ew,3)?(e="TAB",ew+=3):(e=h,0===e_&&ek(tj)),e===h&&("SPC"===t.substr(ew,3)?(e="SPC",ew+=3):(e=h,0===e_&&ek(tU))))))),e}function e2(){let t,e,i,s,r,a,o,l;if(t=ew,(e=e5())!==h){for(i=[],s=ew,r=iu(),(a=e3())!==h?(o=iu(),(l=e5())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=e3())!==h?(o=iu(),(l=e5())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function e3(){let e;return"<<"===t.substr(ew,2)?(e="<<",ew+=2):(e=h,0===e_&&ek(tW)),e===h&&(">>"===t.substr(ew,2)?(e=">>",ew+=2):(e=h,0===e_&&ek(tG))),e}function e5(){let e,i,s,r,a,o,l,u;if(e=ew,(i=e4())!==h){for(s=[],r=ew,a=iu(),o=t.charAt(ew),I.test(o)?ew++:(o=h,0===e_&&ek(tq)),o!==h?(l=iu(),(u=e4())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),o=t.charAt(ew),I.test(o)?ew++:(o=h,0===e_&&ek(tq)),o!==h?(l=iu(),(u=e4())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function e4(){let e,i,s,r,a,o,l,u;if(e=ew,(i=e6())!==h){for(s=[],r=ew,a=iu(),o=t.charAt(ew),z.test(o)?ew++:(o=h,0===e_&&ek(tH)),o!==h?(l=iu(),(u=e6())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),o=t.charAt(ew),z.test(o)?ew++:(o=h,0===e_&&ek(tH)),o!==h?(l=iu(),(u=e6())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function e6(){let e,i,s;return(e=ew,i=t.charAt(ew),k.test(i)?ew++:(i=h,0===e_&&ek(tJ)),i!==h&&(iu(),(s=e8())!==h))?e=a(i,s):(ew=e,e=h),e===h&&((e=ew,"++"===t.substr(ew,2)?(i="++",ew+=2):(i=h,0===e_&&ek(tX)),i===h&&("--"===t.substr(ew,2)?(i="--",ew+=2):(i=h,0===e_&&ek(tZ))),i!==h&&(iu(),(s=e8())!==h))?e=a(i,s):(ew=e,e=h),e===h&&((e=ew,42===t.charCodeAt(ew)?(i="*",ew++):(i=h,0===e_&&ek(tY)),i!==h&&(iu(),(s=e8())!==h))?e={type:"TagDereferenceExpression",argument:s}:(ew=e,e=h),e===h&&(e=function(){let e,i,s;if(e=ew,(i=e9())!==h)if(iu(),"++"===t.substr(ew,2)?(s="++",ew+=2):(s=h,0===e_&&ek(tX)),s===h&&("--"===t.substr(ew,2)?(s="--",ew+=2):(s=h,0===e_&&ek(tZ))),s!==h)e={type:"PostfixExpression",operator:s,argument:i};else ew=e,e=h;else ew=e,e=h;return e===h&&(e=e9()),e}()))),e}function e8(){let t,e,i,s;if(t=ew,(e=eN())!==h)if(iu(),(i=eU())!==h)if(iu(),(s=ej())!==h)t={type:"AssignmentExpression",operator:i,target:e,value:s};else ew=t,t=h;else ew=t,t=h;else ew=t,t=h;return t===h&&(t=e6()),t}function e9(){let e,i,n,a,o,l,u,c,p,d;if(e=ew,(i=function(){let e,i,s,r,n,a,o,l,u,c,p,d,m,f,g,y;if(e=ew,(o=eE())===h&&(o=eO())===h&&(o=function(){let e,i,s,r;if(e=ew,34===t.charCodeAt(ew)?(i='"',ew++):(i=h,0===e_&&ek(t5)),i!==h){for(s=[],r=ir();r!==h;)s.push(r),r=ir();(34===t.charCodeAt(ew)?(r='"',ew++):(r=h,0===e_&&ek(t5)),r!==h)?e={type:"StringLiteral",value:s.join("")}:(ew=e,e=h)}else ew=e,e=h;if(e===h)if(e=ew,39===t.charCodeAt(ew)?(i="'",ew++):(i=h,0===e_&&ek(t4)),i!==h){for(s=[],r=ia();r!==h;)s.push(r),r=ia();(39===t.charCodeAt(ew)?(r="'",ew++):(r=h,0===e_&&ek(t4)),r!==h)?e={type:"StringLiteral",value:s.join(""),tagged:!0}:(ew=e,e=h)}else ew=e,e=h;return e}())===h&&(o=ih())===h&&((l=ew,t.substr(ew,4)===_?(u=_,ew+=4):(u=h,0===e_&&ek(ed)),u===h&&(t.substr(ew,5)===C?(u=C,ew+=5):(u=h,0===e_&&ek(em))),u!==h&&(c=ew,e_++,p=im(),e_--,p===h?c=void 0:(ew=c,c=h),c!==h))?l={type:"BooleanLiteral",value:"true"===u}:(ew=l,l=h),(o=l)===h&&((d=it())===h&&(d=ie())===h&&(d=ii()),(o=d)===h))&&((m=ew,40===t.charCodeAt(ew)?(f="(",ew++):(f=h,0===e_&&ek(H)),f!==h&&(iu(),(g=ej())!==h&&(iu(),41===t.charCodeAt(ew)?(y=")",ew++):(y=h,0===e_&&ek(J)),y!==h)))?m=g:(ew=m,m=h),o=m),(i=o)!==h){for(s=[],r=ew,n=iu(),(a=eF())!==h?r=n=[n,a]:(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),(a=eF())!==h?r=n=[n,a]:(ew=r,r=h);e=s.reduce((t,[,e])=>"property"===e.type?{type:"MemberExpression",object:t,property:e.value}:{type:"IndexExpression",object:t,index:e.value},i)}else ew=e,e=h;return e}())!==h){for(n=[],a=ew,o=iu(),40===t.charCodeAt(ew)?(l="(",ew++):(l=h,0===e_&&ek(H)),l!==h?(u=iu(),(c=e7())===h&&(c=null),p=iu(),41===t.charCodeAt(ew)?(d=")",ew++):(d=h,0===e_&&ek(J)),d!==h?a=o=[o,l,u,c,p,d]:(ew=a,a=h)):(ew=a,a=h),a===h&&(a=ew,o=iu(),(l=eF())!==h?a=o=[o,l]:(ew=a,a=h));a!==h;)n.push(a),a=ew,o=iu(),40===t.charCodeAt(ew)?(l="(",ew++):(l=h,0===e_&&ek(H)),l!==h?(u=iu(),(c=e7())===h&&(c=null),p=iu(),41===t.charCodeAt(ew)?(d=")",ew++):(d=h,0===e_&&ek(J)),d!==h?a=o=[o,l,u,c,p,d]:(ew=a,a=h)):(ew=a,a=h),a===h&&(a=ew,o=iu(),(l=eF())!==h?a=o=[o,l]:(ew=a,a=h));e=n.reduce((t,e)=>{if("("===e[1]){var i;let[,,,n]=e;return i=n||[],"Identifier"===t.type&&"exec"===t.name.toLowerCase()&&(i.length>0&&"StringLiteral"===i[0].type?s.add(i[0].value):r=!0),{type:"CallExpression",callee:t,arguments:i}}let n=e[1];return"property"===n.type?{type:"MemberExpression",object:t,property:n.value}:{type:"IndexExpression",object:t,index:n.value}},i)}else ew=e,e=h;return e}function e7(){let e,i,s,r,n,a,o,l;if(e=ew,(i=ej())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=[i,...s.map(([,,,t])=>t)]}else ew=e,e=h;return e}function it(){let e,i,s,r,n,a,o;if(e=ew,37===t.charCodeAt(ew)?(i="%",ew++):(i=h,0===e_&&ek(tQ)),i!==h){if(s=ew,r=ew,n=t.charAt(ew),B.test(n)?ew++:(n=h,0===e_&&ek(tK)),n!==h){for(a=[],o=t.charAt(ew),R.test(o)?ew++:(o=h,0===e_&&ek(t0));o!==h;)a.push(o),o=t.charAt(ew),R.test(o)?ew++:(o=h,0===e_&&ek(t0));r=n=[n,a]}else ew=r,r=h;(s=r!==h?t.substring(s,ew):r)!==h?e={type:"Variable",scope:"local",name:s}:(ew=e,e=h)}else ew=e,e=h;return e}function ie(){let e,i,s,r,n,a,o,l,u,c,p,d,m;if(e=ew,36===t.charCodeAt(ew)?(i="$",ew++):(i=h,0===e_&&ek(t1)),i!==h){if(s=ew,r=ew,"::"===t.substr(ew,2)?(n="::",ew+=2):(n=h,0===e_&&ek(X)),n===h&&(n=null),a=t.charAt(ew),B.test(a)?ew++:(a=h,0===e_&&ek(tK)),a!==h){for(o=[],l=t.charAt(ew),R.test(l)?ew++:(l=h,0===e_&&ek(t0));l!==h;)o.push(l),l=t.charAt(ew),R.test(l)?ew++:(l=h,0===e_&&ek(t0));if(l=[],u=ew,"::"===t.substr(ew,2)?(c="::",ew+=2):(c=h,0===e_&&ek(X)),c!==h)if(p=t.charAt(ew),B.test(p)?ew++:(p=h,0===e_&&ek(tK)),p!==h){for(d=[],m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));m!==h;)d.push(m),m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));u=c=[c,p,d]}else ew=u,u=h;else ew=u,u=h;for(;u!==h;)if(l.push(u),u=ew,"::"===t.substr(ew,2)?(c="::",ew+=2):(c=h,0===e_&&ek(X)),c!==h)if(p=t.charAt(ew),B.test(p)?ew++:(p=h,0===e_&&ek(tK)),p!==h){for(d=[],m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));m!==h;)d.push(m),m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));u=c=[c,p,d]}else ew=u,u=h;else ew=u,u=h;r=n=[n,a,o,l]}else ew=r,r=h;(s=r!==h?t.substring(s,ew):r)!==h?e={type:"Variable",scope:"global",name:s}:(ew=e,e=h)}else ew=e,e=h;return e}function ii(){let e,i,s,r,n,a,o,l,u,c,p;if(e=ew,i=ew,s=ew,t.substr(ew,6)===A?(r=A,ew+=6):(r=h,0===e_&&ek(t2)),r!==h){for(n=[],a=t.charAt(ew),O.test(a)?ew++:(a=h,0===e_&&ek(t3));a!==h;)n.push(a),a=t.charAt(ew),O.test(a)?ew++:(a=h,0===e_&&ek(t3));if("::"===t.substr(ew,2)?(a="::",ew+=2):(a=h,0===e_&&ek(X)),a!==h){for(o=[],l=t.charAt(ew),O.test(l)?ew++:(l=h,0===e_&&ek(t3));l!==h;)o.push(l),l=t.charAt(ew),O.test(l)?ew++:(l=h,0===e_&&ek(t3));if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));s=r=[r,n,a,o,l,u]}else ew=s,s=h}else ew=s,s=h}else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i.replace(/\s+/g,"")}),(e=i)===h){if(e=ew,i=ew,s=ew,t.substr(ew,6)===A?(r=A,ew+=6):(r=h,0===e_&&ek(t2)),r!==h){if(n=[],a=ew,"::"===t.substr(ew,2)?(o="::",ew+=2):(o=h,0===e_&&ek(X)),o!==h)if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));a=o=[o,l,u]}else ew=a,a=h;else ew=a,a=h;if(a!==h)for(;a!==h;)if(n.push(a),a=ew,"::"===t.substr(ew,2)?(o="::",ew+=2):(o=h,0===e_&&ek(X)),o!==h)if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));a=o=[o,l,u]}else ew=a,a=h;else ew=a,a=h;else n=h;n!==h?s=r=[r,n]:(ew=s,s=h)}else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i}),(e=i)===h){if(e=ew,i=ew,s=ew,r=t.charAt(ew),B.test(r)?ew++:(r=h,0===e_&&ek(tK)),r!==h){for(n=[],a=t.charAt(ew),R.test(a)?ew++:(a=h,0===e_&&ek(t0));a!==h;)n.push(a),a=t.charAt(ew),R.test(a)?ew++:(a=h,0===e_&&ek(t0));if(a=[],o=ew,"::"===t.substr(ew,2)?(l="::",ew+=2):(l=h,0===e_&&ek(X)),l!==h)if(u=t.charAt(ew),B.test(u)?ew++:(u=h,0===e_&&ek(tK)),u!==h){for(c=[],p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));p!==h;)c.push(p),p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));o=l=[l,u,c]}else ew=o,o=h;else ew=o,o=h;for(;o!==h;)if(a.push(o),o=ew,"::"===t.substr(ew,2)?(l="::",ew+=2):(l=h,0===e_&&ek(X)),l!==h)if(u=t.charAt(ew),B.test(u)?ew++:(u=h,0===e_&&ek(tK)),u!==h){for(c=[],p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));p!==h;)c.push(p),p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));o=l=[l,u,c]}else ew=o,o=h;else ew=o,o=h;s=r=[r,n,a]}else ew=s,s=h;(i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i}),e=i}}return e}function is(){let t;return(t=it())===h&&(t=ie())===h&&(t=ii()),t}function ir(){let e,i,s;return(e=ew,92===t.charCodeAt(ew)?(i="\\",ew++):(i=h,0===e_&&ek(t6)),i!==h&&(s=io())!==h)?e=s:(ew=e,e=h),e===h&&(e=t.charAt(ew),E.test(e)?ew++:(e=h,0===e_&&ek(t8))),e}function ia(){let e,i,s;return(e=ew,92===t.charCodeAt(ew)?(i="\\",ew++):(i=h,0===e_&&ek(t6)),i!==h&&(s=io())!==h)?e=s:(ew=e,e=h),e===h&&(e=t.charAt(ew),P.test(e)?ew++:(e=h,0===e_&&ek(t9))),e}function io(){let e,i,s,r,n,a;return e=ew,110===t.charCodeAt(ew)?(i="n",ew++):(i=h,0===e_&&ek(t7)),i!==h&&(i="\n"),(e=i)===h&&(e=ew,114===t.charCodeAt(ew)?(i="r",ew++):(i=h,0===e_&&ek(et)),i!==h&&(i="\r"),(e=i)===h)&&(e=ew,116===t.charCodeAt(ew)?(i="t",ew++):(i=h,0===e_&&ek(ee)),i!==h&&(i=" "),(e=i)===h)&&((e=ew,120===t.charCodeAt(ew)?(i="x",ew++):(i=h,0===e_&&ek(ei)),i!==h&&(s=ew,r=ew,n=t.charAt(ew),L.test(n)?ew++:(n=h,0===e_&&ek(es)),n!==h?(a=t.charAt(ew),L.test(a)?ew++:(a=h,0===e_&&ek(es)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h),(s=r!==h?t.substring(s,ew):r)!==h))?e=String.fromCharCode(parseInt(s,16)):(ew=e,e=h),e===h&&(e=ew,"cr"===t.substr(ew,2)?(i="cr",ew+=2):(i=h,0===e_&&ek(er)),i!==h&&(i="\x0f"),(e=i)===h&&(e=ew,"cp"===t.substr(ew,2)?(i="cp",ew+=2):(i=h,0===e_&&ek(en)),i!==h&&(i="\x10"),(e=i)===h))&&(e=ew,"co"===t.substr(ew,2)?(i="co",ew+=2):(i=h,0===e_&&ek(ea)),i!==h&&(i="\x11"),(e=i)===h)&&((e=ew,99===t.charCodeAt(ew)?(i="c",ew++):(i=h,0===e_&&ek(eo)),i!==h&&(s=t.charAt(ew),N.test(s)?ew++:(s=h,0===e_&&ek(eh)),s!==h))?e=String.fromCharCode([2,3,4,5,6,7,8,11,12,14][parseInt(s,10)]):(ew=e,e=h),e===h&&(e=ew,t.length>ew?(i=t.charAt(ew),ew++):(i=h,0===e_&&ek(el)),e=i))),e}function ih(){let e,i,s,r,n,a,o,l,u;if(e=ew,i=ew,s=ew,48===t.charCodeAt(ew)?(r="0",ew++):(r=h,0===e_&&ek(eu)),r!==h)if(n=t.charAt(ew),F.test(n)?ew++:(n=h,0===e_&&ek(ec)),n!==h){if(a=[],o=t.charAt(ew),L.test(o)?ew++:(o=h,0===e_&&ek(es)),o!==h)for(;o!==h;)a.push(o),o=t.charAt(ew),L.test(o)?ew++:(o=h,0===e_&&ek(es));else a=h;a!==h?s=r=[r,n,a]:(ew=s,s=h)}else ew=s,s=h;else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(s=ew,e_++,r=im(),e_--,r===h?s=void 0:(ew=s,s=h),s!==h)?e={type:"NumberLiteral",value:parseInt(i,16)}:(ew=e,e=h),e===h){if(e=ew,i=ew,s=ew,45===t.charCodeAt(ew)?(r="-",ew++):(r=h,0===e_&&ek(ep)),r===h&&(r=null),n=[],a=t.charAt(ew),N.test(a)?ew++:(a=h,0===e_&&ek(eh)),a!==h)for(;a!==h;)n.push(a),a=t.charAt(ew),N.test(a)?ew++:(a=h,0===e_&&ek(eh));else n=h;if(n!==h){if(a=ew,46===t.charCodeAt(ew)?(o=".",ew++):(o=h,0===e_&&ek(ts)),o!==h){if(l=[],u=t.charAt(ew),N.test(u)?ew++:(u=h,0===e_&&ek(eh)),u!==h)for(;u!==h;)l.push(u),u=t.charAt(ew),N.test(u)?ew++:(u=h,0===e_&&ek(eh));else l=h;l!==h?a=o=[o,l]:(ew=a,a=h)}else ew=a,a=h;a===h&&(a=null),s=r=[r,n,a]}else ew=s,s=h;if(s===h)if(s=ew,45===t.charCodeAt(ew)?(r="-",ew++):(r=h,0===e_&&ek(ep)),r===h&&(r=null),46===t.charCodeAt(ew)?(n=".",ew++):(n=h,0===e_&&ek(ts)),n!==h){if(a=[],o=t.charAt(ew),N.test(o)?ew++:(o=h,0===e_&&ek(eh)),o!==h)for(;o!==h;)a.push(o),o=t.charAt(ew),N.test(o)?ew++:(o=h,0===e_&&ek(eh));else a=h;a!==h?s=r=[r,n,a]:(ew=s,s=h)}else ew=s,s=h;(i=s!==h?t.substring(i,ew):s)!==h&&(s=ew,e_++,r=im(),e_--,r===h?s=void 0:(ew=s,s=h),s!==h)?e={type:"NumberLiteral",value:parseFloat(i)}:(ew=e,e=h)}return e}function il(){let e;return(e=function(){let e,i,s,r,n;if(e=ew,"//"===t.substr(ew,2)?(i="//",ew+=2):(i=h,0===e_&&ek(ef)),i!==h){for(s=ew,r=[],n=t.charAt(ew),$.test(n)?ew++:(n=h,0===e_&&ek(eg));n!==h;)r.push(n),n=t.charAt(ew),$.test(n)?ew++:(n=h,0===e_&&ek(eg));s=t.substring(s,ew),r=t.charAt(ew),V.test(r)?ew++:(r=h,0===e_&&ek(ey)),r===h&&(r=null),e={type:"Comment",value:s}}else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o;if(e=ew,"/*"===t.substr(ew,2)?(i="/*",ew+=2):(i=h,0===e_&&ek(ex)),i!==h){for(s=ew,r=[],n=ew,a=ew,e_++,"*/"===t.substr(ew,2)?(o="*/",ew+=2):(o=h,0===e_&&ek(eb)),e_--,o===h?a=void 0:(ew=a,a=h),a!==h?(t.length>ew?(o=t.charAt(ew),ew++):(o=h,0===e_&&ek(el)),o!==h?n=a=[a,o]:(ew=n,n=h)):(ew=n,n=h);n!==h;)r.push(n),n=ew,a=ew,e_++,"*/"===t.substr(ew,2)?(o="*/",ew+=2):(o=h,0===e_&&ek(eb)),e_--,o===h?a=void 0:(ew=a,a=h),a!==h?(t.length>ew?(o=t.charAt(ew),ew++):(o=h,0===e_&&ek(el)),o!==h?n=a=[a,o]:(ew=n,n=h)):(ew=n,n=h);(s=t.substring(s,ew),"*/"===t.substr(ew,2)?(r="*/",ew+=2):(r=h,0===e_&&ek(eb)),r!==h)?e={type:"Comment",value:s}:(ew=e,e=h)}else ew=e,e=h;return e}()),e}function iu(){let e,i;for(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i===h&&(i=id());i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i===h&&(i=id());return e}function ic(){let e,i,s,r;if(e=ew,i=[],s=t.charAt(ew),D.test(s)?ew++:(s=h,0===e_&&ek(ev)),s!==h)for(;s!==h;)i.push(s),s=t.charAt(ew),D.test(s)?ew++:(s=h,0===e_&&ek(ev));else i=h;if(i!==h){for(s=[],r=t.charAt(ew),D.test(r)?ew++:(r=h,0===e_&&ek(ev)),r===h&&(r=id());r!==h;)s.push(r),r=t.charAt(ew),D.test(r)?ew++:(r=h,0===e_&&ek(ev)),r===h&&(r=id());e=i=[i,s]}else ew=e,e=h;return e}function ip(){let e,i;for(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));return e}function id(){let e,i,s,r,n,a;if(e=ew,"//"===t.substr(ew,2)?(i="//",ew+=2):(i=h,0===e_&&ek(ef)),i!==h){for(s=[],r=t.charAt(ew),$.test(r)?ew++:(r=h,0===e_&&ek(eg));r!==h;)s.push(r),r=t.charAt(ew),$.test(r)?ew++:(r=h,0===e_&&ek(eg));r=t.charAt(ew),V.test(r)?ew++:(r=h,0===e_&&ek(ey)),r===h&&(r=null),e=i=[i,s,r]}else ew=e,e=h;if(e===h)if(e=ew,"/*"===t.substr(ew,2)?(i="/*",ew+=2):(i=h,0===e_&&ek(ex)),i!==h){for(s=[],r=ew,n=ew,e_++,"*/"===t.substr(ew,2)?(a="*/",ew+=2):(a=h,0===e_&&ek(eb)),e_--,a===h?n=void 0:(ew=n,n=h),n!==h?(t.length>ew?(a=t.charAt(ew),ew++):(a=h,0===e_&&ek(el)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=ew,e_++,"*/"===t.substr(ew,2)?(a="*/",ew+=2):(a=h,0===e_&&ek(eb)),e_--,a===h?n=void 0:(ew=n,n=h),n!==h?(t.length>ew?(a=t.charAt(ew),ew++):(a=h,0===e_&&ek(el)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h);"*/"===t.substr(ew,2)?(r="*/",ew+=2):(r=h,0===e_&&ek(eb)),r!==h?e=i=[i,s,r]:(ew=e,e=h)}else ew=e,e=h;return e}function im(){let e;return e=t.charAt(ew),R.test(e)?ew++:(e=h,0===e_&&ek(t0)),e}s=new Set,r=!1;let ig=(i=c())!==h&&ew===t.length;function iy(){var e,s,r;throw i!==h&&ew{"use strict";let s="[^\\\\/]",r="[^/]",n="(?:\\/|$)",a="(?:^|\\/)",o=`\\.{1,2}${n}`,h=`(?!${a}${o})`,l=`(?!\\.{0,1}${n})`,u=`(?!${o})`,c=`${r}*?`,p={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:r,END_ANCHOR:n,DOTS_SLASH:o,NO_DOT:"(?!\\.)",NO_DOTS:h,NO_DOT_SLASH:l,NO_DOTS_SLASH:u,QMARK_NO_DOT:"[^.\\/]",STAR:c,START_ANCHOR:a,SEP:"/"},d={...p,SLASH_LITERAL:"[\\\\/]",QMARK:s,STAR:`${s}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"};e.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars:t=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:t=>!0===t?d:p}},19241,(t,e,i)=>{"use strict";var s=t.i(47167);let{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:a,REGEX_SPECIAL_CHARS_GLOBAL:o}=t.r(53487);i.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),i.hasRegexChars=t=>a.test(t),i.isRegexChar=t=>1===t.length&&i.hasRegexChars(t),i.escapeRegex=t=>t.replace(o,"\\$1"),i.toPosixSlashes=t=>t.replace(r,"/"),i.isWindows=()=>{if("u">typeof navigator&&navigator.platform){let t=navigator.platform.toLowerCase();return"win32"===t||"windows"===t}return void 0!==s.default&&!!s.default.platform&&"win32"===s.default.platform},i.removeBackslashes=t=>t.replace(n,t=>"\\"===t?"":t),i.escapeLast=(t,e,s)=>{let r=t.lastIndexOf(e,s);return -1===r?t:"\\"===t[r-1]?i.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`},i.removePrefix=(t,e={})=>{let i=t;return i.startsWith("./")&&(i=i.slice(2),e.prefix="./"),i},i.wrapOutput=(t,e={},i={})=>{let s=i.contains?"":"^",r=i.contains?"":"$",n=`${s}(?:${t})${r}`;return!0===e.negated&&(n=`(?:^(?!${n}).*$)`),n},i.basename=(t,{windows:e}={})=>{let i=t.split(e?/[\\/]/:"/"),s=i[i.length-1];return""===s?i[i.length-2]:s}},26094,(t,e,i)=>{"use strict";let s=t.r(19241),{CHAR_ASTERISK:r,CHAR_AT:n,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:h,CHAR_EXCLAMATION_MARK:l,CHAR_FORWARD_SLASH:u,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:p,CHAR_LEFT_SQUARE_BRACKET:d,CHAR_PLUS:m,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:y,CHAR_RIGHT_SQUARE_BRACKET:x}=t.r(53487),b=t=>t===u||t===a,v=t=>{!0!==t.isPrefix&&(t.depth=t.isGlobstar?1/0:1)};e.exports=(t,e)=>{let i,w,M=e||{},S=t.length-1,A=!0===M.parts||!0===M.scanToEnd,_=[],C=[],T=[],I=t,z=-1,k=0,B=0,R=!1,O=!1,E=!1,P=!1,L=!1,N=!1,F=!1,$=!1,V=!1,D=!1,j=0,U={value:"",depth:0,isGlob:!1},W=()=>z>=S,G=()=>I.charCodeAt(z+1),q=()=>(i=w,I.charCodeAt(++z));for(;z0&&(J=I.slice(0,k),I=I.slice(k),B-=k),H&&!0===E&&B>0?(H=I.slice(0,B),X=I.slice(B)):!0===E?(H="",X=I):H=I,H&&""!==H&&"/"!==H&&H!==I&&b(H.charCodeAt(H.length-1))&&(H=H.slice(0,-1)),!0===M.unescape&&(X&&(X=s.removeBackslashes(X)),H&&!0===F&&(H=s.removeBackslashes(H)));let Z={prefix:J,input:t,start:k,base:H,glob:X,isBrace:R,isBracket:O,isGlob:E,isExtglob:P,isGlobstar:L,negated:$,negatedExtglob:V};if(!0===M.tokens&&(Z.maxDepth=0,b(w)||C.push(U),Z.tokens=C),!0===M.parts||!0===M.tokens){let e;for(let i=0;i<_.length;i++){let s=e?e+1:k,r=_[i],n=t.slice(s,r);M.tokens&&(0===i&&0!==k?(C[i].isPrefix=!0,C[i].value=J):C[i].value=n,v(C[i]),Z.maxDepth+=C[i].depth),(0!==i||""!==n)&&T.push(n),e=r}if(e&&e+1{"use strict";let s=t.r(53487),r=t.r(19241),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:h,REPLACEMENTS:l}=s,u=(t,e)=>{if("function"==typeof e.expandRange)return e.expandRange(...t,e);t.sort();let i=`[${t.join("-")}]`;try{new RegExp(i)}catch(e){return t.map(t=>r.escapeRegex(t)).join("..")}return i},c=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,p=(t,e)=>{let i;if("string"!=typeof t)throw TypeError("Expected a string");t=l[t]||t;let d={...e},m="number"==typeof d.maxLength?Math.min(n,d.maxLength):n,f=t.length;if(f>m)throw SyntaxError(`Input length: ${f}, exceeds maximum allowed length: ${m}`);let g={type:"bos",value:"",output:d.prepend||""},y=[g],x=d.capture?"":"?:",b=s.globChars(d.windows),v=s.extglobChars(b),{DOT_LITERAL:w,PLUS_LITERAL:M,SLASH_LITERAL:S,ONE_CHAR:A,DOTS_SLASH:_,NO_DOT:C,NO_DOT_SLASH:T,NO_DOTS_SLASH:I,QMARK:z,QMARK_NO_DOT:k,STAR:B,START_ANCHOR:R}=b,O=t=>`(${x}(?:(?!${R}${t.dot?_:w}).)*?)`,E=d.dot?"":C,P=d.dot?z:k,L=!0===d.bash?O(d):B;d.capture&&(L=`(${L})`),"boolean"==typeof d.noext&&(d.noextglob=d.noext);let N={input:t,index:-1,start:0,dot:!0===d.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:y};f=(t=r.removePrefix(t,N)).length;let F=[],$=[],V=[],D=g,j=()=>N.index===f-1,U=N.peek=(e=1)=>t[N.index+e],W=N.advance=()=>t[++N.index]||"",G=()=>t.slice(N.index+1),q=(t="",e=0)=>{N.consumed+=t,N.index+=e},H=t=>{N.output+=null!=t.output?t.output:t.value,q(t.value)},J=()=>{let t=1;for(;"!"===U()&&("("!==U(2)||"?"===U(3));)W(),N.start++,t++;return t%2!=0&&(N.negated=!0,N.start++,!0)},X=t=>{N[t]++,V.push(t)},Z=t=>{N[t]--,V.pop()},Y=t=>{if("globstar"===D.type){let e=N.braces>0&&("comma"===t.type||"brace"===t.type),i=!0===t.extglob||F.length&&("pipe"===t.type||"paren"===t.type);"slash"===t.type||"paren"===t.type||e||i||(N.output=N.output.slice(0,-D.output.length),D.type="star",D.value="*",D.output=L,N.output+=D.output)}if(F.length&&"paren"!==t.type&&(F[F.length-1].inner+=t.value),(t.value||t.output)&&H(t),D&&"text"===D.type&&"text"===t.type){D.output=(D.output||D.value)+t.value,D.value+=t.value;return}t.prev=D,y.push(t),D=t},Q=(t,e)=>{let i={...v[e],conditions:1,inner:""};i.prev=D,i.parens=N.parens,i.output=N.output;let s=(d.capture?"(":"")+i.open;X("parens"),Y({type:t,value:e,output:N.output?"":A}),Y({type:"paren",extglob:!0,value:W(),output:s}),F.push(i)},K=t=>{let s,r=t.close+(d.capture?")":"");if("negate"===t.type){let i=L;if(t.inner&&t.inner.length>1&&t.inner.includes("/")&&(i=O(d)),(i!==L||j()||/^\)+$/.test(G()))&&(r=t.close=`)$))${i}`),t.inner.includes("*")&&(s=G())&&/^\.[^\\/.]+$/.test(s)){let n=p(s,{...e,fastpaths:!1}).output;r=t.close=`)${n})${i})`}"bos"===t.prev.type&&(N.negatedExtglob=!0)}Y({type:"paren",extglob:!0,value:i,output:r}),Z("parens")};if(!1!==d.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(t)){let i=!1,s=t.replace(h,(t,e,s,r,n,a)=>"\\"===r?(i=!0,t):"?"===r?e?e+r+(n?z.repeat(n.length):""):0===a?P+(n?z.repeat(n.length):""):z.repeat(s.length):"."===r?w.repeat(s.length):"*"===r?e?e+r+(n?L:""):L:e?t:`\\${t}`);return(!0===i&&(s=!0===d.unescape?s.replace(/\\/g,""):s.replace(/\\+/g,t=>t.length%2==0?"\\\\":t?"\\":"")),s===t&&!0===d.contains)?N.output=t:N.output=r.wrapOutput(s,N,e),N}for(;!j();){if("\0"===(i=W()))continue;if("\\"===i){let t=U();if("/"===t&&!0!==d.bash||"."===t||";"===t)continue;if(!t){Y({type:"text",value:i+="\\"});continue}let e=/^\\+/.exec(G()),s=0;if(e&&e[0].length>2&&(s=e[0].length,N.index+=s,s%2!=0&&(i+="\\")),!0===d.unescape?i=W():i+=W(),0===N.brackets){Y({type:"text",value:i});continue}}if(N.brackets>0&&("]"!==i||"["===D.value||"[^"===D.value)){if(!1!==d.posix&&":"===i){let t=D.value.slice(1);if(t.includes("[")&&(D.posix=!0,t.includes(":"))){let t=D.value.lastIndexOf("["),e=D.value.slice(0,t),i=a[D.value.slice(t+2)];if(i){D.value=e+i,N.backtrack=!0,W(),g.output||1!==y.indexOf(D)||(g.output=A);continue}}}("["===i&&":"!==U()||"-"===i&&"]"===U())&&(i=`\\${i}`),"]"===i&&("["===D.value||"[^"===D.value)&&(i=`\\${i}`),!0===d.posix&&"!"===i&&"["===D.value&&(i="^"),D.value+=i,H({value:i});continue}if(1===N.quotes&&'"'!==i){i=r.escapeRegex(i),D.value+=i,H({value:i});continue}if('"'===i){N.quotes=+(1!==N.quotes),!0===d.keepQuotes&&Y({type:"text",value:i});continue}if("("===i){X("parens"),Y({type:"paren",value:i});continue}if(")"===i){if(0===N.parens&&!0===d.strictBrackets)throw SyntaxError(c("opening","("));let t=F[F.length-1];if(t&&N.parens===t.parens+1){K(F.pop());continue}Y({type:"paren",value:i,output:N.parens?")":"\\)"}),Z("parens");continue}if("["===i){if(!0!==d.nobracket&&G().includes("]"))X("brackets");else{if(!0!==d.nobracket&&!0===d.strictBrackets)throw SyntaxError(c("closing","]"));i=`\\${i}`}Y({type:"bracket",value:i});continue}if("]"===i){if(!0===d.nobracket||D&&"bracket"===D.type&&1===D.value.length){Y({type:"text",value:i,output:`\\${i}`});continue}if(0===N.brackets){if(!0===d.strictBrackets)throw SyntaxError(c("opening","["));Y({type:"text",value:i,output:`\\${i}`});continue}Z("brackets");let t=D.value.slice(1);if(!0===D.posix||"^"!==t[0]||t.includes("/")||(i=`/${i}`),D.value+=i,H({value:i}),!1===d.literalBrackets||r.hasRegexChars(t))continue;let e=r.escapeRegex(D.value);if(N.output=N.output.slice(0,-D.value.length),!0===d.literalBrackets){N.output+=e,D.value=e;continue}D.value=`(${x}${e}|${D.value})`,N.output+=D.value;continue}if("{"===i&&!0!==d.nobrace){X("braces");let t={type:"brace",value:i,output:"(",outputIndex:N.output.length,tokensIndex:N.tokens.length};$.push(t),Y(t);continue}if("}"===i){let t=$[$.length-1];if(!0===d.nobrace||!t){Y({type:"text",value:i,output:i});continue}let e=")";if(!0===t.dots){let t=y.slice(),i=[];for(let e=t.length-1;e>=0&&(y.pop(),"brace"!==t[e].type);e--)"dots"!==t[e].type&&i.unshift(t[e].value);e=u(i,d),N.backtrack=!0}if(!0!==t.comma&&!0!==t.dots){let s=N.output.slice(0,t.outputIndex),r=N.tokens.slice(t.tokensIndex);for(let n of(t.value=t.output="\\{",i=e="\\}",N.output=s,r))N.output+=n.output||n.value}Y({type:"brace",value:i,output:e}),Z("braces"),$.pop();continue}if("|"===i){F.length>0&&F[F.length-1].conditions++,Y({type:"text",value:i});continue}if(","===i){let t=i,e=$[$.length-1];e&&"braces"===V[V.length-1]&&(e.comma=!0,t="|"),Y({type:"comma",value:i,output:t});continue}if("/"===i){if("dot"===D.type&&N.index===N.start+1){N.start=N.index+1,N.consumed="",N.output="",y.pop(),D=g;continue}Y({type:"slash",value:i,output:S});continue}if("."===i){if(N.braces>0&&"dot"===D.type){"."===D.value&&(D.output=w);let t=$[$.length-1];D.type="dots",D.output+=i,D.value+=i,t.dots=!0;continue}if(N.braces+N.parens===0&&"bos"!==D.type&&"slash"!==D.type){Y({type:"text",value:i,output:w});continue}Y({type:"dot",value:i,output:w});continue}if("?"===i){if(!(D&&"("===D.value)&&!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Q("qmark",i);continue}if(D&&"paren"===D.type){let t=U(),e=i;("("!==D.value||/[!=<:]/.test(t))&&("<"!==t||/<([!=]|\w+>)/.test(G()))||(e=`\\${i}`),Y({type:"text",value:i,output:e});continue}if(!0!==d.dot&&("slash"===D.type||"bos"===D.type)){Y({type:"qmark",value:i,output:k});continue}Y({type:"qmark",value:i,output:z});continue}if("!"===i){if(!0!==d.noextglob&&"("===U()&&("?"!==U(2)||!/[!=<:]/.test(U(3)))){Q("negate",i);continue}if(!0!==d.nonegate&&0===N.index){J();continue}}if("+"===i){if(!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Q("plus",i);continue}if(D&&"("===D.value||!1===d.regex){Y({type:"plus",value:i,output:M});continue}if(D&&("bracket"===D.type||"paren"===D.type||"brace"===D.type)||N.parens>0){Y({type:"plus",value:i});continue}Y({type:"plus",value:M});continue}if("@"===i){if(!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Y({type:"at",extglob:!0,value:i,output:""});continue}Y({type:"text",value:i});continue}if("*"!==i){("$"===i||"^"===i)&&(i=`\\${i}`);let t=o.exec(G());t&&(i+=t[0],N.index+=t[0].length),Y({type:"text",value:i});continue}if(D&&("globstar"===D.type||!0===D.star)){D.type="star",D.star=!0,D.value+=i,D.output=L,N.backtrack=!0,N.globstar=!0,q(i);continue}let e=G();if(!0!==d.noextglob&&/^\([^?]/.test(e)){Q("star",i);continue}if("star"===D.type){if(!0===d.noglobstar){q(i);continue}let s=D.prev,r=s.prev,n="slash"===s.type||"bos"===s.type,a=r&&("star"===r.type||"globstar"===r.type);if(!0===d.bash&&(!n||e[0]&&"/"!==e[0])){Y({type:"star",value:i,output:""});continue}let o=N.braces>0&&("comma"===s.type||"brace"===s.type),h=F.length&&("pipe"===s.type||"paren"===s.type);if(!n&&"paren"!==s.type&&!o&&!h){Y({type:"star",value:i,output:""});continue}for(;"/**"===e.slice(0,3);){let i=t[N.index+4];if(i&&"/"!==i)break;e=e.slice(3),q("/**",3)}if("bos"===s.type&&j()){D.type="globstar",D.value+=i,D.output=O(d),N.output=D.output,N.globstar=!0,q(i);continue}if("slash"===s.type&&"bos"!==s.prev.type&&!a&&j()){N.output=N.output.slice(0,-(s.output+D.output).length),s.output=`(?:${s.output}`,D.type="globstar",D.output=O(d)+(d.strictSlashes?")":"|$)"),D.value+=i,N.globstar=!0,N.output+=s.output+D.output,q(i);continue}if("slash"===s.type&&"bos"!==s.prev.type&&"/"===e[0]){let t=void 0!==e[1]?"|$":"";N.output=N.output.slice(0,-(s.output+D.output).length),s.output=`(?:${s.output}`,D.type="globstar",D.output=`${O(d)}${S}|${S}${t})`,D.value+=i,N.output+=s.output+D.output,N.globstar=!0,q(i+W()),Y({type:"slash",value:"/",output:""});continue}if("bos"===s.type&&"/"===e[0]){D.type="globstar",D.value+=i,D.output=`(?:^|${S}|${O(d)}${S})`,N.output=D.output,N.globstar=!0,q(i+W()),Y({type:"slash",value:"/",output:""});continue}N.output=N.output.slice(0,-D.output.length),D.type="globstar",D.output=O(d),D.value+=i,N.output+=D.output,N.globstar=!0,q(i);continue}let s={type:"star",value:i,output:L};if(!0===d.bash){s.output=".*?",("bos"===D.type||"slash"===D.type)&&(s.output=E+s.output),Y(s);continue}if(D&&("bracket"===D.type||"paren"===D.type)&&!0===d.regex){s.output=i,Y(s);continue}(N.index===N.start||"slash"===D.type||"dot"===D.type)&&("dot"===D.type?(N.output+=T,D.output+=T):!0===d.dot?(N.output+=I,D.output+=I):(N.output+=E,D.output+=E),"*"!==U()&&(N.output+=A,D.output+=A)),Y(s)}for(;N.brackets>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing","]"));N.output=r.escapeLast(N.output,"["),Z("brackets")}for(;N.parens>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing",")"));N.output=r.escapeLast(N.output,"("),Z("parens")}for(;N.braces>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing","}"));N.output=r.escapeLast(N.output,"{"),Z("braces")}if(!0!==d.strictSlashes&&("star"===D.type||"bracket"===D.type)&&Y({type:"maybe_slash",value:"",output:`${S}?`}),!0===N.backtrack)for(let t of(N.output="",N.tokens))N.output+=null!=t.output?t.output:t.value,t.suffix&&(N.output+=t.suffix);return N};p.fastpaths=(t,e)=>{let i={...e},a="number"==typeof i.maxLength?Math.min(n,i.maxLength):n,o=t.length;if(o>a)throw SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${a}`);t=l[t]||t;let{DOT_LITERAL:h,SLASH_LITERAL:u,ONE_CHAR:c,DOTS_SLASH:p,NO_DOT:d,NO_DOTS:m,NO_DOTS_SLASH:f,STAR:g,START_ANCHOR:y}=s.globChars(i.windows),x=i.dot?m:d,b=i.dot?f:d,v=i.capture?"":"?:",w=!0===i.bash?".*?":g;i.capture&&(w=`(${w})`);let M=t=>!0===t.noglobstar?w:`(${v}(?:(?!${y}${t.dot?p:h}).)*?)`,S=t=>{switch(t){case"*":return`${x}${c}${w}`;case".*":return`${h}${c}${w}`;case"*.*":return`${x}${w}${h}${c}${w}`;case"*/*":return`${x}${w}${u}${c}${b}${w}`;case"**":return x+M(i);case"**/*":return`(?:${x}${M(i)}${u})?${b}${c}${w}`;case"**/*.*":return`(?:${x}${M(i)}${u})?${b}${w}${h}${c}${w}`;case"**/.*":return`(?:${x}${M(i)}${u})?${h}${c}${w}`;default:{let e=/^(.*?)\.(\w+)$/.exec(t);if(!e)return;let i=S(e[1]);if(!i)return;return i+h+e[2]}}},A=S(r.removePrefix(t,{negated:!1,prefix:""}));return A&&!0!==i.strictSlashes&&(A+=`${u}?`),A},e.exports=p},53174,(t,e,i)=>{"use strict";let s=t.r(26094),r=t.r(17932),n=t.r(19241),a=t.r(53487),o=(t,e,i=!1)=>{if(Array.isArray(t)){let s=t.map(t=>o(t,e,i));return t=>{for(let e of s){let i=e(t);if(i)return i}return!1}}let s=t&&"object"==typeof t&&!Array.isArray(t)&&t.tokens&&t.input;if(""===t||"string"!=typeof t&&!s)throw TypeError("Expected pattern to be a non-empty string");let r=e||{},n=r.windows,a=s?o.compileRe(t,e):o.makeRe(t,e,!1,!0),h=a.state;delete a.state;let l=()=>!1;if(r.ignore){let t={...e,ignore:null,onMatch:null,onResult:null};l=o(r.ignore,t,i)}let u=(i,s=!1)=>{let{isMatch:u,match:c,output:p}=o.test(i,a,e,{glob:t,posix:n}),d={glob:t,state:h,regex:a,posix:n,input:i,output:p,match:c,isMatch:u};return("function"==typeof r.onResult&&r.onResult(d),!1===u)?(d.isMatch=!1,!!s&&d):l(i)?("function"==typeof r.onIgnore&&r.onIgnore(d),d.isMatch=!1,!!s&&d):("function"==typeof r.onMatch&&r.onMatch(d),!s||d)};return i&&(u.state=h),u};o.test=(t,e,i,{glob:s,posix:r}={})=>{if("string"!=typeof t)throw TypeError("Expected input to be a string");if(""===t)return{isMatch:!1,output:""};let a=i||{},h=a.format||(r?n.toPosixSlashes:null),l=t===s,u=l&&h?h(t):t;return!1===l&&(l=(u=h?h(t):t)===s),(!1===l||!0===a.capture)&&(l=!0===a.matchBase||!0===a.basename?o.matchBase(t,e,i,r):e.exec(u)),{isMatch:!!l,match:l,output:u}},o.matchBase=(t,e,i)=>(e instanceof RegExp?e:o.makeRe(e,i)).test(n.basename(t)),o.isMatch=(t,e,i)=>o(e,i)(t),o.parse=(t,e)=>Array.isArray(t)?t.map(t=>o.parse(t,e)):r(t,{...e,fastpaths:!1}),o.scan=(t,e)=>s(t,e),o.compileRe=(t,e,i=!1,s=!1)=>{if(!0===i)return t.output;let r=e||{},n=r.contains?"":"^",a=r.contains?"":"$",h=`${n}(?:${t.output})${a}`;t&&!0===t.negated&&(h=`^(?!${h}).*$`);let l=o.toRegex(h,e);return!0===s&&(l.state=t),l},o.makeRe=(t,e={},i=!1,s=!1)=>{if(!t||"string"!=typeof t)throw TypeError("Expected a non-empty string");let n={negated:!1,fastpaths:!0};return!1!==e.fastpaths&&("."===t[0]||"*"===t[0])&&(n.output=r.fastpaths(t,e)),n.output||(n=r(t,e)),o.compileRe(n,e,i,s)},o.toRegex=(t,e)=>{try{let i=e||{};return new RegExp(t,i.flags||(i.nocase?"i":""))}catch(t){if(e&&!0===e.debug)throw t;return/$^/}},o.constants=a,e.exports=o},54970,(t,e,i)=>{"use strict";let s=t.r(53174),r=t.r(19241);function n(t,e,i=!1){return e&&(null===e.windows||void 0===e.windows)&&(e={...e,windows:r.isWindows()}),s(t,e,i)}Object.assign(n,s),e.exports=n},62395,33870,38433,86608,t=>{"use strict";var e=t.i(90072);t.s(["parse",()=>E,"runServer",()=>N],86608);var i=t.i(92552);function s(t){let e=t.indexOf("::");return -1===e?null:{namespace:t.slice(0,e),method:t.slice(e+2)}}let r={"+":"$.add","-":"$.sub","*":"$.mul","/":"$.div","<":"$.lt","<=":"$.le",">":"$.gt",">=":"$.ge","==":"$.eq","!=":"$.ne","%":"$.mod","&":"$.bitand","|":"$.bitor","^":"$.bitxor","<<":"$.shl",">>":"$.shr"};class n{indent;runtime;functions;globals;locals;indentLevel=0;currentClass=null;currentFunction=null;constructor(t={}){this.indent=t.indent??" ",this.runtime=t.runtime??"$",this.functions=t.functions??"$f",this.globals=t.globals??"$g",this.locals=t.locals??"$l"}getAccessInfo(t){if("Variable"===t.type){let e=JSON.stringify(t.name),i="global"===t.scope?this.globals:this.locals;return{getter:`${i}.get(${e})`,setter:t=>`${i}.set(${e}, ${t})`,postIncHelper:`${i}.postInc(${e})`,postDecHelper:`${i}.postDec(${e})`}}if("MemberExpression"===t.type){let e=this.expression(t.object),i="Identifier"===t.property.type?JSON.stringify(t.property.name):this.expression(t.property);return{getter:`${this.runtime}.prop(${e}, ${i})`,setter:t=>`${this.runtime}.setProp(${e}, ${i}, ${t})`,postIncHelper:`${this.runtime}.propPostInc(${e}, ${i})`,postDecHelper:`${this.runtime}.propPostDec(${e}, ${i})`}}if("IndexExpression"===t.type){let e=Array.isArray(t.index)?t.index.map(t=>this.expression(t)):[this.expression(t.index)];if("Variable"===t.object.type){let i=JSON.stringify(t.object.name),s="global"===t.object.scope?this.globals:this.locals,r=e.join(", ");return{getter:`${s}.get(${i}, ${r})`,setter:t=>`${s}.set(${i}, ${r}, ${t})`,postIncHelper:`${s}.postInc(${i}, ${r})`,postDecHelper:`${s}.postDec(${i}, ${r})`}}if("MemberExpression"===t.object.type){let i=t.object,s=this.expression(i.object),r="Identifier"===i.property.type?JSON.stringify(i.property.name):this.expression(i.property),n=`${this.runtime}.key(${r}, ${e.join(", ")})`;return{getter:`${this.runtime}.prop(${s}, ${n})`,setter:t=>`${this.runtime}.setProp(${s}, ${n}, ${t})`,postIncHelper:`${this.runtime}.propPostInc(${s}, ${n})`,postDecHelper:`${this.runtime}.propPostDec(${s}, ${n})`}}let i=this.expression(t.object),s=1===e.length?e[0]:`${this.runtime}.key(${e.join(", ")})`;return{getter:`${this.runtime}.getIndex(${i}, ${s})`,setter:t=>`${this.runtime}.setIndex(${i}, ${s}, ${t})`,postIncHelper:`${this.runtime}.indexPostInc(${i}, ${s})`,postDecHelper:`${this.runtime}.indexPostDec(${i}, ${s})`}}return null}generate(t){let e=[];for(let i of t.body){let t=this.statement(i);t&&e.push(t)}return e.join("\n\n")}statement(t){switch(t.type){case"Comment":return"";case"ExpressionStatement":return this.line(`${this.expression(t.expression)};`);case"FunctionDeclaration":return this.functionDeclaration(t);case"PackageDeclaration":return this.packageDeclaration(t);case"DatablockDeclaration":return this.datablockDeclaration(t);case"ObjectDeclaration":return this.line(`${this.objectDeclaration(t)};`);case"IfStatement":return this.ifStatement(t);case"ForStatement":return this.forStatement(t);case"WhileStatement":return this.whileStatement(t);case"DoWhileStatement":return this.doWhileStatement(t);case"SwitchStatement":return this.switchStatement(t);case"ReturnStatement":return this.returnStatement(t);case"BreakStatement":return this.line("break;");case"ContinueStatement":return this.line("continue;");case"BlockStatement":return this.blockStatement(t);default:throw Error(`Unknown statement type: ${t.type}`)}}functionDeclaration(t){let e=s(t.name.name);if(e){let i=e.namespace,s=e.method;this.currentClass=i.toLowerCase(),this.currentFunction=s.toLowerCase();let r=this.functionBody(t.body,t.params);return this.currentClass=null,this.currentFunction=null,`${this.line(`${this.runtime}.registerMethod(${JSON.stringify(i)}, ${JSON.stringify(s)}, function() {`)} -${r} -${this.line("});")}`}{let e=t.name.name;this.currentFunction=e.toLowerCase();let i=this.functionBody(t.body,t.params);return this.currentFunction=null,`${this.line(`${this.runtime}.registerFunction(${JSON.stringify(e)}, function() {`)} -${i} -${this.line("});")}`}}functionBody(t,e){this.indentLevel++;let i=[];i.push(this.line(`const ${this.locals} = ${this.runtime}.locals();`));for(let t=0;tthis.statement(t)).join("\n\n");return this.indentLevel--,`${this.line(`${this.runtime}.package(${e}, function() {`)} -${i} -${this.line("});")}`}datablockDeclaration(t){let e=JSON.stringify(t.className.name),i=t.instanceName?JSON.stringify(t.instanceName.name):"null",s=t.parent?JSON.stringify(t.parent.name):"null",r=this.objectBody(t.body);return this.line(`${this.runtime}.datablock(${e}, ${i}, ${s}, ${r});`)}objectDeclaration(t){let e="Identifier"===t.className.type?JSON.stringify(t.className.name):this.expression(t.className),i=null===t.instanceName?"null":"Identifier"===t.instanceName.type?JSON.stringify(t.instanceName.name):this.expression(t.instanceName),s=[],r=[];for(let e of t.body)"Assignment"===e.type?s.push(e):r.push(e);let n=this.objectBody(s);if(r.length>0){let t=r.map(t=>this.objectDeclaration(t)).join(",\n");return`${this.runtime}.create(${e}, ${i}, ${n}, [ -${t} -])`}return`${this.runtime}.create(${e}, ${i}, ${n})`}objectBody(t){if(0===t.length)return"{}";let e=[];for(let i of t)if("Assignment"===i.type){let t=this.expression(i.value);if("Identifier"===i.target.type){let s=i.target.name;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?e.push(`${s}: ${t}`):e.push(`[${JSON.stringify(s)}]: ${t}`)}else if("IndexExpression"===i.target.type){let s=this.objectPropertyKey(i.target);e.push(`[${s}]: ${t}`)}else{let s=this.expression(i.target);e.push(`[${s}]: ${t}`)}}if(e.length<=1)return`{ ${e.join(", ")} }`;let i=this.indent.repeat(this.indentLevel+1),s=this.indent.repeat(this.indentLevel);return`{ -${i}${e.join(",\n"+i)} -${s}}`}objectPropertyKey(t){let e="Identifier"===t.object.type?JSON.stringify(t.object.name):this.expression(t.object),i=Array.isArray(t.index)?t.index.map(t=>this.expression(t)).join(", "):this.expression(t.index);return`${this.runtime}.key(${e}, ${i})`}ifStatement(t){let e=this.expression(t.test),i=this.statementAsBlock(t.consequent);if(t.alternate)if("IfStatement"===t.alternate.type){let s=this.ifStatement(t.alternate).replace(/^\s*/,"");return this.line(`if (${e}) ${i} else ${s}`)}else{let s=this.statementAsBlock(t.alternate);return this.line(`if (${e}) ${i} else ${s}`)}return this.line(`if (${e}) ${i}`)}forStatement(t){let e=t.init?this.expression(t.init):"",i=t.test?this.expression(t.test):"",s=t.update?this.expression(t.update):"",r=this.statementAsBlock(t.body);return this.line(`for (${e}; ${i}; ${s}) ${r}`)}whileStatement(t){let e=this.expression(t.test),i=this.statementAsBlock(t.body);return this.line(`while (${e}) ${i}`)}doWhileStatement(t){let e=this.statementAsBlock(t.body),i=this.expression(t.test);return this.line(`do ${e} while (${i});`)}switchStatement(t){if(t.stringMode)return this.switchStringStatement(t);let e=this.expression(t.discriminant);this.indentLevel++;let i=[];for(let e of t.cases)i.push(this.switchCase(e));return this.indentLevel--,`${this.line(`switch (${e}) {`)} -${i.join("\n")} -${this.line("}")}`}switchCase(t){let e=[];if(null===t.test)e.push(this.line("default:"));else if(Array.isArray(t.test))for(let i of t.test)e.push(this.line(`case ${this.expression(i)}:`));else e.push(this.line(`case ${this.expression(t.test)}:`));for(let i of(this.indentLevel++,t.consequent))e.push(this.statement(i));return e.push(this.line("break;")),this.indentLevel--,e.join("\n")}switchStringStatement(t){let e=this.expression(t.discriminant),i=[];for(let e of t.cases)if(null===e.test)i.push(`default: () => { ${this.blockContent(e.consequent)} }`);else if(Array.isArray(e.test))for(let t of e.test)i.push(`${this.expression(t)}: () => { ${this.blockContent(e.consequent)} }`);else i.push(`${this.expression(e.test)}: () => { ${this.blockContent(e.consequent)} }`);return this.line(`${this.runtime}.switchStr(${e}, { ${i.join(", ")} });`)}returnStatement(t){return t.value?this.line(`return ${this.expression(t.value)};`):this.line("return;")}blockStatement(t){this.indentLevel++;let e=t.body.map(t=>this.statement(t)).join("\n");return this.indentLevel--,`{ -${e} -${this.line("}")}`}statementAsBlock(t){if("BlockStatement"===t.type)return this.blockStatement(t);this.indentLevel++;let e=this.statement(t);return this.indentLevel--,`{ -${e} -${this.line("}")}`}blockContent(t){return t.map(t=>this.statement(t).trim()).join(" ")}expression(t){switch(t.type){case"Identifier":return this.identifier(t);case"Variable":return this.variable(t);case"NumberLiteral":case"BooleanLiteral":return String(t.value);case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":return this.binaryExpression(t);case"UnaryExpression":return this.unaryExpression(t);case"PostfixExpression":return this.postfixExpression(t);case"AssignmentExpression":return this.assignmentExpression(t);case"ConditionalExpression":return`(${this.expression(t.test)} ? ${this.expression(t.consequent)} : ${this.expression(t.alternate)})`;case"CallExpression":return this.callExpression(t);case"MemberExpression":return this.memberExpression(t);case"IndexExpression":return this.indexExpression(t);case"TagDereferenceExpression":return`${this.runtime}.deref(${this.expression(t.argument)})`;case"ObjectDeclaration":return this.objectDeclaration(t);case"DatablockDeclaration":return`${this.runtime}.datablock(${JSON.stringify(t.className.name)}, ${t.instanceName?JSON.stringify(t.instanceName.name):"null"}, ${t.parent?JSON.stringify(t.parent.name):"null"}, ${this.objectBody(t.body)})`;default:throw Error(`Unknown expression type: ${t.type}`)}}identifier(t){let e=s(t.name);return e&&"parent"===e.namespace.toLowerCase()?t.name:e?`${this.runtime}.nsRef(${JSON.stringify(e.namespace)}, ${JSON.stringify(e.method)})`:JSON.stringify(t.name)}variable(t){return"global"===t.scope?`${this.globals}.get(${JSON.stringify(t.name)})`:`${this.locals}.get(${JSON.stringify(t.name)})`}binaryExpression(t){let e=this.expression(t.left),i=this.expression(t.right),s=t.operator,n=this.concatExpression(e,s,i);if(n)return n;if("$="===s)return`${this.runtime}.streq(${e}, ${i})`;if("!$="===s)return`!${this.runtime}.streq(${e}, ${i})`;if("&&"===s||"||"===s)return`(${e} ${s} ${i})`;let a=r[s];return a?`${a}(${e}, ${i})`:`(${e} ${s} ${i})`}unaryExpression(t){if("++"===t.operator||"--"===t.operator){let e=this.getAccessInfo(t.argument);if(e){let i="++"===t.operator?1:-1;return e.setter(`${this.runtime}.add(${e.getter}, ${i})`)}}let e=this.expression(t.argument);return"~"===t.operator?`${this.runtime}.bitnot(${e})`:"-"===t.operator?`${this.runtime}.neg(${e})`:`${t.operator}${e}`}postfixExpression(t){let e=this.getAccessInfo(t.argument);if(e){let i="++"===t.operator?e.postIncHelper:e.postDecHelper;if(i)return i}return`${this.expression(t.argument)}${t.operator}`}assignmentExpression(t){let e=this.expression(t.value),i=t.operator,s=this.getAccessInfo(t.target);if(!s)throw Error(`Unhandled assignment target type: ${t.target.type}`);if("="===i)return s.setter(e);{let t=i.slice(0,-1),r=this.compoundAssignmentValue(s.getter,t,e);return s.setter(r)}}callExpression(t){let e=t.arguments.map(t=>this.expression(t)).join(", ");if("Identifier"===t.callee.type){let i=t.callee.name,r=s(i);if(r&&"parent"===r.namespace.toLowerCase())if(this.currentClass)return`${this.runtime}.parent(${JSON.stringify(this.currentClass)}, ${JSON.stringify(r.method)}, arguments[0]${e?", "+e:""})`;else if(this.currentFunction)return`${this.runtime}.parentFunc(${JSON.stringify(this.currentFunction)}${e?", "+e:""})`;else throw Error("Parent:: call outside of function context");return r?`${this.runtime}.nsCall(${JSON.stringify(r.namespace)}, ${JSON.stringify(r.method)}${e?", "+e:""})`:`${this.functions}.call(${JSON.stringify(i)}${e?", "+e:""})`}if("MemberExpression"===t.callee.type){let i=this.expression(t.callee.object),s="Identifier"===t.callee.property.type?JSON.stringify(t.callee.property.name):this.expression(t.callee.property);return`${this.runtime}.call(${i}, ${s}${e?", "+e:""})`}let i=this.expression(t.callee);return`${i}(${e})`}memberExpression(t){let e=this.expression(t.object);return t.computed||"Identifier"!==t.property.type?`${this.runtime}.prop(${e}, ${this.expression(t.property)})`:`${this.runtime}.prop(${e}, ${JSON.stringify(t.property.name)})`}indexExpression(t){let e=Array.isArray(t.index)?t.index.map(t=>this.expression(t)):[this.expression(t.index)];if("Variable"===t.object.type){let i=JSON.stringify(t.object.name),s="global"===t.object.scope?this.globals:this.locals;return`${s}.get(${i}, ${e.join(", ")})`}if("MemberExpression"===t.object.type){let i=t.object,s=this.expression(i.object),r="Identifier"===i.property.type?JSON.stringify(i.property.name):this.expression(i.property),n=`${this.runtime}.key(${r}, ${e.join(", ")})`;return`${this.runtime}.prop(${s}, ${n})`}let i=this.expression(t.object);return 1===e.length?`${this.runtime}.getIndex(${i}, ${e[0]})`:`${this.runtime}.getIndex(${i}, ${this.runtime}.key(${e.join(", ")}))`}line(t){return this.indent.repeat(this.indentLevel)+t}concatExpression(t,e,i){switch(e){case"@":return`${this.runtime}.concat(${t}, ${i})`;case"SPC":return`${this.runtime}.concat(${t}, " ", ${i})`;case"TAB":return`${this.runtime}.concat(${t}, "\\t", ${i})`;case"NL":return`${this.runtime}.concat(${t}, "\\n", ${i})`;default:return null}}compoundAssignmentValue(t,e,i){let s=this.concatExpression(t,e,i);if(s)return s;let n=r[e];return n?`${n}(${t}, ${i})`:`(${t} ${e} ${i})`}}t.s(["createRuntime",()=>R,"createScriptCache",()=>I],33870);var a=t.i(54970);class o{map=new Map;keyLookup=new Map;constructor(t){if(t)for(const[e,i]of t)this.set(e,i)}get size(){return this.map.size}get(t){let e=this.keyLookup.get(t.toLowerCase());return void 0!==e?this.map.get(e):void 0}set(t,e){let i=t.toLowerCase(),s=this.keyLookup.get(i);return void 0!==s?this.map.set(s,e):(this.keyLookup.set(i,t),this.map.set(t,e)),this}has(t){return this.keyLookup.has(t.toLowerCase())}delete(t){let e=t.toLowerCase(),i=this.keyLookup.get(e);return void 0!==i&&(this.keyLookup.delete(e),this.map.delete(i))}clear(){this.map.clear(),this.keyLookup.clear()}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}forEach(t){for(let[e,i]of this.map)t(i,e,this)}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}getOriginalKey(t){return this.keyLookup.get(t.toLowerCase())}}class h{set=new Set;constructor(t){if(t)for(const e of t)this.add(e)}get size(){return this.set.size}add(t){return this.set.add(t.toLowerCase()),this}has(t){return this.set.has(t.toLowerCase())}delete(t){return this.set.delete(t.toLowerCase())}clear(){this.set.clear()}[Symbol.iterator](){return this.set[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}function l(t){return t.replace(/\\/g,"/").toLowerCase()}function u(t){return String(t??"")}function c(t){return Number(t)||0}function p(t){let e=u(t||"0 0 0").split(" ").map(Number);return[e[0]||0,e[1]||0,e[2]||0]}function d(t,e,i){let s=0;for(;e+s0;){if(s>=t.length)return"";let r=d(t,s,i);if(s+r>=t.length)return"";s+=r+1,e--}let r=d(t,s,i);return 0===r?"":t.substring(s,s+r)}function f(t,e,i,s){let r=0,n=e;for(;n>0;){if(r>=t.length)return"";let e=d(t,r,s);if(r+e>=t.length)return"";r+=e+1,n--}let a=r,o=i-e+1;for(;o>0;){let e=d(t,r,s);if((r+=e)>=t.length)break;r++,o--}let h=r;return h>a&&s.includes(t[h-1])&&h--,t.substring(a,h)}function g(t,e){if(""===t)return 0;let i=0;for(let s=0;se&&a>=t.length)break}return n.join(r)}function x(t,e,i,s){let r=[],n=0,a=0;for(;ne().$f.call(u(t),...i),eval(t){throw Error("eval() not implemented: requires runtime parsing and execution")},collapseescape:t=>u(t).replace(/\\([ntr\\])/g,(t,e)=>"n"===e?"\n":"t"===e?" ":"r"===e?"\r":"\\"),expandescape:t=>u(t).replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r"),export(t,e,i){console.warn(`export(${t}): not implemented`)},quit(){console.warn("quit(): not implemented in browser")},trace(t){},isobject:t=>e().$.isObject(t),nametoid:t=>e().$.nameToId(t),strlen:t=>u(t).length,strchr(t,e){let i=u(t),s=u(e)[0]??"",r=i.indexOf(s);return r>=0?i.substring(r):""},strpos:(t,e,i)=>u(t).indexOf(u(e),c(i)),strcmp(t,e){let i=u(t),s=u(e);return is)},stricmp(t,e){let i=u(t).toLowerCase(),s=u(e).toLowerCase();return is)},strstr:(t,e)=>u(t).indexOf(u(e)),getsubstr(t,e,i){let s=u(t),r=c(e);return void 0===i?s.substring(r):s.substring(r,r+c(i))},getword:(t,e)=>m(u(t),c(e)," \n"),getwordcount:t=>g(u(t)," \n"),getfield:(t,e)=>m(u(t),c(e)," \n"),getfieldcount:t=>g(u(t)," \n"),setword:(t,e,i)=>y(u(t),c(e),u(i)," \n"," "),setfield:(t,e,i)=>y(u(t),c(e),u(i)," \n"," "),firstword:t=>m(u(t),0," \n"),restwords:t=>f(u(t),1,1e6," \n"),trim:t=>u(t).trim(),ltrim:t=>u(t).replace(/^\s+/,""),rtrim:t=>u(t).replace(/\s+$/,""),strupr:t=>u(t).toUpperCase(),strlwr:t=>u(t).toLowerCase(),strreplace:(t,e,i)=>u(t).split(u(e)).join(u(i)),filterstring:(t,e)=>u(t),stripchars(t,e){let i=u(t),s=new Set(u(e).split(""));return i.split("").filter(t=>!s.has(t)).join("")},getfields(t,e,i){let s=void 0!==i?Number(i):1e6;return f(u(t),c(e),s," \n")},getwords(t,e,i){let s=void 0!==i?Number(i):1e6;return f(u(t),c(e),s," \n")},removeword:(t,e)=>x(u(t),c(e)," \n"," "),removefield:(t,e)=>x(u(t),c(e)," \n"," "),getrecord:(t,e)=>m(u(t),c(e),"\n"),getrecordcount:t=>g(u(t),"\n"),setrecord:(t,e,i)=>y(u(t),c(e),u(i),"\n","\n"),removerecord:(t,e)=>x(u(t),c(e),"\n","\n"),nexttoken(t,e,i){throw Error("nextToken() is not implemented: it requires variable mutation")},strtoplayername:t=>u(t).replace(/[^\w\s-]/g,"").trim(),mabs:t=>Math.abs(c(t)),mfloor:t=>Math.floor(c(t)),mceil:t=>Math.ceil(c(t)),msqrt:t=>Math.sqrt(c(t)),mpow:(t,e)=>Math.pow(c(t),c(e)),msin:t=>Math.sin(c(t)),mcos:t=>Math.cos(c(t)),mtan:t=>Math.tan(c(t)),masin:t=>Math.asin(c(t)),macos:t=>Math.acos(c(t)),matan:(t,e)=>Math.atan2(c(t),c(e)),mlog:t=>Math.log(c(t)),getrandom(t,e){if(void 0===t)return Math.random();if(void 0===e)return Math.floor(Math.random()*(c(t)+1));let i=c(t);return Math.floor(Math.random()*(c(e)-i+1))+i},mdegtorad:t=>c(t)*(Math.PI/180),mradtodeg:t=>c(t)*(180/Math.PI),mfloatlength:(t,e)=>c(t).toFixed(c(e)),getboxcenter(t){let e=u(t).split(" ").map(Number),i=e[0]||0,s=e[1]||0,r=e[2]||0,n=e[3]||0,a=e[4]||0,o=e[5]||0;return`${(i+n)/2} ${(s+a)/2} ${(r+o)/2}`},vectoradd(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${i+n} ${s+a} ${r+o}`},vectorsub(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${i-n} ${s-a} ${r-o}`},vectorscale(t,e){let[i,s,r]=p(t),n=c(e);return`${i*n} ${s*n} ${r*n}`},vectordot(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return i*n+s*a+r*o},vectorcross(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${s*o-r*a} ${r*n-i*o} ${i*a-s*n}`},vectorlen(t){let[e,i,s]=p(t);return Math.sqrt(e*e+i*i+s*s)},vectornormalize(t){let[e,i,s]=p(t),r=Math.sqrt(e*e+i*i+s*s);return 0===r?"0 0 0":`${e/r} ${i/r} ${s/r}`},vectordist(t,e){let[i,s,r]=p(t),[n,a,o]=p(e),h=i-n,l=s-a,u=r-o;return Math.sqrt(h*h+l*l+u*u)},matrixcreate(t,e){throw Error("MatrixCreate() not implemented: requires axis-angle rotation math")},matrixcreatefromeuler(t){throw Error("MatrixCreateFromEuler() not implemented: requires Euler→Quaternion→AxisAngle conversion")},matrixmultiply(t,e){throw Error("MatrixMultiply() not implemented: requires full 4x4 matrix multiplication")},matrixmulpoint(t,e){throw Error("MatrixMulPoint() not implemented: requires full transform application")},matrixmulvector(t,e){throw Error("MatrixMulVector() not implemented: requires rotation matrix application")},getsimtime:()=>Date.now()-e().state.startTime,getrealtime:()=>Date.now(),schedule(t,i,s,...r){let n=Number(t)||0,a=e(),o=setTimeout(()=>{a.state.pendingTimeouts.delete(o);try{a.$f.call(String(s),...r)}catch(t){throw console.error(`schedule: error calling ${s}:`,t),t}},n);return a.state.pendingTimeouts.add(o),o},cancel(t){clearTimeout(t),e().state.pendingTimeouts.delete(t)},iseventpending:t=>e().state.pendingTimeouts.has(t),exec(t){let i=String(t??"");if(console.debug(`exec(${JSON.stringify(i)}): preparing to execute…`),!i.includes("."))return console.error(`exec: invalid script file name ${JSON.stringify(i)}.`),!1;let s=l(i),r=e(),{executedScripts:n,scripts:a}=r.state;if(n.has(s))return console.debug(`exec(${JSON.stringify(i)}): skipping (already executed)`),!0;let o=a.get(s);return null==o?(console.warn(`exec(${JSON.stringify(i)}): script not found`),!1):(n.add(s),console.debug(`exec(${JSON.stringify(i)}): executing!`),r.executeAST(o),!0)},compile(t){throw Error("compile() not implemented: requires DSO bytecode compiler")},isdemo:()=>!1,isfile:t=>i?i.isFile(u(t)):(console.warn("isFile(): no fileSystem handler configured"),!1),fileext(t){let e=u(t),i=e.lastIndexOf(".");return i>=0?e.substring(i):""},filebase(t){let e=u(t),i=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),s=e.lastIndexOf("."),r=i>=0?i+1:0,n=s>r?s:e.length;return e.substring(r,n)},filepath(t){let e=u(t),i=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return i>=0?e.substring(0,i):""},expandfilename(t){throw Error("expandFilename() not implemented: requires filesystem path expansion")},findfirstfile:t=>i?(n=u(t),s=i.findFiles(n),r=0,s[r++]??""):(console.warn("findFirstFile(): no fileSystem handler configured"),""),findnextfile(t){let e=u(t);if(e!==n){if(!i)return"";n=e,s=i.findFiles(e)}return s[r++]??""},getfilecrc:t=>u(t),iswriteablefilename:t=>!1,activatepackage(t){e().$.activatePackage(u(t))},deactivatepackage(t){e().$.deactivatePackage(u(t))},ispackage:t=>e().$.isPackage(u(t)),isactivepackage:t=>e().$.isActivePackage(u(t)),getpackagelist:()=>e().$.getPackageList(),addmessagecallback(t,e){},alxcreatesource:(...t)=>0,alxgetwavelen:t=>0,alxlistenerf(t,e){},alxplay:(...t)=>0,alxsetchannelvolume(t,e){},alxsourcef(t,e,i){},alxstop(t){},alxstopall(){},activatedirectinput(){},activatekeyboard(){},deactivatedirectinput(){},deactivatekeyboard(){},disablejoystick(){},enablejoystick(){},enablewinconsole(t){},isjoystickdetected:()=>!1,lockmouse(t){},addmaterialmapping(t,e){},flushtexturecache(){},getdesktopresolution:()=>"1920 1080 32",getdisplaydevicelist:()=>"OpenGL",getresolutionlist:t=>"640 480 800 600 1024 768 1280 720 1920 1080",getvideodriverinfo:()=>"WebGL",isdevicefullscreenonly:t=>!1,isfullscreen:()=>!1,screenshot(t){},setdisplaydevice:t=>!0,setfov(t){},setinteriorrendermode(t){},setopenglanisotropy(t){},setopenglmipreduction(t){},setopenglskymipreduction(t){},setopengltexturecompressionhint(t){},setscreenmode(t,e,i,s){},setverticalsync(t){},setzoomspeed(t){},togglefullscreen(){},videosetgammacorrection(t){},snaptoggle(){},addtaggedstring:t=>0,buildtaggedstring:(t,...e)=>"",detag:t=>u(t),gettag:t=>0,gettaggedstring:t=>"",removetaggedstring(t){},commandtoclient(t,e){},commandtoserver(t){},cancelserverquery(){},querymasterserver(){},querysingleserver(){},setnetport:t=>!0,allowconnections(t){},startheartbeat(){},stopheartbeat(){},gotowebpage(t){},deletedatablocks(){},preloaddatablock:t=>!0,containerboxempty:(...t)=>!0,containerraycast:(...t)=>"",containersearchcurrdist:()=>0,containersearchnext:()=>0,initcontainerradiussearch(){},calcexplosioncoverage:(...t)=>1,getcontrolobjectaltitude:()=>0,getcontrolobjectspeed:()=>0,getterrainheight:t=>0,lightscene(){},pathonmissionloaddone(){}}}function v(t){return t.toLowerCase()}function w(t){let e=t.trim();return v(e.startsWith("$")?e.slice(1):e)}function M(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}function S(t,e){for(let i of e)t.add(v(i))}function A(t,e,i){if(t.anyClassValues.has("*")||t.anyClassValues.has(i))return!0;for(let s of e){let e=t.valuesByClass.get(v(s));if(e&&(e.has("*")||e.has(i)))return!0}return!1}let _=[{classNames:["SceneObject","GameBase","ShapeBase","Item","Player"],fields:["position","rotation","scale","transform","hidden","renderingdistance","datablock","shapename","shapefile","initialbarrel","skin","team","health","energy","energylevel","damagelevel","damageflash","damagepercent","damagestate","mountobject","mountedimage","targetposition","targetrotation","targetscale","missiontypeslist","renderenabled","vis","velocity","name"]},{classNames:["*"],fields:["position","rotation","scale","hidden","shapefile","datablock"]}],C=[{classNames:["SceneObject","GameBase","ShapeBase","SimObject"],methods:["settransform","setposition","setrotation","setscale","sethidden","setdatablock","setshapename","mountimage","unmountimage","mountobject","unmountobject","setdamagelevel","setenergylevel","schedule","delete","deleteallobjects","add","remove","playthread","stopthread","setthreaddir","pausethread"]},{classNames:["*"],methods:["settransform","setscale","delete","add","remove"]}],T=["missionrunning","loadingmission"];function I(){return{scripts:new Map,generatedCode:new WeakMap}}function z(t){return t.toLowerCase()}function k(t){return Number(t)>>>0}function B(t){if(null==t)return null;if("string"==typeof t)return t||null;if("number"==typeof t)return String(t);throw Error(`Invalid instance name type: ${typeof t}`)}function R(t={}){let e,i,s,r=t.reactiveFieldRules??_,u=t.reactiveMethodRules??C,c=t.reactiveGlobalNames??T,p=(e=function(t){let e=new Set,i=new Map;for(let s of t)for(let t of s.classNames){let r=v(t);if("*"===r){S(e,s.fields);continue}S(M(i,r),s.fields)}return{anyClassValues:e,valuesByClass:i}}(r),(t,i)=>A(e,t,v(i))),d=(i=function(t){let e=new Set,i=new Map;for(let s of t)for(let t of s.classNames){let r=v(t);if("*"===r){S(e,s.methods);continue}S(M(i,r),s.methods)}return{anyClassValues:e,valuesByClass:i}}(u),(t,e)=>A(i,t,v(e))),m=(s=function(t){let e=new Set;for(let i of t)e.add(w(i));return e}(c),t=>{let e=w(t);return s.has("*")||s.has(e)}),f=new o,g=new o,y=new o,x=[],O=new h,P=3,L=1027,N=new Map,F=new o,$=new o,V=new o,D=new o,j=new o,U=new Set,W=[],G=!1,q=0;if(t.globals)for(let[e,i]of Object.entries(t.globals)){if(!e.startsWith("$"))throw Error(`Global variable "${e}" must start with $, e.g. "$${e}"`);V.set(e.slice(1),i)}let H=new Set,J=new Set,X=t.ignoreScripts&&t.ignoreScripts.length>0?(0,a.default)(t.ignoreScripts,{nocase:!0}):null,Z=t.cache??I(),Y=Z.scripts,Q=Z.generatedCode,K=new Map;function tt(t){let e=K.get(t);return e&&e.length>0?e[e.length-1]:void 0}function te(t,e,i){let s;(s=K.get(t))||(s=[],K.set(t,s)),s.push(e);try{return i()}finally{let e;(e=K.get(t))&&e.pop()}}function ti(t,e){return`${t.toLowerCase()}::${e.toLowerCase()}`}function ts(t,e){return f.get(t)?.get(e)??null}function tr(t){if(!t)return[];let e=[],i=new Set,s=t.class||t._className||t._class,r=s?z(String(s)):"";for(;r&&!i.has(r);)e.push(r),i.add(r),r=j.get(r)??"";return t._superClass&&!i.has(t._superClass)&&e.push(t._superClass),e}function tn(){if(G=!1,0===W.length)return;let t=W.splice(0,W.length);for(let e of(q+=1,U))e({type:"batch.flushed",tick:q,events:t})}function ta(t){for(let e of(W.push(t),U))e(t);G||(G=!0,queueMicrotask(tn))}function to(t){ta({type:"object.created",objectId:t._id,object:t})}function th(t,e,i,s){let r=z(e);Object.is(i,s)||p(tr(t),r)&&ta({type:"field.changed",objectId:t._id,field:r,value:i,previousValue:s,object:t})}let tl=new Set,tu=null,tc=null,tp=(t.builtins??b)({runtime:()=>tc,fileSystem:t.fileSystem??null});function td(t){let e=y.get(t);if(!e)return void O.add(t);if(!e.active){for(let[t,i]of(e.active=!0,x.push(e.name),e.methods)){f.has(t)||f.set(t,new o);let e=f.get(t);for(let[t,s]of i)e.has(t)||e.set(t,[]),e.get(t).push(s)}for(let[t,i]of e.functions)g.has(t)||g.set(t,[]),g.get(t).push(i)}}function tm(t){return null==t||""===t?null:"object"==typeof t&&null!=t._id?t:"string"==typeof t?F.get(t)??null:"number"==typeof t?N.get(t)??null:null}function tf(t,e,i){let s=tm(t);if(null==s)return 0;let r=tb(s[e]);return s[e]=r+i,th(s,e,s[e],r),r}function tg(t,e){let i=ts(t,e);return i&&i.length>0?i[i.length-1]:null}function ty(t,e,i,s){let r=ts(t,e);return r&&0!==r.length?{found:!0,result:te(ti(t,e),r.length-1,()=>r[r.length-1](i,...s))}:{found:!1}}function tx(t,e,i,s){let r;d((r=tr(i)).length?r:[t],e)&&ta({type:"method.called",className:z(t),methodName:z(e),objectId:i._id,args:[...s]});let n=D.get(t);if(n){let t=n.get(e);if(t)for(let e of t)e(i,...s)}}function tb(t){if(null==t||""===t)return 0;let e=Number(t);return isNaN(e)?0:e}function tv(t){if(!t||""===t)return null;t.startsWith("/")&&(t=t.slice(1));let e=t.split("/"),i=null;for(let t=0;te._name?.toLowerCase()===t)??null}if(!i)return null}}return i}function tw(t){return null==t||""===t?null:tv(String(t))}function tM(t,e){function i(t,e){return t+e.join("_")}return{get:(e,...s)=>t.get(i(e,s))??"",set(s,...r){if(0===r.length)throw Error("set() requires at least a value argument");if(1===r.length){let i=t.get(s);return t.set(s,r[0]),e?.onSet?.(s,r[0],i),r[0]}let n=r[r.length-1],a=i(s,r.slice(0,-1)),o=t.get(a);return t.set(a,n),e?.onSet?.(a,n,o),n},postInc(s,...r){let n=i(s,r),a=tb(t.get(n)),o=a+1;return t.set(n,o),e?.onSet?.(n,o,a),a},postDec(s,...r){let n=i(s,r),a=tb(t.get(n)),o=a-1;return t.set(n,o),e?.onSet?.(n,o,a),a}}}function tS(){return tM(new o)}let tA={registerMethod:function(t,e,i){if(tu)tu.methods.has(t)||tu.methods.set(t,new o),tu.methods.get(t).set(e,i);else{f.has(t)||f.set(t,new o);let s=f.get(t);s.has(e)||s.set(e,[]),s.get(e).push(i)}},registerFunction:function(t,e){tu?tu.functions.set(t,e):(g.has(t)||g.set(t,[]),g.get(t).push(e))},package:function(t,e){let i=y.get(t);i||(i={name:t,active:!1,methods:new o,functions:new o},y.set(t,i));let s=tu;tu=i,e(),tu=s,O.has(t)&&(O.delete(t),td(t))},activatePackage:td,deactivatePackage:function(t){let e=y.get(t);if(!e||!e.active)return;e.active=!1;let i=x.findIndex(e=>e.toLowerCase()===t.toLowerCase());for(let[t,s]of(-1!==i&&x.splice(i,1),e.methods)){let e=f.get(t);if(e)for(let[t,i]of s){let s=e.get(t);if(s){let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}for(let[t,i]of e.functions){let e=g.get(t);if(e){let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}},create:function(t,e,i,s){let r=z(t),n=function(){for(;N.has(L);)L+=1;let t=L;return L+=1,t}(),a={_class:r,_className:t,_id:n};for(let[t,e]of Object.entries(i))a[z(t)]=e;a.superclass&&(a._superClass=z(String(a.superclass)),a.class&&j.set(z(String(a.class)),a._superClass)),N.set(n,a);let o=B(e);if(o&&(a._name=o,F.set(o,a)),s){for(let t of s)t._parent=a;a._children=s}let h=tg(t,"onAdd");return h&&h(a),to(a),a},datablock:function(t,e,i,s){let r=z(t),n=function(){for(;N.has(P);)P+=1;let t=P;return P+=1,t}(),a={_class:r,_className:t,_id:n,_isDatablock:!0},o=B(i);if(o){let t=$.get(o);if(t){for(let[e,i]of Object.entries(t))e.startsWith("_")||(a[e]=i);a._parent=t}}for(let[t,e]of Object.entries(s))a[z(t)]=e;N.set(n,a);let h=B(e);return h&&(a._name=h,F.set(h,a),$.set(h,a)),to(a),a},deleteObject:function t(e){var i;let s;if(null==e||("number"==typeof e?s=N.get(e):"string"==typeof e?s=F.get(e):"object"==typeof e&&e._id&&(s=e),!s))return!1;let r=tg(s._className,"onRemove");if(r&&r(s),N.delete(s._id),s._name&&F.delete(s._name),s._isDatablock&&s._name&&$.delete(s._name),s._parent&&s._parent._children){let t=s._parent._children.indexOf(s);-1!==t&&s._parent._children.splice(t,1)}if(s._children)for(let e of[...s._children])t(e);return ta({type:"object.deleted",objectId:(i=s)._id,object:i}),!0},prop:function(t,e){let i=tm(t);return null==i?"":i[z(e)]??""},setProp:function(t,e,i){let s=tm(t);if(null==s)return i;let r=z(e),n=s[r];return s[r]=i,th(s,r,i,n),i},getIndex:function(t,e){let i=tm(t);return null==i?"":i[String(e)]??""},setIndex:function(t,e,i){let s=tm(t);if(null==s)return i;let r=String(e),n=s[r];return s[r]=i,th(s,r,i,n),i},propPostInc:function(t,e){return tf(t,z(e),1)},propPostDec:function(t,e){return tf(t,z(e),-1)},indexPostInc:function(t,e){return tf(t,String(e),1)},indexPostDec:function(t,e){return tf(t,String(e),-1)},key:function(t,...e){return t+e.join("_")},call:function(t,e,...i){if(null==t||("string"==typeof t||"number"==typeof t)&&null==(t=tw(t)))return"";let s=t.class||t._className||t._class;if(s){let r=ty(s,e,t,i);if(r.found)return tx(s,e,t,i),r.result}let r=t._superClass||j.get(s);for(;r;){let s=ty(r,e,t,i);if(s.found)return tx(r,e,t,i),s.result;r=j.get(r)}return""},nsCall:function(t,e,...i){let s=ts(t,e);if(!s||0===s.length)return"";let r=ti(t,e),n=s[s.length-1],a=te(r,s.length-1,()=>n(...i)),o=i[0];return o&&"object"==typeof o&&tx(t,e,o,i.slice(1)),a},nsRef:function(t,e){let i=ts(t,e);if(!i||0===i.length)return null;let s=ti(t,e),r=i[i.length-1];return(...t)=>te(s,i.length-1,()=>r(...t))},parent:function(t,e,i,...s){let r=ts(t,e),n=ti(t,e),a=tt(n);if(r&&void 0!==a&&a>=1){let o=a-1,h=te(n,o,()=>r[o](i,...s));return i&&"object"==typeof i&&tx(t,e,i,s),h}let o=j.get(t);for(;o;){let t=ts(o,e);if(t&&t.length>0){let r=te(ti(o,e),t.length-1,()=>t[t.length-1](i,...s));return i&&"object"==typeof i&&tx(o,e,i,s),r}o=j.get(o)}return""},parentFunc:function(t,...e){let i=g.get(t);if(!i)return"";let s=t.toLowerCase(),r=tt(s);if(void 0===r||r<1)return"";let n=r-1;return te(s,n,()=>i[n](...e))},add:function(t,e){return tb(t)+tb(e)},sub:function(t,e){return tb(t)-tb(e)},mul:function(t,e){return tb(t)*tb(e)},div:function(t,e){return tb(t)/tb(e)},neg:function(t){return-tb(t)},lt:function(t,e){return tb(t)tb(e)},ge:function(t,e){return tb(t)>=tb(e)},eq:function(t,e){return tb(t)===tb(e)},ne:function(t,e){return tb(t)!==tb(e)},mod:function(t,e){let i=0|Number(e);return 0===i?0:(0|Number(t))%i},bitand:function(t,e){return k(t)&k(e)},bitor:function(t,e){return k(t)|k(e)},bitxor:function(t,e){return k(t)^k(e)},shl:function(t,e){return k(k(t)<<(31&k(e)))},shr:function(t,e){return k(t)>>>(31&k(e))},bitnot:function(t){return~k(t)>>>0},concat:function(...t){return t.map(t=>String(t??"")).join("")},streq:function(t,e){return String(t??"").toLowerCase()===String(e??"").toLowerCase()},switchStr:function(t,e){let i=String(t??"").toLowerCase();for(let[t,s]of Object.entries(e))if("default"!==t&&z(t)===i)return void s();e.default&&e.default()},deref:tw,nameToId:function(t){let e=tv(t);return e?e._id:-1},isObject:function(t){return null!=t&&("object"==typeof t&&!!t._id||("number"==typeof t?N.has(t):"string"==typeof t&&F.has(t)))},isFunction:function(t){return g.has(t)||t.toLowerCase()in tp},isPackage:function(t){return y.has(t)},isActivePackage:function(t){let e=y.get(t);return e?.active??!1},getPackageList:function(){return x.join(" ")},locals:tS,onMethodCalled(t,e,i){let s=D.get(t);s||(s=new o,D.set(t,s));let r=s.get(e);return r||(r=[],s.set(e,r)),r.push(i),()=>{let t=r.indexOf(i);-1!==t&&r.splice(t,1)}}},t_={call(t,...e){let i=g.get(t);if(i&&i.length>0)return te(t.toLowerCase(),i.length-1,()=>i[i.length-1](...e));let s=tp[t.toLowerCase()];return s?s(...e):(console.warn(`Unknown function: ${t}(${e.map(t=>JSON.stringify(t)).join(", ")})`),"")}},tC=tM(V,{onSet:function(t,e,i){let s=z(t.startsWith("$")?t.slice(1):t);Object.is(e,i)||m(s)&&ta({type:"global.changed",name:s,value:e,previousValue:i})}}),tT={methods:f,functions:g,packages:y,activePackages:x,objectsById:N,objectsByName:F,datablocks:$,globals:V,executedScripts:H,failedScripts:J,scripts:Y,generatedCode:Q,pendingTimeouts:tl,startTime:Date.now()};function tI(t){let e=function(t){let e=Q.get(t);null==e&&(e=new n(void 0).generate(t),Q.set(t,e));return e}(t),i=tS();Function("$","$f","$g","$l",e)(tA,t_,tC,i)}function tz(t,e){return{execute(){if(e){let t=l(e);tT.executedScripts.add(t)}tI(t)}}}async function tk(e,i,s){let r=t.loadScript;if(!r){e.length>0&&console.warn("Script has exec() calls but no loadScript provided:",e);return}async function n(e){t.signal?.throwIfAborted();let n=l(e);if(tT.scripts.has(n)||tT.failedScripts.has(n))return;if(X&&X(n)){console.warn(`Ignoring script: ${e}`),tT.failedScripts.add(n);return}if(s.has(n))return;let a=i.get(n);if(a)return void await a;t.progress?.addItem(e);let o=(async()=>{let a,o=await r(e);if(null==o){console.warn(`Script not found: ${e}`),tT.failedScripts.add(n),t.progress?.completeItem();return}try{a=E(o,{filename:e})}catch(i){console.warn(`Failed to parse script: ${e}`,i),tT.failedScripts.add(n),t.progress?.completeItem();return}let h=new Set(s);h.add(n),await tk(a.execScriptPaths,i,h),tT.scripts.set(n,a),t.progress?.completeItem()})();i.set(n,o),await o}await Promise.all(e.map(n))}async function tB(e){let i=t.loadScript;if(!i)throw Error("loadFromPath requires loadScript option to be set");let s=l(e);if(tT.scripts.has(s))return tz(tT.scripts.get(s),e);t.progress?.addItem(e);let r=await i(e);if(null==r)throw t.progress?.completeItem(),Error(`Script not found: ${e}`);let n=await tR(r,{path:e});return t.progress?.completeItem(),n}async function tR(t,e){if(e?.path){let t=l(e.path);if(tT.scripts.has(t))return tz(tT.scripts.get(t),e.path)}return tO(E(t,{filename:e?.path}),e)}async function tO(e,i){let s=new Map,r=new Set;if(i?.path){let t=l(i.path);tT.scripts.set(t,e),r.add(t)}let n=[...e.execScriptPaths,...t.preloadScripts??[]];return await tk(n,s,r),tz(e,i?.path)}return tc={$:tA,$f:t_,$g:tC,state:tT,destroy:function(){for(let t of(W.length>0&&tn(),tT.pendingTimeouts))clearTimeout(t);tT.pendingTimeouts.clear(),U.clear()},executeAST:tI,loadFromPath:tB,loadFromSource:tR,loadFromAST:tO,call:(t,...e)=>t_.call(t,...e),getObjectByName:t=>F.get(t),subscribeRuntimeEvents:t=>(U.add(t),()=>{U.delete(t)})}}function O(){let t=new Set,e=0,i=0,s=null;function r(){for(let e of t)e()}return{get total(){return e},get loaded(){return i},get current(){return s},get progress(){return 0===e?0:i/e},on(e,i){t.add(i)},off(e,i){t.delete(i)},addItem(t){e++,s=t,r()},completeItem(){i++,s=null,r()},setCurrent(t){s=t,r()}}}function E(t,e){try{return i.default.parse(t)}catch(t){if(e?.filename&&t.location)throw Error(`${e.filename}:${t.location.start.line}:${t.location.start.column}: ${t.message}`,{cause:t});throw t}}function P(t){if("boolean"==typeof t)return t;if("number"==typeof t)return 0!==t;if("string"==typeof t){let e=t.trim().toLowerCase();return""!==e&&"0"!==e&&"false"!==e}return!!t}function L(){let t=Error("Operation aborted");return t.name="AbortError",t}function N(t){let e,{missionName:i,missionType:s,runtimeOptions:r,onMissionLoadDone:n}=t,{signal:a,fileSystem:o,globals:h={},preloadScripts:l=[],reactiveGlobalNames:u}=r??{},c=o?.findFiles("scripts/*Game.cs")??[],p=u?Array.from(new Set([...u,"missionRunning"])):void 0,d=R({...r,reactiveGlobalNames:p,globals:{...h,"$Host::Map":i,"$Host::MissionType":s},preloadScripts:[...l,...c]});(e=d.$.registerMethod.bind(d.$))("ShapeBase","playThread",(t,e,i)=>{t._threads||(t._threads={}),t._threads[Number(e)]={sequence:String(i),playing:!0,direction:!0}}),e("ShapeBase","stopThread",(t,e)=>{t._threads&&delete t._threads[Number(e)]}),e("ShapeBase","setThreadDir",(t,e,i)=>{t._threads||(t._threads={});let s=Number(e);t._threads[s]?t._threads[s].direction=!!Number(i):t._threads[s]={sequence:"",playing:!1,direction:!!Number(i)}}),e("ShapeBase","pauseThread",(t,e)=>{t._threads?.[Number(e)]&&(t._threads[Number(e)].playing=!1)}),e("ShapeBase","playAudio",()=>{}),e("ShapeBase","stopAudio",()=>{}),e("SimObject","getDatablock",t=>{let e=t.datablock;return e?d.getObjectByName(String(e))??"":""}),e("SimObject","getGroup",t=>t._parent??""),e("SimObject","getName",t=>t._name??""),e("SimObject","getType",()=>16384),e("SimGroup","getCount",t=>t._children?t._children.length:0),e("SimGroup","getObject",(t,e)=>{let i=t._children;return i?i[Number(e)]??"":""}),e("GameBase","isEnabled",()=>!0),e("GameBase","isDisabled",()=>!1),e("GameBase","setPoweredState",()=>{}),e("GameBase","setRechargeRate",()=>{}),e("GameBase","getRechargeRate",()=>0),e("GameBase","setEnergyLevel",()=>{}),e("GameBase","getEnergyLevel",()=>0),e("ShapeBase","getDamageLevel",()=>0),e("ShapeBase","setDamageLevel",()=>{}),e("ShapeBase","getRepairRate",()=>0),e("ShapeBase","setRepairRate",()=>{}),e("ShapeBase","getDamagePercent",()=>0),e("GameBase","getControllingClient",()=>0),e("SimObject","schedule",(t,e,i,...s)=>{let r=setTimeout(()=>{d.state.pendingTimeouts.delete(r);try{d.$.call(t,String(i),...s)}catch(e){console.error(`schedule: error calling ${i} on ${t._id}:`,e)}},Number(e)||0);return d.state.pendingTimeouts.add(r),r});let m=async function(){try{let t=await d.loadFromPath("scripts/server.cs");a?.throwIfAborted(),await d.loadFromPath(`missions/${i}.mis`),a?.throwIfAborted(),t.execute();let e=function(t,e){let{signal:i,onMissionLoadDone:s}=e;return new Promise((e,r)=>{let n=!1,a=!1,o=()=>P(t.$g.get("missionRunning")),h=()=>{n||(n=!0,d(),e())},l=t=>{n||(n=!0,d(),r(t))},u=e=>{if(!s||a)return;let i=e??t.getObjectByName("Game");i&&(a=!0,s(i))},c=()=>l(L()),p=t.subscribeRuntimeEvents(t=>{if("global.changed"===t.type&&"missionrunning"===t.name){P(t.value)&&(u(),h());return}"batch.flushed"===t.type&&o()&&(u(),h())});function d(){p(),i?.removeEventListener("abort",c)}if(i){if(i.aborted)return void l(L());i.addEventListener("abort",c,{once:!0})}o()&&(u(),h())})}(d,{signal:a,onMissionLoadDone:n}),s=await d.loadFromSource("CreateServer($Host::Map, $Host::MissionType);");a?.throwIfAborted(),s.execute(),await e}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;throw t}}();return{runtime:d,ready:m}}t.s(["createProgressTracker",()=>O],38433);let F=/^[ \t]*(DisplayName|MissionTypes|BriefingWAV|Bitmap|PlanetName)[ \t]*=[ \t]*(.+)$/i,$=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+BEGIN[ \t]*-+$/i,V=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+END[ \t]*-+$/i,D={arena:"Arena",bounty:"Bounty",cnh:"CnH",ctf:"CTF",dm:"DM",dnd:"DnD",hunters:"Hunters",lakrabbit:"LakRabbit",lakzm:"LakZM",lctf:"LCTF",none:"None",rabbit:"Rabbit",sctf:"SCtF",siege:"Siege",singleplayer:"SinglePlayer",tdm:"TDM",teamhunters:"TeamHunters",teamlak:"TeamLak",tr2:"TR2"};function j(t){let e=E(t),{pragma:i,sections:s}=function(t){let e={},i=[],s={name:null,comments:[]};for(let r of t.body)if("Comment"===r.type){let t=function(t){let e;return(e=t.match($))?{type:"sectionBegin",name:e[1]}:(e=t.match(V))?{type:"sectionEnd",name:e[1]}:(e=t.match(F))?{type:"definition",identifier:e[1],value:e[2]}:null}(r.value);if(t)switch(t.type){case"definition":null===s.name?e[t.identifier.toLowerCase()]=t.value:s.comments.push(r.value);break;case"sectionBegin":(null!==s.name||s.comments.length>0)&&i.push(s),s={name:t.name.toUpperCase(),comments:[]};break;case"sectionEnd":null!==s.name&&i.push(s),s={name:null,comments:[]}}else s.comments.push(r.value)}return(null!==s.name||s.comments.length>0)&&i.push(s),{pragma:e,sections:i}}(e);function r(t){return s.find(e=>e.name===t)?.comments.map(t=>t.trimStart()).join("\n")??null}return{displayName:i.displayname??null,missionTypes:i.missiontypes?.split(/\s+/).filter(Boolean).map(t=>D[t.toLowerCase()]??t)??[],missionBriefing:r("MISSION BRIEFING"),briefingWav:i.briefingwav??null,bitmap:i.bitmap??null,planetName:i.planetname??null,missionBlurb:r("MISSION BLURB"),missionQuote:r("MISSION QUOTE"),missionString:r("MISSION STRING"),execScriptPaths:e.execScriptPaths,hasDynamicExec:e.hasDynamicExec,ast:e}}function U(t,e){if(t)return t[e.toLowerCase()]}function W(t,e){let i=t[e.toLowerCase()];return null==i?i:parseFloat(i)}function G(t,e){let i=t[e.toLowerCase()];return null==i?i:parseInt(i,10)}function q(t){let[e,i,s]=(t.position??"0 0 0").split(" ").map(t=>parseFloat(t));return[i||0,s||0,e||0]}function H(t){let[e,i,s]=(t.scale??"1 1 1").split(" ").map(t=>parseFloat(t));return[i||0,s||0,e||0]}function J(t){let[i,s,r,n]=(t.rotation??"1 0 0 0").split(" ").map(t=>parseFloat(t)),a=new e.Vector3(s,r,i).normalize(),o=-(Math.PI/180*n);return new e.Quaternion().setFromAxisAngle(a,o)}t.s(["getFloat",()=>W,"getInt",()=>G,"getPosition",()=>q,"getProperty",()=>U,"getRotation",()=>J,"getScale",()=>H,"parseMissionScript",()=>j],62395)},12979,t=>{"use strict";var e=t.i(98223),i=t.i(91996),s=t.i(62395),r=t.i(71726);let n="/t2-mapper",a=`${n}/base/`,o=`${n}/magenta.png`;function h(t,e){let s;try{s=(0,i.getActualResourceKey)(t)}catch(i){if(e)return console.warn(`Resource "${t}" not found - rendering fallback.`),e;throw i}let[r,n]=(0,i.getSourceAndPath)(s);return r?`${a}@vl2/${r}/${n}`:`${a}${n}`}function l(t){return h(`interiors/${t}`).replace(/\.dif$/i,".glb")}function u(t){return h(`shapes/${t}`).replace(/\.dts$/i,".glb")}function c(t){return t=t.replace(/^terrain\./,""),h((0,i.getStandardTextureResourceKey)(`textures/terrain/${t}`),o)}function p(t,e){let s=(0,r.normalizePath)(e).split("/"),n=s.length>1?s.slice(0,-1).join("/")+"/":"",a=`${n}${t}`;return h((0,i.getStandardTextureResourceKey)(a),o)}function d(t){return h((0,i.getStandardTextureResourceKey)(`textures/${t}`),o)}function m(t){return h(`audio/${t}`).replace(/\.wav$/i,".ogg")}async function f(t){let e=h(`textures/${t}`),i=await fetch(e);return(await i.text()).split(/(?:\r\n|\r|\n)/).map(t=>{if(!(t=t.trim()).startsWith(";"))return t}).filter(Boolean)}async function g(t){let e,r=(0,i.getMissionInfo)(t),n=await fetch(h(r.resourcePath)),a=await n.arrayBuffer();try{e=new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch{e=new TextDecoder("windows-1252").decode(a)}return e=e.replaceAll("�","'"),(0,s.parseMissionScript)(e)}async function y(t){let e=await fetch(h(`terrains/${t}`));return function(t){let e=new DataView(t),i=0,s=e.getUint8(i++),r=new Uint16Array(65536),n=[],a=t=>{let s="";for(let r=0;r0&&n.push(r)}let o=[];for(let t of n){let t=new Uint8Array(65536);for(let s=0;s<65536;s++){let r=e.getUint8(i++);t[s]=r}o.push(t)}return{version:s,textureNames:n,heightMap:r,alphaMaps:o}}(await e.arrayBuffer())}async function x(t){let i=h(t),s=await fetch(i),r=await s.text();return(0,e.parseImageFileList)(r)}t.s(["FALLBACK_TEXTURE_URL",0,o,"RESOURCE_ROOT_URL",0,a,"audioToUrl",()=>m,"getUrlForPath",()=>h,"iflTextureToUrl",()=>p,"interiorToUrl",()=>l,"loadDetailMapList",()=>f,"loadImageFrameList",()=>x,"loadMission",()=>g,"loadTerrain",()=>y,"shapeToUrl",()=>u,"terrainTextureToUrl",()=>c,"textureToUrl",()=>d],12979)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/576b06837c0cb7a0.js b/docs/_next/static/chunks/576b06837c0cb7a0.js new file mode 100644 index 00000000..45ff4eb4 --- /dev/null +++ b/docs/_next/static/chunks/576b06837c0cb7a0.js @@ -0,0 +1,17 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,53487,(e,t,r)=>{"use strict";let n="[^\\\\/]",s="[^/]",i="(?:\\/|$)",o="(?:^|\\/)",a=`\\.{1,2}${i}`,l=`(?!${o}${a})`,u=`(?!\\.{0,1}${i})`,c=`(?!${a})`,p=`${s}*?`,f={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:s,END_ANCHOR:i,DOTS_SLASH:a,NO_DOT:"(?!\\.)",NO_DOTS:l,NO_DOT_SLASH:u,NO_DOTS_SLASH:c,QMARK_NO_DOT:"[^.\\/]",STAR:p,START_ANCHOR:o,SEP:"/"},h={...f,SLASH_LITERAL:"[\\\\/]",QMARK:n,STAR:`${n}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"};t.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars:e=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:e=>!0===e?h:f}},19241,(e,t,r)=>{"use strict";var n=e.i(47167);let{REGEX_BACKSLASH:s,REGEX_REMOVE_BACKSLASH:i,REGEX_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_GLOBAL:a}=e.r(53487);r.isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r.hasRegexChars=e=>o.test(e),r.isRegexChar=e=>1===e.length&&r.hasRegexChars(e),r.escapeRegex=e=>e.replace(a,"\\$1"),r.toPosixSlashes=e=>e.replace(s,"/"),r.isWindows=()=>{if("u">typeof navigator&&navigator.platform){let e=navigator.platform.toLowerCase();return"win32"===e||"windows"===e}return void 0!==n.default&&!!n.default.platform&&"win32"===n.default.platform},r.removeBackslashes=e=>e.replace(i,e=>"\\"===e?"":e),r.escapeLast=(e,t,n)=>{let s=e.lastIndexOf(t,n);return -1===s?e:"\\"===e[s-1]?r.escapeLast(e,t,s-1):`${e.slice(0,s)}\\${e.slice(s)}`},r.removePrefix=(e,t={})=>{let r=e;return r.startsWith("./")&&(r=r.slice(2),t.prefix="./"),r},r.wrapOutput=(e,t={},r={})=>{let n=r.contains?"":"^",s=r.contains?"":"$",i=`${n}(?:${e})${s}`;return!0===t.negated&&(i=`(?:^(?!${i}).*$)`),i},r.basename=(e,{windows:t}={})=>{let r=e.split(t?/[\\/]/:"/"),n=r[r.length-1];return""===n?r[r.length-2]:n}},26094,(e,t,r)=>{"use strict";let n=e.r(19241),{CHAR_ASTERISK:s,CHAR_AT:i,CHAR_BACKWARD_SLASH:o,CHAR_COMMA:a,CHAR_DOT:l,CHAR_EXCLAMATION_MARK:u,CHAR_FORWARD_SLASH:c,CHAR_LEFT_CURLY_BRACE:p,CHAR_LEFT_PARENTHESES:f,CHAR_LEFT_SQUARE_BRACKET:h,CHAR_PLUS:d,CHAR_QUESTION_MARK:g,CHAR_RIGHT_CURLY_BRACE:m,CHAR_RIGHT_PARENTHESES:b,CHAR_RIGHT_SQUARE_BRACKET:$}=e.r(53487),y=e=>e===c||e===o,x=e=>{!0!==e.isPrefix&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let r,A,C=t||{},S=e.length-1,v=!0===C.parts||!0===C.scanToEnd,w=[],E=[],_=[],k=e,R=-1,L=0,N=0,O=!1,I=!1,j=!1,T=!1,M=!1,B=!1,P=!1,H=!1,D=!1,F=!1,G=0,U={value:"",depth:0,isGlob:!1},q=()=>R>=S,J=()=>k.charCodeAt(R+1),K=()=>(r=A,k.charCodeAt(++R));for(;R0&&(z=k.slice(0,L),k=k.slice(L),N-=L),W&&!0===j&&N>0?(W=k.slice(0,N),V=k.slice(N)):!0===j?(W="",V=k):W=k,W&&""!==W&&"/"!==W&&W!==k&&y(W.charCodeAt(W.length-1))&&(W=W.slice(0,-1)),!0===C.unescape&&(V&&(V=n.removeBackslashes(V)),W&&!0===P&&(W=n.removeBackslashes(W)));let Z={prefix:z,input:e,start:L,base:W,glob:V,isBrace:O,isBracket:I,isGlob:j,isExtglob:T,isGlobstar:M,negated:H,negatedExtglob:D};if(!0===C.tokens&&(Z.maxDepth=0,y(A)||E.push(U),Z.tokens=E),!0===C.parts||!0===C.tokens){let t;for(let r=0;r{"use strict";let n=e.r(53487),s=e.r(19241),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:o,REGEX_NON_SPECIAL_CHARS:a,REGEX_SPECIAL_CHARS_BACKREF:l,REPLACEMENTS:u}=n,c=(e,t)=>{if("function"==typeof t.expandRange)return t.expandRange(...e,t);e.sort();let r=`[${e.join("-")}]`;try{new RegExp(r)}catch(t){return e.map(e=>s.escapeRegex(e)).join("..")}return r},p=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,f=(e,t)=>{let r;if("string"!=typeof e)throw TypeError("Expected a string");e=u[e]||e;let h={...t},d="number"==typeof h.maxLength?Math.min(i,h.maxLength):i,g=e.length;if(g>d)throw SyntaxError(`Input length: ${g}, exceeds maximum allowed length: ${d}`);let m={type:"bos",value:"",output:h.prepend||""},b=[m],$=h.capture?"":"?:",y=n.globChars(h.windows),x=n.extglobChars(y),{DOT_LITERAL:A,PLUS_LITERAL:C,SLASH_LITERAL:S,ONE_CHAR:v,DOTS_SLASH:w,NO_DOT:E,NO_DOT_SLASH:_,NO_DOTS_SLASH:k,QMARK:R,QMARK_NO_DOT:L,STAR:N,START_ANCHOR:O}=y,I=e=>`(${$}(?:(?!${O}${e.dot?w:A}).)*?)`,j=h.dot?"":E,T=h.dot?R:L,M=!0===h.bash?I(h):N;h.capture&&(M=`(${M})`),"boolean"==typeof h.noext&&(h.noextglob=h.noext);let B={input:e,index:-1,start:0,dot:!0===h.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:b};g=(e=s.removePrefix(e,B)).length;let P=[],H=[],D=[],F=m,G=()=>B.index===g-1,U=B.peek=(t=1)=>e[B.index+t],q=B.advance=()=>e[++B.index]||"",J=()=>e.slice(B.index+1),K=(e="",t=0)=>{B.consumed+=e,B.index+=t},W=e=>{B.output+=null!=e.output?e.output:e.value,K(e.value)},z=()=>{let e=1;for(;"!"===U()&&("("!==U(2)||"?"===U(3));)q(),B.start++,e++;return e%2!=0&&(B.negated=!0,B.start++,!0)},V=e=>{B[e]++,D.push(e)},Z=e=>{B[e]--,D.pop()},Q=e=>{if("globstar"===F.type){let t=B.braces>0&&("comma"===e.type||"brace"===e.type),r=!0===e.extglob||P.length&&("pipe"===e.type||"paren"===e.type);"slash"===e.type||"paren"===e.type||t||r||(B.output=B.output.slice(0,-F.output.length),F.type="star",F.value="*",F.output=M,B.output+=F.output)}if(P.length&&"paren"!==e.type&&(P[P.length-1].inner+=e.value),(e.value||e.output)&&W(e),F&&"text"===F.type&&"text"===e.type){F.output=(F.output||F.value)+e.value,F.value+=e.value;return}e.prev=F,b.push(e),F=e},X=(e,t)=>{let r={...x[t],conditions:1,inner:""};r.prev=F,r.parens=B.parens,r.output=B.output;let n=(h.capture?"(":"")+r.open;V("parens"),Q({type:e,value:t,output:B.output?"":v}),Q({type:"paren",extglob:!0,value:q(),output:n}),P.push(r)},Y=e=>{let n,s=e.close+(h.capture?")":"");if("negate"===e.type){let r=M;if(e.inner&&e.inner.length>1&&e.inner.includes("/")&&(r=I(h)),(r!==M||G()||/^\)+$/.test(J()))&&(s=e.close=`)$))${r}`),e.inner.includes("*")&&(n=J())&&/^\.[^\\/.]+$/.test(n)){let i=f(n,{...t,fastpaths:!1}).output;s=e.close=`)${i})${r})`}"bos"===e.prev.type&&(B.negatedExtglob=!0)}Q({type:"paren",extglob:!0,value:r,output:s}),Z("parens")};if(!1!==h.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(e)){let r=!1,n=e.replace(l,(e,t,n,s,i,o)=>"\\"===s?(r=!0,e):"?"===s?t?t+s+(i?R.repeat(i.length):""):0===o?T+(i?R.repeat(i.length):""):R.repeat(n.length):"."===s?A.repeat(n.length):"*"===s?t?t+s+(i?M:""):M:t?e:`\\${e}`);return(!0===r&&(n=!0===h.unescape?n.replace(/\\/g,""):n.replace(/\\+/g,e=>e.length%2==0?"\\\\":e?"\\":"")),n===e&&!0===h.contains)?B.output=e:B.output=s.wrapOutput(n,B,t),B}for(;!G();){if("\0"===(r=q()))continue;if("\\"===r){let e=U();if("/"===e&&!0!==h.bash||"."===e||";"===e)continue;if(!e){Q({type:"text",value:r+="\\"});continue}let t=/^\\+/.exec(J()),n=0;if(t&&t[0].length>2&&(n=t[0].length,B.index+=n,n%2!=0&&(r+="\\")),!0===h.unescape?r=q():r+=q(),0===B.brackets){Q({type:"text",value:r});continue}}if(B.brackets>0&&("]"!==r||"["===F.value||"[^"===F.value)){if(!1!==h.posix&&":"===r){let e=F.value.slice(1);if(e.includes("[")&&(F.posix=!0,e.includes(":"))){let e=F.value.lastIndexOf("["),t=F.value.slice(0,e),r=o[F.value.slice(e+2)];if(r){F.value=t+r,B.backtrack=!0,q(),m.output||1!==b.indexOf(F)||(m.output=v);continue}}}("["===r&&":"!==U()||"-"===r&&"]"===U())&&(r=`\\${r}`),"]"===r&&("["===F.value||"[^"===F.value)&&(r=`\\${r}`),!0===h.posix&&"!"===r&&"["===F.value&&(r="^"),F.value+=r,W({value:r});continue}if(1===B.quotes&&'"'!==r){r=s.escapeRegex(r),F.value+=r,W({value:r});continue}if('"'===r){B.quotes=+(1!==B.quotes),!0===h.keepQuotes&&Q({type:"text",value:r});continue}if("("===r){V("parens"),Q({type:"paren",value:r});continue}if(")"===r){if(0===B.parens&&!0===h.strictBrackets)throw SyntaxError(p("opening","("));let e=P[P.length-1];if(e&&B.parens===e.parens+1){Y(P.pop());continue}Q({type:"paren",value:r,output:B.parens?")":"\\)"}),Z("parens");continue}if("["===r){if(!0!==h.nobracket&&J().includes("]"))V("brackets");else{if(!0!==h.nobracket&&!0===h.strictBrackets)throw SyntaxError(p("closing","]"));r=`\\${r}`}Q({type:"bracket",value:r});continue}if("]"===r){if(!0===h.nobracket||F&&"bracket"===F.type&&1===F.value.length){Q({type:"text",value:r,output:`\\${r}`});continue}if(0===B.brackets){if(!0===h.strictBrackets)throw SyntaxError(p("opening","["));Q({type:"text",value:r,output:`\\${r}`});continue}Z("brackets");let e=F.value.slice(1);if(!0===F.posix||"^"!==e[0]||e.includes("/")||(r=`/${r}`),F.value+=r,W({value:r}),!1===h.literalBrackets||s.hasRegexChars(e))continue;let t=s.escapeRegex(F.value);if(B.output=B.output.slice(0,-F.value.length),!0===h.literalBrackets){B.output+=t,F.value=t;continue}F.value=`(${$}${t}|${F.value})`,B.output+=F.value;continue}if("{"===r&&!0!==h.nobrace){V("braces");let e={type:"brace",value:r,output:"(",outputIndex:B.output.length,tokensIndex:B.tokens.length};H.push(e),Q(e);continue}if("}"===r){let e=H[H.length-1];if(!0===h.nobrace||!e){Q({type:"text",value:r,output:r});continue}let t=")";if(!0===e.dots){let e=b.slice(),r=[];for(let t=e.length-1;t>=0&&(b.pop(),"brace"!==e[t].type);t--)"dots"!==e[t].type&&r.unshift(e[t].value);t=c(r,h),B.backtrack=!0}if(!0!==e.comma&&!0!==e.dots){let n=B.output.slice(0,e.outputIndex),s=B.tokens.slice(e.tokensIndex);for(let i of(e.value=e.output="\\{",r=t="\\}",B.output=n,s))B.output+=i.output||i.value}Q({type:"brace",value:r,output:t}),Z("braces"),H.pop();continue}if("|"===r){P.length>0&&P[P.length-1].conditions++,Q({type:"text",value:r});continue}if(","===r){let e=r,t=H[H.length-1];t&&"braces"===D[D.length-1]&&(t.comma=!0,e="|"),Q({type:"comma",value:r,output:e});continue}if("/"===r){if("dot"===F.type&&B.index===B.start+1){B.start=B.index+1,B.consumed="",B.output="",b.pop(),F=m;continue}Q({type:"slash",value:r,output:S});continue}if("."===r){if(B.braces>0&&"dot"===F.type){"."===F.value&&(F.output=A);let e=H[H.length-1];F.type="dots",F.output+=r,F.value+=r,e.dots=!0;continue}if(B.braces+B.parens===0&&"bos"!==F.type&&"slash"!==F.type){Q({type:"text",value:r,output:A});continue}Q({type:"dot",value:r,output:A});continue}if("?"===r){if(!(F&&"("===F.value)&&!0!==h.noextglob&&"("===U()&&"?"!==U(2)){X("qmark",r);continue}if(F&&"paren"===F.type){let e=U(),t=r;("("!==F.value||/[!=<:]/.test(e))&&("<"!==e||/<([!=]|\w+>)/.test(J()))||(t=`\\${r}`),Q({type:"text",value:r,output:t});continue}if(!0!==h.dot&&("slash"===F.type||"bos"===F.type)){Q({type:"qmark",value:r,output:L});continue}Q({type:"qmark",value:r,output:R});continue}if("!"===r){if(!0!==h.noextglob&&"("===U()&&("?"!==U(2)||!/[!=<:]/.test(U(3)))){X("negate",r);continue}if(!0!==h.nonegate&&0===B.index){z();continue}}if("+"===r){if(!0!==h.noextglob&&"("===U()&&"?"!==U(2)){X("plus",r);continue}if(F&&"("===F.value||!1===h.regex){Q({type:"plus",value:r,output:C});continue}if(F&&("bracket"===F.type||"paren"===F.type||"brace"===F.type)||B.parens>0){Q({type:"plus",value:r});continue}Q({type:"plus",value:C});continue}if("@"===r){if(!0!==h.noextglob&&"("===U()&&"?"!==U(2)){Q({type:"at",extglob:!0,value:r,output:""});continue}Q({type:"text",value:r});continue}if("*"!==r){("$"===r||"^"===r)&&(r=`\\${r}`);let e=a.exec(J());e&&(r+=e[0],B.index+=e[0].length),Q({type:"text",value:r});continue}if(F&&("globstar"===F.type||!0===F.star)){F.type="star",F.star=!0,F.value+=r,F.output=M,B.backtrack=!0,B.globstar=!0,K(r);continue}let t=J();if(!0!==h.noextglob&&/^\([^?]/.test(t)){X("star",r);continue}if("star"===F.type){if(!0===h.noglobstar){K(r);continue}let n=F.prev,s=n.prev,i="slash"===n.type||"bos"===n.type,o=s&&("star"===s.type||"globstar"===s.type);if(!0===h.bash&&(!i||t[0]&&"/"!==t[0])){Q({type:"star",value:r,output:""});continue}let a=B.braces>0&&("comma"===n.type||"brace"===n.type),l=P.length&&("pipe"===n.type||"paren"===n.type);if(!i&&"paren"!==n.type&&!a&&!l){Q({type:"star",value:r,output:""});continue}for(;"/**"===t.slice(0,3);){let r=e[B.index+4];if(r&&"/"!==r)break;t=t.slice(3),K("/**",3)}if("bos"===n.type&&G()){F.type="globstar",F.value+=r,F.output=I(h),B.output=F.output,B.globstar=!0,K(r);continue}if("slash"===n.type&&"bos"!==n.prev.type&&!o&&G()){B.output=B.output.slice(0,-(n.output+F.output).length),n.output=`(?:${n.output}`,F.type="globstar",F.output=I(h)+(h.strictSlashes?")":"|$)"),F.value+=r,B.globstar=!0,B.output+=n.output+F.output,K(r);continue}if("slash"===n.type&&"bos"!==n.prev.type&&"/"===t[0]){let e=void 0!==t[1]?"|$":"";B.output=B.output.slice(0,-(n.output+F.output).length),n.output=`(?:${n.output}`,F.type="globstar",F.output=`${I(h)}${S}|${S}${e})`,F.value+=r,B.output+=n.output+F.output,B.globstar=!0,K(r+q()),Q({type:"slash",value:"/",output:""});continue}if("bos"===n.type&&"/"===t[0]){F.type="globstar",F.value+=r,F.output=`(?:^|${S}|${I(h)}${S})`,B.output=F.output,B.globstar=!0,K(r+q()),Q({type:"slash",value:"/",output:""});continue}B.output=B.output.slice(0,-F.output.length),F.type="globstar",F.output=I(h),F.value+=r,B.output+=F.output,B.globstar=!0,K(r);continue}let n={type:"star",value:r,output:M};if(!0===h.bash){n.output=".*?",("bos"===F.type||"slash"===F.type)&&(n.output=j+n.output),Q(n);continue}if(F&&("bracket"===F.type||"paren"===F.type)&&!0===h.regex){n.output=r,Q(n);continue}(B.index===B.start||"slash"===F.type||"dot"===F.type)&&("dot"===F.type?(B.output+=_,F.output+=_):!0===h.dot?(B.output+=k,F.output+=k):(B.output+=j,F.output+=j),"*"!==U()&&(B.output+=v,F.output+=v)),Q(n)}for(;B.brackets>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing","]"));B.output=s.escapeLast(B.output,"["),Z("brackets")}for(;B.parens>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing",")"));B.output=s.escapeLast(B.output,"("),Z("parens")}for(;B.braces>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing","}"));B.output=s.escapeLast(B.output,"{"),Z("braces")}if(!0!==h.strictSlashes&&("star"===F.type||"bracket"===F.type)&&Q({type:"maybe_slash",value:"",output:`${S}?`}),!0===B.backtrack)for(let e of(B.output="",B.tokens))B.output+=null!=e.output?e.output:e.value,e.suffix&&(B.output+=e.suffix);return B};f.fastpaths=(e,t)=>{let r={...t},o="number"==typeof r.maxLength?Math.min(i,r.maxLength):i,a=e.length;if(a>o)throw SyntaxError(`Input length: ${a}, exceeds maximum allowed length: ${o}`);e=u[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:c,ONE_CHAR:p,DOTS_SLASH:f,NO_DOT:h,NO_DOTS:d,NO_DOTS_SLASH:g,STAR:m,START_ANCHOR:b}=n.globChars(r.windows),$=r.dot?d:h,y=r.dot?g:h,x=r.capture?"":"?:",A=!0===r.bash?".*?":m;r.capture&&(A=`(${A})`);let C=e=>!0===e.noglobstar?A:`(${x}(?:(?!${b}${e.dot?f:l}).)*?)`,S=e=>{switch(e){case"*":return`${$}${p}${A}`;case".*":return`${l}${p}${A}`;case"*.*":return`${$}${A}${l}${p}${A}`;case"*/*":return`${$}${A}${c}${p}${y}${A}`;case"**":return $+C(r);case"**/*":return`(?:${$}${C(r)}${c})?${y}${p}${A}`;case"**/*.*":return`(?:${$}${C(r)}${c})?${y}${A}${l}${p}${A}`;case"**/.*":return`(?:${$}${C(r)}${c})?${l}${p}${A}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let r=S(t[1]);if(!r)return;return r+l+t[2]}}},v=S(s.removePrefix(e,{negated:!1,prefix:""}));return v&&!0!==r.strictSlashes&&(v+=`${c}?`),v},t.exports=f},53174,(e,t,r)=>{"use strict";let n=e.r(26094),s=e.r(17932),i=e.r(19241),o=e.r(53487),a=(e,t,r=!1)=>{if(Array.isArray(e)){let n=e.map(e=>a(e,t,r));return e=>{for(let t of n){let r=t(e);if(r)return r}return!1}}let n=e&&"object"==typeof e&&!Array.isArray(e)&&e.tokens&&e.input;if(""===e||"string"!=typeof e&&!n)throw TypeError("Expected pattern to be a non-empty string");let s=t||{},i=s.windows,o=n?a.compileRe(e,t):a.makeRe(e,t,!1,!0),l=o.state;delete o.state;let u=()=>!1;if(s.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=a(s.ignore,e,r)}let c=(r,n=!1)=>{let{isMatch:c,match:p,output:f}=a.test(r,o,t,{glob:e,posix:i}),h={glob:e,state:l,regex:o,posix:i,input:r,output:f,match:p,isMatch:c};return("function"==typeof s.onResult&&s.onResult(h),!1===c)?(h.isMatch=!1,!!n&&h):u(r)?("function"==typeof s.onIgnore&&s.onIgnore(h),h.isMatch=!1,!!n&&h):("function"==typeof s.onMatch&&s.onMatch(h),!n||h)};return r&&(c.state=l),c};a.test=(e,t,r,{glob:n,posix:s}={})=>{if("string"!=typeof e)throw TypeError("Expected input to be a string");if(""===e)return{isMatch:!1,output:""};let o=r||{},l=o.format||(s?i.toPosixSlashes:null),u=e===n,c=u&&l?l(e):e;return!1===u&&(u=(c=l?l(e):e)===n),(!1===u||!0===o.capture)&&(u=!0===o.matchBase||!0===o.basename?a.matchBase(e,t,r,s):t.exec(c)),{isMatch:!!u,match:u,output:c}},a.matchBase=(e,t,r)=>(t instanceof RegExp?t:a.makeRe(t,r)).test(i.basename(e)),a.isMatch=(e,t,r)=>a(t,r)(e),a.parse=(e,t)=>Array.isArray(e)?e.map(e=>a.parse(e,t)):s(e,{...t,fastpaths:!1}),a.scan=(e,t)=>n(e,t),a.compileRe=(e,t,r=!1,n=!1)=>{if(!0===r)return e.output;let s=t||{},i=s.contains?"":"^",o=s.contains?"":"$",l=`${i}(?:${e.output})${o}`;e&&!0===e.negated&&(l=`^(?!${l}).*$`);let u=a.toRegex(l,t);return!0===n&&(u.state=e),u},a.makeRe=(e,t={},r=!1,n=!1)=>{if(!e||"string"!=typeof e)throw TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return!1!==t.fastpaths&&("."===e[0]||"*"===e[0])&&(i.output=s.fastpaths(e,t)),i.output||(i=s(e,t)),a.compileRe(i,t,r,n)},a.toRegex=(e,t)=>{try{let r=t||{};return new RegExp(e,r.flags||(r.nocase?"i":""))}catch(e){if(t&&!0===t.debug)throw e;return/$^/}},a.constants=o,t.exports=a},54970,(e,t,r)=>{"use strict";let n=e.r(53174),s=e.r(19241);function i(e,t,r=!1){return t&&(null===t.windows||void 0===t.windows)&&(t={...t,windows:s.isWindows()}),n(e,t,r)}Object.assign(i,n),t.exports=i},92552,(e,t,r)=>{"use strict";let n,s;function i(e,t){return t.reduce((e,[t,r])=>({type:"BinaryExpression",operator:t,left:e,right:r}),e)}function o(e,t){return{type:"UnaryExpression",operator:e,argument:t}}class a extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let s=this.location.start,i=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(s):s,o=this.location.source+":"+i.line+":"+i.column;if(r){let e=this.location.end,n="".padEnd(i.line.toString().length," "),a=r[s.line-1],l=(s.line===e.line?e.column:a.length+1)-s.column||1;t+="\n --> "+o+"\n"+n+" |\n"+i.line+" | "+a+"\n"+n+" | "+"".padEnd(s.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+o}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function s(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function i(e){return s(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function o(e){return s(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let a={literal:e=>'"'+i(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return a[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r]/,k=/^[+\-]/,R=/^[%*\/]/,L=/^[!\-~]/,N=/^[a-zA-Z_]/,O=/^[a-zA-Z0-9_]/,I=/^[ \t]/,j=/^[^"\\\n\r]/,T=/^[^'\\\n\r]/,M=/^[0-9a-fA-F]/,B=/^[0-9]/,P=/^[xX]/,H=/^[^\n\r]/,D=/^[\n\r]/,F=/^[ \t\n\r]/,G=tE(";",!1),U=tE("package",!1),q=tE("{",!1),J=tE("}",!1),K=tE("function",!1),W=tE("(",!1),z=tE(")",!1),V=tE("::",!1),Z=tE(",",!1),Q=tE("datablock",!1),X=tE(":",!1),Y=tE("new",!1),ee=tE("[",!1),et=tE("]",!1),er=tE("=",!1),en=tE(".",!1),es=tE("if",!1),ei=tE("else",!1),eo=tE("for",!1),ea=tE("while",!1),el=tE("do",!1),eu=tE("switch$",!1),ec=tE("switch",!1),ep=tE("case",!1),ef=tE("default",!1),eh=tE("or",!1),ed=tE("return",!1),eg=tE("break",!1),em=tE("continue",!1),eb=tE("+=",!1),e$=tE("-=",!1),ey=tE("*=",!1),ex=tE("/=",!1),eA=tE("%=",!1),eC=tE("<<=",!1),eS=tE(">>=",!1),ev=tE("&=",!1),ew=tE("|=",!1),eE=tE("^=",!1),e_=tE("?",!1),ek=tE("||",!1),eR=tE("&&",!1),eL=tE("|",!1),eN=tE("^",!1),eO=tE("&",!1),eI=tE("==",!1),ej=tE("!=",!1),eT=tE("<=",!1),eM=tE(">=",!1),eB=t_(["<",">"],!1,!1,!1),eP=tE("$=",!1),eH=tE("!$=",!1),eD=tE("@",!1),eF=tE("NL",!1),eG=tE("TAB",!1),eU=tE("SPC",!1),eq=tE("<<",!1),eJ=tE(">>",!1),eK=t_(["+","-"],!1,!1,!1),eW=t_(["%","*","/"],!1,!1,!1),ez=t_(["!","-","~"],!1,!1,!1),eV=tE("++",!1),eZ=tE("--",!1),eQ=tE("*",!1),eX=tE("%",!1),eY=t_([["a","z"],["A","Z"],"_"],!1,!1,!1),e0=t_([["a","z"],["A","Z"],["0","9"],"_"],!1,!1,!1),e1=tE("$",!1),e2=tE("parent",!1),e4=t_([" "," "],!1,!1,!1),e3=tE('"',!1),e9=tE("'",!1),e5=tE("\\",!1),e6=t_(['"',"\\","\n","\r"],!0,!1,!1),e8=t_(["'","\\","\n","\r"],!0,!1,!1),e7=tE("n",!1),te=tE("r",!1),tt=tE("t",!1),tr=tE("x",!1),tn=t_([["0","9"],["a","f"],["A","F"]],!1,!1,!1),ts=tE("cr",!1),ti=tE("cp",!1),to=tE("co",!1),ta=tE("c",!1),tl=t_([["0","9"]],!1,!1,!1),tu={type:"any"},tc=tE("0",!1),tp=t_(["x","X"],!1,!1,!1),tf=tE("-",!1),th=tE("true",!1),td=tE("false",!1),tg=tE("//",!1),tm=t_(["\n","\r"],!0,!1,!1),tb=t_(["\n","\r"],!1,!1,!1),t$=tE("/*",!1),ty=tE("*/",!1),tx=t_([" "," ","\n","\r"],!1,!1,!1),tA=0|t.peg$currPos,tC=[{line:1,column:1}],tS=tA,tv=t.peg$maxFailExpected||[],tw=0|t.peg$silentFails;if(t.startRule){if(!(t.startRule in c))throw Error("Can't start parsing from rule \""+t.startRule+'".');p=c[t.startRule]}function tE(e,t){return{type:"literal",text:e,ignoreCase:t}}function t_(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function tk(t){let r,n=tC[t];if(n)return n;if(t>=tC.length)r=tC.length-1;else for(r=t;!tC[--r];);for(n={line:(n=tC[r]).line,column:n.column};rtS&&(tS=tA,tv=[]),tv.push(e))}function tN(){let e,t,r;for(rp(),e=[],t=tA,(r=rl())===l&&(r=tO()),r!==l?t=r=[r,rp()]:(tA=t,t=l);t!==l;)e.push(t),t=tA,(r=rl())===l&&(r=tO()),r!==l?t=r=[r,rp()]:(tA=t,t=l);return{type:"Program",body:e.map(([e])=>e).filter(Boolean),execScriptPaths:Array.from(n),hasDynamicExec:s}}function tO(){let t,r,n,s,i,o,a,u,c,p,d,y,x,v,w,E,_;return(t=function(){let t,r,n,s,i,o,a,u;if(t=tA,e.substr(tA,7)===f?(r=f,tA+=7):(r=l,0===tw&&tL(U)),r!==l)if(rc()!==l)if((n=rn())!==l)if(ru(),123===e.charCodeAt(tA)?(s="{",tA++):(s=l,0===tw&&tL(q)),s!==l){for(rp(),i=[],o=tA,(a=rl())===l&&(a=tO()),a!==l?o=a=[a,u=rp()]:(tA=o,o=l);o!==l;)i.push(o),o=tA,(a=rl())===l&&(a=tO()),a!==l?o=a=[a,u=rp()]:(tA=o,o=l);(125===e.charCodeAt(tA)?(o="}",tA++):(o=l,0===tw&&tL(J)),o!==l)?(a=ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),t={type:"PackageDeclaration",name:n,body:i.map(([e])=>e).filter(Boolean)}):(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a;if(t=tA,e.substr(tA,8)===h?(r=h,tA+=8):(r=l,0===tw&&tL(K)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s;if(t=tA,(r=rn())!==l)if("::"===e.substr(tA,2)?(n="::",tA+=2):(n=l,0===tw&&tL(V)),n!==l)if((s=rn())!==l)t={type:"MethodName",namespace:r,method:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=rn()),t}())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=function(){let t,r,n,s,i,o,a,u;if(t=tA,(r=rn())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=rn())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=rn())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=[r,...n.map(([,,,e])=>e)]}else tA=t,t=l;return t}())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l)if(ru(),(a=tF())!==l)t={type:"FunctionDeclaration",name:n,params:i||[],body:a};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&((n=tA,(s=tI())!==l)?(ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i===l&&(i=null),ru(),n=s):(tA=n,n=l),(t=n)===l&&((o=tA,(a=tj())!==l)?(ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),ru(),o=a):(tA=o,o=l),(t=o)===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p,f;if(t=tA,"if"===e.substr(tA,2)?(r="if",tA+=2):(r=l,0===tw&&tL(es)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),(o=tO())!==l){var h;a=tA,u=ru(),e.substr(tA,4)===g?(c=g,tA+=4):(c=l,0===tw&&tL(ei)),c!==l?(p=ru(),(f=tO())!==l?a=u=[u,c,p,f]:(tA=a,a=l)):(tA=a,a=l),a===l&&(a=null),t={type:"IfStatement",test:s,consequent:o,alternate:(h=a)?h[3]:null}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p;if(t=tA,"for"===e.substr(tA,3)?(r="for",tA+=3):(r=l,0===tw&&tL(eo)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())===l&&(s=null),ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i!==l)if(ru(),(o=tG())===l&&(o=null),ru(),59===e.charCodeAt(tA)?(a=";",tA++):(a=l,0===tw&&tL(G)),a!==l)if(ru(),(u=tG())===l&&(u=null),ru(),41===e.charCodeAt(tA)?(c=")",tA++):(c=l,0===tw&&tL(z)),c!==l)if(ru(),(p=tO())!==l){var f,h;f=s,h=o,t={type:"ForStatement",init:f,test:h,update:u,body:p}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u;if(t=tA,"do"===e.substr(tA,2)?(r="do",tA+=2):(r=l,0===tw&&tL(el)),r!==l)if(ru(),(n=tO())!==l)if(ru(),e.substr(tA,5)===m?(s=m,tA+=5):(s=l,0===tw&&tL(ea)),s!==l)if(ru(),40===e.charCodeAt(tA)?(i="(",tA++):(i=l,0===tw&&tL(W)),i!==l)if(ru(),(o=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(a=")",tA++):(a=l,0===tw&&tL(z)),a!==l)ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),t={type:"DoWhileStatement",test:o,body:n};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o;if(t=tA,e.substr(tA,5)===m?(r=m,tA+=5):(r=l,0===tw&&tL(ea)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),(o=tO())!==l)t={type:"WhileStatement",test:s,body:o};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p;if(t=tA,e.substr(tA,7)===b?(r=b,tA+=7):(r=l,0===tw&&tL(eu)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),123===e.charCodeAt(tA)?(o="{",tA++):(o=l,0===tw&&tL(q)),o!==l){for(rp(),a=[],u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);u!==l;)a.push(u),u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);(125===e.charCodeAt(tA)?(u="}",tA++):(u=l,0===tw&&tL(J)),u!==l)?t={type:"SwitchStatement",stringMode:!0,discriminant:s,cases:a.map(([e])=>e).filter(e=>e&&"SwitchCase"===e.type)}:(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;if(t===l)if(t=tA,e.substr(tA,6)===$?(r=$,tA+=6):(r=l,0===tw&&tL(ec)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),123===e.charCodeAt(tA)?(o="{",tA++):(o=l,0===tw&&tL(q)),o!==l){for(rp(),a=[],u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);u!==l;)a.push(u),u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);(125===e.charCodeAt(tA)?(u="}",tA++):(u=l,0===tw&&tL(J)),u!==l)?t={type:"SwitchStatement",stringMode:!1,discriminant:s,cases:a.map(([e])=>e).filter(e=>e&&"SwitchCase"===e.type)}:(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i;if(t=tA,e.substr(tA,6)===A?(r=A,tA+=6):(r=l,0===tw&&tL(ed)),r!==l)if(n=tA,(s=rc())!==l&&(i=tG())!==l?n=s=[s,i]:(tA=n,n=l),n===l&&(n=null),s=ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i!==l){var o;t={type:"ReturnStatement",value:(o=n)?o[1]:null}}else tA=t,t=l;else tA=t,t=l;return t}())===l&&(c=tA,e.substr(tA,5)===C?(p=C,tA+=5):(p=l,0===tw&&tL(eg)),p!==l?(ru(),59===e.charCodeAt(tA)?(d=";",tA++):(d=l,0===tw&&tL(G)),d!==l?c={type:"BreakStatement"}:(tA=c,c=l)):(tA=c,c=l),(t=c)===l&&(y=tA,e.substr(tA,8)===S?(x=S,tA+=8):(x=l,0===tw&&tL(em)),x!==l?(ru(),59===e.charCodeAt(tA)?(v=";",tA++):(v=l,0===tw&&tL(G)),v!==l?y={type:"ContinueStatement"}:(tA=y,y=l)):(tA=y,y=l),(t=y)===l&&((w=tA,(E=tG())!==l&&(ru(),59===e.charCodeAt(tA)?(_=";",tA++):(_=l,0===tw&&tL(G)),_!==l))?w={type:"ExpressionStatement",expression:E}:(tA=w,w=l),(t=w)===l&&(t=tF())===l&&(t=rl())===l)))))&&(t=tA,ru(),59===e.charCodeAt(tA)?(r=";",tA++):(r=l,0===tw&&tL(G)),r!==l?(ru(),t=null):(tA=t,t=l)),t}function tI(){let t,r,n,s,i,o,a,u,c,p,f,h,g,m;if(t=tA,e.substr(tA,9)===d?(r=d,tA+=9):(r=l,0===tw&&tL(Q)),r!==l)if(rc()!==l)if((n=rn())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=tM())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l){var b,$,y;if(ru(),a=tA,58===e.charCodeAt(tA)?(u=":",tA++):(u=l,0===tw&&tL(X)),u!==l?(c=ru(),(p=rn())!==l?a=u=[u,c,p]:(tA=a,a=l)):(tA=a,a=l),a===l&&(a=null),u=ru(),c=tA,123===e.charCodeAt(tA)?(p="{",tA++):(p=l,0===tw&&tL(q)),p!==l){for(f=ru(),h=[],g=tT();g!==l;)h.push(g),g=tT();g=ru(),125===e.charCodeAt(tA)?(m="}",tA++):(m=l,0===tw&&tL(J)),m!==l?c=p=[p,f,h,g,m,ru()]:(tA=c,c=l)}else tA=c,c=l;c===l&&(c=null),b=i,$=a,y=c,t={type:"DatablockDeclaration",className:n,instanceName:b,parent:$?$[2]:null,body:y?y[2].filter(Boolean):[]}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}function tj(){let t,r,n,s,i,o,a,u,c,p,f,h;if(t=tA,"new"===e.substr(tA,3)?(r="new",tA+=3):(r=l,0===tw&&tL(Y)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s,i,o,a,u,c,p;if((t=tA,40===e.charCodeAt(tA)?(r="(",tA++):(r=l,0===tw&&tL(W)),r!==l&&(n=ru(),(s=tG())!==l&&(i=ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l)))?t=s:(tA=t,t=l),t===l)if(t=tA,(r=rn())!==l){var f;for(n=[],s=tA,i=ru(),91===e.charCodeAt(tA)?(o="[",tA++):(o=l,0===tw&&tL(ee)),o!==l?(a=ru(),(u=tH())!==l?(c=ru(),93===e.charCodeAt(tA)?(p="]",tA++):(p=l,0===tw&&tL(et)),p!==l?s=i=[i,o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),91===e.charCodeAt(tA)?(o="[",tA++):(o=l,0===tw&&tL(ee)),o!==l?(a=ru(),(u=tH())!==l?(c=ru(),93===e.charCodeAt(tA)?(p="]",tA++):(p=l,0===tw&&tL(et)),p!==l?s=i=[i,o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);f=r,t=n.reduce((e,[,,,t])=>({type:"IndexExpression",object:e,index:t}),f)}else tA=t,t=l;return t}())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=tM())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l){var d;if(ru(),a=tA,123===e.charCodeAt(tA)?(u="{",tA++):(u=l,0===tw&&tL(q)),u!==l){for(c=ru(),p=[],f=tT();f!==l;)p.push(f),f=tT();f=ru(),125===e.charCodeAt(tA)?(h="}",tA++):(h=l,0===tw&&tL(J)),h!==l?a=u=[u,c,p,f,h,ru()]:(tA=a,a=l)}else tA=a,a=l;a===l&&(a=null),t={type:"ObjectDeclaration",className:n,instanceName:i,body:(d=a)?d[2].filter(Boolean):[]}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}function tT(){let t,r,n;return(t=tA,(r=tj())!==l)?(ru(),59===e.charCodeAt(tA)?(n=";",tA++):(n=l,0===tw&&tL(G)),n===l&&(n=null),ru(),t=r):(tA=t,t=l),t===l&&((t=tA,(r=tI())!==l)?(ru(),59===e.charCodeAt(tA)?(n=";",tA++):(n=l,0===tw&&tL(G)),n===l&&(n=null),ru(),t=r):(tA=t,t=l),t===l&&(t=function(){let t,r,n,s,i;if(t=tA,ru(),(r=tB())!==l)if(ru(),61===e.charCodeAt(tA)?(n="=",tA++):(n=l,0===tw&&tL(er)),n!==l)if(ru(),(s=tG())!==l)ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i===l&&(i=null),ru(),t={type:"Assignment",target:r,value:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=rl())===l&&(t=function(){let t,r;if(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r!==l)for(;r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));else t=l;return t!==l&&(t=null),t}())),t}function tM(){let e;return(e=tY())===l&&(e=rn())===l&&(e=ra()),e}function tB(){let e,t,r,n;if(e=tA,(t=t8())!==l){for(r=[],n=tP();n!==l;)r.push(n),n=tP();e=r.reduce((e,t)=>"property"===t.type?{type:"MemberExpression",object:e,property:t.value}:{type:"IndexExpression",object:e,index:t.value},t)}else tA=e,e=l;return e}function tP(){let t,r,n,s;return(t=tA,46===e.charCodeAt(tA)?(r=".",tA++):(r=l,0===tw&&tL(en)),r!==l&&(ru(),(n=rn())!==l))?t={type:"property",value:n}:(tA=t,t=l),t===l&&((t=tA,91===e.charCodeAt(tA)?(r="[",tA++):(r=l,0===tw&&tL(ee)),r!==l&&(ru(),(n=tH())!==l&&(ru(),93===e.charCodeAt(tA)?(s="]",tA++):(s=l,0===tw&&tL(et)),s!==l)))?t={type:"index",value:n}:(tA=t,t=l)),t}function tH(){let t,r,n,s,i,o,a,u;if(t=tA,(r=tG())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=n.length>0?[r,...n.map(([,,,e])=>e)]:r}else tA=t,t=l;return t}function tD(){let t,r,n,s,i,o,a,u,c;if(t=tA,e.substr(tA,4)===y?(r=y,tA+=4):(r=l,0===tw&&tL(ep)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s,i,o,a,u;if(t=tA,(r=t3())!==l){for(n=[],s=tA,i=ru(),"or"===e.substr(tA,2)?(o="or",tA+=2):(o=l,0===tw&&tL(eh)),o!==l&&(a=rc())!==l&&(u=t3())!==l?s=i=[i,o,a,u]:(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),"or"===e.substr(tA,2)?(o="or",tA+=2):(o=l,0===tw&&tL(eh)),o!==l&&(a=rc())!==l&&(u=t3())!==l?s=i=[i,o,a,u]:(tA=s,s=l);t=n.length>0?[r,...n.map(([,,,e])=>e)]:r}else tA=t,t=l;return t}())!==l)if(ru(),58===e.charCodeAt(tA)?(s=":",tA++):(s=l,0===tw&&tL(X)),s!==l){for(i=rp(),o=[],a=tA,(u=rl())===l&&(u=tO()),u!==l?a=u=[u,c=rp()]:(tA=a,a=l);a!==l;)o.push(a),a=tA,(u=rl())===l&&(u=tO()),u!==l?a=u=[u,c=rp()]:(tA=a,a=l);t={type:"SwitchCase",test:n,consequent:o.map(([e])=>e).filter(Boolean)}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;if(t===l)if(t=tA,e.substr(tA,7)===x?(r=x,tA+=7):(r=l,0===tw&&tL(ef)),r!==l)if(ru(),58===e.charCodeAt(tA)?(n=":",tA++):(n=l,0===tw&&tL(X)),n!==l){for(rp(),s=[],i=tA,(o=rl())===l&&(o=tO()),o!==l?i=o=[o,a=rp()]:(tA=i,i=l);i!==l;)s.push(i),i=tA,(o=rl())===l&&(o=tO()),o!==l?i=o=[o,a=rp()]:(tA=i,i=l);t={type:"SwitchCase",test:null,consequent:s.map(([e])=>e).filter(Boolean)}}else tA=t,t=l;else tA=t,t=l;return t}function tF(){let t,r,n,s,i,o;if(t=tA,123===e.charCodeAt(tA)?(r="{",tA++):(r=l,0===tw&&tL(q)),r!==l){for(rp(),n=[],s=tA,(i=rl())===l&&(i=tO()),i!==l?s=i=[i,o=rp()]:(tA=s,s=l);s!==l;)n.push(s),s=tA,(i=rl())===l&&(i=tO()),i!==l?s=i=[i,o=rp()]:(tA=s,s=l);(125===e.charCodeAt(tA)?(s="}",tA++):(s=l,0===tw&&tL(J)),s!==l)?t={type:"BlockStatement",body:n.map(([e])=>e).filter(Boolean)}:(tA=t,t=l)}else tA=t,t=l;return t}function tG(){let t,r,n,s;if(t=tA,(r=tB())!==l)if(ru(),(n=tU())!==l)if(ru(),(s=tG())!==l)t={type:"AssignmentExpression",operator:n,target:r,value:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=function(){let t,r,n,s,i,o;if(t=tA,(r=tq())!==l)if(ru(),63===e.charCodeAt(tA)?(n="?",tA++):(n=l,0===tw&&tL(e_)),n!==l)if(ru(),(s=tG())!==l)if(ru(),58===e.charCodeAt(tA)?(i=":",tA++):(i=l,0===tw&&tL(X)),i!==l)if(ru(),(o=tG())!==l)t={type:"ConditionalExpression",test:r,consequent:s,alternate:o};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=tq()),t}()),t}function tU(){let t;return 61===e.charCodeAt(tA)?(t="=",tA++):(t=l,0===tw&&tL(er)),t===l&&("+="===e.substr(tA,2)?(t="+=",tA+=2):(t=l,0===tw&&tL(eb)),t===l&&("-="===e.substr(tA,2)?(t="-=",tA+=2):(t=l,0===tw&&tL(e$)),t===l&&("*="===e.substr(tA,2)?(t="*=",tA+=2):(t=l,0===tw&&tL(ey)),t===l&&("/="===e.substr(tA,2)?(t="/=",tA+=2):(t=l,0===tw&&tL(ex)),t===l&&("%="===e.substr(tA,2)?(t="%=",tA+=2):(t=l,0===tw&&tL(eA)),t===l&&("<<="===e.substr(tA,3)?(t="<<=",tA+=3):(t=l,0===tw&&tL(eC)),t===l&&(">>="===e.substr(tA,3)?(t=">>=",tA+=3):(t=l,0===tw&&tL(eS)),t===l&&("&="===e.substr(tA,2)?(t="&=",tA+=2):(t=l,0===tw&&tL(ev)),t===l&&("|="===e.substr(tA,2)?(t="|=",tA+=2):(t=l,0===tw&&tL(ew)),t===l&&("^="===e.substr(tA,2)?(t="^=",tA+=2):(t=l,0===tw&&tL(eE)))))))))))),t}function tq(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tJ())!==l){for(n=[],s=tA,o=ru(),"||"===e.substr(tA,2)?(a="||",tA+=2):(a=l,0===tw&&tL(ek)),a!==l?(u=ru(),(c=tJ())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),"||"===e.substr(tA,2)?(a="||",tA+=2):(a=l,0===tw&&tL(ek)),a!==l?(u=ru(),(c=tJ())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tJ(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tK())!==l){for(n=[],s=tA,o=ru(),"&&"===e.substr(tA,2)?(a="&&",tA+=2):(a=l,0===tw&&tL(eR)),a!==l?(u=ru(),(c=tK())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),"&&"===e.substr(tA,2)?(a="&&",tA+=2):(a=l,0===tw&&tL(eR)),a!==l?(u=ru(),(c=tK())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tK(){let t,r,n,s,o,a,u,c,p;if(t=tA,(r=tW())!==l){for(n=[],s=tA,o=ru(),124===e.charCodeAt(tA)?(a="|",tA++):(a=l,0===tw&&tL(eL)),a!==l?(u=tA,tw++,124===e.charCodeAt(tA)?(c="|",tA++):(c=l,0===tw&&tL(eL)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tW())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),124===e.charCodeAt(tA)?(a="|",tA++):(a=l,0===tw&&tL(eL)),a!==l?(u=tA,tw++,124===e.charCodeAt(tA)?(c="|",tA++):(c=l,0===tw&&tL(eL)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tW())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,,t])=>[e,t]))}else tA=t,t=l;return t}function tW(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tz())!==l){for(n=[],s=tA,o=ru(),94===e.charCodeAt(tA)?(a="^",tA++):(a=l,0===tw&&tL(eN)),a!==l?(u=ru(),(c=tz())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),94===e.charCodeAt(tA)?(a="^",tA++):(a=l,0===tw&&tL(eN)),a!==l?(u=ru(),(c=tz())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tz(){let t,r,n,s,o,a,u,c,p;if(t=tA,(r=tV())!==l){for(n=[],s=tA,o=ru(),38===e.charCodeAt(tA)?(a="&",tA++):(a=l,0===tw&&tL(eO)),a!==l?(u=tA,tw++,38===e.charCodeAt(tA)?(c="&",tA++):(c=l,0===tw&&tL(eO)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tV())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),38===e.charCodeAt(tA)?(a="&",tA++):(a=l,0===tw&&tL(eO)),a!==l?(u=tA,tw++,38===e.charCodeAt(tA)?(c="&",tA++):(c=l,0===tw&&tL(eO)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tV())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,,t])=>[e,t]))}else tA=t,t=l;return t}function tV(){let e,t,r,n,s,o,a,u;if(e=tA,(t=tQ())!==l){for(r=[],n=tA,s=ru(),(o=tZ())!==l?(a=ru(),(u=tQ())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=tZ())!==l?(a=ru(),(u=tQ())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function tZ(){let t;return"=="===e.substr(tA,2)?(t="==",tA+=2):(t=l,0===tw&&tL(eI)),t===l&&("!="===e.substr(tA,2)?(t="!=",tA+=2):(t=l,0===tw&&tL(ej))),t}function tQ(){let e,t,r,n,s,o,a,u;if(e=tA,(t=tY())!==l){for(r=[],n=tA,s=ru(),(o=tX())!==l?(a=ru(),(u=tY())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=tX())!==l?(a=ru(),(u=tY())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function tX(){let t;return"<="===e.substr(tA,2)?(t="<=",tA+=2):(t=l,0===tw&&tL(eT)),t===l&&(">="===e.substr(tA,2)?(t=">=",tA+=2):(t=l,0===tw&&tL(eM)),t===l&&(t=e.charAt(tA),_.test(t)?tA++:(t=l,0===tw&&tL(eB)))),t}function tY(){let e,t,r,n,s,o,a,u;if(e=tA,(t=t2())!==l){for(r=[],n=tA,s=ru(),(o=t1())!==l?(a=ru(),(u=t0())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=t1())!==l?(a=ru(),(u=t0())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function t0(){let e,t,r,n;if(e=tA,(t=tB())!==l)if(ru(),(r=tU())!==l)if(ru(),(n=tG())!==l)e={type:"AssignmentExpression",operator:r,target:t,value:n};else tA=e,e=l;else tA=e,e=l;else tA=e,e=l;return e===l&&(e=t2()),e}function t1(){let t;return"$="===e.substr(tA,2)?(t="$=",tA+=2):(t=l,0===tw&&tL(eP)),t===l&&("!$="===e.substr(tA,3)?(t="!$=",tA+=3):(t=l,0===tw&&tL(eH)),t===l&&(64===e.charCodeAt(tA)?(t="@",tA++):(t=l,0===tw&&tL(eD)),t===l&&("NL"===e.substr(tA,2)?(t="NL",tA+=2):(t=l,0===tw&&tL(eF)),t===l&&("TAB"===e.substr(tA,3)?(t="TAB",tA+=3):(t=l,0===tw&&tL(eG)),t===l&&("SPC"===e.substr(tA,3)?(t="SPC",tA+=3):(t=l,0===tw&&tL(eU))))))),t}function t2(){let e,t,r,n,s,o,a,u;if(e=tA,(t=t3())!==l){for(r=[],n=tA,s=ru(),(o=t4())!==l?(a=ru(),(u=t3())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=t4())!==l?(a=ru(),(u=t3())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function t4(){let t;return"<<"===e.substr(tA,2)?(t="<<",tA+=2):(t=l,0===tw&&tL(eq)),t===l&&(">>"===e.substr(tA,2)?(t=">>",tA+=2):(t=l,0===tw&&tL(eJ))),t}function t3(){let t,r,n,s,o,a,u,c;if(t=tA,(r=t9())!==l){for(n=[],s=tA,o=ru(),a=e.charAt(tA),k.test(a)?tA++:(a=l,0===tw&&tL(eK)),a!==l?(u=ru(),(c=t9())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),a=e.charAt(tA),k.test(a)?tA++:(a=l,0===tw&&tL(eK)),a!==l?(u=ru(),(c=t9())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function t9(){let t,r,n,s,o,a,u,c;if(t=tA,(r=t5())!==l){for(n=[],s=tA,o=ru(),a=e.charAt(tA),R.test(a)?tA++:(a=l,0===tw&&tL(eW)),a!==l?(u=ru(),(c=t5())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),a=e.charAt(tA),R.test(a)?tA++:(a=l,0===tw&&tL(eW)),a!==l?(u=ru(),(c=t5())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function t5(){let t,r,n;return(t=tA,r=e.charAt(tA),L.test(r)?tA++:(r=l,0===tw&&tL(ez)),r!==l&&(ru(),(n=t6())!==l))?t=o(r,n):(tA=t,t=l),t===l&&((t=tA,"++"===e.substr(tA,2)?(r="++",tA+=2):(r=l,0===tw&&tL(eV)),r===l&&("--"===e.substr(tA,2)?(r="--",tA+=2):(r=l,0===tw&&tL(eZ))),r!==l&&(ru(),(n=t6())!==l))?t=o(r,n):(tA=t,t=l),t===l&&((t=tA,42===e.charCodeAt(tA)?(r="*",tA++):(r=l,0===tw&&tL(eQ)),r!==l&&(ru(),(n=t6())!==l))?t={type:"TagDereferenceExpression",argument:n}:(tA=t,t=l),t===l&&(t=function(){let t,r,n;if(t=tA,(r=t8())!==l)if(ru(),"++"===e.substr(tA,2)?(n="++",tA+=2):(n=l,0===tw&&tL(eV)),n===l&&("--"===e.substr(tA,2)?(n="--",tA+=2):(n=l,0===tw&&tL(eZ))),n!==l)t={type:"PostfixExpression",operator:n,argument:r};else tA=t,t=l;else tA=t,t=l;return t===l&&(t=t8()),t}()))),t}function t6(){let e,t,r,n;if(e=tA,(t=tB())!==l)if(ru(),(r=tU())!==l)if(ru(),(n=tG())!==l)e={type:"AssignmentExpression",operator:r,target:t,value:n};else tA=e,e=l;else tA=e,e=l;else tA=e,e=l;return e===l&&(e=t5()),e}function t8(){let t,r,i,o,a,u,c,p,f,h;if(t=tA,(r=function(){let t,r,n,s,i,o,a,u,c,p,f,h,d,g,m,b;if(t=tA,(a=tj())===l&&(a=tI())===l&&(a=function(){let t,r,n,s;if(t=tA,34===e.charCodeAt(tA)?(r='"',tA++):(r=l,0===tw&&tL(e3)),r!==l){for(n=[],s=rs();s!==l;)n.push(s),s=rs();(34===e.charCodeAt(tA)?(s='"',tA++):(s=l,0===tw&&tL(e3)),s!==l)?t={type:"StringLiteral",value:n.join("")}:(tA=t,t=l)}else tA=t,t=l;if(t===l)if(t=tA,39===e.charCodeAt(tA)?(r="'",tA++):(r=l,0===tw&&tL(e9)),r!==l){for(n=[],s=ri();s!==l;)n.push(s),s=ri();(39===e.charCodeAt(tA)?(s="'",tA++):(s=l,0===tw&&tL(e9)),s!==l)?t={type:"StringLiteral",value:n.join(""),tagged:!0}:(tA=t,t=l)}else tA=t,t=l;return t}())===l&&(a=ra())===l&&((u=tA,e.substr(tA,4)===w?(c=w,tA+=4):(c=l,0===tw&&tL(th)),c===l&&(e.substr(tA,5)===E?(c=E,tA+=5):(c=l,0===tw&&tL(td))),c!==l&&(p=tA,tw++,f=rh(),tw--,f===l?p=void 0:(tA=p,p=l),p!==l))?u={type:"BooleanLiteral",value:"true"===c}:(tA=u,u=l),(a=u)===l&&((h=re())===l&&(h=rt())===l&&(h=rr()),(a=h)===l))&&((d=tA,40===e.charCodeAt(tA)?(g="(",tA++):(g=l,0===tw&&tL(W)),g!==l&&(ru(),(m=tG())!==l&&(ru(),41===e.charCodeAt(tA)?(b=")",tA++):(b=l,0===tw&&tL(z)),b!==l)))?d=m:(tA=d,d=l),a=d),(r=a)!==l){for(n=[],s=tA,i=ru(),(o=tP())!==l?s=i=[i,o]:(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),(o=tP())!==l?s=i=[i,o]:(tA=s,s=l);t=n.reduce((e,[,t])=>"property"===t.type?{type:"MemberExpression",object:e,property:t.value}:{type:"IndexExpression",object:e,index:t.value},r)}else tA=t,t=l;return t}())!==l){for(i=[],o=tA,a=ru(),40===e.charCodeAt(tA)?(u="(",tA++):(u=l,0===tw&&tL(W)),u!==l?(c=ru(),(p=t7())===l&&(p=null),f=ru(),41===e.charCodeAt(tA)?(h=")",tA++):(h=l,0===tw&&tL(z)),h!==l?o=a=[a,u,c,p,f,h]:(tA=o,o=l)):(tA=o,o=l),o===l&&(o=tA,a=ru(),(u=tP())!==l?o=a=[a,u]:(tA=o,o=l));o!==l;)i.push(o),o=tA,a=ru(),40===e.charCodeAt(tA)?(u="(",tA++):(u=l,0===tw&&tL(W)),u!==l?(c=ru(),(p=t7())===l&&(p=null),f=ru(),41===e.charCodeAt(tA)?(h=")",tA++):(h=l,0===tw&&tL(z)),h!==l?o=a=[a,u,c,p,f,h]:(tA=o,o=l)):(tA=o,o=l),o===l&&(o=tA,a=ru(),(u=tP())!==l?o=a=[a,u]:(tA=o,o=l));t=i.reduce((e,t)=>{if("("===t[1]){var r;let[,,,i]=t;return r=i||[],"Identifier"===e.type&&"exec"===e.name.toLowerCase()&&(r.length>0&&"StringLiteral"===r[0].type?n.add(r[0].value):s=!0),{type:"CallExpression",callee:e,arguments:r}}let i=t[1];return"property"===i.type?{type:"MemberExpression",object:e,property:i.value}:{type:"IndexExpression",object:e,index:i.value}},r)}else tA=t,t=l;return t}function t7(){let t,r,n,s,i,o,a,u;if(t=tA,(r=tG())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=[r,...n.map(([,,,e])=>e)]}else tA=t,t=l;return t}function re(){let t,r,n,s,i,o,a;if(t=tA,37===e.charCodeAt(tA)?(r="%",tA++):(r=l,0===tw&&tL(eX)),r!==l){if(n=tA,s=tA,i=e.charAt(tA),N.test(i)?tA++:(i=l,0===tw&&tL(eY)),i!==l){for(o=[],a=e.charAt(tA),O.test(a)?tA++:(a=l,0===tw&&tL(e0));a!==l;)o.push(a),a=e.charAt(tA),O.test(a)?tA++:(a=l,0===tw&&tL(e0));s=i=[i,o]}else tA=s,s=l;(n=s!==l?e.substring(n,tA):s)!==l?t={type:"Variable",scope:"local",name:n}:(tA=t,t=l)}else tA=t,t=l;return t}function rt(){let t,r,n,s,i,o,a,u,c,p,f,h,d;if(t=tA,36===e.charCodeAt(tA)?(r="$",tA++):(r=l,0===tw&&tL(e1)),r!==l){if(n=tA,s=tA,"::"===e.substr(tA,2)?(i="::",tA+=2):(i=l,0===tw&&tL(V)),i===l&&(i=null),o=e.charAt(tA),N.test(o)?tA++:(o=l,0===tw&&tL(eY)),o!==l){for(a=[],u=e.charAt(tA),O.test(u)?tA++:(u=l,0===tw&&tL(e0));u!==l;)a.push(u),u=e.charAt(tA),O.test(u)?tA++:(u=l,0===tw&&tL(e0));if(u=[],c=tA,"::"===e.substr(tA,2)?(p="::",tA+=2):(p=l,0===tw&&tL(V)),p!==l)if(f=e.charAt(tA),N.test(f)?tA++:(f=l,0===tw&&tL(eY)),f!==l){for(h=[],d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));d!==l;)h.push(d),d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));c=p=[p,f,h]}else tA=c,c=l;else tA=c,c=l;for(;c!==l;)if(u.push(c),c=tA,"::"===e.substr(tA,2)?(p="::",tA+=2):(p=l,0===tw&&tL(V)),p!==l)if(f=e.charAt(tA),N.test(f)?tA++:(f=l,0===tw&&tL(eY)),f!==l){for(h=[],d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));d!==l;)h.push(d),d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));c=p=[p,f,h]}else tA=c,c=l;else tA=c,c=l;s=i=[i,o,a,u]}else tA=s,s=l;(n=s!==l?e.substring(n,tA):s)!==l?t={type:"Variable",scope:"global",name:n}:(tA=t,t=l)}else tA=t,t=l;return t}function rr(){let t,r,n,s,i,o,a,u,c,p,f;if(t=tA,r=tA,n=tA,e.substr(tA,6)===v?(s=v,tA+=6):(s=l,0===tw&&tL(e2)),s!==l){for(i=[],o=e.charAt(tA),I.test(o)?tA++:(o=l,0===tw&&tL(e4));o!==l;)i.push(o),o=e.charAt(tA),I.test(o)?tA++:(o=l,0===tw&&tL(e4));if("::"===e.substr(tA,2)?(o="::",tA+=2):(o=l,0===tw&&tL(V)),o!==l){for(a=[],u=e.charAt(tA),I.test(u)?tA++:(u=l,0===tw&&tL(e4));u!==l;)a.push(u),u=e.charAt(tA),I.test(u)?tA++:(u=l,0===tw&&tL(e4));if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));n=s=[s,i,o,a,u,c]}else tA=n,n=l}else tA=n,n=l}else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r.replace(/\s+/g,"")}),(t=r)===l){if(t=tA,r=tA,n=tA,e.substr(tA,6)===v?(s=v,tA+=6):(s=l,0===tw&&tL(e2)),s!==l){if(i=[],o=tA,"::"===e.substr(tA,2)?(a="::",tA+=2):(a=l,0===tw&&tL(V)),a!==l)if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));o=a=[a,u,c]}else tA=o,o=l;else tA=o,o=l;if(o!==l)for(;o!==l;)if(i.push(o),o=tA,"::"===e.substr(tA,2)?(a="::",tA+=2):(a=l,0===tw&&tL(V)),a!==l)if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));o=a=[a,u,c]}else tA=o,o=l;else tA=o,o=l;else i=l;i!==l?n=s=[s,i]:(tA=n,n=l)}else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r}),(t=r)===l){if(t=tA,r=tA,n=tA,s=e.charAt(tA),N.test(s)?tA++:(s=l,0===tw&&tL(eY)),s!==l){for(i=[],o=e.charAt(tA),O.test(o)?tA++:(o=l,0===tw&&tL(e0));o!==l;)i.push(o),o=e.charAt(tA),O.test(o)?tA++:(o=l,0===tw&&tL(e0));if(o=[],a=tA,"::"===e.substr(tA,2)?(u="::",tA+=2):(u=l,0===tw&&tL(V)),u!==l)if(c=e.charAt(tA),N.test(c)?tA++:(c=l,0===tw&&tL(eY)),c!==l){for(p=[],f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));f!==l;)p.push(f),f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));a=u=[u,c,p]}else tA=a,a=l;else tA=a,a=l;for(;a!==l;)if(o.push(a),a=tA,"::"===e.substr(tA,2)?(u="::",tA+=2):(u=l,0===tw&&tL(V)),u!==l)if(c=e.charAt(tA),N.test(c)?tA++:(c=l,0===tw&&tL(eY)),c!==l){for(p=[],f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));f!==l;)p.push(f),f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));a=u=[u,c,p]}else tA=a,a=l;else tA=a,a=l;n=s=[s,i,o]}else tA=n,n=l;(r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r}),t=r}}return t}function rn(){let e;return(e=re())===l&&(e=rt())===l&&(e=rr()),e}function rs(){let t,r,n;return(t=tA,92===e.charCodeAt(tA)?(r="\\",tA++):(r=l,0===tw&&tL(e5)),r!==l&&(n=ro())!==l)?t=n:(tA=t,t=l),t===l&&(t=e.charAt(tA),j.test(t)?tA++:(t=l,0===tw&&tL(e6))),t}function ri(){let t,r,n;return(t=tA,92===e.charCodeAt(tA)?(r="\\",tA++):(r=l,0===tw&&tL(e5)),r!==l&&(n=ro())!==l)?t=n:(tA=t,t=l),t===l&&(t=e.charAt(tA),T.test(t)?tA++:(t=l,0===tw&&tL(e8))),t}function ro(){let t,r,n,s,i,o;return t=tA,110===e.charCodeAt(tA)?(r="n",tA++):(r=l,0===tw&&tL(e7)),r!==l&&(r="\n"),(t=r)===l&&(t=tA,114===e.charCodeAt(tA)?(r="r",tA++):(r=l,0===tw&&tL(te)),r!==l&&(r="\r"),(t=r)===l)&&(t=tA,116===e.charCodeAt(tA)?(r="t",tA++):(r=l,0===tw&&tL(tt)),r!==l&&(r=" "),(t=r)===l)&&((t=tA,120===e.charCodeAt(tA)?(r="x",tA++):(r=l,0===tw&&tL(tr)),r!==l&&(n=tA,s=tA,i=e.charAt(tA),M.test(i)?tA++:(i=l,0===tw&&tL(tn)),i!==l?(o=e.charAt(tA),M.test(o)?tA++:(o=l,0===tw&&tL(tn)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l),(n=s!==l?e.substring(n,tA):s)!==l))?t=String.fromCharCode(parseInt(n,16)):(tA=t,t=l),t===l&&(t=tA,"cr"===e.substr(tA,2)?(r="cr",tA+=2):(r=l,0===tw&&tL(ts)),r!==l&&(r="\x0f"),(t=r)===l&&(t=tA,"cp"===e.substr(tA,2)?(r="cp",tA+=2):(r=l,0===tw&&tL(ti)),r!==l&&(r="\x10"),(t=r)===l))&&(t=tA,"co"===e.substr(tA,2)?(r="co",tA+=2):(r=l,0===tw&&tL(to)),r!==l&&(r="\x11"),(t=r)===l)&&((t=tA,99===e.charCodeAt(tA)?(r="c",tA++):(r=l,0===tw&&tL(ta)),r!==l&&(n=e.charAt(tA),B.test(n)?tA++:(n=l,0===tw&&tL(tl)),n!==l))?t=String.fromCharCode([2,3,4,5,6,7,8,11,12,14][parseInt(n,10)]):(tA=t,t=l),t===l&&(t=tA,e.length>tA?(r=e.charAt(tA),tA++):(r=l,0===tw&&tL(tu)),t=r))),t}function ra(){let t,r,n,s,i,o,a,u,c;if(t=tA,r=tA,n=tA,48===e.charCodeAt(tA)?(s="0",tA++):(s=l,0===tw&&tL(tc)),s!==l)if(i=e.charAt(tA),P.test(i)?tA++:(i=l,0===tw&&tL(tp)),i!==l){if(o=[],a=e.charAt(tA),M.test(a)?tA++:(a=l,0===tw&&tL(tn)),a!==l)for(;a!==l;)o.push(a),a=e.charAt(tA),M.test(a)?tA++:(a=l,0===tw&&tL(tn));else o=l;o!==l?n=s=[s,i,o]:(tA=n,n=l)}else tA=n,n=l;else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(n=tA,tw++,s=rh(),tw--,s===l?n=void 0:(tA=n,n=l),n!==l)?t={type:"NumberLiteral",value:parseInt(r,16)}:(tA=t,t=l),t===l){if(t=tA,r=tA,n=tA,45===e.charCodeAt(tA)?(s="-",tA++):(s=l,0===tw&&tL(tf)),s===l&&(s=null),i=[],o=e.charAt(tA),B.test(o)?tA++:(o=l,0===tw&&tL(tl)),o!==l)for(;o!==l;)i.push(o),o=e.charAt(tA),B.test(o)?tA++:(o=l,0===tw&&tL(tl));else i=l;if(i!==l){if(o=tA,46===e.charCodeAt(tA)?(a=".",tA++):(a=l,0===tw&&tL(en)),a!==l){if(u=[],c=e.charAt(tA),B.test(c)?tA++:(c=l,0===tw&&tL(tl)),c!==l)for(;c!==l;)u.push(c),c=e.charAt(tA),B.test(c)?tA++:(c=l,0===tw&&tL(tl));else u=l;u!==l?o=a=[a,u]:(tA=o,o=l)}else tA=o,o=l;o===l&&(o=null),n=s=[s,i,o]}else tA=n,n=l;if(n===l)if(n=tA,45===e.charCodeAt(tA)?(s="-",tA++):(s=l,0===tw&&tL(tf)),s===l&&(s=null),46===e.charCodeAt(tA)?(i=".",tA++):(i=l,0===tw&&tL(en)),i!==l){if(o=[],a=e.charAt(tA),B.test(a)?tA++:(a=l,0===tw&&tL(tl)),a!==l)for(;a!==l;)o.push(a),a=e.charAt(tA),B.test(a)?tA++:(a=l,0===tw&&tL(tl));else o=l;o!==l?n=s=[s,i,o]:(tA=n,n=l)}else tA=n,n=l;(r=n!==l?e.substring(r,tA):n)!==l&&(n=tA,tw++,s=rh(),tw--,s===l?n=void 0:(tA=n,n=l),n!==l)?t={type:"NumberLiteral",value:parseFloat(r)}:(tA=t,t=l)}return t}function rl(){let t;return(t=function(){let t,r,n,s,i;if(t=tA,"//"===e.substr(tA,2)?(r="//",tA+=2):(r=l,0===tw&&tL(tg)),r!==l){for(n=tA,s=[],i=e.charAt(tA),H.test(i)?tA++:(i=l,0===tw&&tL(tm));i!==l;)s.push(i),i=e.charAt(tA),H.test(i)?tA++:(i=l,0===tw&&tL(tm));n=e.substring(n,tA),s=e.charAt(tA),D.test(s)?tA++:(s=l,0===tw&&tL(tb)),s===l&&(s=null),t={type:"Comment",value:n}}else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a;if(t=tA,"/*"===e.substr(tA,2)?(r="/*",tA+=2):(r=l,0===tw&&tL(t$)),r!==l){for(n=tA,s=[],i=tA,o=tA,tw++,"*/"===e.substr(tA,2)?(a="*/",tA+=2):(a=l,0===tw&&tL(ty)),tw--,a===l?o=void 0:(tA=o,o=l),o!==l?(e.length>tA?(a=e.charAt(tA),tA++):(a=l,0===tw&&tL(tu)),a!==l?i=o=[o,a]:(tA=i,i=l)):(tA=i,i=l);i!==l;)s.push(i),i=tA,o=tA,tw++,"*/"===e.substr(tA,2)?(a="*/",tA+=2):(a=l,0===tw&&tL(ty)),tw--,a===l?o=void 0:(tA=o,o=l),o!==l?(e.length>tA?(a=e.charAt(tA),tA++):(a=l,0===tw&&tL(tu)),a!==l?i=o=[o,a]:(tA=i,i=l)):(tA=i,i=l);(n=e.substring(n,tA),"*/"===e.substr(tA,2)?(s="*/",tA+=2):(s=l,0===tw&&tL(ty)),s!==l)?t={type:"Comment",value:n}:(tA=t,t=l)}else tA=t,t=l;return t}()),t}function ru(){let t,r;for(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r===l&&(r=rf());r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r===l&&(r=rf());return t}function rc(){let t,r,n,s;if(t=tA,r=[],n=e.charAt(tA),F.test(n)?tA++:(n=l,0===tw&&tL(tx)),n!==l)for(;n!==l;)r.push(n),n=e.charAt(tA),F.test(n)?tA++:(n=l,0===tw&&tL(tx));else r=l;if(r!==l){for(n=[],s=e.charAt(tA),F.test(s)?tA++:(s=l,0===tw&&tL(tx)),s===l&&(s=rf());s!==l;)n.push(s),s=e.charAt(tA),F.test(s)?tA++:(s=l,0===tw&&tL(tx)),s===l&&(s=rf());t=r=[r,n]}else tA=t,t=l;return t}function rp(){let t,r;for(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));return t}function rf(){let t,r,n,s,i,o;if(t=tA,"//"===e.substr(tA,2)?(r="//",tA+=2):(r=l,0===tw&&tL(tg)),r!==l){for(n=[],s=e.charAt(tA),H.test(s)?tA++:(s=l,0===tw&&tL(tm));s!==l;)n.push(s),s=e.charAt(tA),H.test(s)?tA++:(s=l,0===tw&&tL(tm));s=e.charAt(tA),D.test(s)?tA++:(s=l,0===tw&&tL(tb)),s===l&&(s=null),t=r=[r,n,s]}else tA=t,t=l;if(t===l)if(t=tA,"/*"===e.substr(tA,2)?(r="/*",tA+=2):(r=l,0===tw&&tL(t$)),r!==l){for(n=[],s=tA,i=tA,tw++,"*/"===e.substr(tA,2)?(o="*/",tA+=2):(o=l,0===tw&&tL(ty)),tw--,o===l?i=void 0:(tA=i,i=l),i!==l?(e.length>tA?(o=e.charAt(tA),tA++):(o=l,0===tw&&tL(tu)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=tA,tw++,"*/"===e.substr(tA,2)?(o="*/",tA+=2):(o=l,0===tw&&tL(ty)),tw--,o===l?i=void 0:(tA=i,i=l),i!==l?(e.length>tA?(o=e.charAt(tA),tA++):(o=l,0===tw&&tL(tu)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l);"*/"===e.substr(tA,2)?(s="*/",tA+=2):(s=l,0===tw&&tL(ty)),s!==l?t=r=[r,n,s]:(tA=t,t=l)}else tA=t,t=l;return t}function rh(){let t;return t=e.charAt(tA),O.test(t)?tA++:(t=l,0===tw&&tL(e0)),t}n=new Set,s=!1;let rd=(r=p())!==l&&tA===e.length;function rg(){var t,n,s;throw r!==l&&tA{"use strict";function t(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")}let r=e.i(87447).default;function n(e){return t(e).toLowerCase()}function s(){return r.resources}function i(e){let[t,...n]=r.resources[e],[s,i]=n[n.length-1];return[s,i??t]}function o(e){let t=n(e);if(r.resources[t])return t;let s=t.replace(/\d+(\.(png))$/i,"$1");if(r.resources[s])return s;throw Error(`Resource not found in manifest: ${e}`)}function a(){return Object.keys(r.resources)}let l=["",".jpg",".png",".gif",".bmp"];function u(e){let t=n(e);for(let e of l){let n=`${t}${e}`;if(r.resources[n])return n}return t}function c(e){let t=r.missions[e];if(!t)throw Error(`Mission not found: ${e}`);return t}function p(){return Object.keys(r.missions)}e.s(["getActualResourceKey",()=>o,"getMissionInfo",()=>c,"getMissionList",()=>p,"getResourceKey",()=>n,"getResourceList",()=>a,"getResourceMap",()=>s,"getSourceAndPath",()=>i,"getStandardTextureResourceKey",()=>u],91996),e.s(["parse",()=>q,"runServer",()=>W],86608);var f=e.i(92552);function h(e){let t=e.indexOf("::");return -1===t?null:{namespace:e.slice(0,t),method:e.slice(t+2)}}let d={"+":"$.add","-":"$.sub","*":"$.mul","/":"$.div","<":"$.lt","<=":"$.le",">":"$.gt",">=":"$.ge","==":"$.eq","!=":"$.ne","%":"$.mod","&":"$.bitand","|":"$.bitor","^":"$.bitxor","<<":"$.shl",">>":"$.shr"};class g{indent;runtime;functions;globals;locals;indentLevel=0;currentClass=null;currentFunction=null;constructor(e={}){this.indent=e.indent??" ",this.runtime=e.runtime??"$",this.functions=e.functions??"$f",this.globals=e.globals??"$g",this.locals=e.locals??"$l"}getAccessInfo(e){if("Variable"===e.type){let t=JSON.stringify(e.name),r="global"===e.scope?this.globals:this.locals;return{getter:`${r}.get(${t})`,setter:e=>`${r}.set(${t}, ${e})`,postIncHelper:`${r}.postInc(${t})`,postDecHelper:`${r}.postDec(${t})`}}if("MemberExpression"===e.type){let t=this.expression(e.object),r="Identifier"===e.property.type?JSON.stringify(e.property.name):this.expression(e.property);return{getter:`${this.runtime}.prop(${t}, ${r})`,setter:e=>`${this.runtime}.setProp(${t}, ${r}, ${e})`,postIncHelper:`${this.runtime}.propPostInc(${t}, ${r})`,postDecHelper:`${this.runtime}.propPostDec(${t}, ${r})`}}if("IndexExpression"===e.type){let t=Array.isArray(e.index)?e.index.map(e=>this.expression(e)):[this.expression(e.index)];if("Variable"===e.object.type){let r=JSON.stringify(e.object.name),n="global"===e.object.scope?this.globals:this.locals,s=t.join(", ");return{getter:`${n}.get(${r}, ${s})`,setter:e=>`${n}.set(${r}, ${s}, ${e})`,postIncHelper:`${n}.postInc(${r}, ${s})`,postDecHelper:`${n}.postDec(${r}, ${s})`}}if("MemberExpression"===e.object.type){let r=e.object,n=this.expression(r.object),s="Identifier"===r.property.type?JSON.stringify(r.property.name):this.expression(r.property),i=`${this.runtime}.key(${s}, ${t.join(", ")})`;return{getter:`${this.runtime}.prop(${n}, ${i})`,setter:e=>`${this.runtime}.setProp(${n}, ${i}, ${e})`,postIncHelper:`${this.runtime}.propPostInc(${n}, ${i})`,postDecHelper:`${this.runtime}.propPostDec(${n}, ${i})`}}let r=this.expression(e.object),n=1===t.length?t[0]:`${this.runtime}.key(${t.join(", ")})`;return{getter:`${this.runtime}.getIndex(${r}, ${n})`,setter:e=>`${this.runtime}.setIndex(${r}, ${n}, ${e})`,postIncHelper:`${this.runtime}.indexPostInc(${r}, ${n})`,postDecHelper:`${this.runtime}.indexPostDec(${r}, ${n})`}}return null}generate(e){let t=[];for(let r of e.body){let e=this.statement(r);e&&t.push(e)}return t.join("\n\n")}statement(e){switch(e.type){case"Comment":return"";case"ExpressionStatement":return this.line(`${this.expression(e.expression)};`);case"FunctionDeclaration":return this.functionDeclaration(e);case"PackageDeclaration":return this.packageDeclaration(e);case"DatablockDeclaration":return this.datablockDeclaration(e);case"ObjectDeclaration":return this.line(`${this.objectDeclaration(e)};`);case"IfStatement":return this.ifStatement(e);case"ForStatement":return this.forStatement(e);case"WhileStatement":return this.whileStatement(e);case"DoWhileStatement":return this.doWhileStatement(e);case"SwitchStatement":return this.switchStatement(e);case"ReturnStatement":return this.returnStatement(e);case"BreakStatement":return this.line("break;");case"ContinueStatement":return this.line("continue;");case"BlockStatement":return this.blockStatement(e);default:throw Error(`Unknown statement type: ${e.type}`)}}functionDeclaration(e){let t=h(e.name.name);if(t){let r=t.namespace,n=t.method;this.currentClass=r.toLowerCase(),this.currentFunction=n.toLowerCase();let s=this.functionBody(e.body,e.params);return this.currentClass=null,this.currentFunction=null,`${this.line(`${this.runtime}.registerMethod(${JSON.stringify(r)}, ${JSON.stringify(n)}, function() {`)} +${s} +${this.line("});")}`}{let t=e.name.name;this.currentFunction=t.toLowerCase();let r=this.functionBody(e.body,e.params);return this.currentFunction=null,`${this.line(`${this.runtime}.registerFunction(${JSON.stringify(t)}, function() {`)} +${r} +${this.line("});")}`}}functionBody(e,t){this.indentLevel++;let r=[];r.push(this.line(`const ${this.locals} = ${this.runtime}.locals();`));for(let e=0;ethis.statement(e)).join("\n\n");return this.indentLevel--,`${this.line(`${this.runtime}.package(${t}, function() {`)} +${r} +${this.line("});")}`}datablockDeclaration(e){let t=JSON.stringify(e.className.name),r=e.instanceName?JSON.stringify(e.instanceName.name):"null",n=e.parent?JSON.stringify(e.parent.name):"null",s=this.objectBody(e.body);return this.line(`${this.runtime}.datablock(${t}, ${r}, ${n}, ${s});`)}objectDeclaration(e){let t="Identifier"===e.className.type?JSON.stringify(e.className.name):this.expression(e.className),r=null===e.instanceName?"null":"Identifier"===e.instanceName.type?JSON.stringify(e.instanceName.name):this.expression(e.instanceName),n=[],s=[];for(let t of e.body)"Assignment"===t.type?n.push(t):s.push(t);let i=this.objectBody(n);if(s.length>0){let e=s.map(e=>this.objectDeclaration(e)).join(",\n");return`${this.runtime}.create(${t}, ${r}, ${i}, [ +${e} +])`}return`${this.runtime}.create(${t}, ${r}, ${i})`}objectBody(e){if(0===e.length)return"{}";let t=[];for(let r of e)if("Assignment"===r.type){let e=this.expression(r.value);if("Identifier"===r.target.type){let n=r.target.name;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?t.push(`${n}: ${e}`):t.push(`[${JSON.stringify(n)}]: ${e}`)}else if("IndexExpression"===r.target.type){let n=this.objectPropertyKey(r.target);t.push(`[${n}]: ${e}`)}else{let n=this.expression(r.target);t.push(`[${n}]: ${e}`)}}if(t.length<=1)return`{ ${t.join(", ")} }`;let r=this.indent.repeat(this.indentLevel+1),n=this.indent.repeat(this.indentLevel);return`{ +${r}${t.join(",\n"+r)} +${n}}`}objectPropertyKey(e){let t="Identifier"===e.object.type?JSON.stringify(e.object.name):this.expression(e.object),r=Array.isArray(e.index)?e.index.map(e=>this.expression(e)).join(", "):this.expression(e.index);return`${this.runtime}.key(${t}, ${r})`}ifStatement(e){let t=this.expression(e.test),r=this.statementAsBlock(e.consequent);if(e.alternate)if("IfStatement"===e.alternate.type){let n=this.ifStatement(e.alternate).replace(/^\s*/,"");return this.line(`if (${t}) ${r} else ${n}`)}else{let n=this.statementAsBlock(e.alternate);return this.line(`if (${t}) ${r} else ${n}`)}return this.line(`if (${t}) ${r}`)}forStatement(e){let t=e.init?this.expression(e.init):"",r=e.test?this.expression(e.test):"",n=e.update?this.expression(e.update):"",s=this.statementAsBlock(e.body);return this.line(`for (${t}; ${r}; ${n}) ${s}`)}whileStatement(e){let t=this.expression(e.test),r=this.statementAsBlock(e.body);return this.line(`while (${t}) ${r}`)}doWhileStatement(e){let t=this.statementAsBlock(e.body),r=this.expression(e.test);return this.line(`do ${t} while (${r});`)}switchStatement(e){if(e.stringMode)return this.switchStringStatement(e);let t=this.expression(e.discriminant);this.indentLevel++;let r=[];for(let t of e.cases)r.push(this.switchCase(t));return this.indentLevel--,`${this.line(`switch (${t}) {`)} +${r.join("\n")} +${this.line("}")}`}switchCase(e){let t=[];if(null===e.test)t.push(this.line("default:"));else if(Array.isArray(e.test))for(let r of e.test)t.push(this.line(`case ${this.expression(r)}:`));else t.push(this.line(`case ${this.expression(e.test)}:`));for(let r of(this.indentLevel++,e.consequent))t.push(this.statement(r));return t.push(this.line("break;")),this.indentLevel--,t.join("\n")}switchStringStatement(e){let t=this.expression(e.discriminant),r=[];for(let t of e.cases)if(null===t.test)r.push(`default: () => { ${this.blockContent(t.consequent)} }`);else if(Array.isArray(t.test))for(let e of t.test)r.push(`${this.expression(e)}: () => { ${this.blockContent(t.consequent)} }`);else r.push(`${this.expression(t.test)}: () => { ${this.blockContent(t.consequent)} }`);return this.line(`${this.runtime}.switchStr(${t}, { ${r.join(", ")} });`)}returnStatement(e){return e.value?this.line(`return ${this.expression(e.value)};`):this.line("return;")}blockStatement(e){this.indentLevel++;let t=e.body.map(e=>this.statement(e)).join("\n");return this.indentLevel--,`{ +${t} +${this.line("}")}`}statementAsBlock(e){if("BlockStatement"===e.type)return this.blockStatement(e);this.indentLevel++;let t=this.statement(e);return this.indentLevel--,`{ +${t} +${this.line("}")}`}blockContent(e){return e.map(e=>this.statement(e).trim()).join(" ")}expression(e){switch(e.type){case"Identifier":return this.identifier(e);case"Variable":return this.variable(e);case"NumberLiteral":case"BooleanLiteral":return String(e.value);case"StringLiteral":return JSON.stringify(e.value);case"BinaryExpression":return this.binaryExpression(e);case"UnaryExpression":return this.unaryExpression(e);case"PostfixExpression":return this.postfixExpression(e);case"AssignmentExpression":return this.assignmentExpression(e);case"ConditionalExpression":return`(${this.expression(e.test)} ? ${this.expression(e.consequent)} : ${this.expression(e.alternate)})`;case"CallExpression":return this.callExpression(e);case"MemberExpression":return this.memberExpression(e);case"IndexExpression":return this.indexExpression(e);case"TagDereferenceExpression":return`${this.runtime}.deref(${this.expression(e.argument)})`;case"ObjectDeclaration":return this.objectDeclaration(e);case"DatablockDeclaration":return`${this.runtime}.datablock(${JSON.stringify(e.className.name)}, ${e.instanceName?JSON.stringify(e.instanceName.name):"null"}, ${e.parent?JSON.stringify(e.parent.name):"null"}, ${this.objectBody(e.body)})`;default:throw Error(`Unknown expression type: ${e.type}`)}}identifier(e){let t=h(e.name);return t&&"parent"===t.namespace.toLowerCase()?e.name:t?`${this.runtime}.nsRef(${JSON.stringify(t.namespace)}, ${JSON.stringify(t.method)})`:JSON.stringify(e.name)}variable(e){return"global"===e.scope?`${this.globals}.get(${JSON.stringify(e.name)})`:`${this.locals}.get(${JSON.stringify(e.name)})`}binaryExpression(e){let t=this.expression(e.left),r=this.expression(e.right),n=e.operator,s=this.concatExpression(t,n,r);if(s)return s;if("$="===n)return`${this.runtime}.streq(${t}, ${r})`;if("!$="===n)return`!${this.runtime}.streq(${t}, ${r})`;if("&&"===n||"||"===n)return`(${t} ${n} ${r})`;let i=d[n];return i?`${i}(${t}, ${r})`:`(${t} ${n} ${r})`}unaryExpression(e){if("++"===e.operator||"--"===e.operator){let t=this.getAccessInfo(e.argument);if(t){let r="++"===e.operator?1:-1;return t.setter(`${this.runtime}.add(${t.getter}, ${r})`)}}let t=this.expression(e.argument);return"~"===e.operator?`${this.runtime}.bitnot(${t})`:"-"===e.operator?`${this.runtime}.neg(${t})`:`${e.operator}${t}`}postfixExpression(e){let t=this.getAccessInfo(e.argument);if(t){let r="++"===e.operator?t.postIncHelper:t.postDecHelper;if(r)return r}return`${this.expression(e.argument)}${e.operator}`}assignmentExpression(e){let t=this.expression(e.value),r=e.operator,n=this.getAccessInfo(e.target);if(!n)throw Error(`Unhandled assignment target type: ${e.target.type}`);if("="===r)return n.setter(t);{let e=r.slice(0,-1),s=this.compoundAssignmentValue(n.getter,e,t);return n.setter(s)}}callExpression(e){let t=e.arguments.map(e=>this.expression(e)).join(", ");if("Identifier"===e.callee.type){let r=e.callee.name,n=h(r);if(n&&"parent"===n.namespace.toLowerCase())if(this.currentClass)return`${this.runtime}.parent(${JSON.stringify(this.currentClass)}, ${JSON.stringify(n.method)}, arguments[0]${t?", "+t:""})`;else if(this.currentFunction)return`${this.runtime}.parentFunc(${JSON.stringify(this.currentFunction)}${t?", "+t:""})`;else throw Error("Parent:: call outside of function context");return n?`${this.runtime}.nsCall(${JSON.stringify(n.namespace)}, ${JSON.stringify(n.method)}${t?", "+t:""})`:`${this.functions}.call(${JSON.stringify(r)}${t?", "+t:""})`}if("MemberExpression"===e.callee.type){let r=this.expression(e.callee.object),n="Identifier"===e.callee.property.type?JSON.stringify(e.callee.property.name):this.expression(e.callee.property);return`${this.runtime}.call(${r}, ${n}${t?", "+t:""})`}let r=this.expression(e.callee);return`${r}(${t})`}memberExpression(e){let t=this.expression(e.object);return e.computed||"Identifier"!==e.property.type?`${this.runtime}.prop(${t}, ${this.expression(e.property)})`:`${this.runtime}.prop(${t}, ${JSON.stringify(e.property.name)})`}indexExpression(e){let t=Array.isArray(e.index)?e.index.map(e=>this.expression(e)):[this.expression(e.index)];if("Variable"===e.object.type){let r=JSON.stringify(e.object.name),n="global"===e.object.scope?this.globals:this.locals;return`${n}.get(${r}, ${t.join(", ")})`}if("MemberExpression"===e.object.type){let r=e.object,n=this.expression(r.object),s="Identifier"===r.property.type?JSON.stringify(r.property.name):this.expression(r.property),i=`${this.runtime}.key(${s}, ${t.join(", ")})`;return`${this.runtime}.prop(${n}, ${i})`}let r=this.expression(e.object);return 1===t.length?`${this.runtime}.getIndex(${r}, ${t[0]})`:`${this.runtime}.getIndex(${r}, ${this.runtime}.key(${t.join(", ")}))`}line(e){return this.indent.repeat(this.indentLevel)+e}concatExpression(e,t,r){switch(t){case"@":return`${this.runtime}.concat(${e}, ${r})`;case"SPC":return`${this.runtime}.concat(${e}, " ", ${r})`;case"TAB":return`${this.runtime}.concat(${e}, "\\t", ${r})`;case"NL":return`${this.runtime}.concat(${e}, "\\n", ${r})`;default:return null}}compoundAssignmentValue(e,t,r){let n=this.concatExpression(e,t,r);if(n)return n;let s=d[t];return s?`${s}(${e}, ${r})`:`(${e} ${t} ${r})`}}e.s(["createRuntime",()=>G,"createScriptCache",()=>P],33870);var m=e.i(54970);class b{map=new Map;keyLookup=new Map;constructor(e){if(e)for(const[t,r]of e)this.set(t,r)}get size(){return this.map.size}get(e){let t=this.keyLookup.get(e.toLowerCase());return void 0!==t?this.map.get(t):void 0}set(e,t){let r=e.toLowerCase(),n=this.keyLookup.get(r);return void 0!==n?this.map.set(n,t):(this.keyLookup.set(r,e),this.map.set(e,t)),this}has(e){return this.keyLookup.has(e.toLowerCase())}delete(e){let t=e.toLowerCase(),r=this.keyLookup.get(t);return void 0!==r&&(this.keyLookup.delete(t),this.map.delete(r))}clear(){this.map.clear(),this.keyLookup.clear()}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}forEach(e){for(let[t,r]of this.map)e(r,t,this)}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}getOriginalKey(e){return this.keyLookup.get(e.toLowerCase())}}class ${set=new Set;constructor(e){if(e)for(const t of e)this.add(t)}get size(){return this.set.size}add(e){return this.set.add(e.toLowerCase()),this}has(e){return this.set.has(e.toLowerCase())}delete(e){return this.set.delete(e.toLowerCase())}clear(){this.set.clear()}[Symbol.iterator](){return this.set[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}function y(e){return e.replace(/\\/g,"/").toLowerCase()}function x(e){return String(e??"")}function A(e){return Number(e)||0}function C(e){let t=x(e||"0 0 0").split(" ").map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function S(e,t,r){let n=0;for(;t+n0;){if(n>=e.length)return"";let s=S(e,n,r);if(n+s>=e.length)return"";n+=s+1,t--}let s=S(e,n,r);return 0===s?"":e.substring(n,n+s)}function w(e,t,r,n){let s=0,i=t;for(;i>0;){if(s>=e.length)return"";let t=S(e,s,n);if(s+t>=e.length)return"";s+=t+1,i--}let o=s,a=r-t+1;for(;a>0;){let t=S(e,s,n);if((s+=t)>=e.length)break;s++,a--}let l=s;return l>o&&n.includes(e[l-1])&&l--,e.substring(o,l)}function E(e,t){if(""===e)return 0;let r=0;for(let n=0;nt&&o>=e.length)break}return i.join(s)}function k(e,t,r,n){let s=[],i=0,o=0;for(;it().$f.call(x(e),...r),eval(e){throw Error("eval() not implemented: requires runtime parsing and execution")},collapseescape:e=>x(e).replace(/\\([ntr\\])/g,(e,t)=>"n"===t?"\n":"t"===t?" ":"r"===t?"\r":"\\"),expandescape:e=>x(e).replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r"),export(e,t,r){console.warn(`export(${e}): not implemented`)},quit(){console.warn("quit(): not implemented in browser")},trace(e){},isobject:e=>t().$.isObject(e),nametoid:e=>t().$.nameToId(e),strlen:e=>x(e).length,strchr(e,t){let r=x(e),n=x(t)[0]??"",s=r.indexOf(n);return s>=0?r.substring(s):""},strpos:(e,t,r)=>x(e).indexOf(x(t),A(r)),strcmp(e,t){let r=x(e),n=x(t);return rn)},stricmp(e,t){let r=x(e).toLowerCase(),n=x(t).toLowerCase();return rn)},strstr:(e,t)=>x(e).indexOf(x(t)),getsubstr(e,t,r){let n=x(e),s=A(t);return void 0===r?n.substring(s):n.substring(s,s+A(r))},getword:(e,t)=>v(x(e),A(t)," \n"),getwordcount:e=>E(x(e)," \n"),getfield:(e,t)=>v(x(e),A(t)," \n"),getfieldcount:e=>E(x(e)," \n"),setword:(e,t,r)=>_(x(e),A(t),x(r)," \n"," "),setfield:(e,t,r)=>_(x(e),A(t),x(r)," \n"," "),firstword:e=>v(x(e),0," \n"),restwords:e=>w(x(e),1,1e6," \n"),trim:e=>x(e).trim(),ltrim:e=>x(e).replace(/^\s+/,""),rtrim:e=>x(e).replace(/\s+$/,""),strupr:e=>x(e).toUpperCase(),strlwr:e=>x(e).toLowerCase(),strreplace:(e,t,r)=>x(e).split(x(t)).join(x(r)),filterstring:(e,t)=>x(e),stripchars(e,t){let r=x(e),n=new Set(x(t).split(""));return r.split("").filter(e=>!n.has(e)).join("")},getfields(e,t,r){let n=void 0!==r?Number(r):1e6;return w(x(e),A(t),n," \n")},getwords(e,t,r){let n=void 0!==r?Number(r):1e6;return w(x(e),A(t),n," \n")},removeword:(e,t)=>k(x(e),A(t)," \n"," "),removefield:(e,t)=>k(x(e),A(t)," \n"," "),getrecord:(e,t)=>v(x(e),A(t),"\n"),getrecordcount:e=>E(x(e),"\n"),setrecord:(e,t,r)=>_(x(e),A(t),x(r),"\n","\n"),removerecord:(e,t)=>k(x(e),A(t),"\n","\n"),nexttoken(e,t,r){throw Error("nextToken() is not implemented: it requires variable mutation")},strtoplayername:e=>x(e).replace(/[^\w\s-]/g,"").trim(),mabs:e=>Math.abs(A(e)),mfloor:e=>Math.floor(A(e)),mceil:e=>Math.ceil(A(e)),msqrt:e=>Math.sqrt(A(e)),mpow:(e,t)=>Math.pow(A(e),A(t)),msin:e=>Math.sin(A(e)),mcos:e=>Math.cos(A(e)),mtan:e=>Math.tan(A(e)),masin:e=>Math.asin(A(e)),macos:e=>Math.acos(A(e)),matan:(e,t)=>Math.atan2(A(e),A(t)),mlog:e=>Math.log(A(e)),getrandom(e,t){if(void 0===e)return Math.random();if(void 0===t)return Math.floor(Math.random()*(A(e)+1));let r=A(e);return Math.floor(Math.random()*(A(t)-r+1))+r},mdegtorad:e=>A(e)*(Math.PI/180),mradtodeg:e=>A(e)*(180/Math.PI),mfloatlength:(e,t)=>A(e).toFixed(A(t)),getboxcenter(e){let t=x(e).split(" ").map(Number),r=t[0]||0,n=t[1]||0,s=t[2]||0,i=t[3]||0,o=t[4]||0,a=t[5]||0;return`${(r+i)/2} ${(n+o)/2} ${(s+a)/2}`},vectoradd(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${r+i} ${n+o} ${s+a}`},vectorsub(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${r-i} ${n-o} ${s-a}`},vectorscale(e,t){let[r,n,s]=C(e),i=A(t);return`${r*i} ${n*i} ${s*i}`},vectordot(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return r*i+n*o+s*a},vectorcross(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${n*a-s*o} ${s*i-r*a} ${r*o-n*i}`},vectorlen(e){let[t,r,n]=C(e);return Math.sqrt(t*t+r*r+n*n)},vectornormalize(e){let[t,r,n]=C(e),s=Math.sqrt(t*t+r*r+n*n);return 0===s?"0 0 0":`${t/s} ${r/s} ${n/s}`},vectordist(e,t){let[r,n,s]=C(e),[i,o,a]=C(t),l=r-i,u=n-o,c=s-a;return Math.sqrt(l*l+u*u+c*c)},matrixcreate(e,t){throw Error("MatrixCreate() not implemented: requires axis-angle rotation math")},matrixcreatefromeuler(e){throw Error("MatrixCreateFromEuler() not implemented: requires Euler→Quaternion→AxisAngle conversion")},matrixmultiply(e,t){throw Error("MatrixMultiply() not implemented: requires full 4x4 matrix multiplication")},matrixmulpoint(e,t){throw Error("MatrixMulPoint() not implemented: requires full transform application")},matrixmulvector(e,t){throw Error("MatrixMulVector() not implemented: requires rotation matrix application")},getsimtime:()=>Date.now()-t().state.startTime,getrealtime:()=>Date.now(),schedule(e,r,n,...s){let i=Number(e)||0,o=t(),a=setTimeout(()=>{o.state.pendingTimeouts.delete(a);try{o.$f.call(String(n),...s)}catch(e){throw console.error(`schedule: error calling ${n}:`,e),e}},i);return o.state.pendingTimeouts.add(a),a},cancel(e){clearTimeout(e),t().state.pendingTimeouts.delete(e)},iseventpending:e=>t().state.pendingTimeouts.has(e),exec(e){let r=String(e??"");if(console.debug(`exec(${JSON.stringify(r)}): preparing to execute…`),!r.includes("."))return console.error(`exec: invalid script file name ${JSON.stringify(r)}.`),!1;let n=y(r),s=t(),{executedScripts:i,scripts:o}=s.state;if(i.has(n))return console.debug(`exec(${JSON.stringify(r)}): skipping (already executed)`),!0;let a=o.get(n);return null==a?(console.warn(`exec(${JSON.stringify(r)}): script not found`),!1):(i.add(n),console.debug(`exec(${JSON.stringify(r)}): executing!`),s.executeAST(a),!0)},compile(e){throw Error("compile() not implemented: requires DSO bytecode compiler")},isdemo:()=>!1,isfile:e=>r?r.isFile(x(e)):(console.warn("isFile(): no fileSystem handler configured"),!1),fileext(e){let t=x(e),r=t.lastIndexOf(".");return r>=0?t.substring(r):""},filebase(e){let t=x(e),r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.lastIndexOf("."),s=r>=0?r+1:0,i=n>s?n:t.length;return t.substring(s,i)},filepath(e){let t=x(e),r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r>=0?t.substring(0,r):""},expandfilename(e){throw Error("expandFilename() not implemented: requires filesystem path expansion")},findfirstfile:e=>r?(i=x(e),n=r.findFiles(i),s=0,n[s++]??""):(console.warn("findFirstFile(): no fileSystem handler configured"),""),findnextfile(e){let t=x(e);if(t!==i){if(!r)return"";i=t,n=r.findFiles(t)}return n[s++]??""},getfilecrc:e=>x(e),iswriteablefilename:e=>!1,activatepackage(e){t().$.activatePackage(x(e))},deactivatepackage(e){t().$.deactivatePackage(x(e))},ispackage:e=>t().$.isPackage(x(e)),isactivepackage:e=>t().$.isActivePackage(x(e)),getpackagelist:()=>t().$.getPackageList(),addmessagecallback(e,t){},alxcreatesource:(...e)=>0,alxgetwavelen:e=>0,alxlistenerf(e,t){},alxplay:(...e)=>0,alxsetchannelvolume(e,t){},alxsourcef(e,t,r){},alxstop(e){},alxstopall(){},activatedirectinput(){},activatekeyboard(){},deactivatedirectinput(){},deactivatekeyboard(){},disablejoystick(){},enablejoystick(){},enablewinconsole(e){},isjoystickdetected:()=>!1,lockmouse(e){},addmaterialmapping(e,t){},flushtexturecache(){},getdesktopresolution:()=>"1920 1080 32",getdisplaydevicelist:()=>"OpenGL",getresolutionlist:e=>"640 480 800 600 1024 768 1280 720 1920 1080",getvideodriverinfo:()=>"WebGL",isdevicefullscreenonly:e=>!1,isfullscreen:()=>!1,screenshot(e){},setdisplaydevice:e=>!0,setfov(e){},setinteriorrendermode(e){},setopenglanisotropy(e){},setopenglmipreduction(e){},setopenglskymipreduction(e){},setopengltexturecompressionhint(e){},setscreenmode(e,t,r,n){},setverticalsync(e){},setzoomspeed(e){},togglefullscreen(){},videosetgammacorrection(e){},snaptoggle(){},addtaggedstring:e=>0,buildtaggedstring:(e,...t)=>"",detag:e=>x(e),gettag:e=>0,gettaggedstring:e=>"",removetaggedstring(e){},commandtoclient(e,t){},commandtoserver(e){},cancelserverquery(){},querymasterserver(){},querysingleserver(){},setnetport:e=>!0,allowconnections(e){},startheartbeat(){},stopheartbeat(){},gotowebpage(e){},deletedatablocks(){},preloaddatablock:e=>!0,containerboxempty:(...e)=>!0,containerraycast:(...e)=>"",containersearchcurrdist:()=>0,containersearchnext:()=>0,initcontainerradiussearch(){},calcexplosioncoverage:(...e)=>1,getcontrolobjectaltitude:()=>0,getcontrolobjectspeed:()=>0,getterrainheight:e=>0,lightscene(){},pathonmissionloaddone(){}}}function L(e){return e.toLowerCase()}function N(e){let t=e.trim();return L(t.startsWith("$")?t.slice(1):t)}function O(e,t){let r=e.get(t);return r||(r=new Set,e.set(t,r)),r}function I(e,t){for(let r of t)e.add(L(r))}function j(e,t,r){if(e.anyClassValues.has("*")||e.anyClassValues.has(r))return!0;for(let n of t){let t=e.valuesByClass.get(L(n));if(t&&(t.has("*")||t.has(r)))return!0}return!1}let T=[{classNames:["SceneObject","GameBase","ShapeBase","Item","Player"],fields:["position","rotation","scale","transform","hidden","renderingdistance","datablock","shapename","shapefile","initialbarrel","skin","team","health","energy","energylevel","damagelevel","damageflash","damagepercent","damagestate","mountobject","mountedimage","targetposition","targetrotation","targetscale","missiontypeslist","renderenabled","vis","velocity","name"]},{classNames:["*"],fields:["position","rotation","scale","hidden","shapefile","datablock"]}],M=[{classNames:["SceneObject","GameBase","ShapeBase","SimObject"],methods:["settransform","setposition","setrotation","setscale","sethidden","setdatablock","setshapename","mountimage","unmountimage","mountobject","unmountobject","setdamagelevel","setenergylevel","schedule","delete","deleteallobjects","add","remove","playthread","stopthread","setthreaddir","pausethread"]},{classNames:["*"],methods:["settransform","setscale","delete","add","remove"]}],B=["missionrunning","loadingmission"];function P(){return{scripts:new Map,generatedCode:new WeakMap}}function H(e){return e.toLowerCase()}function D(e){return Number(e)>>>0}function F(e){if(null==e)return null;if("string"==typeof e)return e||null;if("number"==typeof e)return String(e);throw Error(`Invalid instance name type: ${typeof e}`)}function G(e={}){let t,r,n,s=e.reactiveFieldRules??T,i=e.reactiveMethodRules??M,o=e.reactiveGlobalNames??B,a=(t=function(e){let t=new Set,r=new Map;for(let n of e)for(let e of n.classNames){let s=L(e);if("*"===s){I(t,n.fields);continue}I(O(r,s),n.fields)}return{anyClassValues:t,valuesByClass:r}}(s),(e,r)=>j(t,e,L(r))),l=(r=function(e){let t=new Set,r=new Map;for(let n of e)for(let e of n.classNames){let s=L(e);if("*"===s){I(t,n.methods);continue}I(O(r,s),n.methods)}return{anyClassValues:t,valuesByClass:r}}(i),(e,t)=>j(r,e,L(t))),u=(n=function(e){let t=new Set;for(let r of e)t.add(N(r));return t}(o),e=>{let t=N(e);return n.has("*")||n.has(t)}),c=new b,p=new b,f=new b,h=[],d=new $,x=3,A=1027,C=new Map,S=new b,v=new b,w=new b,E=new b,_=new b,k=new Set,U=[],J=!1,K=0;if(e.globals)for(let[t,r]of Object.entries(e.globals)){if(!t.startsWith("$"))throw Error(`Global variable "${t}" must start with $, e.g. "$${t}"`);w.set(t.slice(1),r)}let W=new Set,z=new Set,V=e.ignoreScripts&&e.ignoreScripts.length>0?(0,m.default)(e.ignoreScripts,{nocase:!0}):null,Z=e.cache??P(),Q=Z.scripts,X=Z.generatedCode,Y=new Map;function ee(e){let t=Y.get(e);return t&&t.length>0?t[t.length-1]:void 0}function et(e,t,r){let n;(n=Y.get(e))||(n=[],Y.set(e,n)),n.push(t);try{return r()}finally{let t;(t=Y.get(e))&&t.pop()}}function er(e,t){return`${e.toLowerCase()}::${t.toLowerCase()}`}function en(e,t){return c.get(e)?.get(t)??null}function es(e){if(!e)return[];let t=[],r=new Set,n=e.class||e._className||e._class,s=n?H(String(n)):"";for(;s&&!r.has(s);)t.push(s),r.add(s),s=_.get(s)??"";return e._superClass&&!r.has(e._superClass)&&t.push(e._superClass),t}function ei(){if(J=!1,0===U.length)return;let e=U.splice(0,U.length);for(let t of(K+=1,k))t({type:"batch.flushed",tick:K,events:e})}function eo(e){for(let t of(U.push(e),k))t(e);J||(J=!0,queueMicrotask(ei))}function ea(e){eo({type:"object.created",objectId:e._id,object:e})}function el(e,t,r,n){let s=H(t);Object.is(r,n)||a(es(e),s)&&eo({type:"field.changed",objectId:e._id,field:s,value:r,previousValue:n,object:e})}let eu=new Set,ec=null,ep=null,ef=(e.builtins??R)({runtime:()=>ep,fileSystem:e.fileSystem??null});function eh(e){let t=f.get(e);if(!t)return void d.add(e);if(!t.active){for(let[e,r]of(t.active=!0,h.push(t.name),t.methods)){c.has(e)||c.set(e,new b);let t=c.get(e);for(let[e,n]of r)t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[e,r]of t.functions)p.has(e)||p.set(e,[]),p.get(e).push(r)}}function ed(e){return null==e||""===e?null:"object"==typeof e&&null!=e._id?e:"string"==typeof e?S.get(e)??null:"number"==typeof e?C.get(e)??null:null}function eg(e,t,r){let n=ed(e);if(null==n)return 0;let s=ey(n[t]);return n[t]=s+r,el(n,t,n[t],s),s}function em(e,t){let r=en(e,t);return r&&r.length>0?r[r.length-1]:null}function eb(e,t,r,n){let s=en(e,t);return s&&0!==s.length?{found:!0,result:et(er(e,t),s.length-1,()=>s[s.length-1](r,...n))}:{found:!1}}function e$(e,t,r,n){let s;l((s=es(r)).length?s:[e],t)&&eo({type:"method.called",className:H(e),methodName:H(t),objectId:r._id,args:[...n]});let i=E.get(e);if(i){let e=i.get(t);if(e)for(let t of e)t(r,...n)}}function ey(e){if(null==e||""===e)return 0;let t=Number(e);return isNaN(t)?0:t}function ex(e){if(!e||""===e)return null;e.startsWith("/")&&(e=e.slice(1));let t=e.split("/"),r=null;for(let e=0;et._name?.toLowerCase()===e)??null}if(!r)return null}}return r}function eA(e){return null==e||""===e?null:ex(String(e))}function eC(e,t){function r(e,t){return e+t.join("_")}return{get:(t,...n)=>e.get(r(t,n))??"",set(n,...s){if(0===s.length)throw Error("set() requires at least a value argument");if(1===s.length){let r=e.get(n);return e.set(n,s[0]),t?.onSet?.(n,s[0],r),s[0]}let i=s[s.length-1],o=r(n,s.slice(0,-1)),a=e.get(o);return e.set(o,i),t?.onSet?.(o,i,a),i},postInc(n,...s){let i=r(n,s),o=ey(e.get(i)),a=o+1;return e.set(i,a),t?.onSet?.(i,a,o),o},postDec(n,...s){let i=r(n,s),o=ey(e.get(i)),a=o-1;return e.set(i,a),t?.onSet?.(i,a,o),o}}}function eS(){return eC(new b)}let ev={registerMethod:function(e,t,r){if(ec)ec.methods.has(e)||ec.methods.set(e,new b),ec.methods.get(e).set(t,r);else{c.has(e)||c.set(e,new b);let n=c.get(e);n.has(t)||n.set(t,[]),n.get(t).push(r)}},registerFunction:function(e,t){ec?ec.functions.set(e,t):(p.has(e)||p.set(e,[]),p.get(e).push(t))},package:function(e,t){let r=f.get(e);r||(r={name:e,active:!1,methods:new b,functions:new b},f.set(e,r));let n=ec;ec=r,t(),ec=n,d.has(e)&&(d.delete(e),eh(e))},activatePackage:eh,deactivatePackage:function(e){let t=f.get(e);if(!t||!t.active)return;t.active=!1;let r=h.findIndex(t=>t.toLowerCase()===e.toLowerCase());for(let[e,n]of(-1!==r&&h.splice(r,1),t.methods)){let t=c.get(e);if(t)for(let[e,r]of n){let n=t.get(e);if(n){let e=n.indexOf(r);-1!==e&&n.splice(e,1)}}}for(let[e,r]of t.functions){let t=p.get(e);if(t){let e=t.indexOf(r);-1!==e&&t.splice(e,1)}}},create:function(e,t,r,n){let s=H(e),i=function(){for(;C.has(A);)A+=1;let e=A;return A+=1,e}(),o={_class:s,_className:e,_id:i};for(let[e,t]of Object.entries(r))o[H(e)]=t;o.superclass&&(o._superClass=H(String(o.superclass)),o.class&&_.set(H(String(o.class)),o._superClass)),C.set(i,o);let a=F(t);if(a&&(o._name=a,S.set(a,o)),n){for(let e of n)e._parent=o;o._children=n}let l=em(e,"onAdd");return l&&l(o),ea(o),o},datablock:function(e,t,r,n){let s=H(e),i=function(){for(;C.has(x);)x+=1;let e=x;return x+=1,e}(),o={_class:s,_className:e,_id:i,_isDatablock:!0},a=F(r);if(a){let e=v.get(a);if(e){for(let[t,r]of Object.entries(e))t.startsWith("_")||(o[t]=r);o._parent=e}}for(let[e,t]of Object.entries(n))o[H(e)]=t;C.set(i,o);let l=F(t);return l&&(o._name=l,S.set(l,o),v.set(l,o)),ea(o),o},deleteObject:function e(t){var r;let n;if(null==t||("number"==typeof t?n=C.get(t):"string"==typeof t?n=S.get(t):"object"==typeof t&&t._id&&(n=t),!n))return!1;let s=em(n._className,"onRemove");if(s&&s(n),C.delete(n._id),n._name&&S.delete(n._name),n._isDatablock&&n._name&&v.delete(n._name),n._parent&&n._parent._children){let e=n._parent._children.indexOf(n);-1!==e&&n._parent._children.splice(e,1)}if(n._children)for(let t of[...n._children])e(t);return eo({type:"object.deleted",objectId:(r=n)._id,object:r}),!0},prop:function(e,t){let r=ed(e);return null==r?"":r[H(t)]??""},setProp:function(e,t,r){let n=ed(e);if(null==n)return r;let s=H(t),i=n[s];return n[s]=r,el(n,s,r,i),r},getIndex:function(e,t){let r=ed(e);return null==r?"":r[String(t)]??""},setIndex:function(e,t,r){let n=ed(e);if(null==n)return r;let s=String(t),i=n[s];return n[s]=r,el(n,s,r,i),r},propPostInc:function(e,t){return eg(e,H(t),1)},propPostDec:function(e,t){return eg(e,H(t),-1)},indexPostInc:function(e,t){return eg(e,String(t),1)},indexPostDec:function(e,t){return eg(e,String(t),-1)},key:function(e,...t){return e+t.join("_")},call:function(e,t,...r){if(null==e||("string"==typeof e||"number"==typeof e)&&null==(e=eA(e)))return"";let n=e.class||e._className||e._class;if(n){let s=eb(n,t,e,r);if(s.found)return e$(n,t,e,r),s.result}let s=e._superClass||_.get(n);for(;s;){let n=eb(s,t,e,r);if(n.found)return e$(s,t,e,r),n.result;s=_.get(s)}return""},nsCall:function(e,t,...r){let n=en(e,t);if(!n||0===n.length)return"";let s=er(e,t),i=n[n.length-1],o=et(s,n.length-1,()=>i(...r)),a=r[0];return a&&"object"==typeof a&&e$(e,t,a,r.slice(1)),o},nsRef:function(e,t){let r=en(e,t);if(!r||0===r.length)return null;let n=er(e,t),s=r[r.length-1];return(...e)=>et(n,r.length-1,()=>s(...e))},parent:function(e,t,r,...n){let s=en(e,t),i=er(e,t),o=ee(i);if(s&&void 0!==o&&o>=1){let a=o-1,l=et(i,a,()=>s[a](r,...n));return r&&"object"==typeof r&&e$(e,t,r,n),l}let a=_.get(e);for(;a;){let e=en(a,t);if(e&&e.length>0){let s=et(er(a,t),e.length-1,()=>e[e.length-1](r,...n));return r&&"object"==typeof r&&e$(a,t,r,n),s}a=_.get(a)}return""},parentFunc:function(e,...t){let r=p.get(e);if(!r)return"";let n=e.toLowerCase(),s=ee(n);if(void 0===s||s<1)return"";let i=s-1;return et(n,i,()=>r[i](...t))},add:function(e,t){return ey(e)+ey(t)},sub:function(e,t){return ey(e)-ey(t)},mul:function(e,t){return ey(e)*ey(t)},div:function(e,t){return ey(e)/ey(t)},neg:function(e){return-ey(e)},lt:function(e,t){return ey(e)ey(t)},ge:function(e,t){return ey(e)>=ey(t)},eq:function(e,t){return ey(e)===ey(t)},ne:function(e,t){return ey(e)!==ey(t)},mod:function(e,t){let r=0|Number(t);return 0===r?0:(0|Number(e))%r},bitand:function(e,t){return D(e)&D(t)},bitor:function(e,t){return D(e)|D(t)},bitxor:function(e,t){return D(e)^D(t)},shl:function(e,t){return D(D(e)<<(31&D(t)))},shr:function(e,t){return D(e)>>>(31&D(t))},bitnot:function(e){return~D(e)>>>0},concat:function(...e){return e.map(e=>String(e??"")).join("")},streq:function(e,t){return String(e??"").toLowerCase()===String(t??"").toLowerCase()},switchStr:function(e,t){let r=String(e??"").toLowerCase();for(let[e,n]of Object.entries(t))if("default"!==e&&H(e)===r)return void n();t.default&&t.default()},deref:eA,nameToId:function(e){let t=ex(e);return t?t._id:-1},isObject:function(e){return null!=e&&("object"==typeof e&&!!e._id||("number"==typeof e?C.has(e):"string"==typeof e&&S.has(e)))},isFunction:function(e){return p.has(e)||e.toLowerCase()in ef},isPackage:function(e){return f.has(e)},isActivePackage:function(e){let t=f.get(e);return t?.active??!1},getPackageList:function(){return h.join(" ")},locals:eS,onMethodCalled(e,t,r){let n=E.get(e);n||(n=new b,E.set(e,n));let s=n.get(t);return s||(s=[],n.set(t,s)),s.push(r),()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}},ew={call(e,...t){let r=p.get(e);if(r&&r.length>0)return et(e.toLowerCase(),r.length-1,()=>r[r.length-1](...t));let n=ef[e.toLowerCase()];return n?n(...t):(console.warn(`Unknown function: ${e}(${t.map(e=>JSON.stringify(e)).join(", ")})`),"")}},eE=eC(w,{onSet:function(e,t,r){let n=H(e.startsWith("$")?e.slice(1):e);Object.is(t,r)||u(n)&&eo({type:"global.changed",name:n,value:t,previousValue:r})}}),e_={methods:c,functions:p,packages:f,activePackages:h,objectsById:C,objectsByName:S,datablocks:v,globals:w,executedScripts:W,failedScripts:z,scripts:Q,generatedCode:X,pendingTimeouts:eu,startTime:Date.now()};function ek(e){let t=function(e){let t=X.get(e);null==t&&(t=new g(void 0).generate(e),X.set(e,t));return t}(e),r=eS();Function("$","$f","$g","$l",t)(ev,ew,eE,r)}function eR(e,t){return{execute(){if(t){let e=y(t);e_.executedScripts.add(e)}ek(e)}}}async function eL(t,r,n){let s=e.loadScript;if(!s){t.length>0&&console.warn("Script has exec() calls but no loadScript provided:",t);return}async function i(t){e.signal?.throwIfAborted();let i=y(t);if(e_.scripts.has(i)||e_.failedScripts.has(i))return;if(V&&V(i)){console.warn(`Ignoring script: ${t}`),e_.failedScripts.add(i);return}if(n.has(i))return;let o=r.get(i);if(o)return void await o;e.progress?.addItem(t);let a=(async()=>{let o,a=await s(t);if(null==a){console.warn(`Script not found: ${t}`),e_.failedScripts.add(i),e.progress?.completeItem();return}try{o=q(a,{filename:t})}catch(r){console.warn(`Failed to parse script: ${t}`,r),e_.failedScripts.add(i),e.progress?.completeItem();return}let l=new Set(n);l.add(i),await eL(o.execScriptPaths,r,l),e_.scripts.set(i,o),e.progress?.completeItem()})();r.set(i,a),await a}await Promise.all(t.map(i))}async function eN(t){let r=e.loadScript;if(!r)throw Error("loadFromPath requires loadScript option to be set");let n=y(t);if(e_.scripts.has(n))return eR(e_.scripts.get(n),t);e.progress?.addItem(t);let s=await r(t);if(null==s)throw e.progress?.completeItem(),Error(`Script not found: ${t}`);let i=await eO(s,{path:t});return e.progress?.completeItem(),i}async function eO(e,t){if(t?.path){let e=y(t.path);if(e_.scripts.has(e))return eR(e_.scripts.get(e),t.path)}return eI(q(e,{filename:t?.path}),t)}async function eI(t,r){let n=new Map,s=new Set;if(r?.path){let e=y(r.path);e_.scripts.set(e,t),s.add(e)}let i=[...t.execScriptPaths,...e.preloadScripts??[]];return await eL(i,n,s),eR(t,r?.path)}return ep={$:ev,$f:ew,$g:eE,state:e_,destroy:function(){for(let e of(U.length>0&&ei(),e_.pendingTimeouts))clearTimeout(e);e_.pendingTimeouts.clear(),k.clear()},executeAST:ek,loadFromPath:eN,loadFromSource:eO,loadFromAST:eI,call:(e,...t)=>ew.call(e,...t),getObjectByName:e=>S.get(e),subscribeRuntimeEvents:e=>(k.add(e),()=>{k.delete(e)})}}function U(){let e=new Set,t=0,r=0,n=null;function s(){for(let t of e)t()}return{get total(){return t},get loaded(){return r},get current(){return n},get progress(){return 0===t?0:r/t},on(t,r){e.add(r)},off(t,r){e.delete(r)},addItem(e){t++,n=e,s()},completeItem(){r++,n=null,s()},setCurrent(e){n=e,s()}}}function q(e,t){try{return f.default.parse(e)}catch(e){if(t?.filename&&e.location)throw Error(`${t.filename}:${e.location.start.line}:${e.location.start.column}: ${e.message}`,{cause:e});throw e}}function J(e){if("boolean"==typeof e)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){let t=e.trim().toLowerCase();return""!==t&&"0"!==t&&"false"!==t}return!!e}function K(){let e=Error("Operation aborted");return e.name="AbortError",e}function W(e){let t,{missionName:r,missionType:n,runtimeOptions:s,onMissionLoadDone:i}=e,{signal:o,fileSystem:a,globals:l={},preloadScripts:u=[],reactiveGlobalNames:c}=s??{},p=a?.findFiles("scripts/*Game.cs")??[],f=c?Array.from(new Set([...c,"missionRunning"])):void 0,h=G({...s,reactiveGlobalNames:f,globals:{...l,"$Host::Map":r,"$Host::MissionType":n},preloadScripts:[...u,...p]});(t=h.$.registerMethod.bind(h.$))("ShapeBase","playThread",(e,t,r)=>{e._threads||(e._threads={}),e._threads[Number(t)]={sequence:String(r),playing:!0,direction:!0}}),t("ShapeBase","stopThread",(e,t)=>{e._threads&&delete e._threads[Number(t)]}),t("ShapeBase","setThreadDir",(e,t,r)=>{e._threads||(e._threads={});let n=Number(t);e._threads[n]?e._threads[n].direction=!!Number(r):e._threads[n]={sequence:"",playing:!1,direction:!!Number(r)}}),t("ShapeBase","pauseThread",(e,t)=>{e._threads?.[Number(t)]&&(e._threads[Number(t)].playing=!1)}),t("ShapeBase","playAudio",()=>{}),t("ShapeBase","stopAudio",()=>{}),t("SimObject","getDatablock",e=>{let t=e.datablock;return t?h.getObjectByName(String(t))??"":""}),t("SimObject","getGroup",e=>e._parent??""),t("SimObject","getName",e=>e._name??""),t("SimObject","getType",()=>16384),t("SimGroup","getCount",e=>e._children?e._children.length:0),t("SimGroup","getObject",(e,t)=>{let r=e._children;return r?r[Number(t)]??"":""}),t("GameBase","isEnabled",()=>!0),t("GameBase","isDisabled",()=>!1),t("GameBase","setPoweredState",()=>{}),t("GameBase","setRechargeRate",()=>{}),t("GameBase","getRechargeRate",()=>0),t("GameBase","setEnergyLevel",()=>{}),t("GameBase","getEnergyLevel",()=>0),t("ShapeBase","getDamageLevel",()=>0),t("ShapeBase","setDamageLevel",()=>{}),t("ShapeBase","getRepairRate",()=>0),t("ShapeBase","setRepairRate",()=>{}),t("ShapeBase","getDamagePercent",()=>0),t("GameBase","getControllingClient",()=>0),t("SimObject","schedule",(e,t,r,...n)=>{let s=setTimeout(()=>{h.state.pendingTimeouts.delete(s);try{h.$.call(e,String(r),...n)}catch(t){console.error(`schedule: error calling ${r} on ${e._id}:`,t)}},Number(t)||0);return h.state.pendingTimeouts.add(s),s});let d=async function(){try{let e=await h.loadFromPath("scripts/server.cs");o?.throwIfAborted(),await h.loadFromPath(`missions/${r}.mis`),o?.throwIfAborted(),e.execute();let t=function(e,t){let{signal:r,onMissionLoadDone:n}=t;return new Promise((t,s)=>{let i=!1,o=!1,a=()=>J(e.$g.get("missionRunning")),l=()=>{i||(i=!0,h(),t())},u=e=>{i||(i=!0,h(),s(e))},c=t=>{if(!n||o)return;let r=t??e.getObjectByName("Game");r&&(o=!0,n(r))},p=()=>u(K()),f=e.subscribeRuntimeEvents(e=>{if("global.changed"===e.type&&"missionrunning"===e.name){J(e.value)&&(c(),l());return}"batch.flushed"===e.type&&a()&&(c(),l())});function h(){f(),r?.removeEventListener("abort",p)}if(r){if(r.aborted)return void u(K());r.addEventListener("abort",p,{once:!0})}a()&&(c(),l())})}(h,{signal:o,onMissionLoadDone:i}),n=await h.loadFromSource("CreateServer($Host::Map, $Host::MissionType);");o?.throwIfAborted(),n.execute(),await t}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}}();return{runtime:h,ready:d}}e.s(["createProgressTracker",()=>U],38433);let z=/^[ \t]*(DisplayName|MissionTypes|BriefingWAV|Bitmap|PlanetName)[ \t]*=[ \t]*(.+)$/i,V=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+BEGIN[ \t]*-+$/i,Z=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+END[ \t]*-+$/i,Q={arena:"Arena",bounty:"Bounty",cnh:"CnH",ctf:"CTF",dm:"DM",dnd:"DnD",hunters:"Hunters",lakrabbit:"LakRabbit",lakzm:"LakZM",lctf:"LCTF",none:"None",rabbit:"Rabbit",sctf:"SCtF",siege:"Siege",singleplayer:"SinglePlayer",tdm:"TDM",teamhunters:"TeamHunters",teamlak:"TeamLak",tr2:"TR2"};function X(e){let t=q(e),{pragma:r,sections:n}=function(e){let t={},r=[],n={name:null,comments:[]};for(let s of e.body)if("Comment"===s.type){let e=function(e){let t;return(t=e.match(V))?{type:"sectionBegin",name:t[1]}:(t=e.match(Z))?{type:"sectionEnd",name:t[1]}:(t=e.match(z))?{type:"definition",identifier:t[1],value:t[2]}:null}(s.value);if(e)switch(e.type){case"definition":null===n.name?t[e.identifier.toLowerCase()]=e.value:n.comments.push(s.value);break;case"sectionBegin":(null!==n.name||n.comments.length>0)&&r.push(n),n={name:e.name.toUpperCase(),comments:[]};break;case"sectionEnd":null!==n.name&&r.push(n),n={name:null,comments:[]}}else n.comments.push(s.value)}return(null!==n.name||n.comments.length>0)&&r.push(n),{pragma:t,sections:r}}(t);function s(e){return n.find(t=>t.name===e)?.comments.map(e=>e.trimStart()).join("\n")??null}return{displayName:r.displayname??null,missionTypes:r.missiontypes?.split(/\s+/).filter(Boolean).map(e=>Q[e.toLowerCase()]??e)??[],missionBriefing:s("MISSION BRIEFING"),briefingWav:r.briefingwav??null,bitmap:r.bitmap??null,planetName:r.planetname??null,missionBlurb:s("MISSION BLURB"),missionQuote:s("MISSION QUOTE"),missionString:s("MISSION STRING"),execScriptPaths:t.execScriptPaths,hasDynamicExec:t.hasDynamicExec,ast:t}}function Y(e,t){if(e)return e[t.toLowerCase()]}function ee(e){let[t,r,n]=(e.position??"0 0 0").split(" ").map(e=>parseFloat(e));return[r||0,n||0,t||0]}function et(e){let[t,r,n]=(e.scale??"1 1 1").split(" ").map(e=>parseFloat(e));return[r||0,n||0,t||0]}e.s(["getPosition",()=>ee,"getProperty",()=>Y,"getScale",()=>et,"parseMissionScript",()=>X],62395);let er="/t2-mapper",en=`${er}/base/`,es=`${er}/magenta.png`;function ei(e,t){let r;try{r=o(e)}catch(r){if(t)return console.warn(`Resource "${e}" not found - rendering fallback.`),t;throw r}let[n,s]=i(r);return n?`${en}@vl2/${n}/${s}`:`${en}${s}`}function eo(e){return ei(`interiors/${e}`).replace(/\.dif$/i,".glb")}function ea(e){return ei(`shapes/${e}`).replace(/\.dts$/i,".glb")}function el(e){return e=e.replace(/^terrain\./,""),ei(u(`textures/terrain/${e}`),es)}function eu(e,r){let n=t(r).split("/"),s=n.length>1?n.slice(0,-1).join("/")+"/":"";return ei(u(`${s}${e}`),es)}function ec(e){return ei(u(`textures/${e}`),es)}function ep(e){return ei(`audio/${e}`).replace(/\.wav$/i,".ogg")}async function ef(e){let t=ei(`textures/${e}`),r=await fetch(t);return(await r.text()).split(/(?:\r\n|\r|\n)/).map(e=>{if(!(e=e.trim()).startsWith(";"))return e}).filter(Boolean)}async function eh(e){let t,r=c(e),n=await fetch(ei(r.resourcePath)),s=await n.arrayBuffer();try{t=new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{t=new TextDecoder("windows-1252").decode(s)}return X(t=t.replaceAll("�","'"))}async function ed(e){let t=await fetch(ei(`terrains/${e}`));return function(e){let t=new DataView(e),r=0,n=t.getUint8(r++),s=new Uint16Array(65536),i=[],o=e=>{let n="";for(let s=0;s0&&i.push(s)}let a=[];for(let e of i){let e=new Uint8Array(65536);for(let n=0;n<65536;n++){let s=t.getUint8(r++);e[n]=s}a.push(e)}return{version:n,textureNames:i,heightMap:s,alphaMaps:a}}(await t.arrayBuffer())}async function eg(e){let t=ei(e),r=await fetch(t);return(await r.text()).split(/(?:\r\n|\r|\n)/g).map(e=>e.trim()).filter(Boolean).filter(e=>!e.startsWith(";")).map(e=>{let t=e.match(/^(.+)\s(\d+)$/);if(!t)return{name:e,frameCount:1};{let e=parseInt(t[2],10);return{name:t[1],frameCount:e}}})}e.s(["FALLBACK_TEXTURE_URL",0,es,"RESOURCE_ROOT_URL",0,en,"audioToUrl",()=>ep,"getUrlForPath",()=>ei,"iflTextureToUrl",()=>eu,"interiorToUrl",()=>eo,"loadDetailMapList",()=>ef,"loadImageFrameList",()=>eg,"loadMission",()=>eh,"loadTerrain",()=>ed,"shapeToUrl",()=>ea,"terrainTextureToUrl",()=>el,"textureToUrl",()=>ec],12979)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/629d98e413c0344a.js b/docs/_next/static/chunks/629d98e413c0344a.js new file mode 100644 index 00000000..646e84fb --- /dev/null +++ b/docs/_next/static/chunks/629d98e413c0344a.js @@ -0,0 +1,397 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66936,(e,t,n)=>{"use strict";function i(e,t){var n=e.length;for(e.push(t);0>>1,r=e[i];if(0>>1;is(l,n))us(c,l)?(e[i]=c,e[u]=n,i=u):(e[i]=l,e[o]=n,i=o);else if(us(c,n))e[i]=c,e[u]=n,i=u;else break}}return t}function s(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if(n.unstable_now=void 0,"object"==typeof performance&&"function"==typeof performance.now){var o,l=performance;n.unstable_now=function(){return l.now()}}else{var u=Date,c=u.now();n.unstable_now=function(){return u.now()-c}}var h=[],d=[],p=1,f=null,m=3,g=!1,v=!1,_=!1,y=!1,x="function"==typeof setTimeout?setTimeout:null,b="function"==typeof clearTimeout?clearTimeout:null,S="u">typeof setImmediate?setImmediate:null;function M(e){for(var t=r(d);null!==t;){if(null===t.callback)a(d);else if(t.startTime<=e)a(d),t.sortIndex=t.expirationTime,i(h,t);else break;t=r(d)}}function T(e){if(_=!1,M(e),!v)if(null!==r(h))v=!0,w||(w=!0,o());else{var t=r(d);null!==t&&N(T,t.startTime-e)}}var w=!1,E=-1,A=5,C=-1;function R(){return!!y||!(n.unstable_now()-Ce&&R());){var s=f.callback;if("function"==typeof s){f.callback=null,m=f.priorityLevel;var l=s(f.expirationTime<=e);if(e=n.unstable_now(),"function"==typeof l){f.callback=l,M(e),t=!0;break t}f===r(h)&&a(h),M(e)}else a(h);f=r(h)}if(null!==f)t=!0;else{var u=r(d);null!==u&&N(T,u.startTime-e),t=!1}}break e}finally{f=null,m=i,g=!1}}}finally{t?o():w=!1}}}if("function"==typeof S)o=function(){S(P)};else if("u">typeof MessageChannel){var I=new MessageChannel,L=I.port2;I.port1.onmessage=P,o=function(){L.postMessage(null)}}else o=function(){x(P,0)};function N(e,t){E=x(function(){e(n.unstable_now())},t)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(e){e.callback=null},n.unstable_forceFrameRate=function(e){0>e||125s?(e.sortIndex=a,i(d,e),null===r(h)&&e===r(d)&&(_?(b(E),E=-1):_=!0,N(T,a-s))):(e.sortIndex=l,i(h,e),v||g||(v=!0,w||(w=!0,o()))),e},n.unstable_shouldYield=R,n.unstable_wrapCallback=function(e){var t=m;return function(){var n=m;m=t;try{return e.apply(this,arguments)}finally{m=n}}}},89499,(e,t,n)=>{"use strict";t.exports=e.r(66936)},40859,90072,8560,46791,e=>{"use strict";let t,n,i,r,a,s,o,l,u,c,h,d,p,f,m,g,v,_;var y,x,b,S,M,T,w=e.i(47167),E=e.i(71645);let A={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},C={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},R="attached",P="detached",I="srgb",L="srgb-linear",N="linear",U="srgb",D="300 es",O={COMPUTE:"compute",RENDER:"render"},F={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},z={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function B(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}let k={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function V(e,t){return new k[e](t)}function H(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function G(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function W(){let e=G("canvas");return e.style.display="block",e}let j={},X=null;function q(e){X=e}function Y(){return X}function Z(...e){let t="THREE."+e.shift();X?X("log",t,...e):console.log(t,...e)}function J(...e){let t="THREE."+e.shift();X?X("warn",t,...e):console.warn(t,...e)}function K(...e){let t="THREE."+e.shift();X?X("error",t,...e):console.error(t,...e)}function $(...e){let t=e.join(" ");t in j||(j[t]=!0,J(...e))}function Q(e,t,n){return new Promise(function(i,r){setTimeout(function a(){switch(e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0)){case e.WAIT_FAILED:r();break;case e.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:i()}},n)})}class ee{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return void 0!==n&&void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){let n=this._listeners;if(void 0===n)return;let i=n[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){let t=this._listeners;if(void 0===t)return;let n=t[e.type];if(void 0!==n){e.target=this;let t=n.slice(0);for(let n=0,i=t.length;n>8&255]+et[e>>16&255]+et[e>>24&255]+"-"+et[255&t]+et[t>>8&255]+"-"+et[t>>16&15|64]+et[t>>24&255]+"-"+et[63&n|128]+et[n>>8&255]+"-"+et[n>>16&255]+et[n>>24&255]+et[255&i]+et[i>>8&255]+et[i>>16&255]+et[i>>24&255]).toLowerCase()}function es(e,t,n){return Math.max(t,Math.min(n,e))}function eo(e,t){return(e%t+t)%t}function el(e,t,n){return(1-n)*e+n*t}function eu(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/0xffffffff;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/0x7fffffff,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}function ec(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(0xffffffff*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(0x7fffffff*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw Error("Invalid component type.")}}let eh={DEG2RAD:ei,RAD2DEG:er,generateUUID:ea,clamp:es,euclideanModulo:eo,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:el,damp:function(e,t,n,i){return el(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(eo(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(en=e);let t=en+=0x6d2b79f5;return t=Math.imul(t^t>>>15,1|t),(((t^=t+Math.imul(t^t>>>7,61|t))^t>>>14)>>>0)/0x100000000},degToRad:function(e){return e*ei},radToDeg:function(e){return e*er},isPowerOfTwo:function(e){return(e&e-1)==0&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,n,i,r){let a=Math.cos,s=Math.sin,o=a(n/2),l=s(n/2),u=a((t+i)/2),c=s((t+i)/2),h=a((t-i)/2),d=s((t-i)/2),p=a((i-t)/2),f=s((i-t)/2);switch(r){case"XYX":e.set(o*c,l*h,l*d,o*u);break;case"YZY":e.set(l*d,o*c,l*h,o*u);break;case"ZXZ":e.set(l*h,l*d,o*c,o*u);break;case"XZX":e.set(o*c,l*f,l*p,o*u);break;case"YXY":e.set(l*p,o*c,l*f,o*u);break;case"ZYZ":e.set(l*f,l*p,o*c,o*u);break;default:J("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:ec,denormalize:eu};class ed{constructor(e=0,t=0){ed.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:Math.acos(es(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*i+e.x,this.y=r*i+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ep{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,r,a,s){let o=n[i+0],l=n[i+1],u=n[i+2],c=n[i+3],h=r[a+0],d=r[a+1],p=r[a+2],f=r[a+3];if(s<=0){e[t+0]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c;return}if(s>=1){e[t+0]=h,e[t+1]=d,e[t+2]=p,e[t+3]=f;return}if(c!==f||o!==h||l!==d||u!==p){let e=o*h+l*d+u*p+c*f;e<0&&(h=-h,d=-d,p=-p,f=-f,e=-e);let t=1-s;if(e<.9995){let n=Math.acos(e),i=Math.sin(n);o=o*(t=Math.sin(t*n)/i)+h*(s=Math.sin(s*n)/i),l=l*t+d*s,u=u*t+p*s,c=c*t+f*s}else{let e=1/Math.sqrt((o=o*t+h*s)*o+(l=l*t+d*s)*l+(u=u*t+p*s)*u+(c=c*t+f*s)*c);o*=e,l*=e,u*=e,c*=e}}e[t]=o,e[t+1]=l,e[t+2]=u,e[t+3]=c}static multiplyQuaternionsFlat(e,t,n,i,r,a){let s=n[i],o=n[i+1],l=n[i+2],u=n[i+3],c=r[a],h=r[a+1],d=r[a+2],p=r[a+3];return e[t]=s*p+u*c+o*d-l*h,e[t+1]=o*p+u*h+l*c-s*d,e[t+2]=l*p+u*d+s*h-o*c,e[t+3]=u*p-s*c-o*h-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){let n=e._x,i=e._y,r=e._z,a=e._order,s=Math.cos,o=Math.sin,l=s(n/2),u=s(i/2),c=s(r/2),h=o(n/2),d=o(i/2),p=o(r/2);switch(a){case"XYZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"YXZ":this._x=h*u*c+l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"ZXY":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c-h*d*p;break;case"ZYX":this._x=h*u*c-l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c+h*d*p;break;case"YZX":this._x=h*u*c+l*d*p,this._y=l*d*c+h*u*p,this._z=l*u*p-h*d*c,this._w=l*u*c-h*d*p;break;case"XZY":this._x=h*u*c-l*d*p,this._y=l*d*c-h*u*p,this._z=l*u*p+h*d*c,this._w=l*u*c+h*d*p;break;default:J("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],i=t[4],r=t[8],a=t[1],s=t[5],o=t[9],l=t[2],u=t[6],c=t[10],h=n+s+c;if(h>0){let e=.5/Math.sqrt(h+1);this._w=.25/e,this._x=(u-o)*e,this._y=(r-l)*e,this._z=(a-i)*e}else if(n>s&&n>c){let e=2*Math.sqrt(1+n-s-c);this._w=(u-o)/e,this._x=.25*e,this._y=(i+a)/e,this._z=(r+l)/e}else if(s>c){let e=2*Math.sqrt(1+s-n-c);this._w=(r-l)/e,this._x=(i+a)/e,this._y=.25*e,this._z=(o+u)/e}else{let e=2*Math.sqrt(1+c-n-s);this._w=(a-i)/e,this._x=(r+l)/e,this._y=(o+u)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0):(this._x=0,this._y=-e.z,this._z=e.y)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x),this._w=n,this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(es(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(0===n)return this;let i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,i=e._y,r=e._z,a=e._w,s=t._x,o=t._y,l=t._z,u=t._w;return this._x=n*u+a*s+i*l-r*o,this._y=i*u+a*o+r*s-n*l,this._z=r*u+a*l+n*o-i*s,this._w=a*u-n*s-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,i=e._y,r=e._z,a=e._w,s=this.dot(e);s<0&&(n=-n,i=-i,r=-r,a=-a,s=-s);let o=1-t;if(s<.9995){let e=Math.acos(s),l=Math.sin(e);o=Math.sin(o*e)/l,t=Math.sin(t*e)/l,this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this._onChangeCallback()}else this._x=this._x*o+n*t,this._y=this._y*o+i*t,this._z=this._z*o+r*t,this._w=this._w*o+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ef{constructor(e=0,t=0,n=0){ef.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(eg.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(eg.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,i=this.z,r=e.x,a=e.y,s=e.z,o=e.w,l=2*(a*i-s*n),u=2*(s*t-r*i),c=2*(r*n-a*t);return this.x=t+o*l+a*c-s*u,this.y=n+o*u+s*l-r*c,this.z=i+o*c+r*u-a*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this.z=es(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this.z=es(this.z,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,i=e.y,r=e.z,a=t.x,s=t.y,o=t.z;return this.x=i*o-r*s,this.y=r*a-n*o,this.z=n*s-i*a,this}projectOnVector(e){let t=e.lengthSq();if(0===t)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return em.copy(this).projectOnVector(e),this.sub(em)}reflect(e){return this.sub(em.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());return 0===t?Math.PI/2:Math.acos(es(this.dot(e)/t,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=2*Math.random()-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let em=new ef,eg=new ep;class ev{constructor(e,t,n,i,r,a,s,o,l){ev.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l)}set(e,t,n,i,r,a,s,o,l){let u=this.elements;return u[0]=e,u[1]=i,u[2]=s,u[3]=t,u[4]=r,u[5]=o,u[6]=n,u[7]=a,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[3],o=n[6],l=n[1],u=n[4],c=n[7],h=n[2],d=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],_=i[4],y=i[7],x=i[2],b=i[5],S=i[8];return r[0]=a*f+s*v+o*x,r[3]=a*m+s*_+o*b,r[6]=a*g+s*y+o*S,r[1]=l*f+u*v+c*x,r[4]=l*m+u*_+c*b,r[7]=l*g+u*y+c*S,r[2]=h*f+d*v+p*x,r[5]=h*m+d*_+p*b,r[8]=h*g+d*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8];return t*a*u-t*s*l-n*r*u+n*s*o+i*r*l-i*a*o}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=u*a-s*l,h=s*o-u*r,d=l*r-a*o,p=t*c+n*h+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);let f=1/p;return e[0]=c*f,e[1]=(i*l-u*n)*f,e[2]=(s*n-i*a)*f,e[3]=h*f,e[4]=(u*t-i*o)*f,e[5]=(i*r-s*t)*f,e[6]=d*f,e[7]=(n*o-l*t)*f,e[8]=(a*t-n*r)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,a,s){let o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*a+l*s)+a+e,-i*l,i*o,-i*(-l*a+o*s)+s+t,0,0,1),this}scale(e,t){return this.premultiply(e_.makeScale(e,t)),this}rotate(e){return this.premultiply(e_.makeRotation(-e)),this}translate(e,t){return this.premultiply(e_.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}let e_=new ev,ey=new ev().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ex=new ev().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),eb=(d=[.64,.33,.3,.6,.15,.06],p=[.2126,.7152,.0722],f=[.3127,.329],(h={enabled:!0,workingColorSpace:L,spaces:{},convert:function(e,t,n){return!1!==this.enabled&&t!==n&&t&&n&&(this.spaces[t].transfer===U&&(e.r=eS(e.r),e.g=eS(e.g),e.b=eS(e.b)),this.spaces[t].primaries!==this.spaces[n].primaries&&(e.applyMatrix3(this.spaces[t].toXYZ),e.applyMatrix3(this.spaces[n].fromXYZ)),this.spaces[n].transfer===U&&(e.r=eM(e.r),e.g=eM(e.g),e.b=eM(e.b))),e},workingToColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},colorSpaceToWorking:function(e,t){return this.convert(e,t,this.workingColorSpace)},getPrimaries:function(e){return this.spaces[e].primaries},getTransfer:function(e){return""===e?N:this.spaces[e].transfer},getToneMappingMode:function(e){return this.spaces[e].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(e,t=this.workingColorSpace){return e.fromArray(this.spaces[t].luminanceCoefficients)},define:function(e){Object.assign(this.spaces,e)},_getMatrix:function(e,t,n){return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ)},_getDrawingBufferColorSpace:function(e){return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(e=this.workingColorSpace){return this.spaces[e].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(e,t){return $("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),h.workingToColorSpace(e,t)},toWorkingColorSpace:function(e,t){return $("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),h.colorSpaceToWorking(e,t)}}).define({[L]:{primaries:d,whitePoint:f,transfer:N,toXYZ:ey,fromXYZ:ex,luminanceCoefficients:p,workingColorSpaceConfig:{unpackColorSpace:I},outputColorSpaceConfig:{drawingBufferColorSpace:I}},[I]:{primaries:d,whitePoint:f,transfer:U,toXYZ:ey,fromXYZ:ex,luminanceCoefficients:p,outputColorSpaceConfig:{drawingBufferColorSpace:I}}}),h);function eS(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function eM(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class eT{static getDataURL(e,n="image/png"){let i;if(/^data:/i.test(e.src)||"u"typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap){let t=G("canvas");t.width=e.width,t.height=e.height;let n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);let i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;etypeof HTMLVideoElement&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):"u">typeof VideoFrame&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):null!==t?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){!0===e&&this.version++}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];let n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;ttypeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap?eT.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(J("Texture: Unable to serialize Texture."),{})}let eC=0,eR=new ef;class eP extends ee{constructor(e=eP.DEFAULT_IMAGE,t=eP.DEFAULT_MAPPING,n=1001,i=1001,r=1006,a=1008,s=1023,o=1009,l=eP.DEFAULT_ANISOTROPY,u=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:eC++}),this.uuid=ea(),this.name="",this.source=new eE(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=o,this.offset=new ed(0,0),this.repeat=new ed(1,1),this.center=new ed(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ev,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=u,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!e&&!!e.depth&&e.depth>1,this.pmremVersion=0}get width(){return this.source.getSize(eR).x}get height(){return this.source.getSize(eR).y}get depth(){return this.source.getSize(eR).z}get image(){return this.source.data}set image(e=null){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(let t in e){let n=e[t];if(void 0===n){J(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){J(`Texture.setValues(): property '${t}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];let n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(300!==this.mapping)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case 1e3:e.x=e.x-Math.floor(e.x);break;case 1001:e.x=e.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case 1e3:e.y=e.y-Math.floor(e.y);break;case 1001:e.y=e.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}eP.DEFAULT_IMAGE=null,eP.DEFAULT_MAPPING=300,eP.DEFAULT_ANISOTROPY=1;class eI{constructor(e=0,t=0,n=0,i=1){eI.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,i=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*i+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r,a=e.elements,s=a[0],o=a[4],l=a[8],u=a[1],c=a[5],h=a[9],d=a[2],p=a[6],f=a[10];if(.01>Math.abs(o-u)&&.01>Math.abs(l-d)&&.01>Math.abs(h-p)){if(.1>Math.abs(o+u)&&.1>Math.abs(l+d)&&.1>Math.abs(h+p)&&.1>Math.abs(s+c+f-3))return this.set(1,0,0,0),this;t=Math.PI;let e=(s+1)/2,a=(c+1)/2,m=(f+1)/2,g=(o+u)/4,v=(l+d)/4,_=(h+p)/4;return e>a&&e>m?e<.01?(n=0,i=.707106781,r=.707106781):(i=g/(n=Math.sqrt(e)),r=v/n):a>m?a<.01?(n=.707106781,i=0,r=.707106781):(n=g/(i=Math.sqrt(a)),r=_/i):m<.01?(n=.707106781,i=.707106781,r=0):(n=v/(r=Math.sqrt(m)),i=_/r),this.set(n,i,r,t),this}let m=Math.sqrt((p-h)*(p-h)+(l-d)*(l-d)+(u-o)*(u-o));return .001>Math.abs(m)&&(m=1),this.x=(p-h)/m,this.y=(l-d)/m,this.z=(u-o)/m,this.w=Math.acos((s+c+f-1)/2),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=es(this.x,e.x,t.x),this.y=es(this.y,e.y,t.y),this.z=es(this.z,e.z,t.z),this.w=es(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=es(this.x,e,t),this.y=es(this.y,e,t),this.z=es(this.z,e,t),this.w=es(this.w,e,t),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(es(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class eL extends ee{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new eI(0,0,e,t),this.scissorTest=!1,this.viewport=new eI(0,0,e,t);const i=new eP({width:e,height:t,depth:n.depth});this.textures=[];const r=n.count;for(let e=0;e1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,ek),ek.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(eY),eZ.subVectors(this.max,eY),eH.subVectors(e.a,eY),eG.subVectors(e.b,eY),eW.subVectors(e.c,eY),ej.subVectors(eG,eH),eX.subVectors(eW,eG),eq.subVectors(eH,eW);let t=[0,-ej.z,ej.y,0,-eX.z,eX.y,0,-eq.z,eq.y,ej.z,0,-ej.x,eX.z,0,-eX.x,eq.z,0,-eq.x,-ej.y,ej.x,0,-eX.y,eX.x,0,-eq.y,eq.x,0];return!!e$(t,eH,eG,eW,eZ)&&!!e$(t=[1,0,0,0,1,0,0,0,1],eH,eG,eW,eZ)&&(eJ.crossVectors(ej,eX),e$(t=[eJ.x,eJ.y,eJ.z],eH,eG,eW,eZ))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ek).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(ek).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(eB[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),eB[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),eB[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),eB[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),eB[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),eB[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),eB[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),eB[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(eB)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}let eB=[new ef,new ef,new ef,new ef,new ef,new ef,new ef,new ef],ek=new ef,eV=new ez,eH=new ef,eG=new ef,eW=new ef,ej=new ef,eX=new ef,eq=new ef,eY=new ef,eZ=new ef,eJ=new ef,eK=new ef;function e$(e,t,n,i,r){for(let a=0,s=e.length-3;a<=s;a+=3){eK.fromArray(e,a);let s=r.x*Math.abs(eK.x)+r.y*Math.abs(eK.y)+r.z*Math.abs(eK.z),o=t.dot(eK),l=n.dot(eK),u=i.dot(eK);if(Math.max(-Math.max(o,l,u),Math.min(o,l,u))>s)return!1}return!0}let eQ=new ez,e0=new ef,e1=new ef;class e2{constructor(e=new ef,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;void 0!==t?n.copy(t):eQ.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?e.makeEmpty():(e.set(this.center,this.center),e.expandByScalar(this.radius)),e}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;e0.subVectors(e,this.center);let t=e0.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(e0,n/e),this.radius+=n}return this}union(e){return e.isEmpty()||(this.isEmpty()?this.copy(e):!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(e1.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(e0.copy(e.center).add(e1)),this.expandByPoint(e0.copy(e.center).sub(e1)))),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let e3=new ef,e4=new ef,e5=new ef,e6=new ef,e8=new ef,e9=new ef,e7=new ef;class te{constructor(e=new ef,t=new ef(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,e3)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=e3.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(e3.copy(this.origin).addScaledVector(this.direction,t),e3.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){let r,a,s,o;e4.copy(e).add(t).multiplyScalar(.5),e5.copy(t).sub(e).normalize(),e6.copy(this.origin).sub(e4);let l=.5*e.distanceTo(t),u=-this.direction.dot(e5),c=e6.dot(this.direction),h=-e6.dot(e5),d=e6.lengthSq(),p=Math.abs(1-u*u);if(p>0)if(r=u*h-c,a=u*c-h,o=l*p,r>=0)if(a>=-o)if(a<=o){let e=1/p;r*=e,a*=e,s=r*(r+u*a+2*c)+a*(u*r+a+2*h)+d}else s=-(r=Math.max(0,-(u*(a=l)+c)))*r+a*(a+2*h)+d;else s=-(r=Math.max(0,-(u*(a=-l)+c)))*r+a*(a+2*h)+d;else a<=-o?(a=(r=Math.max(0,-(-u*l+c)))>0?-l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d):a<=o?(r=0,s=(a=Math.min(Math.max(-l,-h),l))*(a+2*h)+d):(a=(r=Math.max(0,-(u*l+c)))>0?l:Math.min(Math.max(-l,-h),l),s=-r*r+a*(a+2*h)+d);else a=u>0?-l:l,s=-(r=Math.max(0,-(u*a+c)))*r+a*(a+2*h)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,r),i&&i.copy(e4).addScaledVector(e5,a),s}intersectSphere(e,t){e3.subVectors(e.center,this.origin);let n=e3.dot(this.direction),i=e3.dot(e3)-n*n,r=e.radius*e.radius;if(i>r)return null;let a=Math.sqrt(r-i),s=n-a,o=n+a;return o<0?null:s<0?this.at(o,t):this.at(s,t)}intersectsSphere(e){return!(e.radius<0)&&this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return!!(0===t||e.normal.dot(this.direction)*t<0)}intersectBox(e,t){let n,i,r,a,s,o,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,h=this.origin;return(l>=0?(n=(e.min.x-h.x)*l,i=(e.max.x-h.x)*l):(n=(e.max.x-h.x)*l,i=(e.min.x-h.x)*l),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a=0?(s=(e.min.z-h.z)*c,o=(e.max.z-h.z)*c):(s=(e.max.z-h.z)*c,o=(e.min.z-h.z)*c),n>o||s>i||((s>n||n!=n)&&(n=s),(o=0?n:i,t)}intersectsBox(e){return null!==this.intersectBox(e,e3)}intersectTriangle(e,t,n,i,r){let a;e8.subVectors(t,e),e9.subVectors(n,e),e7.crossVectors(e8,e9);let s=this.direction.dot(e7);if(s>0){if(i)return null;a=1}else{if(!(s<0))return null;a=-1,s=-s}e6.subVectors(this.origin,e);let o=a*this.direction.dot(e9.crossVectors(e6,e9));if(o<0)return null;let l=a*this.direction.dot(e8.cross(e6));if(l<0||o+l>s)return null;let u=-a*e6.dot(e7);return u<0?null:this.at(u/s,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class tt{constructor(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){tt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m)}set(e,t,n,i,r,a,s,o,l,u,c,h,d,p,f,m){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=a,g[9]=s,g[13]=o,g[2]=l,g[6]=u,g[10]=c,g[14]=h,g[3]=d,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new tt().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return 0===this.determinant()?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1)):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2)),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(0===e.determinant())return this.identity();let t=this.elements,n=e.elements,i=1/tn.setFromMatrixColumn(e,0).length(),r=1/tn.setFromMatrixColumn(e,1).length(),a=1/tn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,i=e.y,r=e.z,a=Math.cos(n),s=Math.sin(n),o=Math.cos(i),l=Math.sin(i),u=Math.cos(r),c=Math.sin(r);if("XYZ"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=-o*c,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-s*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=a*o}else if("YXZ"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e+r*s,t[4]=i*s-n,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-s,t[2]=n*s-i,t[6]=r+e*s,t[10]=a*o}else if("ZXY"===e.order){let e=o*u,n=o*c,i=l*u,r=l*c;t[0]=e-r*s,t[4]=-a*c,t[8]=i+n*s,t[1]=n+i*s,t[5]=a*u,t[9]=r-e*s,t[2]=-a*l,t[6]=s,t[10]=a*o}else if("ZYX"===e.order){let e=a*u,n=a*c,i=s*u,r=s*c;t[0]=o*u,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*c,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=s*o,t[10]=a*o}else if("YZX"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=r-e*c,t[8]=i*c+n,t[1]=c,t[5]=a*u,t[9]=-s*u,t[2]=-l*u,t[6]=n*c+i,t[10]=e-r*c}else if("XZY"===e.order){let e=a*o,n=a*l,i=s*o,r=s*l;t[0]=o*u,t[4]=-c,t[8]=l*u,t[1]=e*c+r,t[5]=a*u,t[9]=n*c-i,t[2]=i*c-n,t[6]=s*u,t[10]=r*c+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(tr,e,ta)}lookAt(e,t,n){let i=this.elements;return tl.subVectors(e,t),0===tl.lengthSq()&&(tl.z=1),tl.normalize(),ts.crossVectors(n,tl),0===ts.lengthSq()&&(1===Math.abs(n.z)?tl.x+=1e-4:tl.z+=1e-4,tl.normalize(),ts.crossVectors(n,tl)),ts.normalize(),to.crossVectors(tl,ts),i[0]=ts.x,i[4]=to.x,i[8]=tl.x,i[1]=ts.y,i[5]=to.y,i[9]=tl.y,i[2]=ts.z,i[6]=to.z,i[10]=tl.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,i=t.elements,r=this.elements,a=n[0],s=n[4],o=n[8],l=n[12],u=n[1],c=n[5],h=n[9],d=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],_=n[7],y=n[11],x=n[15],b=i[0],S=i[4],M=i[8],T=i[12],w=i[1],E=i[5],A=i[9],C=i[13],R=i[2],P=i[6],I=i[10],L=i[14],N=i[3],U=i[7],D=i[11],O=i[15];return r[0]=a*b+s*w+o*R+l*N,r[4]=a*S+s*E+o*P+l*U,r[8]=a*M+s*A+o*I+l*D,r[12]=a*T+s*C+o*L+l*O,r[1]=u*b+c*w+h*R+d*N,r[5]=u*S+c*E+h*P+d*U,r[9]=u*M+c*A+h*I+d*D,r[13]=u*T+c*C+h*L+d*O,r[2]=p*b+f*w+m*R+g*N,r[6]=p*S+f*E+m*P+g*U,r[10]=p*M+f*A+m*I+g*D,r[14]=p*T+f*C+m*L+g*O,r[3]=v*b+_*w+y*R+x*N,r[7]=v*S+_*E+y*P+x*U,r[11]=v*M+_*A+y*I+x*D,r[15]=v*T+_*C+y*L+x*O,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],a=e[1],s=e[5],o=e[9],l=e[13],u=e[2],c=e[6],h=e[10],d=e[14],p=e[3],f=e[7],m=e[11],g=e[15],v=o*d-l*h,_=s*d-l*c,y=s*h-o*c,x=a*d-l*u,b=a*h-o*u,S=a*c-s*u;return t*(f*v-m*_+g*y)-n*(p*v-m*x+g*b)+i*(p*_-f*x+g*S)-r*(p*y-f*b+m*S)}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(e,t,n){let i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],a=e[4],s=e[5],o=e[6],l=e[7],u=e[8],c=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=c*m*l-f*h*l+f*o*d-s*m*d-c*o*g+s*h*g,_=p*h*l-u*m*l-p*o*d+a*m*d+u*o*g-a*h*g,y=u*f*l-p*c*l+p*s*d-a*f*d-u*s*g+a*c*g,x=p*c*o-u*f*o-p*s*h+a*f*h+u*s*m-a*c*m,b=t*v+n*_+i*y+r*x;if(0===b)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/b;return e[0]=v*S,e[1]=(f*h*r-c*m*r-f*i*d+n*m*d+c*i*g-n*h*g)*S,e[2]=(s*m*r-f*o*r+f*i*l-n*m*l-s*i*g+n*o*g)*S,e[3]=(c*o*r-s*h*r-c*i*l+n*h*l+s*i*d-n*o*d)*S,e[4]=_*S,e[5]=(u*m*r-p*h*r+p*i*d-t*m*d-u*i*g+t*h*g)*S,e[6]=(p*o*r-a*m*r-p*i*l+t*m*l+a*i*g-t*o*g)*S,e[7]=(a*h*r-u*o*r+u*i*l-t*h*l-a*i*d+t*o*d)*S,e[8]=y*S,e[9]=(p*c*r-u*f*r-p*n*d+t*f*d+u*n*g-t*c*g)*S,e[10]=(a*f*r-p*s*r+p*n*l-t*f*l-a*n*g+t*s*g)*S,e[11]=(u*s*r-a*c*r-u*n*l+t*c*l+a*n*d-t*s*d)*S,e[12]=x*S,e[13]=(u*f*i-p*c*i+p*n*h-t*f*h-u*n*m+t*c*m)*S,e[14]=(p*s*i-a*f*i-p*n*o+t*f*o+a*n*m-t*s*m)*S,e[15]=(a*c*i-u*s*i+u*n*o-t*c*o-a*n*h+t*s*h)*S,this}scale(e){let t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements;return Math.sqrt(Math.max(e[0]*e[0]+e[1]*e[1]+e[2]*e[2],e[4]*e[4]+e[5]*e[5]+e[6]*e[6],e[8]*e[8]+e[9]*e[9]+e[10]*e[10]))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),i=Math.sin(t),r=1-n,a=e.x,s=e.y,o=e.z,l=r*a,u=r*s;return this.set(l*a+n,l*s-i*o,l*o+i*s,0,l*s+i*o,u*s+n,u*o-i*a,0,l*o-i*s,u*o+i*a,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,a){return this.set(1,n,r,0,e,1,a,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){let i=this.elements,r=t._x,a=t._y,s=t._z,o=t._w,l=r+r,u=a+a,c=s+s,h=r*l,d=r*u,p=r*c,f=a*u,m=a*c,g=s*c,v=o*l,_=o*u,y=o*c,x=n.x,b=n.y,S=n.z;return i[0]=(1-(f+g))*x,i[1]=(d+y)*x,i[2]=(p-_)*x,i[3]=0,i[4]=(d-y)*b,i[5]=(1-(h+g))*b,i[6]=(m+v)*b,i[7]=0,i[8]=(p+_)*S,i[9]=(m-v)*S,i[10]=(1-(h+f))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){let i=this.elements;if(e.x=i[12],e.y=i[13],e.z=i[14],0===this.determinant())return n.set(1,1,1),t.identity(),this;let r=tn.set(i[0],i[1],i[2]).length(),a=tn.set(i[4],i[5],i[6]).length(),s=tn.set(i[8],i[9],i[10]).length();0>this.determinant()&&(r=-r),ti.copy(this);let o=1/r,l=1/a,u=1/s;return ti.elements[0]*=o,ti.elements[1]*=o,ti.elements[2]*=o,ti.elements[4]*=l,ti.elements[5]*=l,ti.elements[6]*=l,ti.elements[8]*=u,ti.elements[9]*=u,ti.elements[10]*=u,t.setFromRotationMatrix(ti),n.x=r,n.y=a,n.z=s,this}makePerspective(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=r/(a-r),u=a*r/(a-r);else if(2e3===s)l=-(a+r)/(a-r),u=-2*a*r/(a-r);else if(2001===s)l=-a/(a-r),u=-a*r/(a-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+s);return c[0]=2*r/(t-e),c[4]=0,c[8]=(t+e)/(t-e),c[12]=0,c[1]=0,c[5]=2*r/(n-i),c[9]=(n+i)/(n-i),c[13]=0,c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,i,r,a,s=2e3,o=!1){let l,u,c=this.elements;if(o)l=1/(a-r),u=a/(a-r);else if(2e3===s)l=-2/(a-r),u=-(a+r)/(a-r);else if(2001===s)l=-1/(a-r),u=-r/(a-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+s);return c[0]=2/(t-e),c[4]=0,c[8]=0,c[12]=-(t+e)/(t-e),c[1]=0,c[5]=2/(n-i),c[9]=0,c[13]=-(n+i)/(n-i),c[2]=0,c[6]=0,c[10]=l,c[14]=u,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}let tn=new ef,ti=new tt,tr=new ef(0,0,0),ta=new ef(1,1,1),ts=new ef,to=new ef,tl=new ef,tu=new tt,tc=new ep;class th{constructor(e=0,t=0,n=0,i=th.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let i=e.elements,r=i[0],a=i[4],s=i[8],o=i[1],l=i[5],u=i[9],c=i[2],h=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(es(s,-1,1)),.9999999>Math.abs(s)?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-es(u,-1,1)),.9999999>Math.abs(u)?(this._y=Math.atan2(s,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(es(h,-1,1)),.9999999>Math.abs(h)?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-es(c,-1,1)),.9999999>Math.abs(c)?(this._x=Math.atan2(h,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(es(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-u,l),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(s,d));break;case"XZY":this._z=Math.asin(-es(a,-1,1)),.9999999>Math.abs(a)?(this._x=Math.atan2(h,l),this._y=Math.atan2(s,r)):(this._x=Math.atan2(-u,d),this._y=0);break;default:J("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return tu.makeRotationFromQuaternion(e),this.setFromRotationMatrix(tu,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return tc.setFromEuler(this),this.setFromQuaternion(tc,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}th.DEFAULT_ORDER="XYZ";class td{constructor(){this.mask=1}set(e){this.mask=1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(e=>({...e,boundingBox:e.boundingBox?e.boundingBox.toJSON():void 0,boundingSphere:e.boundingSphere?e.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(e=>({...e})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(i.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);let t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){let n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),s.length>0&&(n.images=s),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),u.length>0&&(n.animations=u),c.length>0&&(n.nodes=c)}return n.object=i,n;function a(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){tR.subVectors(i,t),tP.subVectors(n,t),tI.subVectors(e,t);let a=tR.dot(tR),s=tR.dot(tP),o=tR.dot(tI),l=tP.dot(tP),u=tP.dot(tI),c=a*l-s*s;if(0===c)return r.set(0,0,0),null;let h=1/c,d=(l*o-s*u)*h,p=(a*u-s*o)*h;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return null!==this.getBarycoord(e,t,n,i,tL)&&tL.x>=0&&tL.y>=0&&tL.x+tL.y<=1}static getInterpolation(e,t,n,i,r,a,s,o){return null===this.getBarycoord(e,t,n,i,tL)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,tL.x),o.addScaledVector(a,tL.y),o.addScaledVector(s,tL.z),o)}static getInterpolatedAttribute(e,t,n,i,r,a){return tB.setScalar(0),tk.setScalar(0),tV.setScalar(0),tB.fromBufferAttribute(e,t),tk.fromBufferAttribute(e,n),tV.fromBufferAttribute(e,i),a.setScalar(0),a.addScaledVector(tB,r.x),a.addScaledVector(tk,r.y),a.addScaledVector(tV,r.z),a}static isFrontFacing(e,t,n,i){return tR.subVectors(n,t),tP.subVectors(e,t),0>tR.cross(tP).dot(i)}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return tR.subVectors(this.c,this.b),tP.subVectors(this.a,this.b),.5*tR.cross(tP).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tH.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tH.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,i,r){return tH.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tH.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tH.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n,i,r=this.a,a=this.b,s=this.c;tN.subVectors(a,r),tU.subVectors(s,r),tO.subVectors(e,r);let o=tN.dot(tO),l=tU.dot(tO);if(o<=0&&l<=0)return t.copy(r);tF.subVectors(e,a);let u=tN.dot(tF),c=tU.dot(tF);if(u>=0&&c<=u)return t.copy(a);let h=o*c-u*l;if(h<=0&&o>=0&&u<=0)return n=o/(o-u),t.copy(r).addScaledVector(tN,n);tz.subVectors(e,s);let d=tN.dot(tz),p=tU.dot(tz);if(p>=0&&d<=p)return t.copy(s);let f=d*l-o*p;if(f<=0&&l>=0&&p<=0)return i=l/(l-p),t.copy(r).addScaledVector(tU,i);let m=u*p-d*c;if(m<=0&&c-u>=0&&d-p>=0)return tD.subVectors(s,a),i=(c-u)/(c-u+(d-p)),t.copy(a).addScaledVector(tD,i);let g=1/(m+f+h);return n=f*g,i=h*g,t.copy(r).addScaledVector(tN,n).addScaledVector(tU,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let tG={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},tW={h:0,s:0,l:0},tj={h:0,s:0,l:0};function tX(e,t,n){return(n<0&&(n+=1),n>1&&(n-=1),n<1/6)?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*6*(2/3-n):e}class tq{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){return void 0===t&&void 0===n?e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e):this.setRGB(e,t,n),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=I){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,eb.colorSpaceToWorking(this,t),this}setRGB(e,t,n,i=eb.workingColorSpace){return this.r=e,this.g=t,this.b=n,eb.colorSpaceToWorking(this,i),this}setHSL(e,t,n,i=eb.workingColorSpace){if(e=eo(e,1),t=es(t,0,1),n=es(n,0,1),0===t)this.r=this.g=this.b=n;else{let i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=tX(r,i,e+1/3),this.g=tX(r,i,e),this.b=tX(r,i,e-1/3)}return eb.colorSpaceToWorking(this,i),this}setStyle(e,t=I){let n;function i(t){void 0!==t&&1>parseFloat(t)&&J("Color: Alpha component of "+e+" will be ignored.")}if(n=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,a=n[1],s=n[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(s))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:J("Color: Unknown color model "+e)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){let i=n[1],r=i.length;if(3===r)return this.setRGB(parseInt(i.charAt(0),16)/15,parseInt(i.charAt(1),16)/15,parseInt(i.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(i,16),t);J("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=I){let n=tG[e.toLowerCase()];return void 0!==n?this.setHex(n,t):J("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=eS(e.r),this.g=eS(e.g),this.b=eS(e.b),this}copyLinearToSRGB(e){return this.r=eM(e.r),this.g=eM(e.g),this.b=eM(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=I){return eb.workingToColorSpace(tY.copy(this),e),65536*Math.round(es(255*tY.r,0,255))+256*Math.round(es(255*tY.g,0,255))+Math.round(es(255*tY.b,0,255))}getHexString(e=I){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=eb.workingColorSpace){let n,i;eb.workingToColorSpace(tY.copy(this),t);let r=tY.r,a=tY.g,s=tY.b,o=Math.max(r,a,s),l=Math.min(r,a,s),u=(l+o)/2;if(l===o)n=0,i=0;else{let e=o-l;switch(i=u<=.5?e/(o+l):e/(2-o-l),o){case r:n=(a-s)/e+6*(a0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(let t in e){let n=e[t];if(void 0===n){J(`Material: parameter '${t}' has value of undefined.`);continue}let i=this[t];if(void 0===i){J(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n}}toJSON(e){let t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});let n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function i(e){let t=[];for(let n in e){let i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),void 0!==this.dispersion&&(n.dispersion=this.dispersion),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapRotation&&(n.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),!0===this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=!0),204!==this.blendSrc&&(n.blendSrc=this.blendSrc),205!==this.blendDst&&(n.blendDst=this.blendDst),100!==this.blendEquation&&(n.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(n.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(n.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(n.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(n.depthFunc=this.depthFunc),!1===this.depthTest&&(n.depthTest=this.depthTest),!1===this.depthWrite&&(n.depthWrite=this.depthWrite),!1===this.colorWrite&&(n.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(n.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(n.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(n.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(n.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(n.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(n.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(n.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(n.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=!0),!0===this.alphaToCoverage&&(n.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=!0),!0===this.forceSinglePass&&(n.forceSinglePass=!0),!1===this.allowOverride&&(n.allowOverride=!1),!0===this.wireframe&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=!0),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){let t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(null!==t){let e=t.length;n=Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}class tK extends tJ{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new tq(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}let t$=function(){let e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){let t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}let a=new Uint32Array(2048),s=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;(8388608&t)==0;)t<<=1,n-=8388608;t&=-8388609,n+=0x38800000,a[e]=t|n}for(let e=1024;e<2048;++e)a[e]=0x38000000+(e-1024<<13);for(let e=1;e<31;++e)s[e]=e<<23;s[31]=0x47800000,s[32]=0x80000000;for(let e=33;e<63;++e)s[e]=0x80000000+(e-32<<23);s[63]=0xc7800000;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:a,exponentTable:s,offsetTable:o}}();function tQ(e){Math.abs(e)>65504&&J("DataUtils.toHalfFloat(): Value out of range."),e=es(e,-65504,65504),t$.floatView[0]=e;let t=t$.uint32View[0],n=t>>23&511;return t$.baseTable[n]+((8388607&t)>>t$.shiftTable[n])}function t0(e){let t=e>>10;return t$.uint32View[0]=t$.mantissaTable[t$.offsetTable[t]+(1023&e)]+t$.exponentTable[t],t$.floatView[0]}class t1{static toHalfFloat(e){return tQ(e)}static fromHalfFloat(e){return t0(e)}}let t2=new ef,t3=new ed,t4=0;class t5{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:t4++}),this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;it.count&&J("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ez);let e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){K("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ef(-1/0,-1/0,-1/0),new ef(Infinity,Infinity,Infinity));return}if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e0&&(e.userData=this.userData),void 0!==this.parameters){let t=this.parameters;for(let n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let i=n[t];e.data.attributes[t]=i.toJSON(e.data)}let i={},r=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,i=n.length;t0&&(i[t]=a,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let s=this.boundingSphere;return null!==s&&(e.data.boundingSphere=s.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;null!==n&&this.setIndex(n.clone());let i=e.attributes;for(let e in i){let n=i[e];this.setAttribute(e,n.clone(t))}let r=e.morphAttributes;for(let e in r){let n=[],i=r[e];for(let e=0,r=i.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)||(np.copy(r).invert(),nf.copy(e.ray).applyMatrix4(np),(null===n.boundingBox||!1!==nf.intersectsBox(n.boundingBox))&&this._computeIntersections(e,t,nf)))}_computeIntersections(e,t,n){let i,r=this.geometry,a=this.material,s=r.index,o=r.attributes.position,l=r.attributes.uv,u=r.attributes.uv1,c=r.attributes.normal,h=r.groups,d=r.drawRange;if(null!==s)if(Array.isArray(a))for(let r=0,o=h.length;rn.far?null:{distance:l,point:nM.clone(),object:e}}(e,t,n,i,nv,n_,ny,nS);if(c){let e=new ef;tH.getBarycoord(nS,nv,n_,ny,e),r&&(c.uv=tH.getInterpolatedAttribute(r,o,l,u,e,new ed)),a&&(c.uv1=tH.getInterpolatedAttribute(a,o,l,u,e,new ed)),s&&(c.normal=tH.getInterpolatedAttribute(s,o,l,u,e,new ef),c.normal.dot(i.direction)>0&&c.normal.multiplyScalar(-1));let t={a:o,b:l,c:u,normal:new ef,materialIndex:0};tH.getNormal(nv,n_,ny,t.normal),c.face=t,c.barycoord=e}return c}class nE extends nd{constructor(e=1,t=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const s=this;i=Math.floor(i),r=Math.floor(r);const o=[],l=[],u=[],c=[];let h=0,d=0;function p(e,t,n,i,r,a,p,f,m,g,v){let _=a/m,y=p/g,x=a/2,b=p/2,S=f/2,M=m+1,T=g+1,w=0,E=0,A=new ef;for(let a=0;a0?1:-1,u.push(A.x,A.y,A.z),c.push(o/m),c.push(1-a/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class nL extends tC{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tt,this.projectionMatrix=new tt,this.projectionMatrixInverse=new tt,this.coordinateSystem=2e3,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}let nN=new ef,nU=new ed,nD=new ed;class nO extends nL{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=2*er*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(.5*ei*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*er*Math.atan(Math.tan(.5*ei*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){nN.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(nN.x,nN.y).multiplyScalar(-e/nN.z),nN.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(nN.x,nN.y).multiplyScalar(-e/nN.z)}getViewSize(e,t){return this.getViewBounds(e,nU,nD),t.subVectors(nD,nU)}setViewOffset(e,t,n,i,r,a){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(.5*ei*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i,a=this.view;if(null!==this.view&&this.view.enabled){let e=a.fullWidth,s=a.fullHeight;r+=a.offsetX*i/e,t-=a.offsetY*n/s,i*=a.width/e,n*=a.height/s}let s=this.filmOffset;0!==s&&(r+=e*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class nF extends tC{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new nO(-90,1,e,t);i.layers=this.layers,this.add(i);const r=new nO(-90,1,e,t);r.layers=this.layers,this.add(r);const a=new nO(-90,1,e,t);a.layers=this.layers,this.add(a);const s=new nO(-90,1,e,t);s.layers=this.layers,this.add(s);const o=new nO(-90,1,e,t);o.layers=this.layers,this.add(o);const l=new nO(-90,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,i,r,a,s,o]=t;for(let e of t)this.remove(e);if(2e3===e)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),s.up.set(0,1,0),s.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===e)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),s.up.set(0,-1,0),s.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[r,a,s,o,l,u]=this.children,c=e.getRenderTarget(),h=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let f=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,i),e.render(t,r),e.setRenderTarget(n,1,i),e.render(t,a),e.setRenderTarget(n,2,i),e.render(t,s),e.setRenderTarget(n,3,i),e.render(t,o),e.setRenderTarget(n,4,i),e.render(t,l),n.texture.generateMipmaps=f,e.setRenderTarget(n,5,i),e.render(t,u),e.setRenderTarget(c,h,d),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class nz extends eP{constructor(e=[],t=301,n,i,r,a,s,o,l,u){super(e,t,n,i,r,a,s,o,l,u),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class nB extends eN{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1};this.texture=new nz([n,n,n,n,n,n]),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new nE(5,5,5),r=new nI({name:"CubemapFromEquirect",uniforms:nA(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=t;let a=new nT(i,r),s=t.minFilter;return 1008===t.minFilter&&(t.minFilter=1006),new nF(1,10,this).update(e,a),t.minFilter=s,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,i=!0){let r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}class nk extends tC{constructor(){super(),this.isGroup=!0,this.type="Group"}}let nV={type:"move"};class nH{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new nk,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new nk,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ef,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ef),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new nk,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ef,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ef),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,r=null,a=null,s=this._targetRay,o=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){for(let i of(a=!0,e.hand.values())){let e=t.getJointPose(i,n),r=this._getHandJoint(l,i);null!==e&&(r.matrix.fromArray(e.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=e.radius),r.visible=null!==e}let i=l.joints["index-finger-tip"],r=l.joints["thumb-tip"],s=i.position.distanceTo(r.position);l.inputState.pinching&&s>.025?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&s<=.015&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&null!==(r=t.getPose(e.gripSpace,n))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1);null!==s&&(null===(i=t.getPose(e.targetRaySpace,n))&&null!==r&&(i=r),null!==i&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1,this.dispatchEvent(nV)))}return null!==s&&(s.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==a),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){let n=new nk;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class nG{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new tq(e),this.density=t}clone(){return new nG(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class nW{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new tq(e),this.near=t,this.far=n}clone(){return new nW(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class nj extends tC{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new th,this.environmentIntensity=1,this.environmentRotation=new th,this.overrideMaterial=null,"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class nX{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=ea()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:nJ.clone(),uv:tH.getInterpolation(nJ,n2,n3,n4,n5,n6,n8,new ed),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function n7(e,t,n,i,r,a){nQ.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(n0.x=a*nQ.x-r*nQ.y,n0.y=r*nQ.x+a*nQ.y):n0.copy(nQ),e.copy(t),e.x+=n0.x,e.y+=n0.y,e.applyMatrix4(n1)}let ie=new ef,it=new ef;class ii extends tC{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);let t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){ie.setFromMatrixPosition(this.matrixWorld);let n=e.ray.origin.distanceTo(ie);this.getObjectForDistance(n).raycast(e,t)}}update(e){let t=this.levels;if(t.length>1){let n,i;ie.setFromMatrixPosition(e.matrixWorld),it.setFromMatrixPosition(this.matrixWorld);let r=ie.distanceTo(it)/e.zoom;for(n=1,t[0].object.visible=!0,i=t.length;n=e)t[n-1].object.visible=!1,t[n].object.visible=!0;else break}for(this._currentLevel=n-1;n1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||iI.getNormalMatrix(e),i=this.coplanarPoint(iR).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}let iN=new e2,iU=new ed(.5,.5),iD=new ef;class iO{constructor(e=new iL,t=new iL,n=new iL,i=new iL,r=new iL,a=new iL){this.planes=[e,t,n,i,r,a]}set(e,t,n,i,r,a){let s=this.planes;return s[0].copy(e),s[1].copy(t),s[2].copy(n),s[3].copy(i),s[4].copy(r),s[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3,n=!1){let i=this.planes,r=e.elements,a=r[0],s=r[1],o=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],p=r[8],f=r[9],m=r[10],g=r[11],v=r[12],_=r[13],y=r[14],x=r[15];if(i[0].setComponents(l-a,d-u,g-p,x-v).normalize(),i[1].setComponents(l+a,d+u,g+p,x+v).normalize(),i[2].setComponents(l+s,d+c,g+f,x+_).normalize(),i[3].setComponents(l-s,d-c,g-f,x-_).normalize(),n)i[4].setComponents(o,h,m,y).normalize(),i[5].setComponents(l-o,d-h,g-m,x-y).normalize();else if(i[4].setComponents(l-o,d-h,g-m,x-y).normalize(),2e3===t)i[5].setComponents(l+o,d+h,g+m,x+y).normalize();else if(2001===t)i[5].setComponents(o,h,m,y).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),iN.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),iN.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(iN)}intersectsSprite(e){return iN.center.set(0,0,0),iN.radius=.7071067811865476+iU.distanceTo(e.center),iN.applyMatrix4(e.matrixWorld),this.intersectsSphere(iN)}intersectsSphere(e){let t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,iD.y=i.normal.y>0?e.max.y:e.min.y,iD.z=i.normal.z>0?e.max.z:e.min.z,0>i.distanceToPoint(iD))return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(0>t[n].distanceToPoint(e))return!1;return!0}clone(){return new this.constructor().copy(this)}}let iF=new tt,iz=new iO;class iB{constructor(){this.coordinateSystem=2e3}intersectsObject(e,t){if(!t.isArrayCamera||0===t.cameras.length)return!1;for(let n=0;n=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let s=r[this.index];a.push(s),this.index++,s.start=e,s.count=t,s.z=n,s.index=i}reset(){this.list.length=0,this.index=0}},iQ=new nT,i0=[];function i1(e,t){if(e.constructor!==t.constructor){let n=Math.min(e.length,t.length);for(let i=0;i65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new t5(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let n in t.attributes){if(!e.hasAttribute(n))throw Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let i=e.getAttribute(n),r=t.getAttribute(n);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){let t=this._instanceInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){let t=this._geometryInfo;if(e<0||e>=t.length||!1===t[e].active)throw Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new ez);let e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,i=t.length;n=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw Error("THREE.BatchedMesh: Maximum item count reached.");let t={visible:!0,active:!0,geometryIndex:e},n=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(ik),n=this._availableInstanceIds.shift(),this._instanceInfo[n]=t):(n=this._instanceInfo.length,this._instanceInfo.push(t));let i=this._matricesTexture;iG.identity().toArray(i.image.data,16*n),i.needsUpdate=!0;let r=this._colorsTexture;return r&&(iW.toArray(r.image.data,4*n),r.needsUpdate=!0),this._visibilityChanged=!0,n}addGeometry(e,t=-1,n=-1){let i;this._initializeGeometry(e),this._validateGeometry(e);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},a=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=-1===t?e.getAttribute("position").count:t;let s=e.getIndex();if(null!==s&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=-1===n?s.count:n),-1!==r.indexStart&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(ik),a[i=this._availableGeometryIds.shift()]=r):(i=this._geometryCount,this._geometryCount++,a.push(r)),this.setGeometryAt(i,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,i}setGeometryAt(e,t){if(e>=this._geometryCount)throw Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);let n=this.geometry,i=null!==n.getIndex(),r=n.getIndex(),a=t.getIndex(),s=this._geometryInfo[e];if(i&&a.count>s.reservedIndexCount||t.attributes.position.count>s.reservedVertexCount)throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let o=s.vertexStart,l=s.reservedVertexCount;for(let e in s.vertexCount=t.getAttribute("position").count,n.attributes){let i=t.getAttribute(e),r=n.getAttribute(e);!function(e,t,n=0){let i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let r=e.count;for(let a=0;a=t.length||!1===t[e].active)return this;let n=this._instanceInfo;for(let t=0,i=n.length;tt).sort((e,t)=>n[e].vertexStart-n[t].vertexStart),r=this.geometry;for(let a=0,s=n.length;a=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingBox){let e=new ez,t=n.index,r=n.attributes.position;for(let n=i.start,a=i.start+i.count;n=this._geometryCount)return null;let n=this.geometry,i=this._geometryInfo[e];if(null===i.boundingSphere){let t=new e2;this.getBoundingBoxAt(e,iq),iq.getCenter(t.center);let r=n.index,a=n.attributes.position,s=0;for(let e=i.start,n=i.start+i.count;ee.active);if(Math.max(...n.map(e=>e.vertexStart+e.reservedVertexCount))>e)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(e=>e.indexStart+e.reservedIndexCount))>t)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);let i=this.geometry;i.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new nd,this._initializeGeometry(i));let r=this.geometry;for(let e in i.index&&i1(i.index.array,r.index.array),i.attributes)i1(i.attributes[e].array,r.attributes[e].array)}raycast(e,t){let n=this._instanceInfo,i=this._geometryInfo,r=this.matrixWorld,a=this.geometry;iQ.material=this.material,iQ.geometry.index=a.index,iQ.geometry.attributes=a.attributes,null===iQ.geometry.boundingBox&&(iQ.geometry.boundingBox=new ez),null===iQ.geometry.boundingSphere&&(iQ.geometry.boundingSphere=new e2);for(let a=0,s=n.length;a({...e,boundingBox:null!==e.boundingBox?e.boundingBox.clone():null,boundingSphere:null!==e.boundingSphere?e.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(e=>({...e})),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(e,t,n,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=i.getIndex(),s=null===a?1:a.array.BYTES_PER_ELEMENT,o=this._instanceInfo,l=this._multiDrawStarts,u=this._multiDrawCounts,c=this._geometryInfo,h=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data,f=n.isArrayCamera?iX:ij;h&&!n.isArrayCamera&&(iG.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ij.setFromProjectionMatrix(iG,n.coordinateSystem,n.reversedDepth));let m=0;if(this.sortObjects){iG.copy(this.matrixWorld).invert(),iZ.setFromMatrixPosition(n.matrixWorld).applyMatrix4(iG),iJ.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(iG);for(let e=0,t=o.length;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;ei)return;i7.applyMatrix4(e.matrixWorld);let l=t.ray.origin.distanceTo(i7);if(!(lt.far))return{distance:l,point:re.clone().applyMatrix4(e.matrixWorld),index:s,face:null,faceIndex:null,barycoord:null,object:e}}let ri=new ef,rr=new ef;class ra extends rt{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let e=this.geometry;if(null===e.index){let t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){let n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;a.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,faceIndex:null,barycoord:null,object:s})}}class rf extends eP{constructor(e,t,n,i,r=1006,a=1006,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const u=this;"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(function t(){u.needsUpdate=!0,u._requestVideoFrameCallbackId=e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let e=this.image;!1=="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class rm extends rf{constructor(e,t,n,i,r,a,s,o){super({},e,t,n,i,r,a,s,o),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class rg extends eP{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class rv extends eP{constructor(e,t,n,i,r,a,s,o,l,u,c,h){super(null,a,s,o,l,u,i,r,c,h),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class r_ extends rv{constructor(e,t,n,i,r,a){super(e,t,n,r,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class ry extends rv{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class rx extends eP{constructor(e,t,n,i,r,a,s,o,l){super(e,t,n,i,r,a,s,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rb extends eP{constructor(e,t,n=1014,i,r,a,s=1003,o=1003,l,u=1026,c=1){if(1026!==u&&1027!==u)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:e,height:t,depth:c},i,r,a,s,o,u,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new eE(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){let t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class rS extends rb{constructor(e,t=1014,n=301,i,r,a=1003,s=1003,o,l=1026){const u={width:e,height:e,depth:1};super(e,e,t,n,i,r,a,s,o,l),this.image=[u,u,u,u,u,u],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class rM extends eP{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class rT extends nd{constructor(e=1,t=1,n=4,i=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i,heightSegments:r},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),i=Math.max(3,Math.floor(i));const a=[],s=[],o=[],l=[],u=t/2,c=Math.PI/2*e,h=t,d=2*c+h,p=2*n+(r=Math.max(1,Math.floor(r))),f=i+1,m=new ef,g=new ef;for(let v=0;v<=p;v++){let _=0,y=0,x=0,b=0;if(v<=n){const t=v/n,i=t*Math.PI/2;y=-u-e*Math.cos(i),x=e*Math.sin(i),b=-e*Math.cos(i),_=t*c}else if(v<=n+r){const i=(v-n)/r;y=-u+i*t,x=e,b=0,_=c+i*h}else{const t=(v-n-r)/n,i=t*Math.PI/2;y=u+e*Math.sin(i),x=e*Math.cos(i),b=e*Math.sin(i),_=c+h+t*c}const S=Math.max(0,Math.min(1,_/d));let M=0;0===v?M=.5/i:v===p&&(M=-.5/i);for(let e=0;e<=i;e++){const t=e/i,n=t*Math.PI*2,r=Math.sin(n),a=Math.cos(n);g.x=-x*a,g.y=y,g.z=x*r,s.push(g.x,g.y,g.z),m.set(-x*a,b,x*r),m.normalize(),o.push(m.x,m.y,m.z),l.push(t+M,S)}if(v>0){const e=(v-1)*f;for(let t=0;t0||0!==i)&&(u.push(a,s,l),_+=3),(t>0||i!==r-1)&&(u.push(s,o,l),_+=3)}l.addGroup(g,_,0),g+=_})(),!1===a&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(u),this.setAttribute("position",new nr(c,3)),this.setAttribute("normal",new nr(h,3)),this.setAttribute("uv",new nr(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rE(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rA extends rE{constructor(e=1,t=1,n=32,i=1,r=!1,a=0,s=2*Math.PI){super(0,e,t,n,i,r,a,s),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:s}}static fromJSON(e){return new rA(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class rC extends nd{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],a=[];function s(e){r.push(e.x,e.y,e.z)}function o(t,n){let i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function l(e,t,n,i){i<0&&1===e.x&&(a[t]=e.x-1),0===n.x&&0===n.z&&(a[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}(function(e){let n=new ef,i=new ef,r=new ef;for(let a=0;a.9&&s<.1&&(t<.2&&(a[e+0]+=1),n<.2&&(a[e+2]+=1),i<.2&&(a[e+4]+=1))}}()}(),this.setAttribute("position",new nr(r,3)),this.setAttribute("normal",new nr(r.slice(),3)),this.setAttribute("uv",new nr(a,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rC(e.vertices,e.indices,e.radius,e.detail)}}class rR extends rC{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rR(e.radius,e.detail)}}let rP=new ef,rI=new ef,rL=new ef,rN=new tH;class rU extends nd{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=Math.cos(ei*t),i=e.getIndex(),r=e.getAttribute("position"),a=i?i.count:r.count,s=[0,0,0],o=["a","b","c"],l=[,,,],u={},c=[];for(let e=0;e0)o=r-1;else{o=r;break}if(i[r=o]===n)return r/(a-1);let u=i[r],c=i[r+1];return(r+(n-u)/(c-u))/(a-1)}getTangent(e,t){let n=e-1e-4,i=e+1e-4;n<0&&(n=0),i>1&&(i=1);let r=this.getPoint(n),a=this.getPoint(i),s=t||(r.isVector2?new ed:new ef);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){let n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){let n=new ef,i=[],r=[],a=[],s=new ef,o=new tt;for(let t=0;t<=e;t++){let n=t/e;i[t]=this.getTangentAt(n,new ef)}r[0]=new ef,a[0]=new ef;let l=Number.MAX_VALUE,u=Math.abs(i[0].x),c=Math.abs(i[0].y),h=Math.abs(i[0].z);u<=l&&(l=u,n.set(1,0,0)),c<=l&&(l=c,n.set(0,1,0)),h<=l&&n.set(0,0,1),s.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],s),a[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),a[t]=a[t-1].clone(),s.crossVectors(i[t-1],i[t]),s.length()>Number.EPSILON){s.normalize();let e=Math.acos(es(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(s,e))}a[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(es(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(s.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),a[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){let e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class rO extends rD{constructor(e=0,t=0,n=1,i=1,r=0,a=2*Math.PI,s=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=s,this.aRotation=o}getPoint(e,t=new ed){let n=2*Math.PI,i=this.aEndAngle-this.aStartAngle,r=Math.abs(i)n;)i-=n;i0?0:(Math.floor(Math.abs(o)/a)+1)*a:0===l&&o===a-1&&(o=a-2,l=1),this.closed||o>0?n=r[(o-1)%a]:(rB.subVectors(r[0],r[1]).add(r[0]),n=rB);let u=r[o%a],c=r[(o+1)%a];if(this.closed||o+2n.length-2?n.length-1:r+1],u=n[r>n.length-3?n.length-1:r+2];return t.set(rW(a,s.x,o.x,l.x,u.x),rW(a,s.y,o.y,l.y,u.y)),t}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){let e=i[r]-n,a=this.curves[r],s=a.getLength(),o=0===s?0:1-e/s;return a.getPointAt(o,t)}r++}return null}getLength(){let e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let e=[],t=0;for(let n=0,i=this.curves.length;n1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){let e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);let u=l.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){let e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class r3 extends r2{constructor(e){super(e),this.uuid=ea(),this.type="Shape",this.holes=[]}getPointsHoles(e){let t=[];for(let n=0,i=this.holes.length;n0)for(let r=t;r=t;r-=i)a=ao(r/i|0,e[r],e[r+1],a);return a&&at(a,a.next)&&(al(a),a=a.next),a}function r5(e,t){if(!e)return e;t||(t=e);let n=e,i;do if(i=!1,!n.steiner&&(at(n,n.next)||0===ae(n.prev,n,n.next))){if(al(n),(n=t=n.prev)===n.next)break;i=!0}else n=n.next;while(i||n!==t)return t}function r6(e,t){let n=e.x-t.x;return 0===n&&0==(n=e.y-t.y)&&(n=(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)),n}function r8(e,t,n,i,r){return(e=((e=((e=((e=((e=(e-n)*r|0)|e<<8)&0xff00ff)|e<<4)&0xf0f0f0f)|e<<2)&0x33333333)|e<<1)&0x55555555)|(t=((t=((t=((t=((t=(t-i)*r|0)|t<<8)&0xff00ff)|t<<4)&0xf0f0f0f)|t<<2)&0x33333333)|t<<1)&0x55555555)<<1}function r9(e,t,n,i,r,a,s,o){return(r-s)*(t-o)>=(e-s)*(a-o)&&(e-s)*(i-o)>=(n-s)*(t-o)&&(n-s)*(a-o)>=(r-s)*(i-o)}function r7(e,t,n,i,r,a,s,o){return(e!==s||t!==o)&&r9(e,t,n,i,r,a,s,o)}function ae(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function at(e,t){return e.x===t.x&&e.y===t.y}function an(e,t,n,i){let r=ar(ae(e,t,n)),a=ar(ae(e,t,i)),s=ar(ae(n,i,e)),o=ar(ae(n,i,t));return!!(r!==a&&s!==o||0===r&&ai(e,n,t)||0===a&&ai(e,i,t)||0===s&&ai(n,e,i)||0===o&&ai(n,t,i))}function ai(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ar(e){return e>0?1:e<0?-1:0}function aa(e,t){return 0>ae(e.prev,e,e.next)?ae(e,t,e.next)>=0&&ae(e,e.prev,t)>=0:0>ae(e,t,e.prev)||0>ae(e,e.next,t)}function as(e,t){let n=au(e.i,e.x,e.y),i=au(t.i,t.x,t.y),r=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function ao(e,t,n,i){let r=au(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function al(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function au(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class ac{static triangulate(e,t,n=2){return function(e,t,n=2){let i,r,a,s=t&&t.length,o=s?t[0]*n:e.length,l=r4(e,0,o,n,!0),u=[];if(!l||l.next===l.prev)return u;if(s&&(l=function(e,t,n,i){let r=[];for(let n=0,a=t.length;n=i.next.y&&i.next.y!==i.y){let e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,n=i.x=i.x&&i.x>=l&&r!==i.x&&r9(an.x||i.x===n.x&&(h=n,d=i,0>ae(h.prev,h,d.prev)&&0>ae(d.next,h,h.next))))&&(n=i,c=t)}i=i.next}while(i!==o)return n}(e,t);if(!n)return t;let i=as(n,e);return r5(i,i.next),r5(n,n.next)}(r[e],n);return n}(e,t,l,n)),e.length>80*n){i=e[0],r=e[1];let t=i,s=r;for(let a=n;at&&(t=n),o>s&&(s=o)}a=0!==(a=Math.max(t-i,s-r))?32767/a:0}return function e(t,n,i,r,a,s,o){if(!t)return;!o&&s&&function(e,t,n,i){let r=e;do 0===r.z&&(r.z=r8(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==e)r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n=1;do{let i,r=e;e=null;let a=null;for(t=0;r;){t++;let s=r,o=0;for(let e=0;e0||l>0&&s;)0!==o&&(0===l||!s||r.z<=s.z)?(i=r,r=r.nextZ,o--):(i=s,s=s.nextZ,l--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;r=s}a.nextZ=null,n*=2}while(t>1)}(r)}(t,r,a,s);let l=t;for(;t.prev!==t.next;){let u=t.prev,c=t.next;if(s?function(e,t,n,i){let r=e.prev,a=e.next;if(ae(r,e,a)>=0)return!1;let s=r.x,o=e.x,l=a.x,u=r.y,c=e.y,h=a.y,d=Math.min(s,o,l),p=Math.min(u,c,h),f=Math.max(s,o,l),m=Math.max(u,c,h),g=r8(d,p,t,n,i),v=r8(f,m,t,n,i),_=e.prevZ,y=e.nextZ;for(;_&&_.z>=g&&y&&y.z<=v;){if(_.x>=d&&_.x<=f&&_.y>=p&&_.y<=m&&_!==r&&_!==a&&r7(s,u,o,c,l,h,_.x,_.y)&&ae(_.prev,_,_.next)>=0||(_=_.prevZ,y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&r7(s,u,o,c,l,h,y.x,y.y)&&ae(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;_&&_.z>=g;){if(_.x>=d&&_.x<=f&&_.y>=p&&_.y<=m&&_!==r&&_!==a&&r7(s,u,o,c,l,h,_.x,_.y)&&ae(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;y&&y.z<=v;){if(y.x>=d&&y.x<=f&&y.y>=p&&y.y<=m&&y!==r&&y!==a&&r7(s,u,o,c,l,h,y.x,y.y)&&ae(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}(t,r,a,s):function(e){let t=e.prev,n=e.next;if(ae(t,e,n)>=0)return!1;let i=t.x,r=e.x,a=n.x,s=t.y,o=e.y,l=n.y,u=Math.min(i,r,a),c=Math.min(s,o,l),h=Math.max(i,r,a),d=Math.max(s,o,l),p=n.next;for(;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=c&&p.y<=d&&r7(i,s,r,o,a,l,p.x,p.y)&&ae(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}(t)){n.push(u.i,t.i,c.i),al(t),t=c.next,l=c.next;continue}if((t=c)===l){o?1===o?e(t=function(e,t){let n=e;do{let i=n.prev,r=n.next.next;!at(i,r)&&an(i,n,n.next,r)&&aa(i,r)&&aa(r,i)&&(t.push(i.i,n.i,r.i),al(n),al(n.next),n=e=r),n=n.next}while(n!==e)return r5(n)}(r5(t),n),n,i,r,a,s,2):2===o&&function(t,n,i,r,a,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){var l,u;if(o.i!==t.i&&(l=o,u=t,l.next.i!==u.i&&l.prev.i!==u.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&an(n,n.next,e,t))return!0;n=n.next}while(n!==e)return!1}(l,u)&&(aa(l,u)&&aa(u,l)&&function(e,t){let n=e,i=!1,r=(e.x+t.x)/2,a=(e.y+t.y)/2;do n.y>a!=n.next.y>a&&n.next.y!==n.y&&r<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==e)return i}(l,u)&&(ae(l.prev,l,u.prev)||ae(l,u.prev,u))||at(l,u)&&ae(l.prev,l,l.next)>0&&ae(u.prev,u,u.next)>0))){let l=as(o,t);o=r5(o,o.next),l=r5(l,l.next),e(o,n,i,r,a,s,0),e(l,n,i,r,a,s,0);return}t=t.next}o=o.next}while(o!==t)}(t,n,i,r,a,s):e(r5(t),n,i,r,a,s,1);break}}}(l,u,n,i,r,a,0),u}(e,t,n)}}class ah{static area(e){let t=e.length,n=0;for(let i=t-1,r=0;rah.area(e)}static triangulateShape(e,t){let n=[],i=[],r=[];ad(e),ap(n,e);let a=e.length;t.forEach(ad);for(let e=0;e2&&e[t-1].equals(e[0])&&e.pop()}function ap(e,t){for(let n=0;nNumber.EPSILON){let h=Math.sqrt(c),d=Math.sqrt(l*l+u*u),p=t.x-o/h,f=t.y+s/h,m=((n.x-u/d-p)*u-(n.y+l/d-f)*l)/(s*u-o*l),g=(i=p+s*m-e.x)*i+(r=f+o*m-e.y)*r;if(g<=2)return new ed(i,r);a=Math.sqrt(g/2)}else{let e=!1;s>Number.EPSILON?l>Number.EPSILON&&(e=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(u)&&(e=!0),e?(i=-o,r=s,a=Math.sqrt(c)):(i=s,r=o,a=Math.sqrt(c/2))}return new ed(i/a,r/a)}let L=[];for(let e=0,t=C.length,n=t-1,i=e+1;e=0;e--){let t=e/_,n=m*Math.cos(t*Math.PI/2),i=g*Math.sin(t*Math.PI/2)+v;for(let e=0,t=C.length;e=0;){let a=r,s=r-1;s<0&&(s=e.length-1);for(let e=0,r=d+2*_;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class aU extends tJ{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new tq(0xffffff),this.specular=new tq(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aD extends tJ{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new tq(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class aO extends tJ{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class aF extends tJ{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new tq(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new tq(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new th,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class az extends tJ{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class aB extends tJ{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class ak extends tJ{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new tq(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new ed(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class aV extends i3{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function aH(e,t){return e&&e.constructor!==t?"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e):e}function aG(e){let t=e.length,n=Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort(function(t,n){return e[t]-e[n]}),n}function aW(e,t,n){let i=e.length,r=new e.constructor(i);for(let a=0,s=0;s!==i;++a){let i=n[a]*t;for(let n=0;n!==t;++n)r[s++]=e[i+n]}return r}function aj(e,t,n,i){let r=1,a=e[0];for(;void 0!==a&&void 0===a[i];)a=e[r++];if(void 0===a)return;let s=a[i];if(void 0!==s)if(Array.isArray(s))do void 0!==(s=a[i])&&(t.push(a.time),n.push(...s)),a=e[r++];while(void 0!==a)else if(void 0!==s.toArray)do void 0!==(s=a[i])&&(t.push(a.time),s.toArray(n,n.length)),a=e[r++];while(void 0!==a)else do void 0!==(s=a[i])&&(t.push(a.time),n.push(s)),a=e[r++];while(void 0!==a)}class aX{static convertArray(e,t){return aH(e,t)}static isTypedArray(e){return H(e)}static getKeyframeOrder(e){return aG(e)}static sortedArray(e,t,n){return aW(e,t,n)}static flattenJSON(e,t,n,i){aj(e,t,n,i)}static subclip(e,t,n,i,r=30){return function(e,t,n,i,r=30){let a=e.clone();a.name=t;let s=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;na.tracks[e].times[0]&&(o=a.tracks[e].times[0]);for(let e=0;e=r.times[d]){let e=d*u+l,t=e+u-l;i=r.values.slice(e,t)}else{let e=r.createInterpolant(),t=l,n=u-l;e.evaluate(a),i=e.resultBuffer.slice(t,n)}"quaternion"===s&&new ep().fromArray(i).normalize().conjugate().toArray(i);let p=o.times.length;for(let e=0;e=r)){let s=t[1];e=(r=t[--n-1]))break i}a=n,n=0;break r}break n}for(;n>>1;et;)--a;if(++a,0!==r||a!==i){r>=a&&(r=(a=Math.max(a,1))-1);let e=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!=0&&(K("KeyframeTrack: Invalid value size in track.",this),e=!1);let n=this.times,i=this.values,r=n.length;0===r&&(K("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let t=0;t!==r;t++){let i=n[t];if("number"==typeof i&&isNaN(i)){K("KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==a&&a>i){K("KeyframeTrack: Out of order keys.",this,t,i,a),e=!1;break}a=i}if(void 0!==i&&H(i))for(let t=0,n=i.length;t!==n;++t){let n=i[t];if(isNaN(n)){K("KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),i=2302===this.getInterpolation(),r=e.length-1,a=1;for(let s=1;s0){e[a]=e[r];for(let e=r*n,i=a*n,s=0;s!==n;++s)t[i+s]=t[e+s];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=new this.constructor(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}aK.prototype.ValueTypeName="",aK.prototype.TimeBufferType=Float32Array,aK.prototype.ValueBufferType=Float32Array,aK.prototype.DefaultInterpolation=2301;class a$ extends aK{constructor(e,t,n){super(e,t,n)}}a$.prototype.ValueTypeName="bool",a$.prototype.ValueBufferType=Array,a$.prototype.DefaultInterpolation=2300,a$.prototype.InterpolantFactoryMethodLinear=void 0,a$.prototype.InterpolantFactoryMethodSmooth=void 0;class aQ extends aK{constructor(e,t,n,i){super(e,t,n,i)}}aQ.prototype.ValueTypeName="color";class a0 extends aK{constructor(e,t,n,i){super(e,t,n,i)}}a0.prototype.ValueTypeName="number";class a1 extends aq{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){let r=this.resultBuffer,a=this.sampleValues,s=this.valueSize,o=(n-t)/(i-t),l=e*s;for(let e=l+s;l!==e;l+=4)ep.slerpFlat(r,0,a,l-s,a,l,o);return r}}class a2 extends aK{constructor(e,t,n,i){super(e,t,n,i)}InterpolantFactoryMethodLinear(e){return new a1(this.times,this.values,this.getValueSize(),e)}}a2.prototype.ValueTypeName="quaternion",a2.prototype.InterpolantFactoryMethodSmooth=void 0;class a3 extends aK{constructor(e,t,n){super(e,t,n)}}a3.prototype.ValueTypeName="string",a3.prototype.ValueBufferType=Array,a3.prototype.DefaultInterpolation=2300,a3.prototype.InterpolantFactoryMethodLinear=void 0,a3.prototype.InterpolantFactoryMethodSmooth=void 0;class a4 extends aK{constructor(e,t,n,i){super(e,t,n,i)}}a4.prototype.ValueTypeName="vector";class a5{constructor(e="",t=-1,n=[],i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=ea(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){let t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push((function(e){if(void 0===e.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return a0;case"vector":case"vector2":case"vector3":case"vector4":return a4;case"color":return aQ;case"quaternion":return a2;case"bool":case"boolean":return a$;case"string":return a3}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){let t=[],n=[];aj(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)})(n[e]).scale(i));let r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r.userData=JSON.parse(e.userData||"{}"),r}static toJSON(e){let t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let e=0,i=n.length;e!==i;++e)t.push(aK.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){let r=t.length,a=[];for(let e=0;e1){let e=a[1],t=i[e];t||(i[e]=t=[]),t.push(n)}}let a=[];for(let e in i)a.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return a}static parseAnimation(e,t){if(J("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return K("AnimationClip: No animation in JSONLoader data."),null;let n=function(e,t,n,i,r){if(0!==n.length){let a=[],s=[];aj(n,a,s,i),0!==a.length&&r.push(new e(t,a,s))}},i=[],r=e.name||"default",a=e.fps||30,s=e.blendMode,o=e.length||-1,l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)},0),r;if(void 0!==se[e])return void se[e].push({onLoad:t,onProgress:n,onError:i});se[e]=[],se[e].push({onLoad:t,onProgress:n,onError:i});let a=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),s=this.mimeType,o=this.responseType;fetch(a).then(t=>{if(200===t.status||0===t.status){if(0===t.status&&J("FileLoader: HTTP Status 0 received."),"u"{if(i)e.close();else{let i=new ProgressEvent("progress",{lengthComputable:s,loaded:o+=r.byteLength,total:a});for(let e=0,t=n.length;e{e.error(t)})}()}}))}throw new st(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)}).then(e=>{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then(e=>new DOMParser().parseFromString(e,s));case"json":return e.json();default:if(""===s)return e.text();{let t=/charset="?([^;"\s]*)"?/i.exec(s),n=new TextDecoder(t&&t[1]?t[1].toLowerCase():void 0);return e.arrayBuffer().then(e=>n.decode(e))}}}).then(t=>{a6.add(`file:${e}`,t);let n=se[e];delete se[e];for(let e=0,i=n.length;e{let n=se[e];if(void 0===n)throw this.manager.itemError(e),t;delete se[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class si extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):K(t),r.manager.itemError(e)}},n,i)}parse(e){let t=[];for(let n=0;n0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(let t in e.uniforms){let r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=new tq().setHex(r.value);break;case"v2":i.uniforms[t].value=new ed().fromArray(r.value);break;case"v3":i.uniforms[t].value=new ef().fromArray(r.value);break;case"v4":i.uniforms[t].value=new eI().fromArray(r.value);break;case"m3":i.uniforms[t].value=new ev().fromArray(r.value);break;case"m4":i.uniforms[t].value=new tt().fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(let t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=new ed().fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=new ed().fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return sA.createMaterialFromType(e)}static createMaterialFromType(e){return new({ShadowMaterial:aP,SpriteMaterial:nZ,RawShaderMaterial:aI,ShaderMaterial:nI,PointsMaterial:ro,MeshPhysicalMaterial:aN,MeshStandardMaterial:aL,MeshPhongMaterial:aU,MeshToonMaterial:aD,MeshNormalMaterial:aO,MeshLambertMaterial:aF,MeshDepthMaterial:az,MeshDistanceMaterial:aB,MeshBasicMaterial:tK,MeshMatcapMaterial:ak,LineDashedMaterial:aV,LineBasicMaterial:i3,Material:tJ})[e]}}class sC{static extractUrlBase(e){let t=e.lastIndexOf("/");return -1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e))?e:t+e}}class sR extends nd{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){let e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class sP extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(r.manager);a.setPath(r.path),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):K(t),r.manager.itemError(e)}},n,i)}parse(e){let t={},n={};function i(e,i){if(void 0!==t[i])return t[i];let r=e.interleavedBuffers[i],a=function(e,t){if(void 0!==n[t])return n[t];let i=new Uint32Array(e.arrayBuffers[t]).buffer;return n[t]=i,i}(e,r.buffer),s=new nX(V(r.type,a),r.stride);return s.uuid=r.uuid,t[i]=s,s}let r=e.isInstancedBufferGeometry?new sR:new nd,a=e.data.index;if(void 0!==a){let e=V(a.type,a.array);r.setIndex(new t5(e,1))}let s=e.data.attributes;for(let t in s){let n,a=s[t];if(a.isInterleavedBufferAttribute)n=new nY(i(e.data,a.data),a.itemSize,a.offset,a.normalized);else{let e=V(a.type,a.array);n=new(a.isInstancedBufferAttribute?ix:t5)(e,a.itemSize,a.normalized)}void 0!==a.name&&(n.name=a.name),void 0!==a.usage&&n.setUsage(a.usage),r.setAttribute(t,n)}let o=e.data.morphAttributes;if(o)for(let t in o){let n=o[t],a=[];for(let t=0,r=n.length;t0){(n=new ss(new a8(t))).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){(t=new ss(this.manager)).setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t{let t=null,n=null;return void 0!==e.boundingBox&&(t=new ez().fromJSON(e.boundingBox)),void 0!==e.boundingSphere&&(n=new e2().fromJSON(e.boundingSphere)),{...e,boundingBox:t,boundingSphere:n}}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=c(e.matricesTexture.uuid),a._indirectTexture=c(e.indirectTexture.uuid),void 0!==e.colorsTexture&&(a._colorsTexture=c(e.colorsTexture.uuid)),void 0!==e.boundingSphere&&(a.boundingSphere=new e2().fromJSON(e.boundingSphere)),void 0!==e.boundingBox&&(a.boundingBox=new ez().fromJSON(e.boundingBox));break;case"LOD":a=new ii;break;case"Line":a=new rt(l(e.geometry),u(e.material));break;case"LineLoop":a=new rs(l(e.geometry),u(e.material));break;case"LineSegments":a=new ra(l(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new rd(l(e.geometry),u(e.material));break;case"Sprite":a=new n9(u(e.material));break;case"Group":a=new nk;break;case"Bone":a=new im;break;default:a=new tC}if(a.uuid=e.uuid,void 0!==e.name&&(a.name=e.name),void 0!==e.matrix?(a.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(void 0!==e.position&&a.position.fromArray(e.position),void 0!==e.rotation&&a.rotation.fromArray(e.rotation),void 0!==e.quaternion&&a.quaternion.fromArray(e.quaternion),void 0!==e.scale&&a.scale.fromArray(e.scale)),void 0!==e.up&&a.up.fromArray(e.up),void 0!==e.castShadow&&(a.castShadow=e.castShadow),void 0!==e.receiveShadow&&(a.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(a.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(a.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(a.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(a.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&a.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(a.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(a.visible=e.visible),void 0!==e.frustumCulled&&(a.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(a.renderOrder=e.renderOrder),void 0!==e.userData&&(a.userData=e.userData),void 0!==e.layers&&(a.layers.mask=e.layers),void 0!==e.children){let s=e.children;for(let e=0;e{if(!0!==sD.has(a))return t&&t(n),r.manager.itemEnd(e),n;i&&i(sD.get(a)),r.manager.itemError(e),r.manager.itemEnd(e)}):(setTimeout(function(){t&&t(a),r.manager.itemEnd(e)},0),a);let s={};s.credentials="anonymous"===this.crossOrigin?"same-origin":"include",s.headers=this.requestHeader,s.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(e,s).then(function(e){return e.blob()}).then(function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(n){return a6.add(`image-bitmap:${e}`,n),t&&t(n),r.manager.itemEnd(e),n}).catch(function(t){i&&i(t),sD.set(o,t),a6.remove(`image-bitmap:${e}`),r.manager.itemError(e),r.manager.itemEnd(e)});a6.add(`image-bitmap:${e}`,o),r.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class sF{static getContext(){return void 0===i&&(i=new(window.AudioContext||window.webkitAudioContext)),i}static setContext(e){i=e}}class sz extends a7{constructor(e){super(e)}load(e,t,n,i){let r=this,a=new sn(this.manager);function s(t){i?i(t):K(t),r.manager.itemError(e)}a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(e){try{let n=e.slice(0);sF.getContext().decodeAudioData(n,function(e){t(e)}).catch(s)}catch(e){s(e)}},n,i)}}let sB=new tt,sk=new tt,sV=new tt;class sH{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new nO,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new nO,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){let t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){let n,i;t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,sV.copy(e.projectionMatrix);let r=t.eyeSep/2,a=r*t.near/t.focus,s=t.near*Math.tan(ei*t.fov*.5)/t.zoom;sk.elements[12]=-r,sB.elements[12]=r,n=-s*t.aspect+a,i=s*t.aspect+a,sV.elements[0]=2*t.near/(i-n),sV.elements[8]=(i+n)/(i-n),this.cameraL.projectionMatrix.copy(sV),n=-s*t.aspect-a,i=s*t.aspect-a,sV.elements[0]=2*t.near/(i-n),sV.elements[8]=(i+n)/(i-n),this.cameraR.projectionMatrix.copy(sV)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(sk),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(sB)}}class sG extends nO{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class sW{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}let sj=new ef,sX=new ep,sq=new ef,sY=new ef,sZ=new ef;class sJ extends tC{constructor(){super(),this.type="AudioListener",this.context=sF.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new sW}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);let t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(sj,sX,sq),sY.set(0,0,-1).applyQuaternion(sX),sZ.set(0,1,0).applyQuaternion(sX),t.positionX){let e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(sj.x,e),t.positionY.linearRampToValueAtTime(sj.y,e),t.positionZ.linearRampToValueAtTime(sj.z,e),t.forwardX.linearRampToValueAtTime(sY.x,e),t.forwardY.linearRampToValueAtTime(sY.y,e),t.forwardZ.linearRampToValueAtTime(sY.z,e),t.upX.linearRampToValueAtTime(sZ.x,e),t.upY.linearRampToValueAtTime(sZ.y,e),t.upZ.linearRampToValueAtTime(sZ.z,e)}else t.setPosition(sj.x,sj.y,sj.z),t.setOrientation(sY.x,sY.y,sY.z,sZ.x,sZ.y,sZ.z)}}class sK extends tC{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void J("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void J("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;let t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){return!1===this.hasPlaybackControl?void J("Audio: this Audio has no playback control."):(!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this)}stop(e=0){return!1===this.hasPlaybackControl?void J("Audio: this Audio has no playback control."):(this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this)}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){s.setValue(n,i);break}}saveOriginalState(){let e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n;e!==i;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){let e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){ep.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){let a=this._workIndex*r;ep.multiplyQuaternionsFlat(e,a,e,t,e,n),ep.slerpFlat(e,t,e,t,e,a,i)}_lerp(e,t,n,i,r){let a=1-i;for(let s=0;s!==r;++s){let r=t+s;e[r]=e[r]*a+e[n+s]*i}}_lerpAdditive(e,t,n,i,r){for(let a=0;a!==r;++a){let r=t+a;e[r]=e[r]+e[n+a]*i}}}let s5="\\[\\]\\.:\\/",s6=RegExp("["+s5+"]","g"),s8="[^"+s5+"]",s9="[^"+s5.replace("\\.","")+"]",s7=RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",s8)+/(WCOD+)?/.source.replace("WCOD",s9)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",s8)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",s8)+"$"),oe=["material","materials","bones","map"];class ot{constructor(e,t,n){this.path=t,this.parsedPath=n||ot.parseTrackName(t),this.node=ot.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new ot.Composite(e,t,n):new ot(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(s6,"")}static parseTrackName(e){let t=s7.exec(e);if(null===t)throw Error("PropertyBinding: Cannot parse trackName: "+e);let n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){let e=n.nodeName.substring(i+1);-1!==oe.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){let n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){let n=function(e){for(let i=0;i=r){let a=r++,u=e[a];t[u.uuid]=l,e[l]=u,t[o]=a,e[a]=s;for(let e=0;e!==i;++e){let t=n[e],i=t[a],r=t[l];t[l]=i,t[a]=r}}}this.nCachedObjects_=r}uncache(){let e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length,r=this.nCachedObjects_,a=e.length;for(let s=0,o=arguments.length;s!==o;++s){let o=arguments[s],l=o.uuid,u=t[l];if(void 0!==u)if(delete t[l],u0&&(t[s.uuid]=u),e[u]=s,e.pop();for(let e=0;e!==i;++e){let t=n[e];t[u]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){let n=this._bindingsIndicesByPath,i=n[e],r=this._bindings;if(void 0!==i)return r[i];let a=this._paths,s=this._parsedPaths,o=this._objects,l=o.length,u=this.nCachedObjects_,c=Array(l);i=r.length,n[e]=i,a.push(e),s.push(t),r.push(c);for(let n=u,i=o.length;n!==i;++n){let i=o[n];c[n]=new ot(i,e,t)}return c}unsubscribe_(e){let t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){let i=this._paths,r=this._parsedPaths,a=this._bindings,s=a.length-1,o=a[s];t[e[s]]=n,a[n]=o,a.pop(),r[n]=r[s],r.pop(),i[n]=i[s],i.pop()}}}class oi{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const r=t.tracks,a=r.length,s=Array(a),o={endingStart:2400,endingEnd:2400};for(let e=0;e!==a;++e){const t=r[e].createInterpolant(null);s[e]=t,t.settings=o}this._interpolantSettings=o,this._interpolants=s,this._propertyBindings=Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),!0===n){let n=this._clip.duration,i=e._clip.duration;e.warp(1,i/n,t),this.warp(n/i,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){let e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){let i=this._mixer,r=i.time,a=this.timeScale,s=this._timeScaleInterpolant;null===s&&(s=i._lendControlInterpolant(),this._timeScaleInterpolant=s);let o=s.parameterPositions,l=s.sampleValues;return o[0]=r,o[1]=r+n,l[0]=e/a,l[1]=t/a,this}stopWarping(){let e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);let r=this._startTime;if(null!==r){let i=(e-r)*n;i<0||0===n?t=0:(this._startTime=null,t=n*i)}t*=this._updateTimeScale(e);let a=this._updateTime(t),s=this._updateWeight(e);if(s>0){let e=this._interpolants,t=this._propertyBindings;if(2501===this.blendMode)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(a),t[n].accumulateAdditive(s);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(a),t[n].accumulate(i,s)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;let n=this._weightInterpolant;if(null!==n){let i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;let n=this._timeScaleInterpolant;null!==n&&(t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t))}return this._effectiveTimeScale=t,t}_updateTime(e){let t=this._clip.duration,n=this.loop,i=this.time+e,r=this._loopCount,a=2202===n;if(0===e)return -1===r?i:a&&(1&r)==1?t-i:i;if(2200===n){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));s:{if(i>=t)i=t;else if(i<0)i=0;else{this.time=i;break s}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,a)):this._setEndings(0===this.repetitions,!0,a)),i>=t||i<0){let n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);let s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===s){let t=e<0;this._setEndings(t,!t,a)}else this._setEndings(!1,!1,a);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(a&&(1&r)==1)return t-i}return i}_setEndings(e,t,n){let i=this._interpolantSettings;n?(i.endingStart=2401,i.endingEnd=2401):(e?i.endingStart=this.zeroSlopeAtStart?2401:2400:i.endingStart=2402,t?i.endingEnd=this.zeroSlopeAtEnd?2401:2400:i.endingEnd=2402)}_scheduleFading(e,t,n){let i=this._mixer,r=i.time,a=this._weightInterpolant;null===a&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);let s=a.parameterPositions,o=a.sampleValues;return s[0]=r,o[0]=t,s[1]=r+e,o[1]=n,this}}let or=new Float32Array(1);class oa extends ee{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){let n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,a=e._propertyBindings,s=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName,u=l[o];void 0===u&&(u={},l[o]=u);for(let e=0;e!==r;++e){let r=i[e],l=r.name,c=u[l];if(void 0!==c)++c.referenceCount,a[e]=c;else{if(void 0!==(c=a[e])){null===c._cacheIndex&&(++c.referenceCount,this._addInactiveBinding(c,o,l));continue}let i=t&&t._propertyBindings[e].binding.parsedPath;c=new s4(ot.create(n,l,i),r.ValueTypeName,r.getValueSize()),++c.referenceCount,this._addInactiveBinding(c,o,l),a[e]=c}s[e].resultBuffer=c.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){let t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){let t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){let n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){let t=e._cacheIndex;return null!==t&&t=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;let t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),a=this._accuIndex^=1;for(let s=0;s!==n;++s)t[s]._update(i,e,r,a);let s=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)s[e].apply(a);return this}setTime(e){this.time=0;for(let e=0;e=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,ob).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}let oM=new ef,oT=new ef,ow=new ef,oE=new ef,oA=new ef,oC=new ef,oR=new ef;class oP{constructor(e=new ef,t=new ef){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){oM.subVectors(e,this.start),oT.subVectors(this.end,this.start);let n=oT.dot(oT),i=oT.dot(oM)/n;return t&&(i=es(i,0,1)),i}closestPointToPoint(e,t,n){let i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}distanceSqToLine3(e,t=oC,n=oR){let i,r,a=1e-8*1e-8,s=this.start,o=e.start,l=this.end,u=e.end;ow.subVectors(l,s),oE.subVectors(u,o),oA.subVectors(s,o);let c=ow.dot(ow),h=oE.dot(oE),d=oE.dot(oA);if(c<=a&&h<=a)return t.copy(s),n.copy(o),t.sub(n),t.dot(t);if(c<=a)i=0,r=es(r=d/h,0,1);else{let e=ow.dot(oA);if(h<=a)r=0,i=es(-e/c,0,1);else{let t=ow.dot(oE),n=c*h-t*t;i=0!==n?es((t*d-e*h)/n,0,1):0,(r=(t*i+d)/h)<0?(r=0,i=es(-e/c,0,1)):r>1&&(r=1,i=es((t-e)/c,0,1))}}return t.copy(s).add(ow.multiplyScalar(i)),n.copy(o).add(oE.multiplyScalar(r)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}let oI=new ef;class oL extends tC{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new nd,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1;e<32;e++,t++){const n=e/32*Math.PI*2,r=t/32*Math.PI*2;i.push(Math.cos(n),Math.sin(n),1,Math.cos(r),Math.sin(r),1)}n.setAttribute("position",new nr(i,3));const r=new i3({fog:!1,toneMapped:!1});this.cone=new ra(n,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),oI.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(oI),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}let oN=new ef,oU=new tt,oD=new tt;class oO extends ra{constructor(e){const t=function e(t){let n=[];!0===t.isBone&&n.push(t);for(let i=0;i1)for(let n=0;n.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{o2.set(e.z,0,-e.x).normalize();let t=Math.acos(e.y);this.quaternion.setFromAxisAngle(o2,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class o4 extends ra{constructor(e=1){const t=new nd;t.setAttribute("position",new nr([0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],3)),t.setAttribute("color",new nr([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(t,new i3({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){let i=new tq,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(n),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class o5{constructor(){this.type="ShapePath",this.color=new tq,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new r2,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,r,a){return this.currentPath.bezierCurveTo(e,t,n,i,r,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){let t,n,i,r,a,s=ah.isClockWise,o=this.subPaths;if(0===o.length)return[];let l=[];if(1===o.length)return n=o[0],(i=new r3).curves=n.curves,l.push(i),l;let u=!s(o[0].getPoints());u=e?!u:u;let c=[],h=[],d=[],p=0;h[0]=void 0,d[p]=[];for(let i=0,a=o.length;i1){let e=!1,t=0;for(let e=0,t=h.length;eNumber.EPSILON){if(l<0&&(n=t[a],o=-o,s=t[r],l=-l),e.ys.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{let t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(s.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=s.x)return!0}}return i})(a.p,h[i].p)&&(n!==i&&t++,s?(s=!1,c[i].push(a)):e=!0);s&&c[n].push(a)}}t>0&&!1===e&&(d=c)}for(let e=0,t=h.length;et?(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2):(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0),e}static cover(e,t){let n;return(n=e.image&&e.image.width?e.image.width/e.image.height:1)>t?(e.repeat.x=t/n,e.repeat.y=1,e.offset.x=(1-e.repeat.x)/2,e.offset.y=0):(e.repeat.x=1,e.repeat.y=n/t,e.offset.x=0,e.offset.y=(1-e.repeat.y)/2),e}static fill(e){return e.repeat.x=1,e.repeat.y=1,e.offset.x=0,e.offset.y=0,e}static getByteLength(e,t,n,i){return o8(e,t,n,i)}}function o7(){let e=null,t=!1,n=null,i=null;function r(t,a){n(t,a),i=e.requestAnimationFrame(r)}return{start:function(){!0===t||null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function le(e){let t=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),t.get(e)},remove:function(n){n.isInterleavedBufferAttribute&&(n=n.data);let i=t.get(n);i&&(e.deleteBuffer(i.buffer),t.delete(n))},update:function(n,i){if(n.isInterleavedBufferAttribute&&(n=n.data),n.isGLBufferAttribute){let e=t.get(n);(!e||e.versiontypeof Float16Array&&r instanceof Float16Array)i=e.HALF_FLOAT;else if(r instanceof Uint16Array)i=t.isFloat16BufferAttribute?e.HALF_FLOAT:e.UNSIGNED_SHORT;else if(r instanceof Int16Array)i=e.SHORT;else if(r instanceof Uint32Array)i=e.UNSIGNED_INT;else if(r instanceof Int32Array)i=e.INT;else if(r instanceof Int8Array)i=e.BYTE;else if(r instanceof Uint8Array)i=e.UNSIGNED_BYTE;else if(r instanceof Uint8ClampedArray)i=e.UNSIGNED_BYTE;else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: "+r);return{buffer:o,type:i,bytesPerElement:r.BYTES_PER_ELEMENT,version:t.version,size:s}}(n,i));else if(r.versione.start-t.start);let t=0;for(let e=1;etypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}})),"u">typeof window&&(window.__THREE__?J("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182"),e.s(["ACESFilmicToneMapping",()=>4,"AddEquation",()=>100,"AddOperation",()=>2,"AdditiveAnimationBlendMode",()=>2501,"AdditiveBlending",()=>2,"AgXToneMapping",()=>6,"AlphaFormat",()=>1021,"AlwaysCompare",()=>519,"AlwaysDepth",()=>1,"AlwaysStencilFunc",()=>519,"AmbientLight",()=>sM,"AnimationAction",()=>oi,"AnimationClip",()=>a5,"AnimationLoader",()=>si,"AnimationMixer",()=>oa,"AnimationObjectGroup",()=>on,"AnimationUtils",()=>aX,"ArcCurve",()=>rF,"ArrayCamera",()=>sG,"ArrowHelper",()=>o3,"AttachedBindMode",()=>R,"Audio",()=>sK,"AudioAnalyser",()=>s3,"AudioContext",()=>sF,"AudioListener",()=>sJ,"AudioLoader",()=>sz,"AxesHelper",()=>o4,"BackSide",()=>1,"BasicDepthPacking",()=>3200,"BasicShadowMap",()=>0,"BatchedMesh",()=>i2,"Bone",()=>im,"BooleanKeyframeTrack",()=>a$,"Box2",()=>oS,"Box3",()=>ez,"Box3Helper",()=>o0,"BoxGeometry",()=>nE,"BoxHelper",()=>oQ,"BufferAttribute",()=>t5,"BufferGeometry",()=>nd,"BufferGeometryLoader",()=>sP,"ByteType",()=>1010,"Cache",()=>a6,"Camera",()=>nL,"CameraHelper",()=>oJ,"CanvasTexture",()=>rx,"CapsuleGeometry",()=>rT,"CatmullRomCurve3",()=>rG,"CineonToneMapping",()=>3,"CircleGeometry",()=>rw,"ClampToEdgeWrapping",()=>1001,"Clock",()=>sW,"Color",()=>tq,"ColorKeyframeTrack",()=>aQ,"ColorManagement",()=>eb,"CompressedArrayTexture",()=>r_,"CompressedCubeTexture",()=>ry,"CompressedTexture",()=>rv,"CompressedTextureLoader",()=>sr,"ConeGeometry",()=>rA,"ConstantAlphaFactor",()=>213,"ConstantColorFactor",()=>211,"Controls",()=>o6,"CubeCamera",()=>nF,"CubeDepthTexture",()=>rS,"CubeReflectionMapping",()=>301,"CubeRefractionMapping",()=>302,"CubeTexture",()=>nz,"CubeTextureLoader",()=>so,"CubeUVReflectionMapping",()=>306,"CubicBezierCurve",()=>rq,"CubicBezierCurve3",()=>rY,"CubicInterpolant",()=>aY,"CullFaceBack",()=>1,"CullFaceFront",()=>2,"CullFaceFrontBack",()=>3,"CullFaceNone",()=>0,"Curve",()=>rD,"CurvePath",()=>r1,"CustomBlending",()=>5,"CustomToneMapping",()=>5,"CylinderGeometry",()=>rE,"Cylindrical",()=>oy,"Data3DTexture",()=>eO,"DataArrayTexture",()=>eU,"DataTexture",()=>ig,"DataTextureLoader",()=>sl,"DataUtils",()=>t1,"DecrementStencilOp",()=>7683,"DecrementWrapStencilOp",()=>34056,"DefaultLoadingManager",()=>a9,"DepthFormat",()=>1026,"DepthStencilFormat",()=>1027,"DepthTexture",()=>rb,"DetachedBindMode",()=>P,"DirectionalLight",()=>sS,"DirectionalLightHelper",()=>oq,"DiscreteInterpolant",()=>aJ,"DodecahedronGeometry",()=>rR,"DoubleSide",()=>2,"DstAlphaFactor",()=>206,"DstColorFactor",()=>208,"DynamicCopyUsage",()=>35050,"DynamicDrawUsage",()=>35048,"DynamicReadUsage",()=>35049,"EdgesGeometry",()=>rU,"EllipseCurve",()=>rO,"EqualCompare",()=>514,"EqualDepth",()=>4,"EqualStencilFunc",()=>514,"EquirectangularReflectionMapping",()=>303,"EquirectangularRefractionMapping",()=>304,"Euler",()=>th,"EventDispatcher",()=>ee,"ExternalTexture",()=>rM,"ExtrudeGeometry",()=>af,"FileLoader",()=>sn,"Float16BufferAttribute",()=>ni,"Float32BufferAttribute",()=>nr,"FloatType",()=>1015,"Fog",()=>nW,"FogExp2",()=>nG,"FramebufferTexture",()=>rg,"FrontSide",()=>0,"Frustum",()=>iO,"FrustumArray",()=>iB,"GLBufferAttribute",()=>oh,"GLSL1",()=>"100","GLSL3",()=>D,"GreaterCompare",()=>516,"GreaterDepth",()=>6,"GreaterEqualCompare",()=>518,"GreaterEqualDepth",()=>5,"GreaterEqualStencilFunc",()=>518,"GreaterStencilFunc",()=>516,"GridHelper",()=>oH,"Group",()=>nk,"HalfFloatType",()=>1016,"HemisphereLight",()=>sh,"HemisphereLightHelper",()=>oV,"IcosahedronGeometry",()=>ag,"ImageBitmapLoader",()=>sO,"ImageLoader",()=>ss,"ImageUtils",()=>eT,"IncrementStencilOp",()=>7682,"IncrementWrapStencilOp",()=>34055,"InstancedBufferAttribute",()=>ix,"InstancedBufferGeometry",()=>sR,"InstancedInterleavedBuffer",()=>oc,"InstancedMesh",()=>iC,"Int16BufferAttribute",()=>t7,"Int32BufferAttribute",()=>nt,"Int8BufferAttribute",()=>t6,"IntType",()=>1013,"InterleavedBuffer",()=>nX,"InterleavedBufferAttribute",()=>nY,"Interpolant",()=>aq,"InterpolateDiscrete",()=>2300,"InterpolateLinear",()=>2301,"InterpolateSmooth",()=>2302,"InterpolationSamplingMode",()=>z,"InterpolationSamplingType",()=>F,"InvertStencilOp",()=>5386,"KeepStencilOp",()=>7680,"KeyframeTrack",()=>aK,"LOD",()=>ii,"LatheGeometry",()=>av,"Layers",()=>td,"LessCompare",()=>513,"LessDepth",()=>2,"LessEqualCompare",()=>515,"LessEqualDepth",()=>3,"LessEqualStencilFunc",()=>515,"LessStencilFunc",()=>513,"Light",()=>sc,"LightProbe",()=>sE,"Line",()=>rt,"Line3",()=>oP,"LineBasicMaterial",()=>i3,"LineCurve",()=>rZ,"LineCurve3",()=>rJ,"LineDashedMaterial",()=>aV,"LineLoop",()=>rs,"LineSegments",()=>ra,"LinearFilter",()=>1006,"LinearInterpolant",()=>aZ,"LinearMipMapLinearFilter",()=>1008,"LinearMipMapNearestFilter",()=>1007,"LinearMipmapLinearFilter",()=>1008,"LinearMipmapNearestFilter",()=>1007,"LinearSRGBColorSpace",()=>L,"LinearToneMapping",()=>1,"LinearTransfer",()=>N,"Loader",()=>a7,"LoaderUtils",()=>sC,"LoadingManager",()=>a8,"LoopOnce",()=>2200,"LoopPingPong",()=>2202,"LoopRepeat",()=>2201,"MOUSE",()=>A,"Material",()=>tJ,"MaterialLoader",()=>sA,"MathUtils",()=>eh,"Matrix2",()=>ox,"Matrix3",()=>ev,"Matrix4",()=>tt,"MaxEquation",()=>104,"Mesh",()=>nT,"MeshBasicMaterial",()=>tK,"MeshDepthMaterial",()=>az,"MeshDistanceMaterial",()=>aB,"MeshLambertMaterial",()=>aF,"MeshMatcapMaterial",()=>ak,"MeshNormalMaterial",()=>aO,"MeshPhongMaterial",()=>aU,"MeshPhysicalMaterial",()=>aN,"MeshStandardMaterial",()=>aL,"MeshToonMaterial",()=>aD,"MinEquation",()=>103,"MirroredRepeatWrapping",()=>1002,"MixOperation",()=>1,"MultiplyBlending",()=>4,"MultiplyOperation",()=>0,"NearestFilter",()=>1003,"NearestMipMapLinearFilter",()=>1005,"NearestMipMapNearestFilter",()=>1004,"NearestMipmapLinearFilter",()=>1005,"NearestMipmapNearestFilter",()=>1004,"NeutralToneMapping",()=>7,"NeverCompare",()=>512,"NeverDepth",()=>0,"NeverStencilFunc",()=>512,"NoBlending",()=>0,"NoColorSpace",()=>"","NoNormalPacking",()=>"","NoToneMapping",()=>0,"NormalAnimationBlendMode",()=>2500,"NormalBlending",()=>1,"NormalGAPacking",()=>"ga","NormalRGPacking",()=>"rg","NotEqualCompare",()=>517,"NotEqualDepth",()=>7,"NotEqualStencilFunc",()=>517,"NumberKeyframeTrack",()=>a0,"Object3D",()=>tC,"ObjectLoader",()=>sI,"ObjectSpaceNormalMap",()=>1,"OctahedronGeometry",()=>a_,"OneFactor",()=>201,"OneMinusConstantAlphaFactor",()=>214,"OneMinusConstantColorFactor",()=>212,"OneMinusDstAlphaFactor",()=>207,"OneMinusDstColorFactor",()=>209,"OneMinusSrcAlphaFactor",()=>205,"OneMinusSrcColorFactor",()=>203,"OrthographicCamera",()=>sx,"PCFShadowMap",()=>1,"PCFSoftShadowMap",()=>2,"Path",()=>r2,"PerspectiveCamera",()=>nO,"Plane",()=>iL,"PlaneGeometry",()=>ay,"PlaneHelper",()=>o1,"PointLight",()=>sy,"PointLightHelper",()=>oF,"Points",()=>rd,"PointsMaterial",()=>ro,"PolarGridHelper",()=>oG,"PolyhedronGeometry",()=>rC,"PositionalAudio",()=>s2,"PropertyBinding",()=>ot,"PropertyMixer",()=>s4,"QuadraticBezierCurve",()=>rK,"QuadraticBezierCurve3",()=>r$,"Quaternion",()=>ep,"QuaternionKeyframeTrack",()=>a2,"QuaternionLinearInterpolant",()=>a1,"R11_EAC_Format",()=>37488,"RAD2DEG",()=>er,"RED_GREEN_RGTC2_Format",()=>36285,"RED_RGTC1_Format",()=>36283,"REVISION",()=>"182","RG11_EAC_Format",()=>37490,"RGBADepthPacking",()=>3201,"RGBAFormat",()=>1023,"RGBAIntegerFormat",()=>1033,"RGBA_ASTC_10x10_Format",()=>37819,"RGBA_ASTC_10x5_Format",()=>37816,"RGBA_ASTC_10x6_Format",()=>37817,"RGBA_ASTC_10x8_Format",()=>37818,"RGBA_ASTC_12x10_Format",()=>37820,"RGBA_ASTC_12x12_Format",()=>37821,"RGBA_ASTC_4x4_Format",()=>37808,"RGBA_ASTC_5x4_Format",()=>37809,"RGBA_ASTC_5x5_Format",()=>37810,"RGBA_ASTC_6x5_Format",()=>37811,"RGBA_ASTC_6x6_Format",()=>37812,"RGBA_ASTC_8x5_Format",()=>37813,"RGBA_ASTC_8x6_Format",()=>37814,"RGBA_ASTC_8x8_Format",()=>37815,"RGBA_BPTC_Format",()=>36492,"RGBA_ETC2_EAC_Format",()=>37496,"RGBA_PVRTC_2BPPV1_Format",()=>35843,"RGBA_PVRTC_4BPPV1_Format",()=>35842,"RGBA_S3TC_DXT1_Format",()=>33777,"RGBA_S3TC_DXT3_Format",()=>33778,"RGBA_S3TC_DXT5_Format",()=>33779,"RGBDepthPacking",()=>3202,"RGBFormat",()=>1022,"RGBIntegerFormat",()=>1032,"RGB_BPTC_SIGNED_Format",()=>36494,"RGB_BPTC_UNSIGNED_Format",()=>36495,"RGB_ETC1_Format",()=>36196,"RGB_ETC2_Format",()=>37492,"RGB_PVRTC_2BPPV1_Format",()=>35841,"RGB_PVRTC_4BPPV1_Format",()=>35840,"RGB_S3TC_DXT1_Format",()=>33776,"RGDepthPacking",()=>3203,"RGFormat",()=>1030,"RGIntegerFormat",()=>1031,"RawShaderMaterial",()=>aI,"Ray",()=>te,"Raycaster",()=>op,"RectAreaLight",()=>sT,"RedFormat",()=>1028,"RedIntegerFormat",()=>1029,"ReinhardToneMapping",()=>2,"RenderTarget",()=>eL,"RenderTarget3D",()=>os,"RepeatWrapping",()=>1e3,"ReplaceStencilOp",()=>7681,"ReverseSubtractEquation",()=>102,"RingGeometry",()=>ax,"SIGNED_R11_EAC_Format",()=>37489,"SIGNED_RED_GREEN_RGTC2_Format",()=>36286,"SIGNED_RED_RGTC1_Format",()=>36284,"SIGNED_RG11_EAC_Format",()=>37491,"SRGBColorSpace",()=>I,"SRGBTransfer",()=>U,"Scene",()=>nj,"ShaderMaterial",()=>nI,"ShadowMaterial",()=>aP,"Shape",()=>r3,"ShapeGeometry",()=>ab,"ShapePath",()=>o5,"ShapeUtils",()=>ah,"ShortType",()=>1011,"Skeleton",()=>iy,"SkeletonHelper",()=>oO,"SkinnedMesh",()=>ip,"Source",()=>eE,"Sphere",()=>e2,"SphereGeometry",()=>aS,"Spherical",()=>o_,"SphericalHarmonics3",()=>sw,"SplineCurve",()=>rQ,"SpotLight",()=>sv,"SpotLightHelper",()=>oL,"Sprite",()=>n9,"SpriteMaterial",()=>nZ,"SrcAlphaFactor",()=>204,"SrcAlphaSaturateFactor",()=>210,"SrcColorFactor",()=>202,"StaticCopyUsage",()=>35046,"StaticDrawUsage",()=>35044,"StaticReadUsage",()=>35045,"StereoCamera",()=>sH,"StreamCopyUsage",()=>35042,"StreamDrawUsage",()=>35040,"StreamReadUsage",()=>35041,"StringKeyframeTrack",()=>a3,"SubtractEquation",()=>101,"SubtractiveBlending",()=>3,"TOUCH",()=>C,"TangentSpaceNormalMap",()=>0,"TetrahedronGeometry",()=>aM,"Texture",()=>eP,"TextureLoader",()=>su,"TextureUtils",()=>o9,"Timer",()=>og,"TimestampQuery",()=>O,"TorusGeometry",()=>aT,"TorusKnotGeometry",()=>aw,"Triangle",()=>tH,"TriangleFanDrawMode",()=>2,"TriangleStripDrawMode",()=>1,"TrianglesDrawMode",()=>0,"TubeGeometry",()=>aE,"UVMapping",()=>300,"Uint16BufferAttribute",()=>ne,"Uint32BufferAttribute",()=>nn,"Uint8BufferAttribute",()=>t8,"Uint8ClampedBufferAttribute",()=>t9,"Uniform",()=>oo,"UniformsGroup",()=>ou,"UniformsUtils",()=>nP,"UnsignedByteType",()=>1009,"UnsignedInt101111Type",()=>35899,"UnsignedInt248Type",()=>1020,"UnsignedInt5999Type",()=>35902,"UnsignedIntType",()=>1014,"UnsignedShort4444Type",()=>1017,"UnsignedShort5551Type",()=>1018,"UnsignedShortType",()=>1012,"VSMShadowMap",()=>3,"Vector2",()=>ed,"Vector3",()=>ef,"Vector4",()=>eI,"VectorKeyframeTrack",()=>a4,"VideoFrameTexture",()=>rm,"VideoTexture",()=>rf,"WebGL3DRenderTarget",()=>eF,"WebGLArrayRenderTarget",()=>eD,"WebGLCoordinateSystem",()=>2e3,"WebGLCubeRenderTarget",()=>nB,"WebGLRenderTarget",()=>eN,"WebGPUCoordinateSystem",()=>2001,"WebXRController",()=>nH,"WireframeGeometry",()=>aA,"WrapAroundEnding",()=>2402,"ZeroCurvatureEnding",()=>2400,"ZeroFactor",()=>200,"ZeroSlopeEnding",()=>2401,"ZeroStencilOp",()=>0,"arrayNeedsUint32",()=>B,"cloneUniforms",()=>nA,"createCanvasElement",()=>W,"createElementNS",()=>G,"error",()=>K,"getByteLength",()=>o8,"getConsoleFunction",()=>Y,"getUnlitUniformColorSpace",()=>nR,"log",()=>Z,"mergeUniforms",()=>nC,"probeAsync",()=>Q,"setConsoleFunction",()=>q,"warn",()=>J,"warnOnce",()=>$],90072);let lt={alphahash_fragment:"#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif",alphahash_pars_fragment:"#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif",alphamap_fragment:"#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif",batching_pars_vertex:"#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec3 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n }\n#endif",batching_vertex:"#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif",begin_vertex:"vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated",iridescence_fragment:"#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#elif defined( USE_COLOR )\n diffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR )\n varying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n vColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n#endif\n#ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );\n vColor.xyz *= batchingColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n #ifdef FLIP_SIDED\n transformedTangent = - transformedTangent;\n #endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n #else\n vec4 envColor = vec4( 0.0 );\n #endif\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform float flipEnvMap;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif",fog_vertex:"#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n varying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n float v = 0.5 / ( gv + gl );\n return v;\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif",map_fragment:"#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n uniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif",morphinstance_vertex:"#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, dp );\n #else\n shadow = step( dp, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = inverseTransformDirection( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include \n #include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n gl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include \n #include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include \n #include \n #include \n #include \n #include \n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}",distance_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #ifdef USE_DISPLACEMENTMAP\n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vWorldPosition = worldPosition.xyz;\n}",distance_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n vec4 diffuseColor = vec4( 1.0 );\n #include \n #include \n #include \n #include \n #include \n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include \n #include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include \n #include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vLineDistance = scale * lineDistance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include \n #include \n #include \n #include \n #include \n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include \n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include \n #include \n #include \n #include \n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n #include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include \n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vViewPosition = - mvPosition.xyz;\n #include \n #include \n #include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include \n #include \n #include \n #include \n #include \n #include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include \n #include \n #include \n #include \n #include \n #include \n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include \n #include \n #include \n #include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n #include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n #include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include \n #include \n #include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n #include \n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include \n #include \n #include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include \n vec3 outgoingLight = vec3( 0.0 );\n #include \n #include \n #include \n #include \n #include \n outgoingLight = diffuseColor.rgb;\n #include \n #include \n #include \n #include \n}"},ln={common:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},map:{value:null},mapTransform:{value:new ev},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ev}},envmap:{envMap:{value:null},envMapRotation:{value:new ev},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ev}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ev}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ev},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ev},normalScale:{value:new ed(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ev},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ev}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ev}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ev}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new tq(0xffffff)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0},uvTransform:{value:new ev}},sprite:{diffuse:{value:new tq(0xffffff)},opacity:{value:1},center:{value:new ed(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ev},alphaMap:{value:null},alphaMapTransform:{value:new ev},alphaTest:{value:0}}},li={basic:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.fog]),vertexShader:lt.meshbasic_vert,fragmentShader:lt.meshbasic_frag},lambert:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,ln.lights,{emissive:{value:new tq(0)}}]),vertexShader:lt.meshlambert_vert,fragmentShader:lt.meshlambert_frag},phong:{uniforms:nC([ln.common,ln.specularmap,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,ln.lights,{emissive:{value:new tq(0)},specular:{value:new tq(1118481)},shininess:{value:30}}]),vertexShader:lt.meshphong_vert,fragmentShader:lt.meshphong_frag},standard:{uniforms:nC([ln.common,ln.envmap,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.roughnessmap,ln.metalnessmap,ln.fog,ln.lights,{emissive:{value:new tq(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag},toon:{uniforms:nC([ln.common,ln.aomap,ln.lightmap,ln.emissivemap,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.gradientmap,ln.fog,ln.lights,{emissive:{value:new tq(0)}}]),vertexShader:lt.meshtoon_vert,fragmentShader:lt.meshtoon_frag},matcap:{uniforms:nC([ln.common,ln.bumpmap,ln.normalmap,ln.displacementmap,ln.fog,{matcap:{value:null}}]),vertexShader:lt.meshmatcap_vert,fragmentShader:lt.meshmatcap_frag},points:{uniforms:nC([ln.points,ln.fog]),vertexShader:lt.points_vert,fragmentShader:lt.points_frag},dashed:{uniforms:nC([ln.common,ln.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:lt.linedashed_vert,fragmentShader:lt.linedashed_frag},depth:{uniforms:nC([ln.common,ln.displacementmap]),vertexShader:lt.depth_vert,fragmentShader:lt.depth_frag},normal:{uniforms:nC([ln.common,ln.bumpmap,ln.normalmap,ln.displacementmap,{opacity:{value:1}}]),vertexShader:lt.meshnormal_vert,fragmentShader:lt.meshnormal_frag},sprite:{uniforms:nC([ln.sprite,ln.fog]),vertexShader:lt.sprite_vert,fragmentShader:lt.sprite_frag},background:{uniforms:{uvTransform:{value:new ev},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:lt.background_vert,fragmentShader:lt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ev}},vertexShader:lt.backgroundCube_vert,fragmentShader:lt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:lt.cube_vert,fragmentShader:lt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:lt.equirect_vert,fragmentShader:lt.equirect_frag},distance:{uniforms:nC([ln.common,ln.displacementmap,{referencePosition:{value:new ef},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:lt.distance_vert,fragmentShader:lt.distance_frag},shadow:{uniforms:nC([ln.lights,ln.fog,{color:{value:new tq(0)},opacity:{value:1}}]),vertexShader:lt.shadow_vert,fragmentShader:lt.shadow_frag}};li.physical={uniforms:nC([li.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ev},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ev},clearcoatNormalScale:{value:new ed(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ev},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ev},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ev},sheen:{value:0},sheenColor:{value:new tq(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ev},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ev},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ev},transmissionSamplerSize:{value:new ed},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ev},attenuationDistance:{value:0},attenuationColor:{value:new tq(0)},specularColor:{value:new tq(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ev},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ev},anisotropyVector:{value:new ed},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ev}}]),vertexShader:lt.meshphysical_vert,fragmentShader:lt.meshphysical_frag};let lr={r:0,b:0,g:0},la=new th,ls=new tt;function lo(e,t,n,i,r,a,s){let o,l,u=new tq(0),c=+(!0!==a),h=null,d=0,p=null;function f(e){let i=!0===e.isScene?e.background:null;return i&&i.isTexture&&(i=(e.backgroundBlurriness>0?n:t).get(i)),i}function m(t,n){t.getRGB(lr,nR(e)),i.buffers.color.setClear(lr.r,lr.g,lr.b,n,s)}return{getClearColor:function(){return u},setClearColor:function(e,t=1){u.set(e),m(u,c=t)},getClearAlpha:function(){return c},setClearAlpha:function(e){m(u,c=e)},render:function(t){let n=!1,r=f(t);null===r?m(u,c):r&&r.isColor&&(m(r,1),n=!0);let a=e.xr.getEnvironmentBlendMode();"additive"===a?i.buffers.color.setClear(0,0,0,1,s):"alpha-blend"===a&&i.buffers.color.setClear(0,0,0,0,s),(e.autoClear||n)&&(i.buffers.depth.setTest(!0),i.buffers.depth.setMask(!0),i.buffers.color.setMask(!0),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil))},addToRenderList:function(t,n){let i=f(n);i&&(i.isCubeTexture||306===i.mapping)?(void 0===l&&((l=new nT(new nE(1,1,1),new nI({name:"BackgroundCubeMaterial",uniforms:nA(li.backgroundCube.uniforms),vertexShader:li.backgroundCube.vertexShader,fragmentShader:li.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(l)),la.copy(n.backgroundRotation),la.x*=-1,la.y*=-1,la.z*=-1,i.isCubeTexture&&!1===i.isRenderTargetTexture&&(la.y*=-1,la.z*=-1),l.material.uniforms.envMap.value=i,l.material.uniforms.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,l.material.uniforms.backgroundBlurriness.value=n.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(ls.makeRotationFromEuler(la)),l.material.toneMapped=eb.getTransfer(i.colorSpace)!==U,(h!==i||d!==i.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),l.layers.enableAll(),t.unshift(l,l.geometry,l.material,0,0,null)):i&&i.isTexture&&(void 0===o&&((o=new nT(new ay(2,2),new nI({name:"BackgroundMaterial",uniforms:nA(li.background.uniforms),vertexShader:li.background.vertexShader,fragmentShader:li.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1}))).geometry.deleteAttribute("normal"),Object.defineProperty(o.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(o)),o.material.uniforms.t2D.value=i,o.material.uniforms.backgroundIntensity.value=n.backgroundIntensity,o.material.toneMapped=eb.getTransfer(i.colorSpace)!==U,!0===i.matrixAutoUpdate&&i.updateMatrix(),o.material.uniforms.uvTransform.value.copy(i.matrix),(h!==i||d!==i.version||p!==e.toneMapping)&&(o.material.needsUpdate=!0,h=i,d=i.version,p=e.toneMapping),o.layers.enableAll(),t.unshift(o,o.geometry,o.material,0,0,null))},dispose:function(){void 0!==l&&(l.geometry.dispose(),l.material.dispose(),l=void 0),void 0!==o&&(o.geometry.dispose(),o.material.dispose(),o=void 0)}}}function ll(e,t){let n=e.getParameter(e.MAX_VERTEX_ATTRIBS),i={},r=u(null),a=r,s=!1;function o(t){return e.bindVertexArray(t)}function l(t){return e.deleteVertexArray(t)}function u(e){let t=[],i=[],r=[];for(let e=0;e=0){let n=r[t],i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n||n.attribute!==i||i&&n.data!==i.data)return!0;o++}return a.attributesNum!==o||a.index!==i}(n,m,l,g))&&function(e,t,n,i){let r={},s=t.attributes,o=0,l=n.getAttributes();for(let t in l)if(l[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));let i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,o++}a.attributes=r,a.attributesNum=o,a.index=i}(n,m,l,g),null!==g&&t.update(g,e.ELEMENT_ARRAY_BUFFER),(M||s)&&(s=!1,function(n,i,r,a){c();let s=a.attributes,o=r.getAttributes(),l=i.defaultAttributeValues;for(let i in o){let r=o[i];if(r.location>=0){let o=s[i];if(void 0===o&&("instanceMatrix"===i&&n.instanceMatrix&&(o=n.instanceMatrix),"instanceColor"===i&&n.instanceColor&&(o=n.instanceColor)),void 0!==o){let i=o.normalized,s=o.itemSize,l=t.get(o);if(void 0===l)continue;let u=l.buffer,c=l.type,p=l.bytesPerElement,m=c===e.INT||c===e.UNSIGNED_INT||1013===o.gpuType;if(o.isInterleavedBufferAttribute){let t=o.data,l=t.stride,g=o.offset;if(t.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let s=void 0!==n.precision?n.precision:"highp",o=a(s);return o!==s&&(J("WebGLRenderer:",s,"not supported, using",o,"instead."),s=o),{isWebGL2:!0,getMaxAnisotropy:function(){if(void 0!==r)return r;if(!0===t.has("EXT_texture_filter_anisotropic")){let n=t.get("EXT_texture_filter_anisotropic");r=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r},getMaxPrecision:a,textureFormatReadable:function(t){return 1023===t||i.convert(t)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)},textureTypeReadable:function(n){let r=1016===n&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return 1009===n||i.convert(n)===e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n||!!r},precision:s,logarithmicDepthBuffer:!0===n.logarithmicDepthBuffer,reversedDepthBuffer:!0===n.reversedDepthBuffer&&t.has("EXT_clip_control"),maxTextures:e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),maxVertexTextures:e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:e.getParameter(e.MAX_TEXTURE_SIZE),maxCubemapSize:e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),maxAttributes:e.getParameter(e.MAX_VERTEX_ATTRIBS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),maxVaryings:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxSamples:e.getParameter(e.MAX_SAMPLES),samples:e.getParameter(e.SAMPLES)}}function lh(e){let t=this,n=null,i=0,r=!1,a=!1,s=new iL,o=new ev,l={value:null,needsUpdate:!1};function u(e,n,i,r){let a=null!==e?e.length:0,u=null;if(0!==a){if(u=l.value,!0!==r||null===u){let t=i+4*a,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===u||u.length0),t.numPlanes=i,t.numIntersection=0)}}function ld(e){let t=new WeakMap;function n(e,t){return 303===t?e.mapping=301:304===t&&(e.mapping=302),e}function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping;if(303===a||304===a)if(t.has(r))return n(t.get(r).texture,r.mapping);else{let a=r.image;if(!a||!(a.height>0))return null;{let s=new nB(a.height);return s.fromEquirectangularTexture(e,r),t.set(r,s),r.addEventListener("dispose",i),n(s.texture,r.mapping)}}}return r},dispose:function(){t=new WeakMap}}}let lp=[.125,.215,.35,.446,.526,.582],lf=new sx,lm=new tq,lg=null,lv=0,l_=0,ly=!1,lx=new ef;class lb{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,i=100,r={}){let{size:a=256,position:s=lx}=r;lg=this._renderer.getRenderTarget(),lv=this._renderer.getActiveCubeFace(),l_=this._renderer.getActiveMipmapLevel(),ly=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);let o=this._allocateTargets();return o.depthBuffer=!0,this._sceneToCubeUV(e,n,i,o,s),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=lw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=lT(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._ggxMaterial&&this._ggxMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=lp[s-e+4-1]:0===s&&(o=0),n.push(o);let l=1/(a-2),u=-l,c=1+l,h=[u,u,c,u,c,c,u,u,c,c,u,c],d=new Float32Array(108),p=new Float32Array(72),f=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];d.set(i,18*e),p.set(h,12*e);let r=[e,e,e,e,e,e];f.set(r,6*e)}let m=new nd;m.setAttribute("position",new t5(d,3)),m.setAttribute("uv",new t5(p,2)),m.setAttribute("faceIndex",new t5(f,1)),i.push(new nT(m,null)),r>4&&r--}return{lodMeshes:i,sizeLods:t,sigmas:n}}(i)),this._blurMaterial=(r=i,new nI({name:"SphericalGaussianBlur",defines:{n:20,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:new Float32Array(20)},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:new ef(0,1,0)}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:0,depthTest:!1,depthWrite:!1})),this._ggxMaterial=(a=i,new nI({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:256,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:lE(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 3.2: Transform view direction to hemisphere configuration + vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z)); + + // Section 4.1: Orthonormal basis + float lensq = Vh.x * Vh.x + Vh.y * Vh.y; + vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(Vh, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + Vh.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:0,depthTest:!1,depthWrite:!1}))}return i}_compileMaterial(e){let t=new nT(new nd,e);this._renderer.compile(t,lf)}_sceneToCubeUV(e,t,n,i,r){let a=new nO(90,1,t,n),s=[1,-1,1,1,1,1],o=[1,1,1,-1,-1,-1],l=this._renderer,u=l.autoClear,c=l.toneMapping;l.getClearColor(lm),l.toneMapping=0,l.autoClear=!1,l.state.buffers.depth.getReversed()&&(l.setRenderTarget(i),l.clearDepth(),l.setRenderTarget(null)),null===this._backgroundBox&&(this._backgroundBox=new nT(new nE,new tK({name:"PMREM.Background",side:1,depthWrite:!1,depthTest:!1})));let h=this._backgroundBox,d=h.material,p=!1,f=e.background;f?f.isColor&&(d.color.copy(f),e.background=null,p=!0):(d.color.copy(lm),p=!0);for(let t=0;t<6;t++){let n=t%3;0===n?(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x+o[t],r.y,r.z)):1===n?(a.up.set(0,0,s[t]),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y+o[t],r.z)):(a.up.set(0,s[t],0),a.position.set(r.x,r.y,r.z),a.lookAt(r.x,r.y,r.z+o[t]));let u=this._cubeSize;lM(i,n*u,t>2?u:0,u,u),l.setRenderTarget(i),p&&l.render(h,a),l.render(e,a)}l.toneMapping=c,l.autoClear=u,e.background=f}_textureToCubeUV(e,t){let n=this._renderer,i=301===e.mapping||302===e.mapping;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=lw()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=lT());let r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r,r.uniforms.envMap.value=e;let s=this._cubeSize;lM(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,lf)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;let i=this._lodMeshes.length;for(let t=1;th-4?n-h+4:0),f=4*(this._cubeSize-d);o.envMap.value=e.texture,o.roughness.value=c*(0+1.25*l),o.mipInt.value=h-t,lM(r,p,f,3*d,2*d),i.setRenderTarget(r),i.render(s,lf),o.envMap.value=r.texture,o.roughness.value=0,o.mipInt.value=h-n,lM(e,p,f,3*d,2*d),i.setRenderTarget(e),i.render(s,lf)}_blur(e,t,n,i,r){let a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,i,"latitudinal",r),this._halfBlur(a,e,n,n,i,"longitudinal",r)}_halfBlur(e,t,n,i,r,a,s){let o=this._renderer,l=this._blurMaterial;"latitudinal"!==a&&"longitudinal"!==a&&K("blur direction must be either latitudinal or longitudinal!");let u=this._lodMeshes[i];u.material=l;let c=l.uniforms,h=this._sizeLods[n]-1,d=isFinite(r)?Math.PI/(2*h):2*Math.PI/39,p=r/d,f=isFinite(r)?1+Math.floor(3*p):20;f>20&&J(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);let m=[],g=0;for(let e=0;e<20;++e){let t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:ev-4?i-v+4:0),y,3*_,2*_),o.setRenderTarget(t),o.render(u,lf)}}function lS(e,t,n){let i=new eN(e,t,n);return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function lM(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function lT(){return new nI({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function lw(){return new nI({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:lE(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:0,depthTest:!1,depthWrite:!1})}function lE(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function lA(e){let t=new WeakMap,n=null;function i(e){let n=e.target;n.removeEventListener("dispose",i);let r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){let a=r.mapping,s=303===a||304===a,o=301===a||302===a;if(s||o){let a=t.get(r),l=void 0!==a?a.texture.pmremVersion:0;if(r.isRenderTargetTexture&&r.pmremVersion!==l)return null===n&&(n=new lb(e)),(a=s?n.fromEquirectangular(r,a):n.fromCubemap(r,a)).texture.pmremVersion=r.pmremVersion,t.set(r,a),a.texture;{if(void 0!==a)return a.texture;let l=r.image;return s&&l&&l.height>0||o&&l&&function(e){let t=0;for(let n=0;n<6;n++)void 0!==e[n]&&t++;return 6===t}(l)?(null===n&&(n=new lb(e)),(a=s?n.fromEquirectangular(r):n.fromCubemap(r)).texture.pmremVersion=r.pmremVersion,t.set(r,a),r.addEventListener("dispose",i),a.texture):null}}}return r},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function lC(e){let t={};function n(n){if(void 0!==t[n])return t[n];let i=e.getExtension(n);return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(){n("EXT_color_buffer_float"),n("WEBGL_clip_cull_distance"),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture"),n("WEBGL_render_shared_exponent")},get:function(e){let t=n(e);return null===t&&$("WebGLRenderer: "+e+" extension not supported."),t}}}function lR(e,t,n,i){let r={},a=new WeakMap;function s(e){let o=e.target;for(let e in null!==o.index&&t.remove(o.index),o.attributes)t.remove(o.attributes[e]);o.removeEventListener("dispose",s),delete r[o.id];let l=a.get(o);l&&(t.remove(l),a.delete(o)),i.releaseStatesOfGeometry(o),!0===o.isInstancedBufferGeometry&&delete o._maxInstanceCount,n.memory.geometries--}function o(e){let n=[],i=e.index,r=e.attributes.position,s=0;if(null!==i){let e=i.array;s=i.version;for(let t=0,i=e.length;tt.maxTextureSize&&(f=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let m=new Float32Array(p*f*4*c),g=new eU(m,p,f,c);g.type=1015,g.needsUpdate=!0;let v=4*d;for(let t=0;t + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),c=new nT(l,u),h=new sx(-1,1,1,-1,0,1),d=null,p=null,f=!1,m=null,g=[],v=!1;this.setSize=function(e,t){s.setSize(e,t),o.setSize(e,t);for(let n=0;n0&&!0===g[0].isRenderPass;let t=s.width,n=s.height;for(let e=0;e0)return e;let r=t*n,a=lV[r];if(void 0===a&&(a=new Float32Array(r),lV[r]=a),0!==t){i.toArray(a,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(a,r)}return a}function lq(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n0&&(this.seq=i.concat(r))}setValue(e,t,n,i){let r=this.map[t];void 0!==r&&r.setValue(e,n,i)}setOptional(e,t,n){let i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let r=0,a=t.length;r!==a;++r){let a=t[r],s=n[a.id];!1!==s.needsUpdate&&a.setValue(e,s.value,i)}}static seqWithValue(e,t){let n=[];for(let i=0,r=e.length;i!==r;++i){let r=e[i];r.id in t&&n.push(r)}return n}}function uP(e,t,n){let i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let uI=0,uL=new ev;function uN(e,t,n){let i=e.getShaderParameter(t,e.COMPILE_STATUS),r=(e.getShaderInfoLog(t)||"").trim();if(i&&""===r)return"";let a=/ERROR: 0:(\d+)/.exec(r);if(!a)return r;{let i=parseInt(a[1]);return n.toUpperCase()+"\n\n"+r+"\n\n"+function(e,t){let n=e.split("\n"),i=[],r=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let e=r;e":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}}let uU={1:"Linear",2:"Reinhard",3:"Cineon",4:"ACESFilmic",6:"AgX",7:"Neutral",5:"Custom"},uD=new ef;function uO(e){return""!==e}function uF(e,t){let n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function uz(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}let uB=/^[ \t]*#include +<([\w\d./]+)>/gm;function uk(e){return e.replace(uB,uH)}let uV=new Map;function uH(e,t){let n=lt[t];if(void 0===n){let e=uV.get(t);if(void 0!==e)n=lt[e],J('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e);else throw Error("Can not resolve #include <"+t+">")}return uk(n)}let uG=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function uW(e){return e.replace(uG,uj)}function uj(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(s+="\n"),(o=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(uO).join("\n")).length>0&&(o+="\n");else{let e,t,i,l,u;s=[uX(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+g:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif","\n"].filter(uO).join("\n"),o=[uX(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+m:"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",_?"#define CUBEUV_TEXEL_WIDTH "+_.texelWidth:"",_?"#define CUBEUV_TEXEL_HEIGHT "+_.texelHeight:"",_?"#define CUBEUV_MAX_MIP "+_.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.dispersion?"#define USE_DISPERSION":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor||n.batchingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+f:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==n.toneMapping?"#define TONE_MAPPING":"",0!==n.toneMapping?lt.tonemapping_pars_fragment:"",0!==n.toneMapping?(r="toneMapping",void 0===(e=uU[a=n.toneMapping])?(J("WebGLProgram: Unsupported toneMapping:",a),"vec3 "+r+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",lt.colorspace_pars_fragment,(t=function(e){eb._getMatrix(uL,eb.workingColorSpace,e);let t=`mat3( ${uL.elements.map(e=>e.toFixed(4))} )`;switch(eb.getTransfer(e)){case N:return[t,"LinearTransferOETF"];case U:return[t,"sRGBTransferOETF"];default:return J("WebGLProgram: Unsupported color space: ",e),[t,"LinearTransferOETF"]}}(n.outputColorSpace),`vec4 linearToOutputTexel( vec4 value ) { + return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) ); +}`),(eb.getLuminanceCoefficients(uD),i=uD.x.toFixed(4),l=uD.y.toFixed(4),u=uD.z.toFixed(4),`float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( ${i}, ${l}, ${u} ); + return dot( weights, rgb ); +}`),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(uO).join("\n")}d=uz(d=uF(d=uk(d),n),n),p=uz(p=uF(p=uk(p),n),n),d=uW(d),p=uW(p),!0!==n.isRawShaderMaterial&&(S="#version 300 es\n",s=[y,"#define attribute in\n#define varying out\n#define texture2D texture"].join("\n")+"\n"+s,o=["#define varying in",n.glslVersion===D?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===D?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+"\n"+o);let M=S+s+d,T=S+o+p,w=uP(c,c.VERTEX_SHADER,M),E=uP(c,c.FRAGMENT_SHADER,T);function A(t){if(e.debug.checkShaderErrors){let n=c.getProgramInfoLog(b)||"",i=c.getShaderInfoLog(w)||"",r=c.getShaderInfoLog(E)||"",a=n.trim(),l=i.trim(),u=r.trim(),h=!0,d=!0;if(!1===c.getProgramParameter(b,c.LINK_STATUS))if(h=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(c,b,w,E);else{let e=uN(c,w,"vertex"),n=uN(c,E,"fragment");K("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(b,c.VALIDATE_STATUS)+"\n\nMaterial Name: "+t.name+"\nMaterial Type: "+t.type+"\n\nProgram Info Log: "+a+"\n"+e+"\n"+n)}else""!==a?J("WebGLProgram: Program Info Log:",a):(""===l||""===u)&&(d=!1);d&&(t.diagnostics={runnable:h,programLog:a,vertexShader:{log:l,prefix:s},fragmentShader:{log:u,prefix:o}})}c.deleteShader(w),c.deleteShader(E),l=new uR(c,b),u=function(e,t){let n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,Y=a.clearcoat>0,Z=a.dispersion>0,K=a.iridescence>0,$=a.sheen>0,Q=a.transmission>0,ee=q&&!!a.anisotropyMap,et=Y&&!!a.clearcoatMap,en=Y&&!!a.clearcoatNormalMap,ei=Y&&!!a.clearcoatRoughnessMap,er=K&&!!a.iridescenceMap,ea=K&&!!a.iridescenceThicknessMap,es=$&&!!a.sheenColorMap,eo=$&&!!a.sheenRoughnessMap,el=!!a.specularMap,eu=!!a.specularColorMap,ec=!!a.specularIntensityMap,eh=Q&&!!a.transmissionMap,ed=Q&&!!a.thicknessMap,ep=!!a.gradientMap,ef=!!a.alphaMap,em=a.alphaTest>0,eg=!!a.alphaHash,ev=!!a.extensions,e_=0;a.toneMapped&&(null===P||!0===P.isXRRenderTarget)&&(e_=e.toneMapping);let ey={shaderID:E,shaderType:a.type,shaderName:a.name,vertexShader:v,fragmentShader:_,defines:a.defines,customVertexShaderID:y,customFragmentShaderID:x,isRawShaderMaterial:!0===a.isRawShaderMaterial,glslVersion:a.glslVersion,precision:p,batching:D,batchingColor:D&&null!==g._colorsTexture,instancing:N,instancingColor:N&&null!==g.instanceColor,instancingMorph:N&&null!==g.morphTexture,outputColorSpace:null===P?e.outputColorSpace:!0===P.isXRRenderTarget?P.texture.colorSpace:L,alphaToCoverage:!!a.alphaToCoverage,map:O,matcap:F,envMap:z,envMapMode:z&&T.mapping,envMapCubeUVHeight:w,aoMap:B,lightMap:k,bumpMap:V,normalMap:H,displacementMap:G,emissiveMap:W,normalMapObjectSpace:H&&1===a.normalMapType,normalMapTangentSpace:H&&0===a.normalMapType,metalnessMap:j,roughnessMap:X,anisotropy:q,anisotropyMap:ee,clearcoat:Y,clearcoatMap:et,clearcoatNormalMap:en,clearcoatRoughnessMap:ei,dispersion:Z,iridescence:K,iridescenceMap:er,iridescenceThicknessMap:ea,sheen:$,sheenColorMap:es,sheenRoughnessMap:eo,specularMap:el,specularColorMap:eu,specularIntensityMap:ec,transmission:Q,transmissionMap:eh,thicknessMap:ed,gradientMap:ep,opaque:!1===a.transparent&&1===a.blending&&!1===a.alphaToCoverage,alphaMap:ef,alphaTest:em,alphaHash:eg,combine:a.combine,mapUv:O&&m(a.map.channel),aoMapUv:B&&m(a.aoMap.channel),lightMapUv:k&&m(a.lightMap.channel),bumpMapUv:V&&m(a.bumpMap.channel),normalMapUv:H&&m(a.normalMap.channel),displacementMapUv:G&&m(a.displacementMap.channel),emissiveMapUv:W&&m(a.emissiveMap.channel),metalnessMapUv:j&&m(a.metalnessMap.channel),roughnessMapUv:X&&m(a.roughnessMap.channel),anisotropyMapUv:ee&&m(a.anisotropyMap.channel),clearcoatMapUv:et&&m(a.clearcoatMap.channel),clearcoatNormalMapUv:en&&m(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ei&&m(a.clearcoatRoughnessMap.channel),iridescenceMapUv:er&&m(a.iridescenceMap.channel),iridescenceThicknessMapUv:ea&&m(a.iridescenceThicknessMap.channel),sheenColorMapUv:es&&m(a.sheenColorMap.channel),sheenRoughnessMapUv:eo&&m(a.sheenRoughnessMap.channel),specularMapUv:el&&m(a.specularMap.channel),specularColorMapUv:eu&&m(a.specularColorMap.channel),specularIntensityMapUv:ec&&m(a.specularIntensityMap.channel),transmissionMapUv:eh&&m(a.transmissionMap.channel),thicknessMapUv:ed&&m(a.thicknessMap.channel),alphaMapUv:ef&&m(a.alphaMap.channel),vertexTangents:!!S.attributes.tangent&&(H||q),vertexColors:a.vertexColors,vertexAlphas:!0===a.vertexColors&&!!S.attributes.color&&4===S.attributes.color.itemSize,pointsUvs:!0===g.isPoints&&!!S.attributes.uv&&(O||ef),fog:!!b,useFog:!0===a.fog,fogExp2:!!b&&b.isFogExp2,flatShading:!0===a.flatShading&&!1===a.wireframe,sizeAttenuation:!0===a.sizeAttenuation,logarithmicDepthBuffer:d,reversedDepthBuffer:I,skinning:!0===g.isSkinnedMesh,morphTargets:void 0!==S.morphAttributes.position,morphNormals:void 0!==S.morphAttributes.normal,morphColors:void 0!==S.morphAttributes.color,morphTargetsCount:C,morphTextureStride:R,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numLightProbes:o.numLightProbes,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:e_,decodeVideoTexture:O&&!0===a.map.isVideoTexture&&eb.getTransfer(a.map.colorSpace)===U,decodeVideoTextureEmissive:W&&!0===a.emissiveMap.isVideoTexture&&eb.getTransfer(a.emissiveMap.colorSpace)===U,premultipliedAlpha:a.premultipliedAlpha,doubleSided:2===a.side,flipSided:1===a.side,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionClipCullDistance:ev&&!0===a.extensions.clipCullDistance&&i.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(ev&&!0===a.extensions.multiDraw||D)&&i.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:i.has("KHR_parallel_shader_compile"),customProgramCacheKey:a.customProgramCacheKey()};return ey.vertexUv1s=u.has(1),ey.vertexUv2s=u.has(2),ey.vertexUv3s=u.has(3),u.clear(),ey},getProgramCacheKey:function(t){var n,i,r,a;let s=[];if(t.shaderID?s.push(t.shaderID):(s.push(t.customVertexShaderID),s.push(t.customFragmentShaderID)),void 0!==t.defines)for(let e in t.defines)s.push(e),s.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(n=s,i=t,n.push(i.precision),n.push(i.outputColorSpace),n.push(i.envMapMode),n.push(i.envMapCubeUVHeight),n.push(i.mapUv),n.push(i.alphaMapUv),n.push(i.lightMapUv),n.push(i.aoMapUv),n.push(i.bumpMapUv),n.push(i.normalMapUv),n.push(i.displacementMapUv),n.push(i.emissiveMapUv),n.push(i.metalnessMapUv),n.push(i.roughnessMapUv),n.push(i.anisotropyMapUv),n.push(i.clearcoatMapUv),n.push(i.clearcoatNormalMapUv),n.push(i.clearcoatRoughnessMapUv),n.push(i.iridescenceMapUv),n.push(i.iridescenceThicknessMapUv),n.push(i.sheenColorMapUv),n.push(i.sheenRoughnessMapUv),n.push(i.specularMapUv),n.push(i.specularColorMapUv),n.push(i.specularIntensityMapUv),n.push(i.transmissionMapUv),n.push(i.thicknessMapUv),n.push(i.combine),n.push(i.fogExp2),n.push(i.sizeAttenuation),n.push(i.morphTargetsCount),n.push(i.morphAttributeCount),n.push(i.numDirLights),n.push(i.numPointLights),n.push(i.numSpotLights),n.push(i.numSpotLightMaps),n.push(i.numHemiLights),n.push(i.numRectAreaLights),n.push(i.numDirLightShadows),n.push(i.numPointLightShadows),n.push(i.numSpotLightShadows),n.push(i.numSpotLightShadowsWithMaps),n.push(i.numLightProbes),n.push(i.shadowMapType),n.push(i.toneMapping),n.push(i.numClippingPlanes),n.push(i.numClipIntersection),n.push(i.depthPacking),r=s,a=t,o.disableAll(),a.instancing&&o.enable(0),a.instancingColor&&o.enable(1),a.instancingMorph&&o.enable(2),a.matcap&&o.enable(3),a.envMap&&o.enable(4),a.normalMapObjectSpace&&o.enable(5),a.normalMapTangentSpace&&o.enable(6),a.clearcoat&&o.enable(7),a.iridescence&&o.enable(8),a.alphaTest&&o.enable(9),a.vertexColors&&o.enable(10),a.vertexAlphas&&o.enable(11),a.vertexUv1s&&o.enable(12),a.vertexUv2s&&o.enable(13),a.vertexUv3s&&o.enable(14),a.vertexTangents&&o.enable(15),a.anisotropy&&o.enable(16),a.alphaHash&&o.enable(17),a.batching&&o.enable(18),a.dispersion&&o.enable(19),a.batchingColor&&o.enable(20),a.gradientMap&&o.enable(21),r.push(o.mask),o.disableAll(),a.fog&&o.enable(0),a.useFog&&o.enable(1),a.flatShading&&o.enable(2),a.logarithmicDepthBuffer&&o.enable(3),a.reversedDepthBuffer&&o.enable(4),a.skinning&&o.enable(5),a.morphTargets&&o.enable(6),a.morphNormals&&o.enable(7),a.morphColors&&o.enable(8),a.premultipliedAlpha&&o.enable(9),a.shadowMapEnabled&&o.enable(10),a.doubleSided&&o.enable(11),a.flipSided&&o.enable(12),a.useDepthPacking&&o.enable(13),a.dithering&&o.enable(14),a.transmission&&o.enable(15),a.sheen&&o.enable(16),a.opaque&&o.enable(17),a.pointsUvs&&o.enable(18),a.decodeVideoTexture&&o.enable(19),a.decodeVideoTextureEmissive&&o.enable(20),a.alphaToCoverage&&o.enable(21),r.push(o.mask),s.push(e.outputColorSpace)),s.push(t.customProgramCacheKey),s.join()},getUniforms:function(e){let t,n=f[e.type];if(n){let e=li[n];t=nP.clone(e.uniforms)}else t=e.uniforms;return t},acquireProgram:function(t,n){let i=h.get(n);return void 0!==i?++i.usedTimes:(i=new uK(e,n,t,a),c.push(i),h.set(n,i)),i},releaseProgram:function(e){if(0==--e.usedTimes){let t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),h.delete(e.cacheKey),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function u2(){let e=new WeakMap;return{has:function(t){return e.has(t)},get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function u3(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function u4(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function u5(){let e=[],t=0,n=[],i=[],r=[];function a(n,i,r,a,s,o){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:r,groupOrder:a,renderOrder:n.renderOrder,z:s,group:o},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=r,l.groupOrder=a,l.renderOrder=n.renderOrder,l.z=s,l.group=o),t++,l}return{opaque:n,transmissive:i,transparent:r,init:function(){t=0,n.length=0,i.length=0,r.length=0},push:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.push(c):!0===s.transparent?r.push(c):n.push(c)},unshift:function(e,t,s,o,l,u){let c=a(e,t,s,o,l,u);s.transmission>0?i.unshift(c):!0===s.transparent?r.unshift(c):n.unshift(c)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||u3),i.length>1&&i.sort(t||u4),r.length>1&&r.sort(t||u4)}}}function u6(){let e=new WeakMap;return{get:function(t,n){let i,r=e.get(t);return void 0===r?(i=new u5,e.set(t,[i])):n>=r.length?(i=new u5,r.push(i)):i=r[n],i},dispose:function(){e=new WeakMap}}}function u8(){let e={};return{get:function(t){let n;if(void 0!==e[t.id])return e[t.id];switch(t.type){case"DirectionalLight":n={direction:new ef,color:new tq};break;case"SpotLight":n={position:new ef,direction:new ef,color:new tq,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ef,color:new tq,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ef,skyColor:new tq,groundColor:new tq};break;case"RectAreaLight":n={color:new tq,position:new ef,halfWidth:new ef,halfHeight:new ef}}return e[t.id]=n,n}}}let u9=0;function u7(e,t){return 2*!!t.castShadow-2*!!e.castShadow+ +!!t.map-!!e.map}function ce(e){let t,n=new u8,i=(t={},{get:function(e){let n;if(void 0!==t[e.id])return t[e.id];switch(e.type){case"DirectionalLight":case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ed};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ed,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=n,n}}),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)r.probe.push(new ef);let a=new ef,s=new tt,o=new tt;return{setup:function(t){let a=0,s=0,o=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let l=0,u=0,c=0,h=0,d=0,p=0,f=0,m=0,g=0,v=0,_=0;t.sort(u7);for(let e=0,y=t.length;e0&&(!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=ln.LTC_FLOAT_1,r.rectAreaLTC2=ln.LTC_FLOAT_2):(r.rectAreaLTC1=ln.LTC_HALF_1,r.rectAreaLTC2=ln.LTC_HALF_2)),r.ambient[0]=a,r.ambient[1]=s,r.ambient[2]=o;let y=r.hash;(y.directionalLength!==l||y.pointLength!==u||y.spotLength!==c||y.rectAreaLength!==h||y.hemiLength!==d||y.numDirectionalShadows!==p||y.numPointShadows!==f||y.numSpotShadows!==m||y.numSpotMaps!==g||y.numLightProbes!==_)&&(r.directional.length=l,r.spot.length=c,r.rectArea.length=h,r.point.length=u,r.hemi.length=d,r.directionalShadow.length=p,r.directionalShadowMap.length=p,r.pointShadow.length=f,r.pointShadowMap.length=f,r.spotShadow.length=m,r.spotShadowMap.length=m,r.directionalShadowMatrix.length=p,r.pointShadowMatrix.length=f,r.spotLightMatrix.length=m+g-v,r.spotLightMap.length=g,r.numSpotLightShadowsWithMaps=v,r.numLightProbes=_,y.directionalLength=l,y.pointLength=u,y.spotLength=c,y.rectAreaLength=h,y.hemiLength=d,y.numDirectionalShadows=p,y.numPointShadows=f,y.numSpotShadows=m,y.numSpotMaps=g,y.numLightProbes=_,r.version=u9++)},setupView:function(e,t){let n=0,i=0,l=0,u=0,c=0,h=t.matrixWorldInverse;for(let t=0,d=e.length;t=a.length?(r=new ct(e),a.push(r)):r=a[i],r},dispose:function(){t=new WeakMap}}}let ci=[new ef(1,0,0),new ef(-1,0,0),new ef(0,1,0),new ef(0,-1,0),new ef(0,0,1),new ef(0,0,-1)],cr=[new ef(0,-1,0),new ef(0,-1,0),new ef(0,0,1),new ef(0,0,-1),new ef(0,-1,0),new ef(0,-1,0)],ca=new tt,cs=new ef,co=new ef;function cl(e,t,n){let i=new iO,r=new ed,a=new ed,s=new eI,o=new az,l=new aB,u={},c=n.maxTextureSize,h={0:1,1:0,2:2},d=new nI({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ed},radius:{value:4}},vertexShader:"void main() {\n gl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let f=new nd;f.setAttribute("position",new t5(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let m=new nT(f,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let v=this.type;function _(t,n,i,r){let a=null,s=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==s)a=s;else if(a=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0||!0===n.alphaToCoverage){let e=a.uuid,t=n.uuid,i=u[e];void 0===i&&(i={},u[e]=i);let r=i[t];void 0===r&&(r=a.clone(),i[t]=r,n.addEventListener("dispose",y)),a=r}return a.visible=n.visible,a.wireframe=n.wireframe,3===r?a.side=null!==n.shadowSide?n.shadowSide:n.side:a.side=null!==n.shadowSide?n.shadowSide:h[n.side],a.alphaMap=n.alphaMap,a.alphaTest=!0===n.alphaToCoverage?.5:n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,!0===i.isPointLight&&!0===a.isMeshDistanceMaterial&&(e.properties.get(a).light=i),a}function y(e){for(let t in e.target.removeEventListener("dispose",y),u){let n=u[t],i=e.target.uuid;i in n&&(n[i].dispose(),delete n[i])}}this.render=function(n,o,l){if(!1===g.enabled||!1===g.autoUpdate&&!1===g.needsUpdate||0===n.length)return;2===n.type&&(J("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),n.type=1);let u=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),y=e.state;y.setBlending(0),!0===y.buffers.depth.getReversed()?y.buffers.color.setClear(0,0,0,0):y.buffers.color.setClear(1,1,1,1),y.buffers.depth.setTest(!0),y.setScissorTest(!1);let x=v!==this.type;x&&o.traverse(function(e){e.material&&(Array.isArray(e.material)?e.material.forEach(e=>e.needsUpdate=!0):e.material.needsUpdate=!0)});for(let u=0,h=n.length;uc||r.y>c)&&(r.x>c&&(a.x=Math.floor(c/g.x),r.x=a.x*g.x,f.mapSize.x=a.x),r.y>c&&(a.y=Math.floor(c/g.y),r.y=a.y*g.y,f.mapSize.y=a.y)),null===f.map||!0===x){if(null!==f.map&&(null!==f.map.depthTexture&&(f.map.depthTexture.dispose(),f.map.depthTexture=null),f.map.dispose()),3===this.type){if(h.isPointLight){J("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}f.map=new eN(r.x,r.y,{format:1030,type:1016,minFilter:1006,magFilter:1006,generateMipmaps:!1}),f.map.texture.name=h.name+".shadowMap",f.map.depthTexture=new rb(r.x,r.y,1015),f.map.depthTexture.name=h.name+".shadowMapDepth",f.map.depthTexture.format=1026,f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003}else{h.isPointLight?(f.map=new nB(r.x),f.map.depthTexture=new rS(r.x,1014)):(f.map=new eN(r.x,r.y),f.map.depthTexture=new rb(r.x,r.y,1014)),f.map.depthTexture.name=h.name+".shadowMap",f.map.depthTexture.format=1026;let t=e.state.buffers.depth.getReversed();1===this.type?(f.map.depthTexture.compareFunction=t?518:515,f.map.depthTexture.minFilter=1006,f.map.depthTexture.magFilter=1006):(f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=1003,f.map.depthTexture.magFilter=1003)}f.camera.updateProjectionMatrix()}let v=f.map.isWebGLCubeRenderTarget?6:1;for(let n=0;n=1:-1!==P.indexOf("OpenGL ES")&&(R=parseFloat(/^OpenGL ES (\d)/.exec(P)[1])>=2);let I=null,L={},N=e.getParameter(e.SCISSOR_BOX),U=e.getParameter(e.VIEWPORT),D=new eI().fromArray(N),O=new eI().fromArray(U);function F(t,n,i,r){let a=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;stypeof navigator&&/OculusBrowser/g.test(navigator.userAgent),c=new ed,h=new WeakMap,d=new WeakMap,p=!1;try{p="u">typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function f(e,t){return p?new OffscreenCanvas(e,t):G("canvas")}function m(e,t,n){let i=1,r=X(e);if((r.width>n||r.height>n)&&(i=n/Math.max(r.width,r.height)),i<1)if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof VideoFrame&&e instanceof VideoFrame){let n=Math.floor(i*r.width),a=Math.floor(i*r.height);void 0===o&&(o=f(n,a));let s=t?f(n,a):o;return s.width=n,s.height=a,s.getContext("2d").drawImage(e,0,0,n,a),J("WebGLRenderer: Texture has been resized from ("+r.width+"x"+r.height+") to ("+n+"x"+a+")."),s}else"data"in e&&J("WebGLRenderer: Image in DataTexture is too big ("+r.width+"x"+r.height+").");return e}function g(e){return e.generateMipmaps}function v(t){e.generateMipmap(t)}function _(n,i,r,a,s=!1){if(null!==n){if(void 0!==e[n])return e[n];J("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let o=i;if(i===e.RED&&(r===e.FLOAT&&(o=e.R32F),r===e.HALF_FLOAT&&(o=e.R16F),r===e.UNSIGNED_BYTE&&(o=e.R8)),i===e.RED_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.R8UI),r===e.UNSIGNED_SHORT&&(o=e.R16UI),r===e.UNSIGNED_INT&&(o=e.R32UI),r===e.BYTE&&(o=e.R8I),r===e.SHORT&&(o=e.R16I),r===e.INT&&(o=e.R32I)),i===e.RG&&(r===e.FLOAT&&(o=e.RG32F),r===e.HALF_FLOAT&&(o=e.RG16F),r===e.UNSIGNED_BYTE&&(o=e.RG8)),i===e.RG_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RG8UI),r===e.UNSIGNED_SHORT&&(o=e.RG16UI),r===e.UNSIGNED_INT&&(o=e.RG32UI),r===e.BYTE&&(o=e.RG8I),r===e.SHORT&&(o=e.RG16I),r===e.INT&&(o=e.RG32I)),i===e.RGB_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGB8UI),r===e.UNSIGNED_SHORT&&(o=e.RGB16UI),r===e.UNSIGNED_INT&&(o=e.RGB32UI),r===e.BYTE&&(o=e.RGB8I),r===e.SHORT&&(o=e.RGB16I),r===e.INT&&(o=e.RGB32I)),i===e.RGBA_INTEGER&&(r===e.UNSIGNED_BYTE&&(o=e.RGBA8UI),r===e.UNSIGNED_SHORT&&(o=e.RGBA16UI),r===e.UNSIGNED_INT&&(o=e.RGBA32UI),r===e.BYTE&&(o=e.RGBA8I),r===e.SHORT&&(o=e.RGBA16I),r===e.INT&&(o=e.RGBA32I)),i===e.RGB&&(r===e.UNSIGNED_INT_5_9_9_9_REV&&(o=e.RGB9_E5),r===e.UNSIGNED_INT_10F_11F_11F_REV&&(o=e.R11F_G11F_B10F)),i===e.RGBA){let t=s?N:eb.getTransfer(a);r===e.FLOAT&&(o=e.RGBA32F),r===e.HALF_FLOAT&&(o=e.RGBA16F),r===e.UNSIGNED_BYTE&&(o=t===U?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(o=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(o=e.RGB5_A1)}return(o===e.R16F||o===e.R32F||o===e.RG16F||o===e.RG32F||o===e.RGBA16F||o===e.RGBA32F)&&t.get("EXT_color_buffer_float"),o}function y(t,n){let i;return t?null===n||1014===n||1020===n?i=e.DEPTH24_STENCIL8:1015===n?i=e.DEPTH32F_STENCIL8:1012===n&&(i=e.DEPTH24_STENCIL8,J("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):null===n||1014===n||1020===n?i=e.DEPTH_COMPONENT24:1015===n?i=e.DEPTH_COMPONENT32F:1012===n&&(i=e.DEPTH_COMPONENT16),i}function x(e,t){return!0===g(e)||e.isFramebufferTexture&&1003!==e.minFilter&&1006!==e.minFilter?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function b(e){let t=e.target;t.removeEventListener("dispose",b),function(e){let t=i.get(e);if(void 0===t.__webglInit)return;let n=e.source,r=d.get(n);if(r){let i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&M(e),0===Object.keys(r).length&&d.delete(n)}i.remove(e)}(t),t.isVideoTexture&&h.delete(t)}function S(t){let n=t.target;n.removeEventListener("dispose",S),function(t){let n=i.get(t);if(t.depthTexture&&(t.depthTexture.dispose(),i.remove(t.depthTexture)),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(n.__webglFramebuffer[t]))for(let i=0;i0&&l.__version!==t.version){let e=t.image;if(null===e)J("WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void D(l,t,r);J("WebGLRenderer: Texture marked for update but image is incomplete")}}else t.isExternalTexture&&(l.__webglTexture=t.sourceTexture?t.sourceTexture:null);n.bindTexture(e.TEXTURE_2D,l.__webglTexture,e.TEXTURE0+r)}let E={1e3:e.REPEAT,1001:e.CLAMP_TO_EDGE,1002:e.MIRRORED_REPEAT},A={1003:e.NEAREST,1004:e.NEAREST_MIPMAP_NEAREST,1005:e.NEAREST_MIPMAP_LINEAR,1006:e.LINEAR,1007:e.LINEAR_MIPMAP_NEAREST,1008:e.LINEAR_MIPMAP_LINEAR},C={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function R(n,a){if((1015===a.type&&!1===t.has("OES_texture_float_linear")&&(1006===a.magFilter||1007===a.magFilter||1005===a.magFilter||1008===a.magFilter||1006===a.minFilter||1007===a.minFilter||1005===a.minFilter||1008===a.minFilter)&&J("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),e.texParameteri(n,e.TEXTURE_WRAP_S,E[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,E[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,E[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,A[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,A[a.minFilter]),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,C[a.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic"))&&1003!==a.magFilter&&(1005===a.minFilter||1008===a.minFilter)&&(1015!==a.type||!1!==t.has("OES_texture_float_linear"))&&(a.anisotropy>1||i.get(a).__currentAnisotropy)){let s=t.get("EXT_texture_filter_anisotropic");e.texParameterf(n,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,r.getMaxAnisotropy())),i.get(a).__currentAnisotropy=a.anisotropy}}function P(t,n){let i,r=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",b));let a=n.source,o=d.get(a);void 0===o&&(o={},d.set(a,o));let l=((i=[]).push(n.wrapS),i.push(n.wrapT),i.push(n.wrapR||0),i.push(n.magFilter),i.push(n.minFilter),i.push(n.anisotropy),i.push(n.internalFormat),i.push(n.format),i.push(n.type),i.push(n.generateMipmaps),i.push(n.premultiplyAlpha),i.push(n.flipY),i.push(n.unpackAlignment),i.push(n.colorSpace),i.join());if(l!==t.__cacheKey){void 0===o[l]&&(o[l]={texture:e.createTexture(),usedTimes:0},s.memory.textures++,r=!0),o[l].usedTimes++;let i=o[t.__cacheKey];void 0!==i&&(o[t.__cacheKey].usedTimes--,0===i.usedTimes&&M(n)),t.__cacheKey=l,t.__webglTexture=o[l].texture}return r}function I(e,t,n){return Math.floor(Math.floor(e/n)/t)}function D(t,s,o){let l=e.TEXTURE_2D;(s.isDataArrayTexture||s.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),s.isData3DTexture&&(l=e.TEXTURE_3D);let u=P(t,s),c=s.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+o);let h=i.get(c);if(c.version!==h.__version||!0===u){let t;n.activeTexture(e.TEXTURE0+o);let i=eb.getPrimaries(eb.workingColorSpace),d=""===s.colorSpace?null:eb.getPrimaries(s.colorSpace),p=""===s.colorSpace||i===d?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let f=m(s.image,!1,r.maxTextureSize);f=j(s,f);let b=a.convert(s.format,s.colorSpace),S=a.convert(s.type),M=_(s.internalFormat,b,S,s.colorSpace,s.isVideoTexture);R(l,s);let T=s.mipmaps,w=!0!==s.isVideoTexture,E=void 0===h.__version||!0===u,A=c.dataReady,C=x(s,f);if(s.isDepthTexture)M=y(1027===s.format,s.type),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,M,f.width,f.height):n.texImage2D(e.TEXTURE_2D,0,M,f.width,f.height,0,b,S,null));else if(s.isDataTexture)if(T.length>0){w&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,T[0].width,T[0].height);for(let i=0,r=T.length;ie.start-t.start);let o=0;for(let e=1;e0){let r=o8(t.width,t.height,s.format,s.type);for(let a of s.layerUpdates){let s=t.data.subarray(a*r/t.data.BYTES_PER_ELEMENT,(a+1)*r/t.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,a,t.width,t.height,1,b,s)}s.clearLayerUpdates()}else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,t.data)}else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,t.data,0,0);else J("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else w?A&&n.texSubImage3D(e.TEXTURE_2D_ARRAY,i,0,0,0,t.width,t.height,f.depth,b,S,t.data):n.texImage3D(e.TEXTURE_2D_ARRAY,i,M,t.width,t.height,f.depth,0,b,S,t.data)}else{w&&E&&n.texStorage2D(e.TEXTURE_2D,C,M,T[0].width,T[0].height);for(let i=0,r=T.length;i0){let t=o8(f.width,f.height,s.format,s.type);for(let i of s.layerUpdates){let r=f.data.subarray(i*t/f.data.BYTES_PER_ELEMENT,(i+1)*t/f.data.BYTES_PER_ELEMENT);n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,i,f.width,f.height,1,b,S,r)}s.clearLayerUpdates()}else n.texSubImage3D(e.TEXTURE_2D_ARRAY,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)}else n.texImage3D(e.TEXTURE_2D_ARRAY,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isData3DTexture)w?(E&&n.texStorage3D(e.TEXTURE_3D,C,M,f.width,f.height,f.depth),A&&n.texSubImage3D(e.TEXTURE_3D,0,0,0,0,f.width,f.height,f.depth,b,S,f.data)):n.texImage3D(e.TEXTURE_3D,0,M,f.width,f.height,f.depth,0,b,S,f.data);else if(s.isFramebufferTexture){if(E)if(w)n.texStorage2D(e.TEXTURE_2D,C,M,f.width,f.height);else{let t=f.width,i=f.height;for(let r=0;r>=1,i>>=1}}else if(T.length>0){if(w&&E){let t=X(T[0]);n.texStorage2D(e.TEXTURE_2D,C,M,t.width,t.height)}for(let i=0,r=T.length;i>c),i=Math.max(1,r.height>>c);u===e.TEXTURE_3D||u===e.TEXTURE_2D_ARRAY?n.texImage3D(u,c,p,t,i,r.depth,0,h,d,null):n.texImage2D(u,c,p,t,i,0,h,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),W(r)?l.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,o,u,m.__webglTexture,0,H(r)):(u===e.TEXTURE_2D||u>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&u<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,u,m.__webglTexture,c),n.bindFramebuffer(e.FRAMEBUFFER,null)}function F(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer){let r=n.depthTexture,a=r&&r.isDepthTexture?r.type:null,s=y(n.stencilBuffer,a),o=n.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;W(n)?l.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,H(n),s,n.width,n.height):i?e.renderbufferStorageMultisample(e.RENDERBUFFER,H(n),s,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,s,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,o,e.RENDERBUFFER,t)}else{let t=n.textures;for(let r=0;r{delete r.__boundDepthTexture,delete r.__depthDisposeCallback,e.removeEventListener("dispose",t)};e.addEventListener("dispose",t),r.__depthDisposeCallback=t}r.__boundDepthTexture=e}if(t.depthTexture&&!r.__autoAllocateDepthBuffer)if(a)for(let e=0;e<6;e++)z(r.__webglFramebuffer[e],t,e);else{let e=t.texture.mipmaps;e&&e.length>0?z(r.__webglFramebuffer[0],t,0):z(r.__webglFramebuffer,t,0)}else if(a){r.__webglDepthbuffer=[];for(let i=0;i<6;i++)if(n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[i]),void 0===r.__webglDepthbuffer[i])r.__webglDepthbuffer[i]=e.createRenderbuffer(),F(r.__webglDepthbuffer[i],t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,a=r.__webglDepthbuffer[i];e.bindRenderbuffer(e.RENDERBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,a)}}else{let i=t.texture.mipmaps;if(i&&i.length>0?n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer[0]):n.bindFramebuffer(e.FRAMEBUFFER,r.__webglFramebuffer),void 0===r.__webglDepthbuffer)r.__webglDepthbuffer=e.createRenderbuffer(),F(r.__webglDepthbuffer,t,!1);else{let n=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,i=r.__webglDepthbuffer;e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,n,e.RENDERBUFFER,i)}}n.bindFramebuffer(e.FRAMEBUFFER,null)}let k=[],V=[];function H(e){return Math.min(r.maxSamples,e.samples)}function W(e){let n=i.get(e);return e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function j(e,t){let n=e.colorSpace,i=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||n!==L&&""!==n&&(eb.getTransfer(n)===U?(1023!==i||1009!==r)&&J("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):K("WebGLTextures: Unsupported texture color space:",n)),t}function X(e){return"u">typeof HTMLImageElement&&e instanceof HTMLImageElement?(c.width=e.naturalWidth||e.width,c.height=e.naturalHeight||e.height):"u">typeof VideoFrame&&e instanceof VideoFrame?(c.width=e.displayWidth,c.height=e.displayHeight):(c.width=e.width,c.height=e.height),c}this.allocateTextureUnit=function(){let e=T;return e>=r.maxTextures&&J("WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+r.maxTextures),T+=1,e},this.resetTextureUnits=function(){T=0},this.setTexture2D=w,this.setTexture2DArray=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?D(a,t,r):(t.isExternalTexture&&(a.__webglTexture=t.sourceTexture?t.sourceTexture:null),n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+r))},this.setTexture3D=function(t,r){let a=i.get(t);!1===t.isRenderTargetTexture&&t.version>0&&a.__version!==t.version?D(a,t,r):n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,s){let o=i.get(t);!0!==t.isCubeDepthTexture&&t.version>0&&o.__version!==t.version?function(t,s,o){if(6!==s.image.length)return;let l=P(t,s),u=s.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+o);let c=i.get(u);if(u.version!==c.__version||!0===l){let t;n.activeTexture(e.TEXTURE0+o);let i=eb.getPrimaries(eb.workingColorSpace),h=""===s.colorSpace?null:eb.getPrimaries(s.colorSpace),d=""===s.colorSpace||i===h?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,s.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,s.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,d);let p=s.isCompressedTexture||s.image[0].isCompressedTexture,f=s.image[0]&&s.image[0].isDataTexture,y=[];for(let e=0;e<6;e++)p||f?y[e]=f?s.image[e].image:s.image[e]:y[e]=m(s.image[e],!0,r.maxCubemapSize),y[e]=j(s,y[e]);let b=y[0],S=a.convert(s.format,s.colorSpace),M=a.convert(s.type),T=_(s.internalFormat,S,M,s.colorSpace),w=!0!==s.isVideoTexture,E=void 0===c.__version||!0===l,A=u.dataReady,C=x(s,b);if(R(e.TEXTURE_CUBE_MAP,s),p){w&&E&&n.texStorage2D(e.TEXTURE_CUBE_MAP,C,T,b.width,b.height);for(let i=0;i<6;i++){t=y[i].mipmaps;for(let r=0;r0&&C++;let i=X(y[0]);n.texStorage2D(e.TEXTURE_CUBE_MAP,C,T,i.width,i.height)}for(let i=0;i<6;i++)if(f){w?A&&n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,0,0,y[i].width,y[i].height,S,M,y[i].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,T,y[i].width,y[i].height,0,S,M,y[i].data);for(let r=0;r1;if(!h&&(void 0===l.__webglTexture&&(l.__webglTexture=e.createTexture()),l.__version=r.version,s.memory.textures++),c){o.__webglFramebuffer=[];for(let t=0;t<6;t++)if(r.mipmaps&&r.mipmaps.length>0){o.__webglFramebuffer[t]=[];for(let n=0;n0){o.__webglFramebuffer=[];for(let t=0;t0&&!1===W(t)){o.__webglMultisampledFramebuffer=e.createFramebuffer(),o.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,o.__webglMultisampledFramebuffer);for(let n=0;n0)for(let i=0;i0)for(let n=0;n0){if(!1===W(t)){let r=t.textures,a=t.width,s=t.height,o=e.COLOR_BUFFER_BIT,l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,c=i.get(t),h=r.length>1;if(h)for(let t=0;t0?n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer[0]):n.bindFramebuffer(e.DRAW_FRAMEBUFFER,c.__webglFramebuffer);for(let n=0;n= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class cm{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(null===this.texture){let n=new rM(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(null!==this.texture&&null===this.mesh){let t=e.cameras[0].viewport,n=new nI({vertexShader:cp,fragmentShader:cf,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new nT(new ay(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class cg extends ee{constructor(e,t){super();const n=this;let i=null,r=1,a=null,s="local-floor",o=1,l=null,u=null,c=null,h=null,d=null,p=null;const f="u">typeof XRWebGLBinding,m=new cm,g={},v=t.getContextAttributes();let _=null,y=null;const x=[],b=[],S=new ed;let M=null;const T=new nO;T.viewport=new eI;const w=new nO;w.viewport=new eI;const E=[T,w],A=new sG;let C=null,R=null;function P(e){let t=b.indexOf(e.inputSource);if(-1===t)return;let n=x[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function I(){i.removeEventListener("select",P),i.removeEventListener("selectstart",P),i.removeEventListener("selectend",P),i.removeEventListener("squeeze",P),i.removeEventListener("squeezestart",P),i.removeEventListener("squeezeend",P),i.removeEventListener("end",I),i.removeEventListener("inputsourceschange",L);for(let e=0;e=0&&(b[i]=null,x[i].disconnect(n))}for(let t=0;t=b.length){b.push(n),i=e;break}else if(null===b[e]){b[e]=n,i=e;break}if(-1===i)break}let r=x[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getGripSpace()},this.getHand=function(e){let t=x[e];return void 0===t&&(t=new nH,x[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&J("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){s=e,!0===n.isPresenting&&J("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==h?h:d},this.getBinding=function(){return null===c&&f&&(c=new XRWebGLBinding(i,t)),c},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(u){if(null!==(i=u)){if(_=e.getRenderTarget(),i.addEventListener("select",P),i.addEventListener("selectstart",P),i.addEventListener("selectend",P),i.addEventListener("squeeze",P),i.addEventListener("squeezestart",P),i.addEventListener("squeezeend",P),i.addEventListener("end",I),i.addEventListener("inputsourceschange",L),!0!==v.xrCompatible&&await t.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(S),f&&"createProjectionLayer"in XRWebGLBinding.prototype){let n=null,a=null,s=null;v.depth&&(s=v.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=v.stencil?1027:1026,a=v.stencil?1020:1014);let o={colorFormat:t.RGBA8,depthFormat:s,scaleFactor:r};h=(c=this.getBinding()).createProjectionLayer(o),i.updateRenderState({layers:[h]}),e.setPixelRatio(1),e.setSize(h.textureWidth,h.textureHeight,!1),y=new eN(h.textureWidth,h.textureHeight,{format:1023,type:1009,depthTexture:new rb(h.textureWidth,h.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:v.stencil,colorSpace:e.outputColorSpace,samples:4*!!v.antialias,resolveDepthBuffer:!1===h.ignoreDepthValues,resolveStencilBuffer:!1===h.ignoreDepthValues})}else{let n={antialias:v.antialias,alpha:!0,depth:v.depth,stencil:v.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),e.setPixelRatio(1),e.setSize(d.framebufferWidth,d.framebufferHeight,!1),y=new eN(d.framebufferWidth,d.framebufferHeight,{format:1023,type:1009,colorSpace:e.outputColorSpace,stencilBuffer:v.stencil,resolveDepthBuffer:!1===d.ignoreDepthValues,resolveStencilBuffer:!1===d.ignoreDepthValues})}y.isXRRenderTarget=!0,this.setFoveation(o),l=null,a=await i.requestReferenceSpace(s),F.setContext(i),F.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};const N=new ef,U=new ef;function D(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){var t,n,r;if(null===i)return;let a=e.near,s=e.far;null!==m.texture&&(m.depthNear>0&&(a=m.depthNear),m.depthFar>0&&(s=m.depthFar)),A.near=w.near=T.near=a,A.far=w.far=T.far=s,(C!==A.near||R!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),C=A.near,R=A.far),A.layers.mask=6|e.layers.mask,T.layers.mask=3&A.layers.mask,w.layers.mask=5&A.layers.mask;let o=e.parent,l=A.cameras;D(A,o);for(let e=0;e0&&(e.alphaTest.value=i.alphaTest);let r=t.get(i),a=r.envMap,s=r.envMapRotation;a&&(e.envMap.value=a,cv.copy(s),cv.x*=-1,cv.y*=-1,cv.z*=-1,a.isCubeTexture&&!1===a.isRenderTargetTexture&&(cv.y*=-1,cv.z*=-1),e.envMapRotation.value.setFromMatrix4(c_.makeRotationFromEuler(cv)),e.flipEnvMap.value=a.isCubeTexture&&!1===a.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio),i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity,n(i.lightMap,e.lightMapTransform)),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,e.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,nR(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,a,s,o){var l,u,c,h,d,p,f,m,g,v,_,y,x,b,S,M,T,w,E,A,C,R,P;let I;r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),l=e,(u=r).gradientMap&&(l.gradientMap.value=u.gradientMap)):r.isMeshPhongMaterial?(i(e,r),c=e,h=r,c.specular.value.copy(h.specular),c.shininess.value=Math.max(h.shininess,1e-4)):r.isMeshStandardMaterial?(i(e,r),d=e,p=r,d.metalness.value=p.metalness,p.metalnessMap&&(d.metalnessMap.value=p.metalnessMap,n(p.metalnessMap,d.metalnessMapTransform)),d.roughness.value=p.roughness,p.roughnessMap&&(d.roughnessMap.value=p.roughnessMap,n(p.roughnessMap,d.roughnessMapTransform)),p.envMap&&(d.envMapIntensity.value=p.envMapIntensity),r.isMeshPhysicalMaterial&&(f=e,m=r,g=o,f.ior.value=m.ior,m.sheen>0&&(f.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),f.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(f.sheenColorMap.value=m.sheenColorMap,n(m.sheenColorMap,f.sheenColorMapTransform)),m.sheenRoughnessMap&&(f.sheenRoughnessMap.value=m.sheenRoughnessMap,n(m.sheenRoughnessMap,f.sheenRoughnessMapTransform))),m.clearcoat>0&&(f.clearcoat.value=m.clearcoat,f.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(f.clearcoatMap.value=m.clearcoatMap,n(m.clearcoatMap,f.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(f.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,n(m.clearcoatRoughnessMap,f.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(f.clearcoatNormalMap.value=m.clearcoatNormalMap,n(m.clearcoatNormalMap,f.clearcoatNormalMapTransform),f.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),1===m.side&&f.clearcoatNormalScale.value.negate())),m.dispersion>0&&(f.dispersion.value=m.dispersion),m.iridescence>0&&(f.iridescence.value=m.iridescence,f.iridescenceIOR.value=m.iridescenceIOR,f.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],f.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(f.iridescenceMap.value=m.iridescenceMap,n(m.iridescenceMap,f.iridescenceMapTransform)),m.iridescenceThicknessMap&&(f.iridescenceThicknessMap.value=m.iridescenceThicknessMap,n(m.iridescenceThicknessMap,f.iridescenceThicknessMapTransform))),m.transmission>0&&(f.transmission.value=m.transmission,f.transmissionSamplerMap.value=g.texture,f.transmissionSamplerSize.value.set(g.width,g.height),m.transmissionMap&&(f.transmissionMap.value=m.transmissionMap,n(m.transmissionMap,f.transmissionMapTransform)),f.thickness.value=m.thickness,m.thicknessMap&&(f.thicknessMap.value=m.thicknessMap,n(m.thicknessMap,f.thicknessMapTransform)),f.attenuationDistance.value=m.attenuationDistance,f.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(f.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(f.anisotropyMap.value=m.anisotropyMap,n(m.anisotropyMap,f.anisotropyMapTransform))),f.specularIntensity.value=m.specularIntensity,f.specularColor.value.copy(m.specularColor),m.specularColorMap&&(f.specularColorMap.value=m.specularColorMap,n(m.specularColorMap,f.specularColorMapTransform)),m.specularIntensityMap&&(f.specularIntensityMap.value=m.specularIntensityMap,n(m.specularIntensityMap,f.specularIntensityMapTransform)))):r.isMeshMatcapMaterial?(i(e,r),v=e,(_=r).matcap&&(v.matcap.value=_.matcap)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),y=e,x=r,I=t.get(x).light,y.referencePosition.value.setFromMatrixPosition(I.matrixWorld),y.nearDistance.value=I.shadow.camera.near,y.farDistance.value=I.shadow.camera.far):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(b=e,S=r,b.diffuse.value.copy(S.color),b.opacity.value=S.opacity,S.map&&(b.map.value=S.map,n(S.map,b.mapTransform)),r.isLineDashedMaterial&&(M=e,T=r,M.dashSize.value=T.dashSize,M.totalSize.value=T.dashSize+T.gapSize,M.scale.value=T.scale)):r.isPointsMaterial?(w=e,E=r,A=a,C=s,w.diffuse.value.copy(E.color),w.opacity.value=E.opacity,w.size.value=E.size*A,w.scale.value=.5*C,E.map&&(w.map.value=E.map,n(E.map,w.uvTransform)),E.alphaMap&&(w.alphaMap.value=E.alphaMap,n(E.alphaMap,w.alphaMapTransform)),E.alphaTest>0&&(w.alphaTest.value=E.alphaTest)):r.isSpriteMaterial?(R=e,P=r,R.diffuse.value.copy(P.color),R.opacity.value=P.opacity,R.rotation.value=P.rotation,P.map&&(R.map.value=P.map,n(P.map,R.mapTransform)),P.alphaMap&&(R.alphaMap.value=P.alphaMap,n(P.alphaMap,R.alphaMapTransform)),P.alphaTest>0&&(R.alphaTest.value=P.alphaTest)):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function cx(e,t,n,i){let r={},a={},s=[],o=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function l(e){let t={boundary:0,storage:0};return"number"==typeof e||"boolean"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?J("WebGLRenderer: Texture samplers can not be part of an uniforms group."):J("WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){let n=t.target;n.removeEventListener("dispose",u);let i=s.indexOf(n.__bindingPointIndex);s.splice(i,1),e.deleteBuffer(r[n.id]),delete r[n.id],delete a[n.id]}return{bind:function(e,t){let n=t.program;i.uniformBlockBinding(e,n)},update:function(n,c){var h;let d,p,f,m,g=r[n.id];void 0===g&&(function(e){let t=e.uniforms,n=0;for(let e=0,i=t.length;e0&&(n+=16-i),e.__size=n,e.__cache={}}(n),(h=n).__bindingPointIndex=d=function(){for(let e=0;etypeof WebGLRenderingContext&&A instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");t=A.getContextAttributes().alpha}else t=P;const k=new Set([1033,1031,1029]),V=new Set([1009,1014,1012,1020,1017,1018]),H=new Uint32Array(4),G=new Int32Array(4);let j=null,X=null;const q=[],Y=[];let ee=null;this.domElement=E,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const et=this;let en=!1;this._outputColorSpace=I;let ei=0,er=0,ea=null,es=-1,eo=null;const el=new eI,eu=new eI;let ec=null;const eh=new tq(0);let ed=0,ep=E.width,em=E.height,eg=1,ev=null,e_=null;const ey=new eI(0,0,ep,em),ex=new eI(0,0,ep,em);let eS=!1;const eM=new iO;let eT=!1,ew=!1;const eE=new tt,eA=new ef,eC=new eI,eR={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let eP=!1;function eL(){return null===ea?eg:1}let eU=A;function eD(e,t){return E.getContext(e,t)}try{if("setAttribute"in E&&E.setAttribute("data-engine","three.js r182"),E.addEventListener("webglcontextlost",ez,!1),E.addEventListener("webglcontextrestored",eB,!1),E.addEventListener("webglcontextcreationerror",ek,!1),null===eU){const e="webgl2";if(eU=eD(e,{alpha:!0,depth:C,stencil:R,antialias:N,premultipliedAlpha:U,preserveDrawingBuffer:D,powerPreference:O,failIfMajorPerformanceCaveat:F}),null===eU)if(eD(e))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(e){throw K("WebGLRenderer: "+e.message),e}function eO(){(n=new lC(eU)).init(),M=new cd(eU,n),i=new lc(eU,n,e,M),r=new cc(eU,n),i.reversedDepthBuffer&&z&&r.buffers.depth.setReversed(!0),a=new lI(eU),s=new u2,o=new ch(eU,n,r,s,i,M,a),l=new ld(et),u=new lA(et),c=new le(eU),T=new ll(eU,c),h=new lR(eU,c,a,T),d=new lN(eU,h,c,a),x=new lL(eU,i,o),v=new lh(s),p=new u1(et,l,u,n,i,T,v),f=new cy(et,s),m=new u6,g=new cn(n),y=new lo(et,l,u,r,d,t,U),_=new cl(et,d,i),w=new cx(eU,a,i,r),b=new lu(eU,n,a),S=new lP(eU,n,a),a.programs=p.programs,et.capabilities=i,et.extensions=n,et.properties=s,et.renderLists=m,et.shadowMap=_,et.state=r,et.info=a}eO(),1009!==B&&(ee=new lD(B,E.width,E.height,C,R));const eF=new cg(et,eU);function ez(e){e.preventDefault(),Z("WebGLRenderer: Context Lost."),en=!0}function eB(){Z("WebGLRenderer: Context Restored."),en=!1;let e=a.autoReset,t=_.enabled,n=_.autoUpdate,i=_.needsUpdate,r=_.type;eO(),a.autoReset=e,_.enabled=t,_.autoUpdate=n,_.needsUpdate=i,_.type=r}function ek(e){K("WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function eV(e){var t,n;let i,r=e.target;r.removeEventListener("dispose",eV),n=t=r,void 0!==(i=s.get(n).programs)&&(i.forEach(function(e){p.releaseProgram(e)}),n.isShaderMaterial&&p.releaseShaderCache(n)),s.remove(t)}function eH(e,t,n){!0===e.transparent&&2===e.side&&!1===e.forceSinglePass?(e.side=1,e.needsUpdate=!0,e$(e,t,n),e.side=0,e.needsUpdate=!0,e$(e,t,n),e.side=2):e$(e,t,n)}this.xr=eF,this.getContext=function(){return eU},this.getContextAttributes=function(){return eU.getContextAttributes()},this.forceContextLoss=function(){let e=n.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){let e=n.get("WEBGL_lose_context");e&&e.restoreContext()},this.getPixelRatio=function(){return eg},this.setPixelRatio=function(e){void 0!==e&&(eg=e,this.setSize(ep,em,!1))},this.getSize=function(e){return e.set(ep,em)},this.setSize=function(e,t,n=!0){eF.isPresenting?J("WebGLRenderer: Can't change size while VR device is presenting."):(ep=e,em=t,E.width=Math.floor(e*eg),E.height=Math.floor(t*eg),!0===n&&(E.style.width=e+"px",E.style.height=t+"px"),null!==ee&&ee.setSize(E.width,E.height),this.setViewport(0,0,e,t))},this.getDrawingBufferSize=function(e){return e.set(ep*eg,em*eg).floor()},this.setDrawingBufferSize=function(e,t,n){ep=e,em=t,eg=n,E.width=Math.floor(e*n),E.height=Math.floor(t*n),this.setViewport(0,0,e,t)},this.setEffects=function(e){if(1009===B)return void console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");if(e){for(let t=0;tp.matrixWorld.determinant(),y=function(e,t,n,a,c){var h,d;!0!==t.isScene&&(t=eR),o.resetTextureUnits();let p=t.fog,m=a.isMeshStandardMaterial?t.environment:null,g=null===ea?et.outputColorSpace:!0===ea.isXRRenderTarget?ea.texture.colorSpace:L,_=(a.isMeshStandardMaterial?u:l).get(a.envMap||m),y=!0===a.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,b=!!n.attributes.tangent&&(!!a.normalMap||a.anisotropy>0),S=!!n.morphAttributes.position,M=!!n.morphAttributes.normal,T=!!n.morphAttributes.color,E=0;a.toneMapped&&(null===ea||!0===ea.isXRRenderTarget)&&(E=et.toneMapping);let A=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,C=void 0!==A?A.length:0,R=s.get(a),P=X.state.lights;if(!0===eT&&(!0===ew||e!==eo)){let t=e===eo&&a.id===es;v.setState(a,e,t)}let I=!1;a.version===R.__version?R.needsLights&&R.lightsStateVersion!==P.state.version||R.outputColorSpace!==g||c.isBatchedMesh&&!1===R.batching?I=!0:c.isBatchedMesh||!0!==R.batching?c.isBatchedMesh&&!0===R.batchingColor&&null===c.colorTexture||c.isBatchedMesh&&!1===R.batchingColor&&null!==c.colorTexture||c.isInstancedMesh&&!1===R.instancing?I=!0:c.isInstancedMesh||!0!==R.instancing?c.isSkinnedMesh&&!1===R.skinning?I=!0:c.isSkinnedMesh||!0!==R.skinning?c.isInstancedMesh&&!0===R.instancingColor&&null===c.instanceColor||c.isInstancedMesh&&!1===R.instancingColor&&null!==c.instanceColor||c.isInstancedMesh&&!0===R.instancingMorph&&null===c.morphTexture||c.isInstancedMesh&&!1===R.instancingMorph&&null!==c.morphTexture||R.envMap!==_||!0===a.fog&&R.fog!==p||void 0!==R.numClippingPlanes&&(R.numClippingPlanes!==v.numPlanes||R.numIntersection!==v.numIntersection)||R.vertexAlphas!==y||R.vertexTangents!==b||R.morphTargets!==S||R.morphNormals!==M||R.morphColors!==T||R.toneMapping!==E?I=!0:R.morphTargetsCount!==C&&(I=!0):I=!0:I=!0:I=!0:(I=!0,R.__version=a.version);let N=R.currentProgram;!0===I&&(N=e$(a,t,c));let U=!1,D=!1,O=!1,F=N.getUniforms(),z=R.uniforms;if(r.useProgram(N.program)&&(U=!0,D=!0,O=!0),a.id!==es&&(es=a.id,D=!0),U||eo!==e){r.buffers.depth.getReversed()&&!0!==e.reversedDepth&&(e._reversedDepth=!0,e.updateProjectionMatrix()),F.setValue(eU,"projectionMatrix",e.projectionMatrix),F.setValue(eU,"viewMatrix",e.matrixWorldInverse);let t=F.map.cameraPosition;void 0!==t&&t.setValue(eU,eA.setFromMatrixPosition(e.matrixWorld)),i.logarithmicDepthBuffer&&F.setValue(eU,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)&&F.setValue(eU,"isOrthographic",!0===e.isOrthographicCamera),eo!==e&&(eo=e,D=!0,O=!0)}if(R.needsLights&&(P.state.directionalShadowMap.length>0&&F.setValue(eU,"directionalShadowMap",P.state.directionalShadowMap,o),P.state.spotShadowMap.length>0&&F.setValue(eU,"spotShadowMap",P.state.spotShadowMap,o),P.state.pointShadowMap.length>0&&F.setValue(eU,"pointShadowMap",P.state.pointShadowMap,o)),c.isSkinnedMesh){F.setOptional(eU,c,"bindMatrix"),F.setOptional(eU,c,"bindMatrixInverse");let e=c.skeleton;e&&(null===e.boneTexture&&e.computeBoneTexture(),F.setValue(eU,"boneTexture",e.boneTexture,o))}c.isBatchedMesh&&(F.setOptional(eU,c,"batchingTexture"),F.setValue(eU,"batchingTexture",c._matricesTexture,o),F.setOptional(eU,c,"batchingIdTexture"),F.setValue(eU,"batchingIdTexture",c._indirectTexture,o),F.setOptional(eU,c,"batchingColorTexture"),null!==c._colorsTexture&&F.setValue(eU,"batchingColorTexture",c._colorsTexture,o));let B=n.morphAttributes;if((void 0!==B.position||void 0!==B.normal||void 0!==B.color)&&x.update(c,n,N),(D||R.receiveShadow!==c.receiveShadow)&&(R.receiveShadow=c.receiveShadow,F.setValue(eU,"receiveShadow",c.receiveShadow)),a.isMeshGouraudMaterial&&null!==a.envMap&&(z.envMap.value=_,z.flipEnvMap.value=_.isCubeTexture&&!1===_.isRenderTargetTexture?-1:1),a.isMeshStandardMaterial&&null===a.envMap&&null!==t.environment&&(z.envMapIntensity.value=t.environmentIntensity),void 0!==z.dfgLUT&&(z.dfgLUT.value=(null===cS&&((cS=new ig(cb,16,16,1030,1016)).name="DFG_LUT",cS.minFilter=1006,cS.magFilter=1006,cS.wrapS=1001,cS.wrapT=1001,cS.generateMipmaps=!1,cS.needsUpdate=!0),cS)),D&&(F.setValue(eU,"toneMappingExposure",et.toneMappingExposure),R.needsLights&&(h=z,d=O,h.ambientLightColor.needsUpdate=d,h.lightProbe.needsUpdate=d,h.directionalLights.needsUpdate=d,h.directionalLightShadows.needsUpdate=d,h.pointLights.needsUpdate=d,h.pointLightShadows.needsUpdate=d,h.spotLights.needsUpdate=d,h.spotLightShadows.needsUpdate=d,h.rectAreaLights.needsUpdate=d,h.hemisphereLights.needsUpdate=d),p&&!0===a.fog&&f.refreshFogUniforms(z,p),f.refreshMaterialUniforms(z,a,eg,em,X.state.transmissionRenderTarget[e.id]),uR.upload(eU,eQ(R),z,o)),a.isShaderMaterial&&!0===a.uniformsNeedUpdate&&(uR.upload(eU,eQ(R),z,o),a.uniformsNeedUpdate=!1),a.isSpriteMaterial&&F.setValue(eU,"center",c.center),F.setValue(eU,"modelViewMatrix",c.modelViewMatrix),F.setValue(eU,"normalMatrix",c.normalMatrix),F.setValue(eU,"modelMatrix",c.matrixWorld),a.isShaderMaterial||a.isRawShaderMaterial){let e=a.uniformsGroups;for(let t=0,n=e.length;t{function i(){(r.forEach(function(e){s.get(e).currentProgram.isReady()&&r.delete(e)}),0===r.size)?t(e):setTimeout(i,10)}null!==n.get("KHR_parallel_shader_compile")?i():setTimeout(i,10)})};let eG=null;function eW(){eX.stop()}function ej(){eX.start()}const eX=new o7;function eq(e,t,n,i){if(!1===e.visible)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)X.pushLight(e),e.castShadow&&X.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||eM.intersectsSprite(e)){i&&eC.setFromMatrixPosition(e.matrixWorld).applyMatrix4(eE);let t=d.update(e),r=e.material;r.visible&&j.push(e,t,r,n,eC.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||eM.intersectsObject(e))){let t=d.update(e),r=e.material;if(i&&(void 0!==e.boundingSphere?(null===e.boundingSphere&&e.computeBoundingSphere(),eC.copy(e.boundingSphere.center)):(null===t.boundingSphere&&t.computeBoundingSphere(),eC.copy(t.boundingSphere.center)),eC.applyMatrix4(e.matrixWorld).applyMatrix4(eE)),Array.isArray(r)){let i=t.groups;for(let a=0,s=i.length;a0&&eJ(a,t,n),s.length>0&&eJ(s,t,n),o.length>0&&eJ(o,t,n),r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),r.setPolygonOffset(!1)}function eZ(e,t,r,a){if(null!==(!0===r.isScene?r.overrideMaterial:null))return;if(void 0===X.state.transmissionRenderTarget[a.id]){let e=n.has("EXT_color_buffer_half_float")||n.has("EXT_color_buffer_float");X.state.transmissionRenderTarget[a.id]=new eN(1,1,{generateMipmaps:!0,type:e?1016:1009,minFilter:1008,samples:i.samples,stencilBuffer:R,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:eb.workingColorSpace})}let s=X.state.transmissionRenderTarget[a.id],l=a.viewport||el;s.setSize(l.z*et.transmissionResolutionScale,l.w*et.transmissionResolutionScale);let u=et.getRenderTarget(),c=et.getActiveCubeFace(),h=et.getActiveMipmapLevel();et.setRenderTarget(s),et.getClearColor(eh),(ed=et.getClearAlpha())<1&&et.setClearColor(0xffffff,.5),et.clear(),eP&&y.render(r);let d=et.toneMapping;et.toneMapping=0;let p=a.viewport;if(void 0!==a.viewport&&(a.viewport=void 0),X.setupLightsView(a),!0===eT&&v.setGlobalState(et.clippingPlanes,a),eJ(e,r,a),o.updateMultisampleRenderTarget(s),o.updateRenderTargetMipmap(s),!1===n.has("WEBGL_multisampled_render_to_texture")){let e=!1;for(let n=0,i=t.length;ntypeof self&&eX.setContext(self),this.setAnimationLoop=function(e){eG=e,eF.setAnimationLoop(e),null===e?eX.stop():eX.start()},eF.addEventListener("sessionstart",eW),eF.addEventListener("sessionend",ej),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void K("WebGLRenderer.render: camera is not an instance of THREE.Camera.");if(!0===en)return;let n=!0===eF.enabled&&!0===eF.isPresenting,i=null!==ee&&(null===ea||n)&&ee.begin(et,ea);if(!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===eF.enabled&&!0===eF.isPresenting&&(null===ee||!1===ee.isCompositing())&&(!0===eF.cameraAutoUpdate&&eF.updateCamera(t),t=eF.getCamera()),!0===e.isScene&&e.onBeforeRender(et,e,t,ea),(X=g.get(e,Y.length)).init(t),Y.push(X),eE.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),eM.setFromProjectionMatrix(eE,2e3,t.reversedDepth),ew=this.localClippingEnabled,eT=v.init(this.clippingPlanes,ew),(j=m.get(e,q.length)).init(),q.push(j),!0===eF.enabled&&!0===eF.isPresenting){let e=et.xr.getDepthSensingMesh();null!==e&&eq(e,t,-1/0,et.sortObjects)}eq(e,t,0,et.sortObjects),j.finish(),!0===et.sortObjects&&j.sort(ev,e_),(eP=!1===eF.enabled||!1===eF.isPresenting||!1===eF.hasDepthSensing())&&y.addToRenderList(j,e),this.info.render.frame++,!0===eT&&v.beginShadows();let r=X.state.shadowsArray;if(_.render(r,e,t),!0===eT&&v.endShadows(),!0===this.info.autoReset&&this.info.reset(),!1===(i&&ee.hasRenderPass())){let n=j.opaque,i=j.transmissive;if(X.setupLights(),t.isArrayCamera){let r=t.cameras;if(i.length>0)for(let t=0,a=r.length;t0&&eZ(n,i,e,t),eP&&y.render(e),eY(j,e,t)}null!==ea&&0===er&&(o.updateMultisampleRenderTarget(ea),o.updateRenderTargetMipmap(ea)),i&&ee.end(et),!0===e.isScene&&e.onAfterRender(et,e,t),T.resetDefaultState(),es=-1,eo=null,Y.pop(),Y.length>0?(X=Y[Y.length-1],!0===eT&&v.setGlobalState(et.clippingPlanes,X.state.camera)):X=null,q.pop(),j=q.length>0?q[q.length-1]:null},this.getActiveCubeFace=function(){return ei},this.getActiveMipmapLevel=function(){return er},this.getRenderTarget=function(){return ea},this.setRenderTargetTextures=function(e,t,n){let i=s.get(e);i.__autoAllocateDepthBuffer=!1===e.resolveDepthBuffer,!1===i.__autoAllocateDepthBuffer&&(i.__useRenderToTexture=!1),s.get(e.texture).__webglTexture=t,s.get(e.depthTexture).__webglTexture=i.__autoAllocateDepthBuffer?void 0:n,i.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=s.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t};const e1=eU.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){ea=e,ei=t,er=n;let i=null,a=!1,l=!1;if(e){let u=s.get(e);if(void 0!==u.__useDefaultFramebuffer){r.bindFramebuffer(eU.FRAMEBUFFER,u.__webglFramebuffer),el.copy(e.viewport),eu.copy(e.scissor),ec=e.scissorTest,r.viewport(el),r.scissor(eu),r.setScissorTest(ec),es=-1;return}if(void 0===u.__webglFramebuffer)o.setupRenderTarget(e);else if(u.__hasExternalTextures)o.rebindTextures(e,s.get(e.texture).__webglTexture,s.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(u.__boundDepthTexture!==t){if(null!==t&&s.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");o.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(l=!0);let h=s.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(h[t])?h[t][n]:h[t],a=!0):i=e.samples>0&&!1===o.useMultisampledRTT(e)?s.get(e).__webglMultisampledFramebuffer:Array.isArray(h)?h[n]:h,el.copy(e.viewport),eu.copy(e.scissor),ec=e.scissorTest}else el.copy(ey).multiplyScalar(eg).floor(),eu.copy(ex).multiplyScalar(eg).floor(),ec=eS;if(0!==n&&(i=e1),r.bindFramebuffer(eU.FRAMEBUFFER,i)&&r.drawBuffers(e,i),r.viewport(el),r.scissor(eu),r.setScissorTest(ec),a){let i=s.get(e.texture);eU.framebufferTexture2D(eU.FRAMEBUFFER,eU.COLOR_ATTACHMENT0,eU.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(l)for(let i=0;i=0&&t<=e.width-a&&n>=0&&n<=e.height-o&&(e.textures.length>1&&eU.readBuffer(eU.COLOR_ATTACHMENT0+c),eU.readPixels(t,n,a,o,M.convert(s),M.convert(u),l))}finally{let e=null!==ea?s.get(ea).__webglFramebuffer:null;r.bindFramebuffer(eU.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,a,o,l,u,c=0){if(!(e&&e.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let h=s.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==u&&(h=h[u]),h)if(t>=0&&t<=e.width-a&&n>=0&&n<=e.height-o){r.bindFramebuffer(eU.FRAMEBUFFER,h);let u=e.textures[c],d=u.format,p=u.type;if(!i.textureFormatReadable(d))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!i.textureTypeReadable(p))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let f=eU.createBuffer();eU.bindBuffer(eU.PIXEL_PACK_BUFFER,f),eU.bufferData(eU.PIXEL_PACK_BUFFER,l.byteLength,eU.STREAM_READ),e.textures.length>1&&eU.readBuffer(eU.COLOR_ATTACHMENT0+c),eU.readPixels(t,n,a,o,M.convert(d),M.convert(p),0);let m=null!==ea?s.get(ea).__webglFramebuffer:null;r.bindFramebuffer(eU.FRAMEBUFFER,m);let g=eU.fenceSync(eU.SYNC_GPU_COMMANDS_COMPLETE,0);return eU.flush(),await Q(eU,g,4),eU.bindBuffer(eU.PIXEL_PACK_BUFFER,f),eU.getBufferSubData(eU.PIXEL_PACK_BUFFER,0,l),eU.deleteBuffer(f),eU.deleteSync(g),l}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(e,t=null,n=0){let i=Math.pow(2,-n),a=Math.floor(e.image.width*i),s=Math.floor(e.image.height*i),l=null!==t?t.x:0,u=null!==t?t.y:0;o.setTexture2D(e,0),eU.copyTexSubImage2D(eU.TEXTURE_2D,n,0,0,l,u,a,s),r.unbindTexture()};const e2=eU.createFramebuffer(),e3=eU.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,i=null,a=0,l=null){let u,c,h,d,p,f,m,g,v,_;null===l&&(0!==a?($("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),l=a,a=0):l=0);let y=e.isCompressedTexture?e.mipmaps[l]:e.image;if(null!==n)u=n.max.x-n.min.x,c=n.max.y-n.min.y,h=n.isBox3?n.max.z-n.min.z:1,d=n.min.x,p=n.min.y,f=n.isBox3?n.min.z:0;else{let t=Math.pow(2,-a);u=Math.floor(y.width*t),c=Math.floor(y.height*t),h=e.isDataArrayTexture?y.depth:e.isData3DTexture?Math.floor(y.depth*t):1,d=0,p=0,f=0}null!==i?(m=i.x,g=i.y,v=i.z):(m=0,g=0,v=0);let x=M.convert(t.format),b=M.convert(t.type);t.isData3DTexture?(o.setTexture3D(t,0),_=eU.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(o.setTexture2DArray(t,0),_=eU.TEXTURE_2D_ARRAY):(o.setTexture2D(t,0),_=eU.TEXTURE_2D),eU.pixelStorei(eU.UNPACK_FLIP_Y_WEBGL,t.flipY),eU.pixelStorei(eU.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),eU.pixelStorei(eU.UNPACK_ALIGNMENT,t.unpackAlignment);let S=eU.getParameter(eU.UNPACK_ROW_LENGTH),T=eU.getParameter(eU.UNPACK_IMAGE_HEIGHT),w=eU.getParameter(eU.UNPACK_SKIP_PIXELS),E=eU.getParameter(eU.UNPACK_SKIP_ROWS),A=eU.getParameter(eU.UNPACK_SKIP_IMAGES);eU.pixelStorei(eU.UNPACK_ROW_LENGTH,y.width),eU.pixelStorei(eU.UNPACK_IMAGE_HEIGHT,y.height),eU.pixelStorei(eU.UNPACK_SKIP_PIXELS,d),eU.pixelStorei(eU.UNPACK_SKIP_ROWS,p),eU.pixelStorei(eU.UNPACK_SKIP_IMAGES,f);let C=e.isDataArrayTexture||e.isData3DTexture,R=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=s.get(e),i=s.get(t),o=s.get(n.__renderTarget),_=s.get(i.__renderTarget);r.bindFramebuffer(eU.READ_FRAMEBUFFER,o.__webglFramebuffer),r.bindFramebuffer(eU.DRAW_FRAMEBUFFER,_.__webglFramebuffer);for(let n=0;ntypeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return 2e3}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=eb._getDrawingBufferColorSpace(e),t.unpackColorSpace=eb._getUnpackColorSpace()}}e.s(["PMREMGenerator",()=>lb,"ShaderChunk",()=>lt,"ShaderLib",()=>li,"UniformsLib",()=>ln,"WebGLRenderer",()=>cM,"WebGLUtils",()=>cd],8560);var cT=e.i(66748);let cw=[];function cE(e,t,n=(e,t)=>e===t){if(e===t)return!0;if(!e||!t)return!1;let i=e.length;if(t.length!==i)return!1;for(let r=0;r0&&(r.timeout&&clearTimeout(r.timeout),r.timeout=setTimeout(r.remove,i.lifespan)),r.response;if(!n)throw r.promise}let r={keys:t,equal:i.equal,remove:()=>{let e=cw.indexOf(r);-1!==e&&cw.splice(e,1)},promise:("object"==typeof e&&"function"==typeof e.then?e:e(...t)).then(e=>{r.response=e,i.lifespan&&i.lifespan>0&&(r.timeout=setTimeout(r.remove,i.lifespan))}).catch(e=>r.error=e)};if(cw.push(r),!n)throw r.promise}var cC=e.i(89499),cR=e.i(43476),cP=E;function cI(e,t,n){if(!e)return;if(!0===n(e))return e;let i=t?e.return:e.child;for(;i;){let e=cI(i,t,n);if(e)return e;i=t?null:i.sibling}}function cL(e){try{return Object.defineProperties(e,{_currentRenderer:{get:()=>null,set(){}},_currentRenderer2:{get:()=>null,set(){}}})}catch(t){return e}}"u">typeof window&&((null==(y=window.document)?void 0:y.createElement)||(null==(x=window.navigator)?void 0:x.product)==="ReactNative")?cP.useLayoutEffect:cP.useEffect;let cN=cL(cP.createContext(null));class cU extends cP.Component{render(){return cP.createElement(cN.Provider,{value:this._reactInternals},this.props.children)}}function cD(){let e=cP.useContext(cN);if(null===e)throw Error("its-fine: useFiber must be called within a !");let t=cP.useId();return cP.useMemo(()=>{for(let n of[e,null==e?void 0:e.alternate]){if(!n)continue;let e=cI(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}let cO=Symbol.for("react.context"),cF=e=>null!==e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===cO;function cz(){let e=function(){let e=cD(),[t]=cP.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;cF(e)&&e!==cN&&!t.has(e)&&t.set(e,cP.use(cL(e))),n=n.return}return t}();return cP.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>i=>cP.createElement(t,null,cP.createElement(n.Provider,{...i,value:e.get(n)})),e=>cP.createElement(cU,{...e})),[e])}function cB(e){let t=e.root;for(;t.getState().previousRoot;)t=t.getState().previousRoot;return t}e.s(["FiberProvider",()=>cU,"traverseFiber",()=>cI,"useContextBridge",()=>cz,"useFiber",()=>cD],46791),E.act;let ck=e=>e&&e.hasOwnProperty("current"),cV=e=>null!=e&&("string"==typeof e||"number"==typeof e||e.isColor),cH="u">typeof window&&((null==(m=window.document)?void 0:m.createElement)||(null==(g=window.navigator)?void 0:g.product)==="ReactNative")?E.useLayoutEffect:E.useEffect;function cG(e){let t=E.useRef(e);return cH(()=>void(t.current=e),[e]),t}function cW(){let e=cD(),t=cz();return E.useMemo(()=>({children:n})=>{let i=cI(e,!0,e=>e.type===E.StrictMode)?E.StrictMode:E.Fragment;return(0,cR.jsx)(i,{children:(0,cR.jsx)(t,{children:n})})},[e,t])}function cj({set:e}){return cH(()=>(e(new Promise(()=>null)),()=>e(!1)),[e]),null}let cX=((v=class extends E.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}).getDerivedStateFromError=()=>({error:!0}),v);function cq(e){var t;let n="u">typeof window?null!=(t=window.devicePixelRatio)?t:2:1;return Array.isArray(e)?Math.min(Math.max(e[0],n),e[1]):e}function cY(e){var t;return null==(t=e.__r3f)?void 0:t.root.getState()}let cZ={obj:e=>e===Object(e)&&!cZ.arr(e)&&"function"!=typeof e,fun:e=>"function"==typeof e,str:e=>"string"==typeof e,num:e=>"number"==typeof e,boo:e=>"boolean"==typeof e,und:e=>void 0===e,nul:e=>null===e,arr:e=>Array.isArray(e),equ(e,t,{arrays:n="shallow",objects:i="reference",strict:r=!0}={}){let a;if(typeof e!=typeof t||!!e!=!!t)return!1;if(cZ.str(e)||cZ.num(e)||cZ.boo(e))return e===t;let s=cZ.obj(e);if(s&&"reference"===i)return e===t;let o=cZ.arr(e);if(o&&"reference"===n)return e===t;if((o||s)&&e===t)return!0;for(a in e)if(!(a in t))return!1;if(s&&"shallow"===n&&"shallow"===i){for(a in r?t:e)if(!cZ.equ(e[a],t[a],{strict:r,objects:"reference"}))return!1}else for(a in r?t:e)if(e[a]!==t[a])return!1;if(cZ.und(a)){if(o&&0===e.length&&0===t.length||s&&0===Object.keys(e).length&&0===Object.keys(t).length)return!0;if(e!==t)return!1}return!0}},cJ=["children","key","ref"];function cK(e,t,n,i){let r=null==e?void 0:e.__r3f;return!r&&(r={root:t,type:n,parent:null,children:[],props:function(e){let t={};for(let n in e)cJ.includes(n)||(t[n]=e[n]);return t}(i),object:e,eventCount:0,handlers:{},isHidden:!1},e&&(e.__r3f=r)),r}function c$(e,t){if(!t.includes("-")||t in e)return{root:e,key:t,target:e[t]};let n=e,i=t.split("-");for(let r of i){if("object"!=typeof n||null===n){if(void 0!==n)return{root:n,key:i.slice(i.indexOf(r)).join("-"),target:void 0};return{root:e,key:t,target:void 0}}t=r,e=n,n=n[t]}return{root:e,key:t,target:n}}let cQ=/-\d+$/;function c0(e,t){if(cZ.str(t.props.attach)){if(cQ.test(t.props.attach)){let n=t.props.attach.replace(cQ,""),{root:i,key:r}=c$(e.object,n);Array.isArray(i[r])||(i[r]=[])}let{root:n,key:i}=c$(e.object,t.props.attach);t.previousAttach=n[i],n[i]=t.object}else cZ.fun(t.props.attach)&&(t.previousAttach=t.props.attach(e.object,t.object))}function c1(e,t){if(cZ.str(t.props.attach)){let{root:n,key:i}=c$(e.object,t.props.attach),r=t.previousAttach;void 0===r?delete n[i]:n[i]=r}else null==t.previousAttach||t.previousAttach(e.object,t.object);delete t.previousAttach}let c2=[...cJ,"args","dispose","attach","object","onUpdate","dispose"],c3=new Map,c4=["map","emissiveMap","sheenColorMap","specularColorMap","envMap"],c5=/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/;function c6(e,t){var n,i;let r=e.__r3f,a=r&&cB(r).getState(),s=null==r?void 0:r.eventCount;for(let n in t){let s=t[n];if(c2.includes(n))continue;if(r&&c5.test(n)){"function"==typeof s?r.handlers[n]=s:delete r.handlers[n],r.eventCount=Object.keys(r.handlers).length;continue}if(void 0===s)continue;let{root:o,key:l,target:u}=c$(e,n);if(void 0===u&&("object"!=typeof o||null===o))throw Error(`R3F: Cannot set "${n}". Ensure it is an object before setting "${l}".`);u instanceof td&&s instanceof td?u.mask=s.mask:u instanceof tq&&cV(s)?u.set(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"function"==typeof u.copy&&null!=s&&s.constructor&&u.constructor===s.constructor?u.copy(s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&Array.isArray(s)?"function"==typeof u.fromArray?u.fromArray(s):u.set(...s):null!==u&&"object"==typeof u&&"function"==typeof u.set&&"number"==typeof s?"function"==typeof u.setScalar?u.setScalar(s):u.set(s):(o[l]=s,a&&!a.linear&&c4.includes(l)&&null!=(i=o[l])&&i.isTexture&&1023===o[l].format&&1009===o[l].type&&(o[l].colorSpace=I))}if(null!=r&&r.parent&&null!=a&&a.internal&&null!=(n=r.object)&&n.isObject3D&&s!==r.eventCount){let e=r.object,t=a.internal.interaction.indexOf(e);t>-1&&a.internal.interaction.splice(t,1),r.eventCount&&null!==e.raycast&&a.internal.interaction.push(e)}return r&&void 0===r.props.attach&&(r.object.isBufferGeometry?r.props.attach="geometry":r.object.isMaterial&&(r.props.attach="material")),r&&c8(r),e}function c8(e){var t;if(!e.parent)return;null==e.props.onUpdate||e.props.onUpdate(e.object);let n=null==(t=e.root)||null==t.getState?void 0:t.getState();n&&0===n.internal.frames&&n.invalidate()}let c9=e=>null==e?void 0:e.isObject3D;function c7(e){return(e.eventObject||e.object).uuid+"/"+e.index+e.instanceId}function he(e,t,n,i){let r=n.get(t);r&&(n.delete(t),0===n.size&&(e.delete(i),r.target.releasePointerCapture(i)))}let ht=e=>!!(null!=e&&e.render),hn=E.createContext(null);function hi(){let e=E.useContext(hn);if(!e)throw Error("R3F: Hooks can only be used within the Canvas component!");return e}function hr(e=e=>e,t){return hi()(e,t)}function ha(e,t=0){let n=hi(),i=n.getState().internal.subscribe,r=cG(e);return cH(()=>i(r,t,n),[t,i,n]),null}let hs=new WeakMap;function ho(e,t){return function(n,...i){var r;let a;return"function"==typeof n&&(null==n||null==(r=n.prototype)?void 0:r.constructor)===n?(a=hs.get(n))||(a=new n,hs.set(n,a)):a=n,e&&e(a),Promise.all(i.map(e=>new Promise((n,i)=>a.load(e,e=>{var t;let i;c9(null==e?void 0:e.scene)&&Object.assign(e,(t=e.scene,i={nodes:{},materials:{},meshes:{}},t&&t.traverse(e=>{e.name&&(i.nodes[e.name]=e),e.material&&!i.materials[e.material.name]&&(i.materials[e.material.name]=e.material),e.isMesh&&!i.meshes[e.name]&&(i.meshes[e.name]=e)}),i)),n(e)},t,t=>i(Error(`Could not load ${e}: ${null==t?void 0:t.message}`))))))}}function hl(e,t,n,i){let r=Array.isArray(t)?t:[t],a=cA(ho(n,i),[e,...r],!1,{equal:cZ.equ});return Array.isArray(t)?a:a[0]}hl.preload=function(e,t,n){let i,r=Array.isArray(t)?t:[t];cA(ho(n),[e,...r],!0,i)},hl.clear=function(e,t){var n=[e,...Array.isArray(t)?t:[t]];if(void 0===n||0===n.length)cw.splice(0,cw.length);else{let e=cw.find(e=>cE(n,e.keys,e.equal));e&&e.remove()}};var hu={exports:{}},hc={exports:{}};hc.exports;let hh=(T||(T=1,M||(M=1,hc.exports=function(e){function t(e,t,n,i){return new iJ(e,t,n,i)}function n(){}function i(e){var t="https://react.dev/errors/"+e;if(1sT||(e.current=sM[sT],sM[sT]=null,sT--)}function h(e,t){sM[++sT]=e.current,e.current=t}function d(e){var t=42&e;if(0!==t)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return 261888&e;case 262144:case 524288:case 1048576:case 2097152:return 3932160&e;case 4194304:case 8388608:case 0x1000000:case 0x2000000:return 0x3c00000&e;case 0x4000000:return 0x4000000;case 0x8000000:return 0x8000000;case 0x10000000:return 0x10000000;case 0x20000000:return 0x20000000;case 0x40000000:return 0;default:return e}}function p(e,t,n){var i=e.pendingLanes;if(0===i)return 0;var r=0,a=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var o=0x7ffffff&i;return 0!==o?0!=(i=o&~a)?r=d(i):0!=(s&=o)?r=d(s):n||0!=(n=o&~e)&&(r=d(n)):0!=(o=i&~a)?r=d(o):0!==s?r=d(s):n||0!=(n=i&~e)&&(r=d(n)),0===r?0:0!==t&&t!==r&&(t&a)==0&&((a=r&-r)>=(n=t&-t)||32===a&&(4194048&n)!=0)?t:r}function f(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)==0}function m(){var e=sI;return(0x3c00000&(sI<<=1))==0&&(sI=4194304),e}function g(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function v(e,t){e.pendingLanes|=t,0x10000000!==t&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function _(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var i=31-sE(t);e.entangledLanes|=t,e.entanglements[i]=0x40000000|e.entanglements[i]|261930&n}function y(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var i=31-sE(n),r=1<)":-1r||l[i]!==u[r]){var c=` +`+l[i].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=i&&0<=r)break}}}finally{sY=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?T(n):""}function C(e){try{var t="",n=null;do t+=function(e,t){switch(e.tag){case 26:case 27:case 5:return T(e.type);case 16:return T("Lazy");case 13:return e.child!==t&&null!==t?T("Suspense Fallback"):T("Suspense");case 19:return T("SuspenseList");case 0:case 15:return A(e.type,!1);case 11:return A(e.type.render,!1);case 1:return A(e.type,!0);case 31:return T("Activity");default:return""}}(e,n),n=e,e=e.return;while(e)return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}function R(e,t){if("object"==typeof e&&null!==e){var n=sZ.get(e);return void 0!==n?n:(t={value:e,source:t,stack:C(t)},sZ.set(e,t),t)}return{value:e,source:t,stack:C(t)}}function P(e,t){sJ[sK++]=sQ,sJ[sK++]=s$,s$=e,sQ=t}function I(e,t,n){s0[s1++]=s3,s0[s1++]=s4,s0[s1++]=s2,s2=e;var i=s3;e=s4;var r=32-sE(i)-1;i&=~(1<>=s,r-=s,s3=1<<32-sE(t)+r|n<d?(p=h,h=null):p=h.sibling;var v=m(t,h,s[d],o);if(null===v){null===h&&(h=p);break}e&&h&&null===v.alternate&&n(t,h),i=l(v,i,d),null===c?u=v:c.sibling=v,c=v,h=p}if(d===s.length)return r(t,h),ot&&P(t,d),u;if(null===h){for(;dp?(v=d,d=null):v=d.sibling;var y=m(t,d,_.value,u);if(null===y){null===d&&(d=v);break}e&&d&&null===y.alternate&&n(t,d),s=l(y,s,p),null===h?c=y:h.sibling=y,h=y,d=v}if(_.done)return r(t,d),ot&&P(t,p),c;if(null===d){for(;!_.done;p++,_=o.next())null!==(_=f(t,_.value,u))&&(s=l(_,s,p),null===h?c=_:h.sibling=_,h=_);return ot&&P(t,p),c}for(d=a(d);!_.done;p++,_=o.next())null!==(_=g(d,t,p,_.value,u))&&(e&&null!==_.alternate&&d.delete(null===_.key?p:_.key),s=l(_,s,p),null===h?c=_:h.sibling=_,h=_);return e&&d.forEach(function(e){return n(t,e)}),ot&&P(t,p),c}(c,h,d=v.call(d),p)}if("function"==typeof d.then)return t(c,h,eM(d),p);if(d.$$typeof===rd)return t(c,h,ee(c,d),p);ew(c,d)}return"string"==typeof d&&""!==d||"number"==typeof d||"bigint"==typeof d?(d=""+d,null!==h&&6===h.tag?(r(c,h.sibling),(p=s(h,d)).return=c):(r(c,h),(p=i2(d,c.mode,p)).return=c),u(c=p)):r(c,h)}(c,h,d,p);return oR=null,v}catch(e){if(e===oT||e===oE)throw e;var _=t(29,e,null,c.mode);return _.lanes=p,_.return=c,_}finally{}}}function eA(){for(var e=oU,t=oD=oU=0;ta?a:8);var s=rM.T,o={};rM.T=o,t$(e,!1,t,n);try{var l=r(),u=rM.S;if(null!==u&&u(o,l),null!==l&&"object"==typeof l&&"function"==typeof l.then){var c,h,d=(c=[],h={status:"pending",value:null,reason:null,then:function(e){c.push(e)}},l.then(function(){h.status="fulfilled",h.value=i;for(var e=0;e";case lu:return":has("+(id(e)||"")+")";case lc:return'[role="'+e.value+'"]';case ld:return'"'+e.value+'"';case lh:return'[data-testname="'+e.value+'"]';default:throw Error(i(365))}}function ip(e,t){var n=[];e=[e,0];for(var i=0;ilO&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304)}else{if(!a)if(null!==(e=eK(s))){if(t.flags|=128,a=!0,t.updateQueue=e=e.updateQueue,nD(t,e),nO(r,!0),null===r.tail&&"hidden"===r.tailMode&&!s.alternate&&!ot)return nF(t),null}else 2*sO()-r.renderingStartTime>lO&&0x20000000!==n&&(t.flags|=128,a=!0,nO(r,!1),t.lanes=4194304);r.isBackwards?(s.sibling=t.child,t.child=s):(null!==(e=r.last)?e.sibling=s:t.child=s,r.last=s)}return null!==r.tail?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=sO(),e.sibling=null,n=oH.current,h(oH,a?1&n|2:1&n),ot&&P(t,r.treeForkCount),e):(nF(t),null);case 22:case 23:return eJ(t),ej(),r=null!==t.memoizedState,null!==e?null!==e.memoizedState!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(0x20000000&n)!=0&&(128&t.flags)==0&&(nF(t),6&t.subtreeFlags&&(t.flags|=8192)):nF(t),null!==(n=t.updateQueue)&&nD(t,n.retryQueue),n=null,null!==e&&null!==e.memoizedState&&null!==e.memoizedState.cachePool&&(n=e.memoizedState.cachePool.pool),r=null,null!==t.memoizedState&&null!==t.memoizedState.cachePool&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),null!==e&&c(oM),null;case 24:return n=null,null!==e&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),q(oh),nF(t),null;case 25:case 30:return null}throw Error(i(156,t.tag))}(t.alternate,t,lT);if(null!==n){lv=n;return}if(null!==(t=t.sibling)){lv=t;return}lv=t=e}while(null!==t)0===lw&&(lw=5)}function iD(e,t){do{var n=function(e,t){switch(N(t),t.tag){case 1:return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return q(oh),O(),(65536&(e=t.flags))!=0&&(128&e)==0?(t.flags=-65537&e|128,t):null;case 26:case 27:case 5:return z(t),null;case 31:if(null!==t.memoizedState){if(eJ(t),null===t.alternate)throw Error(i(340));G()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 13:if(eJ(t),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));G()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return c(oH),null;case 4:return O(),null;case 10:return q(t.type),null;case 22:case 23:return eJ(t),ej(),null!==e&&c(oM),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 24:return q(oh),null;default:return null}}(e.alternate,e);if(null!==n){n.flags&=32767,lv=n;return}if(null!==(n=e.return)&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&null!==(e=e.sibling)){lv=e;return}lv=e=n}while(null!==e)lw=6,lv=null}function iO(e,t,n,r,a,s,o,l,u){e.cancelPendingCommit=null;do iV();while(0!==lB)if((6&lm)!=0)throw Error(i(327));if(null!==t){if(t===e.current)throw Error(i(177));if(function(e,t,n,i,r,a){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var o=e.entanglements,l=e.expirationTimes,u=e.hiddenUpdates;for(n=s&~n;0n?32:n;n=rM.T;var a=rq();try{rX(r),rM.T=null,r=lW,lW=null;var s=lk,o=lH;if(lB=0,lV=lk=null,lH=0,(6&lm)!=0)throw Error(i(331));var l=lm;if(lm|=4,il(s.current),it(s,s.current,o,r),lm=l,es(0,!1),sW&&"function"==typeof sW.onPostCommitFiberRoot)try{sW.onPostCommitFiberRoot(sG,s)}catch{}return!0}finally{rX(a),rM.T=n,ik(e,t)}}function iG(e,t,n){t=R(n,t),t=t9(e.stateNode,t,2),null!==(e=eO(e,t,2))&&(v(e,2),ea(e))}function iW(e,t,n){if(3===e.tag)iG(e,e,n);else for(;null!==t;){if(3===t.tag){iG(t,e,n);break}if(1===t.tag){var i=t.stateNode;if("function"==typeof t.type.getDerivedStateFromError||"function"==typeof i.componentDidCatch&&(null===lz||!lz.has(i))){e=R(n,e),null!==(i=eO(t,n=t7(2),2))&&(ne(n,i,t,e),v(i,2),ea(i));break}}t=t.return}}function ij(e,t,n){var i=e.pingCache;if(null===i){i=e.pingCache=new lf;var r=new Set;i.set(t,r)}else void 0===(r=i.get(t))&&(r=new Set,i.set(t,r));r.has(n)||(lM=!0,r.add(n),e=iX.bind(null,e,t,n),t.then(e,e))}function iX(e,t,n){var i=e.pingCache;null!==i&&i.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,lg===e&&(l_&n)===n&&(4===lw||3===lw&&(0x3c00000&l_)===l_&&300>sO()-lU?(2&lm)==0&&iT(e,0):lC|=n,lP===l_&&(lP=0)),ea(e)}function iq(e,t){0===t&&(t=m()),null!==(e=eP(e,t))&&(v(e,t),ea(e))}function iY(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),iq(e,n)}function iZ(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;null!==a&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}null!==r&&r.delete(t),iq(e,n)}function iJ(e,t,n,i){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function iK(e){return!(!(e=e.prototype)||!e.isReactComponent)}function i$(e,n){var i=e.alternate;return null===i?((i=t(e.tag,n,e.key,e.mode)).elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=n,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=0x3e00000&e.flags,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,n=e.dependencies,i.dependencies=null===n?null:{lanes:n.lanes,firstContext:n.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i.refCleanup=e.refCleanup,i}function iQ(e,t){e.flags&=0x3e00002;var n=e.alternate;return null===n?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,e.dependencies=null===(t=n.dependencies)?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function i0(e,n,r,a,s,o){var l=0;if(a=e,"function"==typeof e)iK(e)&&(l=1);else if("string"==typeof e)l=si&&sv?sr(e,r,s5.current)?26:sb(e)?27:5:si?sr(e,r,s5.current)?26:5:sv&&sb(e)?27:5;else o:switch(e){case r_:return(e=t(31,r,n,s)).elementType=r_,e.lanes=o,e;case rl:return i1(r.children,s,o,n);case ru:l=8,s|=24;break;case rc:return(e=t(12,r,n,2|s)).elementType=rc,e.lanes=o,e;case rf:return(e=t(13,r,n,s)).elementType=rf,e.lanes=o,e;case rm:return(e=t(19,r,n,s)).elementType=rm,e.lanes=o,e;default:if("object"==typeof e&&null!==e)switch(e.$$typeof){case rd:l=10;break o;case rh:l=9;break o;case rp:l=11;break o;case rg:l=14;break o;case rv:l=16,a=null;break o}l=29,r=Error(i(130,null===e?"null":typeof e,"")),a=null}return(n=t(l,r,n,s)).elementType=e,n.type=a,n.lanes=o,n}function i1(e,n,i,r){return(e=t(7,e,r,n)).lanes=i,e}function i2(e,n,i){return(e=t(6,e,null,n)).lanes=i,e}function i3(e){var n=t(18,null,null,0);return n.stateNode=e,n}function i4(e,n,i){return(n=t(4,null!==e.children?e.children:[],e.key,n)).lanes=i,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function i5(e,t,n,i,r,a,s,o,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=rB,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=g(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=g(0),this.hiddenUpdates=g(null),this.identifierPrefix=i,this.onUncaughtError=r,this.onCaughtError=a,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function i6(e,n,i,r,a,s,o,l,u,c,h,d){return e=new i5(e,n,i,o,u,c,h,d,l),n=1,!0===s&&(n|=24),s=t(3,null,null,n),e.current=s,s.stateNode=e,n=en(),n.refCount++,e.pooledCache=n,n.refCount++,s.memoizedState={element:r,isDehydrated:i,cache:n},eN(s),e}function i8(e){var t=e._reactInternals;if(void 0===t)throw"function"==typeof e.render?Error(i(188)):Error(i(268,e=Object.keys(e).join(",")));return null===(e=null!==(e=s(t))?function e(t){var n=t.tag;if(5===n||26===n||27===n||6===n)return t;for(t=t.child;null!==t;){if(null!==(n=e(t)))return n;t=t.sibling}return null}(e):null)?null:rA(e.stateNode)}function i9(e,t,n,i,r,a){r=sw,null===i.context?i.context=r:i.pendingContext=r,(i=eD(t)).payload={element:n},null!==(a=void 0===a?null:a)&&(i.callback=a),null!==(n=eO(e,i,t))&&(i_(n,e,t),eF(n,e,t))}function i7(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n>>=0)?32:31-(sA(e)/sC|0)|0},sA=Math.log,sC=Math.LN2,sR=256,sP=262144,sI=4194304,sL=ri.unstable_scheduleCallback,sN=ri.unstable_cancelCallback,sU=ri.unstable_shouldYield,sD=ri.unstable_requestPaint,sO=ri.unstable_now,sF=ri.unstable_ImmediatePriority,sz=ri.unstable_UserBlockingPriority,sB=ri.unstable_NormalPriority,sk=ri.unstable_IdlePriority,sV=ri.log,sH=ri.unstable_setDisableYieldValue,sG=null,sW=null,sj="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},sX="function"==typeof reportError?reportError:function(e){if("object"==typeof window&&"function"==typeof window.ErrorEvent){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:"object"==typeof e&&null!==e&&"string"==typeof e.message?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if("object"==typeof w.default&&"function"==typeof w.default.emit)return void w.default.emit("uncaughtException",e);console.error(e)},sq=Object.prototype.hasOwnProperty,sY=!1,sZ=new WeakMap,sJ=[],sK=0,s$=null,sQ=0,s0=[],s1=0,s2=null,s3=1,s4="",s5=u(null),s6=u(null),s8=u(null),s9=u(null),s7=null,oe=null,ot=!1,on=null,oi=!1,or=Error(i(519)),oa=u(null),os=null,oo=null,ol="u">typeof AbortController?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ou=ri.unstable_scheduleCallback,oc=ri.unstable_NormalPriority,oh={$$typeof:rd,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},od=null,op=null,of=!1,om=!1,og=!1,ov=0,o_=null,oy=0,ox=0,ob=null,oS=rM.S;rM.S=function(e,t){lD=sO(),"object"==typeof t&&null!==t&&"function"==typeof t.then&&function(e,t){if(null===o_){var n=o_=[];oy=0,ox=ed(),ob={status:"pending",value:void 0,then:function(e){n.push(e)}}}oy++,t.then(ep,ep)}(0,t),null!==oS&&oS(e,t)};var oM=u(null),oT=Error(i(460)),ow=Error(i(474)),oE=Error(i(542)),oA={then:function(){}},oC=null,oR=null,oP=0,oI=eE(!0),oL=eE(!1),oN=[],oU=0,oD=0,oO=!1,oF=!1,oz=u(null),oB=u(0),ok=u(null),oV=null,oH=u(0),oG=0,oW=null,oj=null,oX=null,oq=!1,oY=!1,oZ=!1,oJ=0,oK=0,o$=null,oQ=0,o0={readContext:Q,use:tt,useCallback:e$,useContext:e$,useEffect:e$,useImperativeHandle:e$,useLayoutEffect:e$,useInsertionEffect:e$,useMemo:e$,useReducer:e$,useRef:e$,useState:e$,useDebugValue:e$,useDeferredValue:e$,useTransition:e$,useSyncExternalStore:e$,useId:e$,useHostTransitionStatus:e$,useFormState:e$,useActionState:e$,useOptimistic:e$,useMemoCache:e$,useCacheRefresh:e$};o0.useEffectEvent=e$;var o1={readContext:Q,use:tt,useCallback:function(e,t){return e8().memoizedState=[e,void 0===t?null:t],e},useContext:Q,useEffect:tI,useImperativeHandle:function(e,t,n){n=null!=n?n.concat([e]):null,tR(4194308,4,tO.bind(null,t,e),n)},useLayoutEffect:function(e,t){return tR(4194308,4,e,t)},useInsertionEffect:function(e,t){tR(4,2,e,t)},useMemo:function(e,t){var n=e8();t=void 0===t?null:t;var i=e();return n.memoizedState=[i,t],i},useReducer:function(e,t,n){var i=e8();if(void 0!==n)var r=n(t);else r=t;return i.memoizedState=i.baseState=r,i.queue=e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},e=e.dispatch=tZ.bind(null,oW,e),[i.memoizedState,e]},useRef:function(e){return e8().memoizedState={current:e}},useState:function(e){var t=(e=tp(e)).queue,n=tJ.bind(null,oW,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:tz,useDeferredValue:function(e,t){return tV(e8(),e,t)},useTransition:function(){var e=tp(!1);return e=tG.bind(null,oW,e.queue,!0,!1),e8().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=oW,a=e8();if(ot){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===lg)throw Error(i(349));(127&l_)!=0||tl(r,t,n)}a.memoizedState=n;var s={value:n,getSnapshot:t};return a.queue=s,tI(tc.bind(null,r,s,e),[e]),r.flags|=2048,tA(9,{destroy:void 0},tu.bind(null,r,s,n,t),null),n},useId:function(){var e=e8(),t=lg.identifierPrefix;if(ot){var n=s4,i=s3;t="_"+t+"R_"+(n=(i&~(1<<32-sE(i)-1)).toString(32)+n),0<(n=oJ++)&&(t+="H"+n.toString(32)),t+="_"}else t="_"+t+"r_"+(n=oQ++).toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:tj,useFormState:tS,useActionState:tS,useOptimistic:function(e){var t=e8();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=t$.bind(null,oW,!0,n),n.dispatch=t,[e,t]},useMemoCache:tn,useCacheRefresh:function(){return e8().memoizedState=tY.bind(null,oW)},useEffectEvent:function(e){var t=e8(),n={impl:e};return t.memoizedState=n,function(){if((2&lm)!=0)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},o2={readContext:Q,use:tt,useCallback:tB,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tU,useLayoutEffect:tD,useMemo:tk,useReducer:tr,useRef:tC,useState:function(){return tr(ti)},useDebugValue:tz,useDeferredValue:function(e,t){return tH(e9(),oj.memoizedState,e,t)},useTransition:function(){var e=tr(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tj,useFormState:tM,useActionState:tM,useOptimistic:function(e,t){return tf(e9(),oj,e,t)},useMemoCache:tn,useCacheRefresh:tq};o2.useEffectEvent=tN;var o3={readContext:Q,use:tt,useCallback:tB,useContext:Q,useEffect:tL,useImperativeHandle:tF,useInsertionEffect:tU,useLayoutEffect:tD,useMemo:tk,useReducer:ts,useRef:tC,useState:function(){return ts(ti)},useDebugValue:tz,useDeferredValue:function(e,t){var n=e9();return null===oj?tV(n,e,t):tH(n,oj.memoizedState,e,t)},useTransition:function(){var e=ts(ti)[0],t=e9().memoizedState;return["boolean"==typeof e?e:te(e),t]},useSyncExternalStore:to,useId:tX,useHostTransitionStatus:tj,useFormState:tE,useActionState:tE,useOptimistic:function(e,t){var n=e9();return null!==oj?tf(n,oj,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:tn,useCacheRefresh:tq};o3.useEffectEvent=tN;var o4={enqueueSetState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eD(i);r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(i_(t,e,i),eF(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var i=ig(),r=eD(i);r.tag=1,r.payload=t,null!=n&&(r.callback=n),null!==(t=eO(e,r,i))&&(i_(t,e,i),eF(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ig(),i=eD(n);i.tag=2,null!=t&&(i.callback=t),null!==(t=eO(e,i,n))&&(i_(t,e,n),eF(t,e,n))}},o5=Error(i(461)),o6=!1,o8={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},o9=!1,o7=!1,le=!1,lt="function"==typeof WeakSet?WeakSet:Set,ln=null,li=null,lr=!1,la=null,ls=8192,lo={getCacheForType:function(e){var t=Q(oh),n=t.data.get(e);return void 0===n&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Q(oh).controller.signal}},ll=0,lu=1,lc=2,lh=3,ld=4;if("function"==typeof Symbol&&Symbol.for){var lp=Symbol.for;ll=lp("selector.component"),lu=lp("selector.has_pseudo_class"),lc=lp("selector.role"),lh=lp("selector.test_id"),ld=lp("selector.text")}var lf="function"==typeof WeakMap?WeakMap:Map,lm=0,lg=null,lv=null,l_=0,ly=0,lx=null,lb=!1,lS=!1,lM=!1,lT=0,lw=0,lE=0,lA=0,lC=0,lR=0,lP=0,lI=null,lL=null,lN=!1,lU=0,lD=0,lO=1/0,lF=null,lz=null,lB=0,lk=null,lV=null,lH=0,lG=0,lW=null,lj=null,lX=0,lq=null;return rt.attemptContinuousHydration=function(e){if(13===e.tag||31===e.tag){var t=eP(e,0x4000000);null!==t&&i_(t,e,0x4000000),re(e,0x4000000)}},rt.attemptHydrationAtCurrentPriority=function(e){if(13===e.tag||31===e.tag){var t=ig(),n=eP(e,t=b(t));null!==n&&i_(n,e,t),re(e,t)}},rt.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if((e=e.stateNode).current.memoizedState.isDehydrated){var t=d(e.pendingLanes);if(0!==t){for(e.pendingLanes|=2,e.entangledLanes|=2;t;){var n=1<<31-sE(t);e.entanglements[1]|=n,t&=~n}ea(e),(6&lm)==0&&(lO=sO()+500,es(0,!1))}}break;case 31:case 13:null!==(t=eP(e,2))&&i_(t,e,2),iS(),re(e,2)}},rt.batchedUpdates=function(e,t){return e(t)},rt.createComponentSelector=function(e){return{$$typeof:ll,value:e}},rt.createContainer=function(e,t,n,i,r,a,s,o,l,u){return i6(e,t,!1,null,n,i,a,null,s,o,l,u)},rt.createHasPseudoClassSelector=function(e){return{$$typeof:lu,value:e}},rt.createHydrationContainer=function(e,t,n,i,r,a,s,o,l,u,c,h,d,p){var f;return(e=i6(n,i,!0,e,r,a,o,p,l,u,c,h)).context=sw,n=e.current,(r=eD(i=b(i=ig()))).callback=null!=(f=t)?f:null,eO(n,r,i),t=i,e.current.lanes=t,v(e,t),ea(e),e},rt.createPortal=function(e,t,n){var i=3=c&&s>=d&&a<=h&&o<=p){e.splice(t,1);break}if(r!==c||n.width!==u.width||po){if(!(s!==d||n.height!==u.height||ha)){c>r&&(u.width+=c-r,u.x=r),hs&&(u.height+=d-s,u.y=s),pn&&(n=l)),l ")+` + +No matching component was found for: + `+e.join(" > ")}return null},rt.getPublicRootInstance=function(e){if(!(e=e.current).child)return null;switch(e.child.tag){case 27:case 5:return rA(e.child.stateNode);default:return e.child.stateNode}},rt.injectIntoDevTools=function(){var e={bundleType:0,version:rT,rendererPackageName:rw,currentDispatcherRef:rM,reconcilerVersion:"19.2.0"};if(null!==rE&&(e.rendererConfig=rE),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{sG=t.inject(e),sW=t}catch{}e=!!t.checkDCE}}return e},rt.isAlreadyRendering=function(){return(6&lm)!=0},rt.observeVisibleRects=function(e,t,n,r){if(!r7)throw Error(i(363));var a=as(e=im(e,t),n,r).disconnect;return{disconnect:function(){a()}}},rt.shouldError=function(){return null},rt.shouldSuspend=function(){return!1},rt.startHostTransition=function(e,t,r,a){if(5!==e.tag)throw Error(i(476));var s=tW(e).queue;tG(e,s,t,r4,null===r?n:function(){var t=tW(e);return null===t.next&&(t=e.alternate.memoizedState),tK(e,t.next.queue,{},ig()),r(a)})},rt.updateContainer=function(e,t,n,i){var r=t.current,a=ig();return i9(r,a,e,t,n,i),a},rt.updateContainerSync=function(e,t,n,i){return i9(t.current,2,e,t,n,i),2},rt},hc.exports.default=hc.exports,Object.defineProperty(hc.exports,"__esModule",{value:!0})),hu.exports=hc.exports),(b=hu.exports)&&b.__esModule&&Object.prototype.hasOwnProperty.call(b,"default"))?b.default:b,hd={},hp=/^three(?=[A-Z])/,hf=e=>`${e[0].toUpperCase()}${e.slice(1)}`,hm=0;function hg(e){if("function"==typeof e){let t=`${hm++}`;return hd[t]=e,t}Object.assign(hd,e)}function hv(e,t){let n=hf(e),i=hd[n];if("primitive"!==e&&!i)throw Error(`R3F: ${n} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if("primitive"===e&&!t.object)throw Error("R3F: Primitives without 'object' are invalid!");if(void 0!==t.args&&!Array.isArray(t.args))throw Error("R3F: The args prop must be an array!")}function h_(e){if(e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?c0(e.parent,e):c9(e.object)&&!1!==e.props.visible&&(e.object.visible=!0),e.isHidden=!1,c8(e)}}function hy(e,t,n){let i=t.root.getState();if(e.parent||e.object===i.scene){if(!t.object){var r,a;let e=hd[hf(t.type)];t.object=null!=(r=t.props.object)?r:new e(...null!=(a=t.props.args)?a:[]),t.object.__r3f=t}if(c6(t.object,t.props),t.props.attach)c0(e,t);else if(c9(t.object)&&c9(e.object)){let i=e.object.children.indexOf(null==n?void 0:n.object);if(n&&-1!==i){let n=e.object.children.indexOf(t.object);-1!==n?(e.object.children.splice(n,1),e.object.children.splice(n{try{e.dispose()}catch{}};"u">typeof IS_REACT_ACT_ENVIRONMENT?t():(0,cC.unstable_scheduleCallback)(cC.unstable_IdlePriority,t)}}function hM(e,t,n){if(!t)return;t.parent=null;let i=e.children.indexOf(t);-1!==i&&e.children.splice(i,1),t.props.attach?c1(e,t):c9(t.object)&&c9(e.object)&&(e.object.remove(t.object),function(e,t){let{internal:n}=e.getState();n.interaction=n.interaction.filter(e=>e!==t),n.initialHits=n.initialHits.filter(e=>e!==t),n.hovered.forEach((e,i)=>{(e.eventObject===t||e.object===t)&&n.hovered.delete(i)}),n.capturedMap.forEach((e,i)=>{he(n.capturedMap,t,e,i)})}(cB(t),t.object));let r=null!==t.props.dispose&&!1!==n;for(let e=t.children.length-1;e>=0;e--){let n=t.children[e];hM(t,n,r)}t.children.length=0,delete t.object.__r3f,r&&"primitive"!==t.type&&"Scene"!==t.object.type&&hS(t.object),void 0===n&&c8(t)}let hT=[],hw=()=>{},hE={},hA=0,hC=(S={isPrimaryRenderer:!1,warnsIfNotActing:!1,supportsMutation:!0,supportsPersistence:!1,supportsHydration:!1,createInstance:function(e,t,n){var i;return hv(e=hf(e)in hd?e:e.replace(hp,""),t),"primitive"===e&&null!=(i=t.object)&&i.__r3f&&delete t.object.__r3f,cK(t.object,n,e,t)},removeChild:hM,appendChild:hx,appendInitialChild:hx,insertBefore:hb,appendChildToContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hx(n,t)},removeChildFromContainer(e,t){let n=e.getState().scene.__r3f;t&&n&&hM(n,t)},insertInContainerBefore(e,t,n){let i=e.getState().scene.__r3f;t&&n&&i&&hb(i,t,n)},getRootHostContext:()=>hE,getChildHostContext:()=>hE,commitUpdate(e,t,n,i,r){var a,s,o;hv(t,i);let l=!1;if("primitive"===e.type&&n.object!==i.object||(null==(a=i.args)?void 0:a.length)!==(null==(s=n.args)?void 0:s.length)?l=!0:null!=(o=i.args)&&o.some((e,t)=>{var i;return e!==(null==(i=n.args)?void 0:i[t])})&&(l=!0),l)hT.push([e,{...i},r]);else{let t=function(e,t){let n={};for(let i in t)if(!c2.includes(i)&&!cZ.equ(t[i],e.props[i]))for(let e in n[i]=t[i],t)e.startsWith(`${i}-`)&&(n[e]=t[e]);for(let i in e.props){if(c2.includes(i)||t.hasOwnProperty(i))continue;let{root:r,key:a}=c$(e.object,i);if(r.constructor&&0===r.constructor.length){let e=function(e){let t=c3.get(e.constructor);try{t||(t=new e.constructor,c3.set(e.constructor,t))}catch(e){}return t}(r);cZ.und(e)||(n[a]=e[a])}else n[a]=0}return n}(e,i);Object.keys(t).length&&(Object.assign(e.props,t),c6(e.object,t))}(null===r.sibling||(4&r.flags)==0)&&function(){for(let[e]of hT){let t=e.parent;if(t)for(let n of(e.props.attach?c1(t,e):c9(e.object)&&c9(t.object)&&t.object.remove(e.object),e.children))n.props.attach?c1(e,n):c9(n.object)&&c9(e.object)&&e.object.remove(n.object);e.isHidden&&h_(e),e.object.__r3f&&delete e.object.__r3f,"primitive"!==e.type&&hS(e.object)}for(let[i,r,a]of hT){i.props=r;let s=i.parent;if(s){let r=hd[hf(i.type)];i.object=null!=(e=i.props.object)?e:new r(...null!=(t=i.props.args)?t:[]),i.object.__r3f=i;var e,t,n=i.object;for(let e of[a,a.alternate])if(null!==e)if("function"==typeof e.ref){null==e.refCleanup||e.refCleanup();let t=e.ref(n);"function"==typeof t&&(e.refCleanup=t)}else e.ref&&(e.ref.current=n);for(let e of(c6(i.object,i.props),i.props.attach?c0(s,i):c9(i.object)&&c9(s.object)&&s.object.add(i.object),i.children))e.props.attach?c0(i,e):c9(e.object)&&c9(i.object)&&i.object.add(e.object);c8(i)}}hT.length=0}()},finalizeInitialChildren:()=>!1,commitMount(){},getPublicInstance:e=>null==e?void 0:e.object,prepareForCommit:()=>null,preparePortalMount:e=>cK(e.getState().scene,e,"",{}),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance:function(e){if(!e.isHidden){var t;e.props.attach&&null!=(t=e.parent)&&t.object?c1(e.parent,e):c9(e.object)&&(e.object.visible=!1),e.isHidden=!0,c8(e)}},unhideInstance:h_,createTextInstance:hw,hideTextInstance:hw,unhideTextInstance:hw,scheduleTimeout:"function"==typeof setTimeout?setTimeout:void 0,cancelTimeout:"function"==typeof clearTimeout?clearTimeout:void 0,noTimeout:-1,getInstanceFromNode:()=>null,beforeActiveInstanceBlur(){},afterActiveInstanceBlur(){},detachDeletedInstance(){},prepareScopeUpdate(){},getInstanceFromScope:()=>null,shouldAttemptEagerTransition:()=>!1,trackSchedulerEvent:()=>{},resolveEventType:()=>null,resolveEventTimeStamp:()=>-1.1,requestPostPaintCallback(){},maySuspendCommit:()=>!1,preloadInstance:()=>!0,suspendInstance(){},waitForCommitToBeReady:()=>null,NotPendingTransition:null,HostTransitionContext:E.createContext(null),setCurrentUpdatePriority(e){hA=e},getCurrentUpdatePriority:()=>hA,resolveUpdatePriority(){var e;if(0!==hA)return hA;switch("u">typeof window&&(null==(e=window.event)?void 0:e.type)){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return 2;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return 8;default:return 32}},resetFormInstance(){},rendererPackageName:"@react-three/fiber",rendererVersion:"9.5.0",applyViewTransitionName(e,t,n){},restoreViewTransitionName(e,t){},cancelViewTransitionName(e,t,n){},cancelRootViewTransitionName(e){},restoreRootViewTransitionName(e){},InstanceMeasurement:null,measureInstance:e=>null,wasInstanceInViewport:e=>!0,hasInstanceChanged:(e,t)=>!1,hasInstanceAffectedParent:(e,t)=>!1,suspendOnActiveViewTransition(e,t){},startGestureTransition:()=>null,startViewTransition:()=>null,stopViewTransition(e){},createViewTransitionInstance:e=>null,getCurrentGestureOffset(e){throw Error("startGestureTransition is not yet supported in react-three-fiber.")},cloneMutableInstance:(e,t)=>e,cloneMutableTextInstance:e=>e,cloneRootViewTransitionContainer(e){throw Error("Not implemented.")},removeRootViewTransitionClone(e,t){throw Error("Not implemented.")},createFragmentInstance:e=>null,updateFragmentInstanceFiber(e,t){},commitNewChildToFragmentInstance(e,t){},deleteChildFromFragmentInstance(e,t){},measureClonedInstance:e=>null,maySuspendCommitOnUpdate:(e,t,n)=>!1,maySuspendCommitInSyncRender:(e,t)=>!1,startSuspendingCommit:()=>null,getSuspendedCommitReason:(e,t)=>null},(_=hh(S)).injectIntoDevTools(),_),hR=new Map,hP={objects:"shallow",strict:!1};function hI(e){var t,n;let i,r,a,s,o,l,u,c=hR.get(e),h=null==c?void 0:c.fiber,d=null==c?void 0:c.store;c&&console.warn("R3F.createRoot should only be called once!");let p="function"==typeof reportError?reportError:console.error,f=d||(t=hX,n=hq,o=(s=(a=(0,cT.createWithEqualityFn)((e,i)=>{let r,a=new ef,s=new ef,o=new ef;function l(e=i().camera,t=s,n=i().size){let{width:r,height:u,top:c,left:h}=n,d=r/u;t.isVector3?o.copy(t):o.set(...t);let p=e.getWorldPosition(a).distanceTo(o);if(e&&e.isOrthographicCamera)return{width:r/e.zoom,height:u/e.zoom,top:c,left:h,factor:1,distance:p,aspect:d};{let t=2*Math.tan(e.fov*Math.PI/180/2)*p,n=r/u*t;return{width:n,height:t,top:c,left:h,factor:r/n,distance:p,aspect:d}}}let u=t=>e(e=>({performance:{...e.performance,current:t}})),c=new ed;return{set:e,get:i,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},scene:null,xr:null,invalidate:(e=1)=>t(i(),e),advance:(e,t)=>n(e,t,i()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new sW,pointer:c,mouse:c,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{let e=i();r&&clearTimeout(r),e.performance.current!==e.performance.min&&u(e.performance.min),r=setTimeout(()=>u(i().performance.max),e.performance.debounce)}},size:{width:0,height:0,top:0,left:0},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:l},setEvents:t=>e(e=>({...e,events:{...e.events,...t}})),setSize:(t,n,r=0,a=0)=>{let o=i().camera,u={width:t,height:n,top:r,left:a};e(e=>({size:u,viewport:{...e.viewport,...l(o,s,u)}}))},setDpr:t=>e(e=>{let n=cq(t);return{viewport:{...e.viewport,dpr:n,initialDpr:e.viewport.initialDpr||n}}}),setFrameloop:(t="always")=>{let n=i().clock;n.stop(),n.elapsedTime=0,"never"!==t&&(n.start(),n.elapsedTime=0),e(()=>({frameloop:t}))},previousRoot:void 0,internal:{interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,lastEvent:E.createRef(),active:!1,frames:0,priority:0,subscribe:(e,t,n)=>{let r=i().internal;return r.priority=r.priority+ +(t>0),r.subscribers.push({ref:e,priority:t,store:n}),r.subscribers=r.subscribers.sort((e,t)=>e.priority-t.priority),()=>{let n=i().internal;null!=n&&n.subscribers&&(n.priority=n.priority-(t>0),n.subscribers=n.subscribers.filter(t=>t.ref!==e))}}}}})).getState()).size,l=s.viewport.dpr,u=s.camera,a.subscribe(()=>{let{camera:e,size:t,viewport:n,gl:i,set:r}=a.getState();if(t.width!==o.width||t.height!==o.height||n.dpr!==l){o=t,l=n.dpr;!e.manual&&(e&&e.isOrthographicCamera?(e.left=-(t.width/2),e.right=t.width/2,e.top=t.height/2,e.bottom=-(t.height/2)):e.aspect=t.width/t.height,e.updateProjectionMatrix());n.dpr>0&&i.setPixelRatio(n.dpr);let r="u">typeof HTMLCanvasElement&&i.domElement instanceof HTMLCanvasElement;i.setSize(t.width,t.height,r)}e!==u&&(u=e,r(t=>({viewport:{...t.viewport,...t.viewport.getCurrentViewport(e)}})))}),a.subscribe(e=>t(e)),a),m=h||hC.createContainer(f,1,null,!1,null,"",p,p,p,null);c||hR.set(e,{fiber:m,store:f});let g=!1,v=null;return{async configure(t={}){var n,a;let s;v=new Promise(e=>s=e);let{gl:o,size:l,scene:u,events:c,onCreated:h,shadows:d=!1,linear:p=!1,flat:m=!1,legacy:_=!1,orthographic:y=!1,frameloop:x="always",dpr:b=[1,2],performance:S,raycaster:M,camera:T,onPointerMissed:w}=t,E=f.getState(),A=E.gl;if(!E.gl){let t={canvas:e,powerPreference:"high-performance",antialias:!0,alpha:!0},n="function"==typeof o?await o(t):o;A=ht(n)?n:new cM({...t,...o}),E.set({gl:A})}let C=E.raycaster;C||E.set({raycaster:C=new op});let{params:R,...P}=M||{};if(cZ.equ(P,C,hP)||c6(C,{...P}),cZ.equ(R,C.params,hP)||c6(C,{params:{...C.params,...R}}),!E.camera||E.camera===r&&!cZ.equ(r,T,hP)){r=T;let e=null==T?void 0:T.isCamera,t=e?T:y?new sx(0,0,0,0,.1,1e3):new nO(75,0,.1,1e3);!e&&(t.position.z=5,T&&(c6(t,T),!t.manual&&("aspect"in T||"left"in T||"right"in T||"bottom"in T||"top"in T)&&(t.manual=!0,t.updateProjectionMatrix())),E.camera||null!=T&&T.rotation||t.lookAt(0,0,0)),E.set({camera:t}),C.camera=t}if(!E.scene){let e;null!=u&&u.isScene?cK(e=u,f,"",{}):(cK(e=new nj,f,"",{}),u&&c6(e,u)),E.set({scene:e})}c&&!E.events.handlers&&E.set({events:c(f)});let N=function(e,t){if(!t&&"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&e.parentElement){let{width:t,height:n,top:i,left:r}=e.parentElement.getBoundingClientRect();return{width:t,height:n,top:i,left:r}}return!t&&"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas?{width:e.width,height:e.height,top:0,left:0}:{width:0,height:0,top:0,left:0,...t}}(e,l);if(cZ.equ(N,E.size,hP)||E.setSize(N.width,N.height,N.top,N.left),b&&E.viewport.dpr!==cq(b)&&E.setDpr(b),E.frameloop!==x&&E.setFrameloop(x),E.onPointerMissed||E.set({onPointerMissed:w}),S&&!cZ.equ(S,E.performance,hP)&&E.set(e=>({performance:{...e.performance,...S}})),!E.xr){let e=(e,t)=>{let n=f.getState();"never"!==n.frameloop&&hq(e,!0,n,t)},t=()=>{let t=f.getState();t.gl.xr.enabled=t.gl.xr.isPresenting,t.gl.xr.setAnimationLoop(t.gl.xr.isPresenting?e:null),t.gl.xr.isPresenting||hX(t)},i={connect(){let e=f.getState().gl;e.xr.addEventListener("sessionstart",t),e.xr.addEventListener("sessionend",t)},disconnect(){let e=f.getState().gl;e.xr.removeEventListener("sessionstart",t),e.xr.removeEventListener("sessionend",t)}};"function"==typeof(null==(n=A.xr)?void 0:n.addEventListener)&&i.connect(),E.set({xr:i})}if(A.shadowMap){let e=A.shadowMap.enabled,t=A.shadowMap.type;A.shadowMap.enabled=!!d,cZ.boo(d)?A.shadowMap.type=2:cZ.str(d)?A.shadowMap.type=null!=(a=({basic:0,percentage:1,soft:2,variance:3})[d])?a:2:cZ.obj(d)&&Object.assign(A.shadowMap,d),(e!==A.shadowMap.enabled||t!==A.shadowMap.type)&&(A.shadowMap.needsUpdate=!0)}return eb.enabled=!_,g||(A.outputColorSpace=p?L:I,A.toneMapping=4*!m),E.legacy!==_&&E.set(()=>({legacy:_})),E.linear!==p&&E.set(()=>({linear:p})),E.flat!==m&&E.set(()=>({flat:m})),!o||cZ.fun(o)||ht(o)||cZ.equ(o,A,hP)||c6(A,o),i=h,g=!0,s(),this},render(t){return g||v||this.configure(),v.then(()=>{hC.updateContainer((0,cR.jsx)(hL,{store:f,children:t,onCreated:i,rootElement:e}),m,null,()=>void 0)}),f},unmount(){hN(e)}}}function hL({store:e,children:t,onCreated:n,rootElement:i}){return cH(()=>{let t=e.getState();t.set(e=>({internal:{...e.internal,active:!0}})),n&&n(t),e.getState().events.connected||null==t.events.connect||t.events.connect(i)},[]),(0,cR.jsx)(hn.Provider,{value:e,children:t})}function hN(e,t){let n=hR.get(e),i=null==n?void 0:n.fiber;if(i){let r=null==n?void 0:n.store.getState();r&&(r.internal.active=!1),hC.updateContainer(null,i,null,()=>{r&&setTimeout(()=>{try{null==r.events.disconnect||r.events.disconnect(),null==(n=r.gl)||null==(i=n.renderLists)||null==i.dispose||i.dispose(),null==(a=r.gl)||null==a.forceContextLoss||a.forceContextLoss(),null!=(s=r.gl)&&s.xr&&r.xr.disconnect();var n,i,a,s,o=r.scene;for(let e in"Scene"!==o.type&&(null==o.dispose||o.dispose()),o){let t=o[e];(null==t?void 0:t.type)!=="Scene"&&(null==t||null==t.dispose||t.dispose())}hR.delete(e),t&&t(e)}catch(e){}},500)})}}function hU(e,t){let n={callback:e};return t.add(n),()=>void t.delete(n)}let hD=new Set,hO=new Set,hF=new Set,hz=e=>hU(e,hD),hB=e=>hU(e,hO);function hk(e,t){if(e.size)for(let{callback:n}of e.values())n(t)}function hV(e,t){switch(e){case"before":return hk(hD,t);case"after":return hk(hO,t);case"tail":return hk(hF,t)}}function hH(e,t,n){let i=t.clock.getDelta();"never"===t.frameloop&&"number"==typeof e&&(i=e-t.clock.elapsedTime,t.clock.oldTime=t.clock.elapsedTime,t.clock.elapsedTime=e),s=t.internal.subscribers;for(let e=0;e0)&&!(null!=(t=c.gl.xr)&&t.isPresenting)&&(l+=hH(e,c))}if(hW=!1,hV("after",e),0===l)return hV("tail",e),hG=!1,cancelAnimationFrame(u)}function hX(e,t=1){var n;if(!e)return hR.forEach(e=>hX(e.store.getState(),t));(null==(n=e.gl.xr)||!n.isPresenting)&&e.internal.active&&"never"!==e.frameloop&&(t>1?e.internal.frames=Math.min(60,e.internal.frames+t):hW?e.internal.frames=2:e.internal.frames=1,hG||(hG=!0,requestAnimationFrame(hj)))}function hq(e,t=!0,n,i){if(t&&hV("before",e),n)hH(e,n,i);else for(let t of hR.values())hH(e,t.store.getState());t&&hV("after",e)}let hY={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function hZ(e){let{handlePointer:t}=function(e){function t(e){return e.filter(e=>["Move","Over","Enter","Out","Leave"].some(t=>{var n;return null==(n=e.__r3f)?void 0:n.handlers["onPointer"+t]}))}function n(t){let{internal:n}=e.getState();for(let e of n.hovered.values())if(!t.length||!t.find(t=>t.object===e.object&&t.index===e.index&&t.instanceId===e.instanceId)){let i=e.eventObject.__r3f;if(n.hovered.delete(c7(e)),null!=i&&i.eventCount){let n=i.handlers,r={...e,intersections:t};null==n.onPointerOut||n.onPointerOut(r),null==n.onPointerLeave||n.onPointerLeave(r)}}}function i(e,t){for(let n=0;nn([]);case"onLostPointerCapture":return t=>{let{internal:i}=e.getState();"pointerId"in t&&i.capturedMap.has(t.pointerId)&&requestAnimationFrame(()=>{i.capturedMap.has(t.pointerId)&&(i.capturedMap.delete(t.pointerId),n([]))})}}return function(a){let{onPointerMissed:s,internal:o}=e.getState();o.lastEvent.current=a;let l="onPointerMove"===r,u="onClick"===r||"onContextMenu"===r||"onDoubleClick"===r,c=function(t,n){let i=e.getState(),r=new Set,a=[],s=n?n(i.internal.interaction):i.internal.interaction;for(let e=0;e{let n=cY(e.object),i=cY(t.object);return n&&i&&i.events.priority-n.events.priority||e.distance-t.distance}).filter(e=>{let t=c7(e);return!r.has(t)&&(r.add(t),!0)});for(let e of(i.events.filter&&(o=i.events.filter(o,i)),o)){let t=e.object;for(;t;){var l;null!=(l=t.__r3f)&&l.eventCount&&a.push({...e,eventObject:t}),t=t.parent}}if("pointerId"in t&&i.internal.capturedMap.has(t.pointerId))for(let e of i.internal.capturedMap.get(t.pointerId).values())r.has(c7(e.intersection))||a.push(e.intersection);return a}(a,l?t:void 0),h=u?function(t){let{internal:n}=e.getState(),i=t.offsetX-n.initialClick[0],r=t.offsetY-n.initialClick[1];return Math.round(Math.sqrt(i*i+r*r))}(a):0;"onPointerDown"===r&&(o.initialClick=[a.offsetX,a.offsetY],o.initialHits=c.map(e=>e.eventObject)),u&&!c.length&&h<=2&&(i(a,o.interaction),s&&s(a)),l&&n(c),!function(e,t,i,r){if(e.length){let a={stopped:!1};for(let s of e){let o=cY(s.object);if(o||s.object.traverseAncestors(e=>{let t=cY(e);if(t)return o=t,!1}),o){let{raycaster:l,pointer:u,camera:c,internal:h}=o,d=new ef(u.x,u.y,0).unproject(c),p=e=>{var t,n;return null!=(t=null==(n=h.capturedMap.get(e))?void 0:n.has(s.eventObject))&&t},f=e=>{let n={intersection:s,target:t.target};h.capturedMap.has(e)?h.capturedMap.get(e).set(s.eventObject,n):h.capturedMap.set(e,new Map([[s.eventObject,n]])),t.target.setPointerCapture(e)},m=e=>{let t=h.capturedMap.get(e);t&&he(h.capturedMap,s.eventObject,t,e)},g={};for(let e in t){let n=t[e];"function"!=typeof n&&(g[e]=n)}let v={...s,...g,pointer:u,intersections:e,stopped:a.stopped,delta:i,unprojectedPoint:d,ray:l.ray,camera:c,stopPropagation(){let i="pointerId"in t&&h.capturedMap.get(t.pointerId);(!i||i.has(s.eventObject))&&(v.stopped=a.stopped=!0,h.hovered.size&&Array.from(h.hovered.values()).find(e=>e.eventObject===s.eventObject)&&n([...e.slice(0,e.indexOf(s)),s]))},target:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},currentTarget:{hasPointerCapture:p,setPointerCapture:f,releasePointerCapture:m},nativeEvent:t};if(r(v),!0===a.stopped)break}}}}(c,a,h,function(e){let t=e.eventObject,n=t.__r3f;if(!(null!=n&&n.eventCount))return;let s=n.handlers;if(l){if(s.onPointerOver||s.onPointerEnter||s.onPointerOut||s.onPointerLeave){let t=c7(e),n=o.hovered.get(t);n?n.stopped&&e.stopPropagation():(o.hovered.set(t,e),null==s.onPointerOver||s.onPointerOver(e),null==s.onPointerEnter||s.onPointerEnter(e))}null==s.onPointerMove||s.onPointerMove(e)}else{let n=s[r];n?(!u||o.initialHits.includes(t))&&(i(a,o.interaction.filter(e=>!o.initialHits.includes(e))),n(e)):u&&o.initialHits.includes(t)&&i(a,o.interaction.filter(e=>!o.initialHits.includes(e)))}})}}}}(e);return{priority:1,enabled:!0,compute(e,t,n){t.pointer.set(e.offsetX/t.size.width*2-1,-(2*(e.offsetY/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)},connected:void 0,handlers:Object.keys(hY).reduce((e,n)=>({...e,[n]:t(n)}),{}),update:()=>{var t;let{events:n,internal:i}=e.getState();null!=(t=i.lastEvent)&&t.current&&n.handlers&&n.handlers.onPointerMove(i.lastEvent.current)},connect:t=>{let{set:n,events:i}=e.getState();if(null==i.disconnect||i.disconnect(),n(e=>({events:{...e.events,connected:t}})),i.handlers)for(let e in i.handlers){let n=i.handlers[e],[r,a]=hY[e];t.addEventListener(r,n,{passive:a})}},disconnect:()=>{let{set:t,events:n}=e.getState();if(n.connected){if(n.handlers)for(let e in n.handlers){let t=n.handlers[e],[i]=hY[e];n.connected.removeEventListener(i,t)}t(e=>({events:{...e.events,connected:void 0}}))}}}}e.s(["B",()=>cj,"C",()=>hr,"D",()=>ha,"E",()=>cX,"G",()=>hl,"a",()=>cG,"b",()=>cH,"c",()=>hI,"d",()=>hN,"e",()=>hg,"f",()=>hZ,"i",()=>ck,"j",()=>hz,"k",()=>hB,"u",()=>cW],40859)},71753,e=>{"use strict";var t=e.i(40859);e.s(["useFrame",()=>t.D])},15080,e=>{"use strict";var t=e.i(40859);e.s(["useThree",()=>t.C])},79123,e=>{"use strict";var t=e.i(43476),n=e.i(71645);let i=(0,n.createContext)(null),r=(0,n.createContext)(null),a=(0,n.createContext)(null);function s(){return(0,n.useContext)(i)}function o(){return(0,n.useContext)(r)}function l(){return(0,n.useContext)(a)}function u({children:e,fogEnabledOverride:s,onClearFogEnabledOverride:o}){let[l,u]=(0,n.useState)(!0),[c,h]=(0,n.useState)(!1),[d,p]=(0,n.useState)(1),[f,m]=(0,n.useState)(90),[g,v]=(0,n.useState)(!1),[_,y]=(0,n.useState)(!0),[x,b]=(0,n.useState)(!1),[S,M]=(0,n.useState)("moveLookStick"),T=(0,n.useCallback)(e=>{u(e),o()},[o]),w=(0,n.useMemo)(()=>({fogEnabled:s??l,setFogEnabled:T,highQualityFog:c,setHighQualityFog:h,fov:f,setFov:m,audioEnabled:g,setAudioEnabled:v,animationEnabled:_,setAnimationEnabled:y}),[l,s,T,c,f,g,_]),E=(0,n.useMemo)(()=>({debugMode:x,setDebugMode:b}),[x,b]),A=(0,n.useMemo)(()=>({speedMultiplier:d,setSpeedMultiplier:p,touchMode:S,setTouchMode:M}),[d,p,S,M]);(0,n.useLayoutEffect)(()=>{let e={};try{e=JSON.parse(localStorage.getItem("settings"))||{}}catch(e){}null!=e.debugMode&&b(e.debugMode),null!=e.audioEnabled&&v(e.audioEnabled),null!=e.animationEnabled&&y(e.animationEnabled),null!=e.fogEnabled&&u(e.fogEnabled),null!=e.highQualityFog&&h(e.highQualityFog),null!=e.speedMultiplier&&p(e.speedMultiplier),null!=e.fov&&m(e.fov),null!=e.touchMode&&M(e.touchMode)},[]);let C=(0,n.useRef)(null);return(0,n.useEffect)(()=>(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{try{localStorage.setItem("settings",JSON.stringify({fogEnabled:l,highQualityFog:c,speedMultiplier:d,fov:f,audioEnabled:g,animationEnabled:_,debugMode:x,touchMode:S}))}catch(e){}},500),()=>{C.current&&clearTimeout(C.current)}),[l,c,d,f,g,_,x,S]),(0,t.jsx)(i.Provider,{value:w,children:(0,t.jsx)(r.Provider,{value:E,children:(0,t.jsx)(a.Provider,{value:A,children:e})})})}e.s(["SettingsProvider",()=>u,"useControls",()=>l,"useDebug",()=>o,"useSettings",()=>s])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/687860f86433eb04.js b/docs/_next/static/chunks/687860f86433eb04.js new file mode 100644 index 00000000..053b887e --- /dev/null +++ b/docs/_next/static/chunks/687860f86433eb04.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,29055,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(15080),o=e.i(71753),i=e.i(90072),u=e.i(12979),c=e.i(51434),a=e.i(79123),s=e.i(89887);e.i(13876);var l=e.i(58647);let f=new Map,d=new Map;function p(e,t=1){d.set(e,t)}function m(e){d.delete(e)}let y=0;function h(){return y}function D(){for(let[e]of(y++,d)){try{e.stop()}catch{}try{e.disconnect()}catch{}}d.clear()}function g(e,t){let r=t(e),n=r?.filename;if(!n)return null;let o=n.endsWith(".wav")?n:`${n}.wav`,i=r.description,u=null!=i?t(i):void 0,c=u?.is3D??!0,a=u?.isLooping??!1,s=u?.referenceDistance??20;return{filename:o,is3D:c,isLooping:a,refDist:s,maxDist:u?.maxDistance??100,volume:u?.volume??1}}function v(e,t,r,n,o){let c;try{c=(0,u.audioToUrl)(e.filename)}catch{return}let a=l.engineStore.getState().playback.rate,s=y;R(c,r,r=>{if(s===y)try{if(e.is3D&&o){let u=new i.PositionalAudio(t);u.setBuffer(r),u.setDistanceModel("inverse"),u.setRefDistance(e.refDist),u.setMaxDistance(e.maxDist),u.setRolloffFactor(1),u.setVolume(e.volume),u.setPlaybackRate(a),n&&u.position.copy(n),o.add(u),d.set(u,1),u.play(),u.source.onended=()=>{d.delete(u);try{u.disconnect()}catch{}o.remove(u)}}else{let n=new i.Audio(t);n.setBuffer(r),n.setVolume(e.volume),n.setPlaybackRate(a),d.set(n,1),n.play(),n.source.onended=()=>{d.delete(n);try{n.disconnect()}catch{}}}}catch{}})}function R(e,t,r){f.has(e)?r(f.get(e)):t.load(e,t=>{f.set(e,t),r(t)},void 0,t=>{console.error("Audio load error",e,t)})}l.engineStore.subscribe(e=>e.playback.rate,e=>{for(let[t,r]of d)try{t.setPlaybackRate(r*e)}catch{}});let M=(0,r.memo)(function({entity:e}){let{debugMode:l}=(0,a.useDebug)(),f=e.audioFileName??"",d=e.audioVolume??1,p=e.audioMinDistance??1,m=e.audioMaxDistance??1,y=e.audioMinLoopGap??0,h=e.audioMaxLoopGap??0,D=e.audioIs3D??!0?1:0,g=e.audioIsLooping??!0,[v,M,T]=e.position??[0,0,0],{scene:b,camera:x}=(0,n.useThree)(),{audioLoader:A,audioListener:S}=(0,c.useAudio)(),{audioEnabled:w}=(0,a.useSettings)(),P=(0,r.useRef)(null),k=(0,r.useRef)(null),B=(0,r.useRef)(null),L=(0,r.useRef)(!1),V=(0,r.useRef)(!1),j=(0,r.useRef)(new i.Vector3(v,M,T)),F=(0,r.useRef)(0),C=()=>{null!=k.current&&(clearTimeout(k.current),k.current=null),null!=B.current&&(clearTimeout(B.current),B.current=null)};(0,r.useEffect)(()=>{let e;if(A&&S){if(F.current++,D){let t=new i.PositionalAudio(S);t.position.copy(j.current),t.setDistanceModel("inverse"),t.setRefDistance(p),t.setMaxDistance(m),t.setRolloffFactor(1),t.setVolume(d),e=t,b.add(e)}else(e=new i.Audio(S)).setVolume(d);return P.current=e,()=>{C();try{e.stop()}catch{}try{e.disconnect()}catch{}D&&b.remove(e),P.current=null,L.current=!1,V.current=!1}}},[A,S,D,p,m,d,b]);let E=(e,t)=>{if(g)if(y>0||h>0){let r=Math.max(0,y),n=Math.max(r,h),o=r===n?r:Math.random()*(n-r)+r;e.loop=!1;let i=()=>{t===F.current&&(!1===e.isPlaying?k.current=setTimeout(()=>{if(t===F.current)try{e.play(),E(e,t)}catch{}},o):B.current=setTimeout(i,100))};B.current=setTimeout(i,100)}else e.setLoop(!0)},G=e=>{if(!A)return;let t=F.current;if(L.current)try{e.isPlaying||(e.play(),E(e,t))}catch{}else{let r;try{r=(0,u.audioToUrl)(f)}catch{return}R(r,A,r=>{if(t===F.current&&!e.buffer){e.setBuffer(r),L.current=!0;try{e.play(),E(e,t)}catch{}}})}};return(0,r.useEffect)(()=>{let e=P.current;e&&!D&&w&&f&&G(e)},[w,D,f,A,S]),(0,o.useFrame)(()=>{let e=P.current;if(!e||!D||!w||!f)return;let t=x.position.distanceTo(j.current),r=V.current,n=t<=m;if(n&&!r)V.current=!0,G(e);else if(!n&&r){V.current=!1,C();try{e.stop()}catch{}}}),(0,r.useEffect)(()=>{let e=P.current;if(e&&!w){C();try{e.stop()}catch{}V.current=!1}},[w]),l?(0,t.jsxs)("mesh",{position:j.current,children:[(0,t.jsx)("sphereGeometry",{args:[p,12,12]}),(0,t.jsx)("meshBasicMaterial",{color:"#00ff00",wireframe:!0,opacity:.05,transparent:!0,toneMapped:!1}),(0,t.jsx)(s.FloatingLabel,{color:"#00ff00",position:[0,p+1,0],children:f})]}):null});e.s(["AudioEmitter",0,M,"audioBufferCache",0,f,"getCachedAudioBuffer",()=>R,"getSoundGeneration",()=>h,"playOneShotSound",()=>v,"resolveAudioProfile",()=>g,"stopAllTrackedSounds",()=>D,"trackSound",()=>p,"untrackSound",()=>m])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/6f1c1038c8b3b80c.js b/docs/_next/static/chunks/6f1c1038c8b3b80c.js new file mode 100644 index 00000000..48946d16 --- /dev/null +++ b/docs/_next/static/chunks/6f1c1038c8b3b80c.js @@ -0,0 +1,75 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63724,e=>{"use strict";var r=e.i(43476),o=e.i(932),a=e.i(71645),t=e.i(47071),l=e.i(71753),c=e.i(90072),n=e.i(12979),i=e.i(79123);let u=` +#include + +varying vec2 vUv; + +void main() { + vUv = uv; + vec4 mvPosition = modelViewMatrix * vec4(position, 1.0); + gl_Position = projectionMatrix * mvPosition; + #include +} +`,s=` +#include + +uniform sampler2D frame0; +uniform sampler2D frame1; +uniform sampler2D frame2; +uniform sampler2D frame3; +uniform sampler2D frame4; +uniform int currentFrame; +uniform float vScroll; +uniform vec2 uvScale; +uniform vec3 tintColor; +uniform float opacity; +uniform float opacityFactor; + +varying vec2 vUv; + +void main() { + // Scale and scroll UVs + vec2 scrolledUv = vec2(vUv.x * uvScale.x, vUv.y * uvScale.y + vScroll); + + // Sample the current frame + vec4 texColor; + if (currentFrame == 0) { + texColor = texture2D(frame0, scrolledUv); + } else if (currentFrame == 1) { + texColor = texture2D(frame1, scrolledUv); + } else if (currentFrame == 2) { + texColor = texture2D(frame2, scrolledUv); + } else if (currentFrame == 3) { + texColor = texture2D(frame3, scrolledUv); + } else { + texColor = texture2D(frame4, scrolledUv); + } + + // Tribes 2 GL_MODULATE: output = texture * vertexColor + // No gamma correction - textures use NoColorSpace and values pass through + // directly to display, matching how WaterBlock handles sRGB textures. + vec3 modulatedColor = texColor.rgb * tintColor; + + float adjustedOpacity = opacity * opacityFactor; + + gl_FragColor = vec4(modulatedColor, adjustedOpacity); + + // Custom fog for additive blending: fade out rather than blend to fog color. + // Standard fog (mix toward fogColor) doesn't work with additive blending + // because we'd still be adding fogColor to the framebuffer. + // Uses Torque's quadratic haze formula for consistency. + #ifdef USE_FOG + float dist = vFogDepth; + float fogFactor = 0.0; + if (dist > fogNear) { + if (dist >= fogFar) { + fogFactor = 1.0; + } else { + float fogScale = 1.0 / (fogFar - fogNear); + float distFactor = (dist - fogNear) * fogScale - 1.0; + fogFactor = 1.0 - distFactor * distFactor; + } + } + gl_FragColor.a *= 1.0 - fogFactor; + #endif +} +`;function f(e){let r,t,l,n=(0,o.c)(7),[i,u,s]=e;n[0]!==i||n[1]!==u||n[2]!==s?((r=new c.BoxGeometry(i,u,s)).translate(i/2,u/2,s/2),n[0]=i,n[1]=u,n[2]=s,n[3]=r):r=n[3];let f=r;return n[4]!==f?(t=()=>()=>f.dispose(),l=[f],n[4]=f,n[5]=t,n[6]=l):(t=n[5],l=n[6]),(0,a.useEffect)(t,l),f}function m(e){let a,t,l,n=(0,o.c)(10),{scale:i,color:u,baseTranslucency:s}=e,m=f(i);n[0]!==u[0]||n[1]!==u[1]||n[2]!==u[2]?(a=new c.Color(u[0],u[1],u[2]),n[0]=u[0],n[1]=u[1],n[2]=u[2],n[3]=a):a=n[3];let d=a,v=+s;return n[4]!==d||n[5]!==v?(t=(0,r.jsx)("meshBasicMaterial",{color:d,transparent:!0,opacity:v,blending:c.AdditiveBlending,side:c.DoubleSide,depthWrite:!1,fog:!1}),n[4]=d,n[5]=v,n[6]=t):t=n[6],n[7]!==m||n[8]!==t?(l=(0,r.jsx)("mesh",{geometry:m,renderOrder:1,children:t}),n[7]=m,n[8]=t,n[9]=l):l=n[9],l}function d({scale:e,data:o}){let{animationEnabled:m}=(0,i.useSettings)(),d=f(e),v=(0,a.useMemo)(()=>o.textures.map(e=>(0,n.textureToUrl)(e)),[o.textures]),g=(0,t.useTexture)(v,e=>{e.forEach(e=>{e.wrapS=e.wrapT=c.RepeatWrapping,e.colorSpace=c.NoColorSpace,e.flipY=!1,e.needsUpdate=!0})}),p=(0,a.useMemo)(()=>(function({textures:e,scale:r,umapping:o,vmapping:a,color:t,baseTranslucency:l}){let n=[...r].sort((e,r)=>r-e),i=new c.Vector2(n[0]*o,n[1]*a),f=e[0];return new c.ShaderMaterial({uniforms:{frame0:{value:f},frame1:{value:e[1]??f},frame2:{value:e[2]??f},frame3:{value:e[3]??f},frame4:{value:e[4]??f},currentFrame:{value:0},vScroll:{value:0},uvScale:{value:i},tintColor:{value:new c.Color(...t)},opacity:{value:l},opacityFactor:{value:1},fogColor:{value:new c.Color},fogNear:{value:1},fogFar:{value:2e3}},vertexShader:u,fragmentShader:s,transparent:!0,blending:c.AdditiveBlending,side:c.DoubleSide,depthWrite:!1,fog:!0})})({textures:g,scale:e,umapping:o.umapping,vmapping:o.vmapping,color:o.color,baseTranslucency:o.baseTranslucency}),[g,e,o]);(0,a.useEffect)(()=>()=>p.dispose(),[p]);let x=(0,a.useRef)(0);return(0,l.useFrame)((e,r)=>{if(!m){x.current=0,p.uniforms.currentFrame.value=0,p.uniforms.vScroll.value=0;return}x.current+=r,p.uniforms.currentFrame.value=Math.floor(x.current*o.framesPerSec)%o.numFrames,p.uniforms.vScroll.value=x.current*o.scrollSpeed}),(0,r.jsx)("mesh",{geometry:d,material:p,renderOrder:1})}function v(e){let t,l,c,n=(0,o.c)(14),{data:i,scale:u}=e;if(0===i.textures.map(g).length){let e;return n[0]!==i.baseTranslucency||n[1]!==i.color||n[2]!==u?(e=(0,r.jsx)(m,{scale:u,color:i.color,baseTranslucency:i.baseTranslucency}),n[0]=i.baseTranslucency,n[1]=i.color,n[2]=u,n[3]=e):e=n[3],e}return n[4]!==i.baseTranslucency||n[5]!==i.color||n[6]!==u?(t=(0,r.jsx)(m,{scale:u,color:i.color,baseTranslucency:i.baseTranslucency}),n[4]=i.baseTranslucency,n[5]=i.color,n[6]=u,n[7]=t):t=n[7],n[8]!==i||n[9]!==u?(l=(0,r.jsx)(d,{scale:u,data:i}),n[8]=i,n[9]=u,n[10]=l):l=n[10],n[11]!==t||n[12]!==l?(c=(0,r.jsx)(a.Suspense,{fallback:t,children:l}),n[11]=t,n[12]=l,n[13]=c):c=n[13],c}function g(e){return(0,n.textureToUrl)(e)}e.s(["ForceFieldBare",()=>v],63724)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/718b5c36c0eed37e.js b/docs/_next/static/chunks/718b5c36c0eed37e.js new file mode 100644 index 00000000..de55c7c8 --- /dev/null +++ b/docs/_next/static/chunks/718b5c36c0eed37e.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66438,e=>{e.v({Bullet:"GuiMarkup-module__CLgNnq__Bullet",GuiMarkup:"GuiMarkup-module__CLgNnq__GuiMarkup"})},41973,e=>{e.v({Body:"MapInfoDialog-module__m0lXla__Body",CloseButton:"MapInfoDialog-module__m0lXla__CloseButton "+e.i(6090).DialogButton,Dialog:"MapInfoDialog-module__m0lXla__Dialog",Footer:"MapInfoDialog-module__m0lXla__Footer",Hint:"MapInfoDialog-module__m0lXla__Hint",Left:"MapInfoDialog-module__m0lXla__Left",MapBlurb:"MapInfoDialog-module__m0lXla__MapBlurb",MapMeta:"MapInfoDialog-module__m0lXla__MapMeta",MapPlanet:"MapInfoDialog-module__m0lXla__MapPlanet",MapQuote:"MapInfoDialog-module__m0lXla__MapQuote",MusicButton:"MapInfoDialog-module__m0lXla__MusicButton",MusicTrack:"MapInfoDialog-module__m0lXla__MusicTrack",MusicTrackName:"MapInfoDialog-module__m0lXla__MusicTrackName",Overlay:"MapInfoDialog-module__m0lXla__Overlay",PreviewImage:"MapInfoDialog-module__m0lXla__PreviewImage",PreviewImageFloating:"MapInfoDialog-module__m0lXla__PreviewImageFloating",Section:"MapInfoDialog-module__m0lXla__Section",SectionTitle:"MapInfoDialog-module__m0lXla__SectionTitle",Title:"MapInfoDialog-module__m0lXla__Title"})},94247,e=>{"use strict";var t=e.i(43476),a=e.i(932),l=e.i(71645),n=e.i(11152),i=e.i(66027),r=e.i(12979),s=e.i(91996),o=e.i(66438);let u=new Set(["spop","spush","lmargin","font","color","bitmap","a","/a"]),c=new Map;function m(e){let l,n=(0,a.c)(5),{name:i}=e;n[0]!==i?(l=function(e){let t;if(c.has(e))return c.get(e);try{t=(0,r.getUrlForPath)((0,s.getStandardTextureResourceKey)(`textures/gui/${e}`))}catch{t=null}return c.set(e,t),t}(i),n[0]=i,n[1]=l):l=n[1];let u=l;if(u){let e;return n[2]!==u?(e=(0,t.jsx)("img",{src:u,alt:"",className:o.default.Bitmap}),n[2]=u,n[3]=e):e=n[3],e}if(/bullet/i.test(i)){let e;return n[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("span",{className:o.default.Bullet,children:"•"}),n[4]=e):e=n[4],e}return null}let p=/<(?:font|color|bitmap|just|lmargin|a):/i;function d(e){let n,i,r=(0,a.c)(4),{markup:s}=e;r[0]!==s?(n=function(e){let a=e.split(/<([^><]+)>/g).map((e,t)=>{if(t%2==0)return e?{type:"text",value:e}:null;{let[t,...a]=e.split(":");return u.has(t.toLowerCase())?{type:"tag",name:t,args:a}:{type:"text",value:`<${e}>`}}}).filter(e=>null!=e),n={type:"span",source:"root",style:{},children:[]},i=n,r=[i],s=e=>null!=e.children&&e.children.some(e=>"string"==typeof e||s(e));for(let e of a)switch(e.type){case"text":i.children.push(e.value);break;case"tag":switch(e.name){case"spush":{let e={type:"span",source:"spush",style:{},children:[]};i.children.push(e),i=e,r.push(i);break}case"spop":if("root"!==i.source){let e=r.pop();for(;"spush"!==e.source;)e=r.pop();i=r[r.length-1]}break;case"lmargin":break;case"font":{let t=function(e){let[t,a]=e;return{fontDescription:t,fontSize:a?Math.max(11,Math.min(parseInt(a.trim(),10),16)):void 0}}(e.args).fontSize;if(s(i)){let e={type:"span",source:"spush",style:{fontSize:t},children:[]};i.children.push(e),i=e,r.push(i)}else i.style.fontSize=t;break}case"color":if(s(i)){let t={type:"span",source:"spush",style:{color:`#${e.args[0].trim()}`},children:[]};i.children.push(t),i=t,r.push(i)}else i.style.color=`#${e.args[0].trim()}`;break;case"bitmap":{let t={type:"bitmap",value:e.args[0]};i.children.push(t);break}case"a":{let t=e.args[0].trim().split(" "),a=2===t.length&&"wwwlink"===t[0]?t[1]:t[0],l={type:"a",source:"a",value:`http://${a}`,style:{},children:[]};i.children.push(l),i=l,r.push(i);break}case"/a":{let e=r.pop();for(;"a"!==e.source;)e=r.pop();i=r[r.length-1]}}}return function e(a){switch(a.type){case"span":return l.default.createElement("span",{style:0===Object.keys(a.style).length?void 0:a.style},...a.children.map(t=>"string"==typeof t?t:e(t)));case"a":return l.default.createElement("a",{href:a.value,style:0===Object.keys(a.style).length?void 0:a.style,rel:"noopener noreferrer",target:"_blank"},...a.children.map(t=>"string"==typeof t?t:e(t)));case"bitmap":return(0,t.jsx)(m,{name:a.value})}}(n)}(s),r[0]=s,r[1]=n):n=r[1];let c=n;return r[2]!==c?(i=(0,t.jsx)("div",{className:o.default.GuiMarkup,children:c}),r[2]=c,r[3]=i):i=r[3],i}var f=e.i(41973);function h(e){let n,i,r,s=(0,a.c)(7),{src:o,alt:u,className:c}=e,m=void 0===c?f.default.PreviewImage:c,[p,d]=(0,l.useState)(null);return(s[0]!==o?(n=()=>{let e,t=!1;return fetch(o).then(M).then(y).then(g).then(a=>{!t&&a&&d(e=URL.createObjectURL(a))}).catch(_),()=>{t=!0,e&&URL.revokeObjectURL(e)}},i=[o],s[0]=o,s[1]=n,s[2]=i):(n=s[1],i=s[2]),(0,l.useEffect)(n,i),p)?(s[3]!==u||s[4]!==m||s[5]!==p?(r=(0,t.jsx)("img",{src:p,alt:u,className:m}),s[3]=u,s[4]=m,s[5]=p,s[6]=r):r=s[6],r):null}function _(){}function g(e){return new Promise(t=>{let a=document.createElement("canvas");a.width=e.width,a.height=e.height,a.getContext("2d")?.drawImage(e,0,0),e.close(),a.toBlob(t)})}function y(e){return createImageBitmap(e,{colorSpaceConversion:"none"})}function M(e){return e.blob()}function v(e){let i,s,o,u,c,m,p,d,h,_,g,y=(0,a.c)(22),{track:M}=e,[v,x]=(0,l.useState)(!1),[b,j]=(0,l.useState)(!0),k=(0,l.useRef)(null);y[0]!==M?(i=M.toLowerCase(),y[0]=M,y[1]=i):i=y[1];let I=`${r.RESOURCE_ROOT_URL}music/${i}.mp3`;y[2]===Symbol.for("react.memo_cache_sentinel")?(s=()=>()=>{k.current?.pause()},o=[],y[2]=s,y[3]=o):(s=y[2],o=y[3]),(0,l.useEffect)(s,o),y[4]!==v?(u=()=>{let e=k.current;e&&(v?e.pause():e.play().catch(()=>j(!1)))},y[4]=v,y[5]=u):u=y[5];let w=u;return y[6]===Symbol.for("react.memo_cache_sentinel")?(c=()=>x(!0),m=()=>x(!1),p=()=>j(!1),y[6]=c,y[7]=m,y[8]=p):(c=y[6],m=y[7],p=y[8]),y[9]!==I?(d=(0,t.jsx)("audio",{ref:k,src:I,loop:!0,onPlay:c,onPause:m,onError:p}),y[9]=I,y[10]=d):d=y[10],y[11]!==M?(h=(0,t.jsx)("span",{className:f.default.MusicTrackName,children:M}),y[11]=M,y[12]=h):h=y[12],y[13]!==b||y[14]!==v||y[15]!==w?(_=b&&(0,t.jsx)("button",{className:f.default.MusicButton,onClick:w,"aria-label":v?"Pause music":"Play music",children:v?(0,t.jsx)(n.FaVolumeUp,{}):(0,t.jsx)(n.FaVolumeMute,{})}),y[13]=b,y[14]=v,y[15]=w,y[16]=_):_=y[16],y[17]!==v||y[18]!==_||y[19]!==d||y[20]!==h?(g=(0,t.jsxs)("div",{className:f.default.MusicTrack,"data-playing":v,children:[d,h,_]}),y[17]=v,y[18]=_,y[19]=d,y[20]=h,y[21]=g):g=y[21],g}function x(e){var n,o,u;let c,m,_,g,y,M,x,I,w,N,B,S,D,P,C,L,T,X,E,R,U,O,F,$,K,Q,q,G,z,A,H,V,J,W,Y,Z,ee,et=(0,a.c)(102),{open:ea,onClose:el,missionName:en,missionType:ei}=e,{data:er}=((ee=(0,a.c)(2))[0]!==en?(Z={queryKey:["parsedMission",en],queryFn:()=>(0,r.loadMission)(en)},ee[0]=en,ee[1]=Z):Z=ee[1],(0,i.useQuery)(Z)),es=(0,l.useRef)(null);if(et[0]!==ea?(c=()=>{if(ea){es.current?.focus();try{document.exitPointerLock()}catch{}}},m=[ea],et[0]=ea,et[1]=c,et[2]=m):(c=et[1],m=et[2]),(0,l.useEffect)(c,m),et[3]!==el||et[4]!==ea?(_=()=>{if(!ea)return;let e=e=>{if("KeyI"===e.code||"Escape"===e.key)el();else if("k"===e.key&&(e.metaKey||e.ctrlKey))return void el();e.stopImmediatePropagation()};return window.addEventListener("keydown",e,{capture:!0}),window.addEventListener("keyup",k,{capture:!0}),()=>{window.removeEventListener("keydown",e,{capture:!0}),window.removeEventListener("keyup",k,{capture:!0})}},g=[ea,el],et[3]=el,et[4]=ea,et[5]=_,et[6]=g):(_=et[5],g=et[6]),(0,l.useEffect)(_,g),!ea)return null;et[7]!==er?(y=er?function(e){for(let t of e.body){if("ObjectDeclaration"!==t.type)continue;let{instanceName:e,body:a}=t;if(e&&"Identifier"===e.type&&"missiongroup"===e.name.toLowerCase()){let e={};for(let t of a){if("Assignment"!==t.type)continue;let{target:a,value:l}=t;"Identifier"===a.type&&"StringLiteral"===l.type&&(e[a.name.toLowerCase()]=l.value)}return e}}return{}}(er.ast):{},et[7]=er,et[8]=y):y=et[8];let eo=y;et[9]!==en||et[10]!==er?(M=er?function(e,t){if(e)try{let t=(0,s.getStandardTextureResourceKey)(`textures/gui/${e}`);return(0,r.getUrlForPath)(t)}catch{}try{let e=(0,s.getStandardTextureResourceKey)(`textures/gui/Load_${t}`);return(0,r.getUrlForPath)(e)}catch{}return null}(er.bitmap,en):null,et[9]=en,et[10]=er,et[11]=M):M=et[11];let eu=M,ec=er?.displayName??en;et[12]!==ei?(x=ei.toLowerCase(),et[12]=ei,et[13]=x):x=et[13];let em="singleplayer"===x,ep=eo.musictrack;if(et[14]!==eu||et[15]!==ec||et[16]!==em||et[17]!==ei||et[18]!==el||et[19]!==er){let e,a,l,i,r,s,c=er?.missionString?(n=er.missionString,s=ei.toUpperCase(),n.split("\n").flatMap(e=>{let t=e.match(/^\[([^\]]+)\]/);return t&&!t[1].toUpperCase().split(/\s+/).includes(s)?[]:[e.replace(/^\[[^\]]+\]/,"")]}).join("\n")):null;if(et[38]!==er?.missionQuote){if(o=i=er?.missionQuote?.trim()??"",l="",e="",!(a=p.test(o)))for(let t of i.split("\n")){let a=t.trim();a.match(/^--[^-]/)?e=a.replace(/^-+\s*/,"").trim():a&&(l+=(l?"\n":"")+a)}et[38]=er?.missionQuote,et[39]=e,et[40]=a,et[41]=l,et[42]=i}else e=et[39],a=et[40],l=et[41],i=et[42];(O=f.default.Overlay,F=el,P=es,C=f.default.Dialog,L=j,T=b,X="dialog",E="true",R="Map Information",U=-1,D=f.default.Body,$=f.default.Left,et[43]!==eu||et[44]!==ec||et[45]!==em?(K=eu&&em&&(0,t.jsx)(h,{className:f.default.PreviewImageFloating,src:eu,alt:`${ec} preview`},eu),et[43]=eu,et[44]=ec,et[45]=em,et[46]=K):K=et[46],et[47]!==ec?(I=(0,t.jsx)("h1",{className:f.default.Title,children:ec}),et[47]=ec,et[48]=I):I=et[48],et[49]!==er?(r=er?.planetName&&(0,t.jsx)("span",{className:f.default.MapPlanet,children:er.planetName}),et[49]=er,et[50]=r):r=et[50],et[51]!==r?(w=(0,t.jsx)("div",{className:f.default.MapMeta,children:r}),et[51]=r,et[52]=w):w=et[52],et[53]!==e||et[54]!==a||et[55]!==l||et[56]!==i?(N=a?(0,t.jsx)("blockquote",{className:f.default.MapQuote,children:(0,t.jsx)(d,{markup:i})}):l?(0,t.jsxs)("blockquote",{className:f.default.MapQuote,children:[(0,t.jsx)("p",{children:l}),e&&(0,t.jsxs)("cite",{children:["— ",e]})]}):null,et[53]=e,et[54]=a,et[55]=l,et[56]=i,et[57]=N):N=et[57],et[58]!==er)?(B=er?.missionBlurb&&(0,t.jsx)("div",{className:f.default.MapBlurb,children:(u=er.missionBlurb,p.test(u))?(0,t.jsx)(d,{markup:er.missionBlurb.trim()}):er.missionBlurb.trim()}),et[58]=er,et[59]=B):B=et[59],S=c&&c.trim()&&(0,t.jsx)("div",{className:f.default.Section,children:(0,t.jsx)(d,{markup:c})}),et[14]=eu,et[15]=ec,et[16]=em,et[17]=ei,et[18]=el,et[19]=er,et[20]=I,et[21]=w,et[22]=N,et[23]=B,et[24]=S,et[25]=D,et[26]=P,et[27]=C,et[28]=L,et[29]=T,et[30]=X,et[31]=E,et[32]=R,et[33]=U,et[34]=O,et[35]=F,et[36]=$,et[37]=K}else I=et[20],w=et[21],N=et[22],B=et[23],S=et[24],D=et[25],P=et[26],C=et[27],L=et[28],T=et[29],X=et[30],E=et[31],R=et[32],U=et[33],O=et[34],F=et[35],$=et[36],K=et[37];return et[60]!==er?(Q=er?.missionBriefing&&(0,t.jsxs)("div",{className:f.default.Section,children:[(0,t.jsx)("h2",{className:f.default.SectionTitle,children:"Mission Briefing"}),(0,t.jsx)(d,{markup:er.missionBriefing})]}),et[60]=er,et[61]=Q):Q=et[61],et[62]!==ep?(q=ep&&(0,t.jsx)(v,{track:ep}),et[62]=ep,et[63]=q):q=et[63],et[64]!==I||et[65]!==w||et[66]!==N||et[67]!==B||et[68]!==S||et[69]!==Q||et[70]!==q||et[71]!==$||et[72]!==K?(G=(0,t.jsxs)("div",{className:$,children:[K,I,w,N,B,S,Q,q]}),et[64]=I,et[65]=w,et[66]=N,et[67]=B,et[68]=S,et[69]=Q,et[70]=q,et[71]=$,et[72]=K,et[73]=G):G=et[73],et[74]!==eu||et[75]!==ec||et[76]!==em?(z=eu&&!em&&(0,t.jsx)(h,{src:eu,alt:`${ec} preview`},eu),et[74]=eu,et[75]=ec,et[76]=em,et[77]=z):z=et[77],et[78]!==D||et[79]!==G||et[80]!==z?(A=(0,t.jsxs)("div",{className:D,children:[G,z]}),et[78]=D,et[79]=G,et[80]=z,et[81]=A):A=et[81],et[82]!==el?(H=(0,t.jsx)("button",{className:f.default.CloseButton,onClick:el,children:"Close"}),et[82]=el,et[83]=H):H=et[83],et[84]===Symbol.for("react.memo_cache_sentinel")?(V=(0,t.jsx)("span",{className:f.default.Hint,children:"I or Esc to close"}),et[84]=V):V=et[84],et[85]!==H?(J=(0,t.jsxs)("div",{className:f.default.Footer,children:[H,V]}),et[85]=H,et[86]=J):J=et[86],et[87]!==P||et[88]!==C||et[89]!==L||et[90]!==T||et[91]!==X||et[92]!==E||et[93]!==R||et[94]!==U||et[95]!==A||et[96]!==J?(W=(0,t.jsxs)("div",{ref:P,className:C,onClick:L,onKeyDown:T,role:X,"aria-modal":E,"aria-label":R,tabIndex:U,children:[A,J]}),et[87]=P,et[88]=C,et[89]=L,et[90]=T,et[91]=X,et[92]=E,et[93]=R,et[94]=U,et[95]=A,et[96]=J,et[97]=W):W=et[97],et[98]!==O||et[99]!==F||et[100]!==W?(Y=(0,t.jsx)("div",{className:O,onClick:F,children:W}),et[98]=O,et[99]=F,et[100]=W,et[101]=Y):Y=et[101],Y}function b(e){return e.stopPropagation()}function j(e){return e.stopPropagation()}function k(e){e.stopImmediatePropagation()}e.s(["MapInfoDialog",()=>x],94247)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/796073b9f885dcbc.js b/docs/_next/static/chunks/796073b9f885dcbc.js new file mode 100644 index 00000000..66b4e73c --- /dev/null +++ b/docs/_next/static/chunks/796073b9f885dcbc.js @@ -0,0 +1,166 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,42585,e=>{"use strict";var t=e.i(43476),a=e.i(932),o=e.i(71645),r=e.i(31067),i=e.i(90072);let n=o.forwardRef(({args:e,children:t,...a},i)=>{let n=o.useRef(null);return o.useImperativeHandle(i,()=>n.current),o.useLayoutEffect(()=>void 0),o.createElement("mesh",(0,r.default)({ref:n},a),o.createElement("boxGeometry",{attach:"geometry",args:e}),t)});var s=e.i(47071),l=e.i(71753),u=e.i(15080),c=e.i(12979);e.i(70847);var f=e.i(63318),v=e.i(75567),d=e.i(48066),m=e.i(47021);let p=` + #include + + #ifdef USE_FOG + #define USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; + #endif + + uniform float uTime; + uniform float uWaveMagnitude; + + varying vec3 vWorldPosition; + varying vec3 vViewVector; + varying float vDistance; + + // Wave function matching Tribes 2 engine + // Z = surfaceZ + (sin(X*0.05 + time) + sin(Y*0.05 + time)) * waveFactor + // waveFactor = waveAmplitude * 0.25 + // Note: Using xz for Three.js Y-up (Torque uses XY with Z-up) + float getWaveHeight(vec3 worldPos) { + float waveFactor = uWaveMagnitude * 0.25; + return (sin(worldPos.x * 0.05 + uTime) + sin(worldPos.z * 0.05 + uTime)) * waveFactor; + } + + void main() { + // Get world position for wave calculation + vec4 worldPos = modelMatrix * vec4(position, 1.0); + vWorldPosition = worldPos.xyz; + + // Apply wave displacement to Y (vertical axis in Three.js) + vec3 displaced = position; + displaced.y += getWaveHeight(worldPos.xyz); + + // Calculate final world position after displacement for fog + #ifdef USE_FOG + vec4 displacedWorldPos = modelMatrix * vec4(displaced, 1.0); + vFogWorldPosition = displacedWorldPos.xyz; + #endif + + // Calculate view vector for environment mapping + vViewVector = cameraPosition - worldPos.xyz; + vDistance = length(vViewVector); + + vec4 mvPosition = viewMatrix * modelMatrix * vec4(displaced, 1.0); + gl_Position = projectionMatrix * mvPosition; + + // Set fog depth (distance from camera) - normally done by fog_vertex include + // but we can't use that include because it references 'transformed' which we don't have + #ifdef USE_FOG + vFogDepth = length(mvPosition.xyz); + #endif + } +`,g=` + #include + + // Enable volumetric fog (must be defined before fog uniforms) + #ifdef USE_FOG + #define USE_VOLUMETRIC_FOG + #define USE_FOG_WORLD_POSITION + #endif + + uniform float uTime; + uniform float uOpacity; + uniform float uEnvMapIntensity; + uniform sampler2D uBaseTexture; + uniform sampler2D uEnvMapTexture; + + // Volumetric fog uniforms + #ifdef USE_FOG + uniform float fogVolumeData[12]; + uniform float cameraHeight; + uniform bool fogEnabled; + varying vec3 vFogWorldPosition; + #endif + + varying vec3 vWorldPosition; + varying vec3 vViewVector; + varying float vDistance; + + #define TWO_PI 6.283185307179586 + + // Constants from Tribes 2 engine + #define BASE_DRIFT_CYCLE_TIME 8.0 + #define BASE_DRIFT_RATE 0.02 + #define BASE_DRIFT_SCALAR 0.03 + #define TEXTURE_SCALE (1.0 / 48.0) + + // Environment map UV wobble constants + #define Q1 150.0 + #define Q2 2.0 + #define Q3 0.01 + + // Rotate UV coordinates + vec2 rotateUV(vec2 uv, float angle) { + float c = cos(angle); + float s = sin(angle); + return vec2( + uv.x * c - uv.y * s, + uv.x * s + uv.y * c + ); + } + + void main() { + // Calculate base texture UVs using world position (1/48 tiling) + vec2 baseUV = vWorldPosition.xz * TEXTURE_SCALE; + + // Phase (time in radians for drift cycle) + float phase = mod(uTime * (TWO_PI / BASE_DRIFT_CYCLE_TIME), TWO_PI); + + // Base texture drift + float baseDriftX = uTime * BASE_DRIFT_RATE; + float baseDriftY = cos(phase) * BASE_DRIFT_SCALAR; + + // === Phase 1a: First base texture pass (rotated 30 degrees) === + vec2 uv1a = rotateUV(baseUV, radians(30.0)); + + // === Phase 1b: Second base texture pass (rotated 60 degrees total, with drift) === + vec2 uv1b = rotateUV(baseUV + vec2(baseDriftX, baseDriftY), radians(60.0)); + + // Calculate cross-fade swing value + float A1 = cos(((vWorldPosition.x / Q1) + (uTime / Q2)) * 6.0); + float A2 = sin(((vWorldPosition.z / Q1) + (uTime / Q2)) * TWO_PI); + float swing = (A1 + A2) * 0.15 + 0.5; + + // Cross-fade alpha calculation from engine + float alpha1a = ((1.0 - swing) * uOpacity) / max(1.0 - (swing * uOpacity), 0.001); + float alpha1b = swing * uOpacity; + + // Sample base texture for both passes + vec4 texColor1a = texture2D(uBaseTexture, uv1a); + vec4 texColor1b = texture2D(uBaseTexture, uv1b); + + // Combined alpha and color + float combinedAlpha = 1.0 - (1.0 - alpha1a) * (1.0 - alpha1b); + vec3 baseColor = (texColor1a.rgb * alpha1a * (1.0 - alpha1b) + texColor1b.rgb * alpha1b) / max(combinedAlpha, 0.001); + + // === Phase 3: Environment map / specular === + vec3 reflectVec = -vViewVector; + reflectVec.y = abs(reflectVec.y); + if (reflectVec.y < 0.001) reflectVec.y = 0.001; + + vec2 envUV; + if (vDistance < 0.001) { + envUV = vec2(0.0); + } else { + float value = (vDistance - reflectVec.y) / (vDistance * vDistance); + envUV.x = reflectVec.x * value; + envUV.y = reflectVec.z * value; + } + + envUV = envUV * 0.5 + 0.5; + envUV.x += A1 * Q3; + envUV.y += A2 * Q3; + + vec4 envColor = texture2D(uEnvMapTexture, envUV); + vec3 finalColor = baseColor + envColor.rgb * envColor.a * uEnvMapIntensity; + + // Note: Tribes 2 water does NOT use lighting - Phase 2 (lightmap) is disabled + // in the original engine. Water colors come directly from textures. + + gl_FragColor = vec4(finalColor, combinedAlpha); + + // Apply volumetric fog using shared Torque-style fog shader + ${m.fogFragmentShader} + } +`;var h=e.i(79123);function x(e){let o,r,n=(0,a.c)(5),{surfaceTexture:l,attach:u}=e;n[0]!==l?(o=(0,c.textureToUrl)(l),n[0]=l,n[1]=o):o=n[1];let f=o,v=(0,s.useTexture)(f,T);return n[2]!==u||n[3]!==v?(r=(0,t.jsx)("meshStandardMaterial",{attach:u,map:v,transparent:!0,opacity:.8,side:i.DoubleSide}),n[2]=u,n[3]=v,n[4]=r):r=n[4],r}function T(e){return(0,v.setupTexture)(e)}let b=(0,o.memo)(function(e){let r,s,c,v,d,m,p,g,x,T,b,E,_,S,V,P,U,C,F,D=(0,a.c)(59),{scene:A}=e,{debugMode:O}=(0,h.useDebug)();D[0]!==A.transform?(r=(0,f.matrixFToQuaternion)(A.transform),D[0]=A.transform,D[1]=r):r=D[1];let W=r;D[2]!==A.transform.position?(s=(0,f.torqueToThree)(A.transform.position),D[2]=A.transform.position,D[3]=s):s=D[3];let I=s;D[4]!==A.scale?(c=(0,f.torqueScaleToThree)(A.scale),D[4]=A.scale,D[5]=c):c=D[5];let R=c,[z,B,j]=R,G=(0,u.useThree)(w),N=(C=(0,a.c)(1),F=(0,o.useRef)(null),C[0]===Symbol.for("react.memo_cache_sentinel")?(U=e=>{if(!F.current)return F.current=e.clone(),!0;let t=F.current.x===e.x&&F.current.y===e.y&&F.current.z===e.z;return t||F.current.copy(e),t},C[0]=U):U=C[0],U),L=A.waveMagnitude,[Q,Y,X]=I,q=Q+1024,H=X+1024;D[6]!==q?(v=Math.round(q/8),D[6]=q,D[7]=v):v=D[7];let $=v;D[8]!==H?(d=Math.round(H/8),D[8]=H,D[9]=d):d=D[9];let Z=d,k=8*($=Math.max(0,Math.min(2040,$))),J=8*(Z=Math.max(0,Math.min(2040,Z)));D[10]!==k||D[11]!==J||D[12]!==Y?(m=[k,Y,J],D[10]=k,D[11]=J,D[12]=Y,D[13]=m):m=D[13];let K=m,ee=M;D[14]!==G.position.x||D[15]!==G.position.z?(p=()=>ee(G.position.x,G.position.z),D[14]=G.position.x,D[15]=G.position.z,D[16]=p):p=D[16];let[et,ea]=(0,o.useState)(p);D[17]!==G.position||D[18]!==N?(g=()=>{if(!N(G.position))return;let e=ee(G.position.x,G.position.z);ea(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)},D[17]=G.position,D[18]=N,D[19]=g):g=D[19],(0,l.useFrame)(g);let eo=A.surfaceName||"liquidTiles/BlueWater",er=A.envMapName||void 0,ei=A.surfaceOpacity,en=A.envMapIntensity;if(D[20]!==z||D[21]!==B||D[22]!==j){let e,[t,a]=(e=z<=1024&&j<=1024?8:16,[Math.max(4,Math.ceil(z/e)),Math.max(4,Math.ceil(j/e))]);(x=new i.PlaneGeometry(z,j,t,a)).rotateX(-Math.PI/2),x.translate(z/2,B,j/2),D[20]=z,D[21]=B,D[22]=j,D[23]=x}else x=D[23];let es=x;if(D[24]!==es?(b=()=>()=>{es.dispose()},T=[es],D[24]=es,D[25]=T,D[26]=b):(T=D[25],b=D[26]),(0,o.useEffect)(b,T),D[27]!==O||D[28]!==I[0]||D[29]!==I[1]||D[30]!==I[2]||D[31]!==R||D[32]!==z||D[33]!==B||D[34]!==j?(E=O&&(0,t.jsx)(n,{args:R,position:[I[0]+z/2,I[1]+B/2,I[2]+j/2],children:(0,t.jsx)("meshBasicMaterial",{color:"#00fbff",wireframe:!0})}),D[27]=O,D[28]=I[0],D[29]=I[1],D[30]=I[2],D[31]=R,D[32]=z,D[33]=B,D[34]=j,D[35]=E):E=D[35],D[36]!==K||D[37]!==et||D[38]!==es){let e;D[40]!==K||D[41]!==es?(e=e=>{let[a,o]=e,r=K[0]+2048*a-1024,n=K[2]+2048*o-1024;return(0,t.jsx)("mesh",{geometry:es,position:[r,K[1],n],children:(0,t.jsx)("meshStandardMaterial",{color:"#00fbff",transparent:!0,opacity:.4,wireframe:!0,side:i.DoubleSide})},`${a},${o}`)},D[40]=K,D[41]=es,D[42]=e):e=D[42],_=et.map(e),D[36]=K,D[37]=et,D[38]=es,D[39]=_}else _=D[39];return D[43]!==K||D[44]!==en||D[45]!==er||D[46]!==ei||D[47]!==et||D[48]!==es||D[49]!==eo||D[50]!==L?(S=(0,t.jsx)(y,{reps:et,basePosition:K,surfaceGeometry:es,surfaceTexture:eo,envMapTexture:er,opacity:ei,waveMagnitude:L,envMapIntensity:en}),D[43]=K,D[44]=en,D[45]=er,D[46]=ei,D[47]=et,D[48]=es,D[49]=eo,D[50]=L,D[51]=S):S=D[51],D[52]!==_||D[53]!==S?(V=(0,t.jsx)(o.Suspense,{fallback:_,children:S}),D[52]=_,D[53]=S,D[54]=V):V=D[54],D[55]!==W||D[56]!==E||D[57]!==V?(P=(0,t.jsxs)("group",{quaternion:W,children:[E,V]}),D[55]=W,D[56]=E,D[57]=V,D[58]=P):P=D[58],P}),y=(0,o.memo)(function({reps:e,basePosition:a,surfaceGeometry:r,surfaceTexture:n,envMapTexture:u,opacity:f,waveMagnitude:m,envMapIntensity:x}){let T=(0,c.textureToUrl)(n),b=(0,c.textureToUrl)(u??"special/lush_env"),[y,w]=(0,s.useTexture)([T,b],e=>{(Array.isArray(e)?e:[e]).forEach(e=>{(0,v.setupTexture)(e),e.colorSpace=i.NoColorSpace,e.wrapS=i.RepeatWrapping,e.wrapT=i.RepeatWrapping})}),{animationEnabled:M}=(0,h.useSettings)(),E=(0,o.useMemo)(()=>{var e;return e={opacity:f,waveMagnitude:m,envMapIntensity:x,baseTexture:y,envMapTexture:w},new i.ShaderMaterial({uniforms:{uTime:{value:0},uOpacity:{value:e?.opacity??.75},uWaveMagnitude:{value:e?.waveMagnitude??1},uEnvMapIntensity:{value:e?.envMapIntensity??1},uBaseTexture:{value:e?.baseTexture??null},uEnvMapTexture:{value:e?.envMapTexture??null},fogColor:{value:new i.Color},fogNear:{value:1},fogFar:{value:2e3},fogVolumeData:d.globalFogUniforms.fogVolumeData,cameraHeight:d.globalFogUniforms.cameraHeight,fogEnabled:d.globalFogUniforms.fogEnabled},vertexShader:p,fragmentShader:g,transparent:!0,side:i.DoubleSide,depthWrite:!0,fog:!0})},[f,m,x,y,w]),_=(0,o.useRef)(0);return(0,l.useFrame)((e,t)=>{M?(_.current+=t,E.uniforms.uTime.value=_.current):(_.current=0,E.uniforms.uTime.value=0)}),(0,o.useEffect)(()=>()=>{E.dispose()},[E]),(0,t.jsx)(t.Fragment,{children:e.map(([e,o])=>{let i=a[0]+2048*e-1024,n=a[2]+2048*o-1024;return(0,t.jsx)("mesh",{geometry:r,material:E,position:[i,a[1],n]},`${e},${o}`)})})});function w(e){return e.camera}function M(e,t){let a=e+1024,o=t+1024,r=Math.trunc(a/2048),i=Math.trunc(o/2048);a<0&&r--,o<0&&i--;let n=[];for(let e=i-1;e<=i+1;e++)for(let t=r-1;t<=r+1;t++)n.push([t,e]);return n}e.s(["WaterBlock",0,b,"WaterMaterial",()=>x],42585)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/818dce712bc45cb4.js b/docs/_next/static/chunks/818dce712bc45cb4.js new file mode 100644 index 00000000..a1230a42 --- /dev/null +++ b/docs/_next/static/chunks/818dce712bc45cb4.js @@ -0,0 +1,174 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,19273,80166,e=>{"use strict";e.i(47167);var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function i(e){setTimeout(e,0)}e.s(["systemSetTimeoutZero",()=>i,"timeoutManager",()=>r],80166);var s="u"=0&&e!==1/0}function u(e,t){return Math.max(e+(t||0)-Date.now(),0)}function l(e,t){return"function"==typeof e?e(t):e}function c(e,t){return"function"==typeof e?e(t):e}function h(e,t){let{type:r="all",exact:i,fetchStatus:s,predicate:n,queryKey:a,stale:o}=e;if(a){if(i){if(t.queryHash!==d(a,t.options))return!1}else if(!v(t.queryKey,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!s||s===t.state.fetchStatus)&&(!n||!!n(t))}function f(e,t){let{exact:r,status:i,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(p(t.options.mutationKey)!==p(n))return!1}else if(!v(t.options.mutationKey,n))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))}function d(e,t){return(t?.queryKeyHashFn||p)(e)}function p(e){return JSON.stringify(e,(e,t)=>b(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function v(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>v(e[r],t[r]))}var m=Object.prototype.hasOwnProperty;function g(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function y(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function b(e){if(!S(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function S(e){return"[object Object]"===Object.prototype.toString.call(e)}function T(e){return new Promise(t=>{r.setTimeout(t,e)})}function O(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?function e(t,r,i=0){if(t===r)return t;if(i>500)return r;let s=y(t)&&y(r);if(!s&&!(b(t)&&b(r)))return r;let n=(s?t:Object.keys(t)).length,a=s?r:Object.keys(r),o=a.length,u=s?Array(o):{},l=0;for(let c=0;cr?i.slice(1):i}function R(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var E=Symbol();function C(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==E?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function w(e,t){return"function"==typeof e?e(...t):!!e}function D(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e}e.s(["addConsumeAwareSignal",()=>D,"addToEnd",()=>F,"addToStart",()=>R,"ensureQueryFn",()=>C,"functionalUpdate",()=>a,"hashKey",()=>p,"hashQueryKeyByOptions",()=>d,"isServer",()=>s,"isValidTimeout",()=>o,"matchMutation",()=>f,"matchQuery",()=>h,"noop",()=>n,"partialMatchKey",()=>v,"replaceData",()=>O,"resolveEnabled",()=>c,"resolveStaleTime",()=>l,"shallowEqualObjects",()=>g,"shouldThrowError",()=>w,"skipToken",()=>E,"sleep",()=>T,"timeUntilStale",()=>u],19273)},40143,e=>{"use strict";let t,r,i,s,n,a;var o=e.i(80166).systemSetTimeoutZero,u=(t=[],r=0,i=e=>{e()},s=e=>{e()},n=o,{batch:e=>{let a;r++;try{a=e()}finally{let e;--r||(e=t,t=[],e.length&&n(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a=e=>{r?t.push(e):n(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}});e.s(["notifyManager",()=>u])},15823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",()=>t])},75555,e=>{"use strict";var t=e.i(15823),r=e.i(19273),i=new class extends t.Subscribable{#r;#i;#s;constructor(){super(),this.#s=e=>{if(!r.isServer&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",()=>i])},86491,14448,93803,36553,88587,e=>{"use strict";e.i(47167);var t=e.i(19273),r=e.i(40143),i=e.i(75555),s=e.i(15823),n=new class extends s.Subscribable{#n=!0;#i;#s;constructor(){super(),this.#s=e=>{if(!t.isServer&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};function a(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}function o(e){return Math.min(1e3*2**e,3e4)}function u(e){return(e??"online")!=="online"||n.isOnline()}e.s(["onlineManager",()=>n],14448),e.s(["pendingThenable",()=>a],93803);var l=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function c(e){let r,s=!1,c=0,h=a(),f=()=>i.focusManager.isFocused()&&("always"===e.networkMode||n.isOnline())&&e.canRun(),d=()=>u(e.networkMode)&&e.canRun(),p=e=>{"pending"===h.status&&(r?.(),h.resolve(e))},v=e=>{"pending"===h.status&&(r?.(),h.reject(e))},m=()=>new Promise(t=>{r=e=>{("pending"!==h.status||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===h.status&&e.onContinue?.()}),g=()=>{let r;if("pending"!==h.status)return;let i=0===c?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(p).catch(r=>{if("pending"!==h.status)return;let i=e.retry??3*!t.isServer,n=e.retryDelay??o,a="function"==typeof n?n(c,r):n,u=!0===i||"number"==typeof i&&cf()?void 0:m()).then(()=>{s?v(r):g()}))})};return{promise:h,status:()=>h.status,cancel:t=>{if("pending"===h.status){let r=new l(t);v(r),e.onCancel?.(r)}},continue:()=>(r?.(),h),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:d,start:()=>(d()?g():m().then(g),h)}}e.s(["CancelledError",()=>l,"canFetch",()=>u,"createRetryer",()=>c],36553);var h=e.i(80166),f=class{#a;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,t.isValidTimeout)(this.gcTime)&&(this.#a=h.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(t.isServer?1/0:3e5))}clearGcTimeout(){this.#a&&(h.timeoutManager.clearTimeout(this.#a),this.#a=void 0)}};e.s(["Removable",()=>f],88587);var d=class extends f{#o;#u;#l;#c;#h;#f;#d;constructor(e){super(),this.#d=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#l=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=m(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#f,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=m(this.options);void 0!==e.data&&(this.setState(v(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#l.remove(this)}setData(e,r){let i=(0,t.replaceData)(this.state.data,e,this.options);return this.#p({data:i,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),i}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){let r=this.#h?.promise;return this.#h?.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some(e=>!1!==(0,t.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t.skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,t.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#d?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(e,r){let i;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&r?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let s=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,s.signal)})},a=()=>{let e,i=(0,t.ensureQueryFn)(this.options,r),s=(n(e={client:this.#c,queryKey:this.queryKey,meta:this.meta}),e);return(this.#d=!1,this.options.persister)?this.options.persister(i,s,this):i(s)},o=(n(i={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:a}),i);this.options.behavior?.onFetch(o,this),this.#u=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#p({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=c({initialPromise:r?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof l&&e.revert&&this.setState({...this.#u,fetchStatus:"idle"}),s.abort()},onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#l.config.onSuccess?.(e,this),this.#l.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof l){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#p({type:"error",error:e}),this.#l.config.onError?.(e,this),this.#l.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#p(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...p(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...v(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#u=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:e})})}};function p(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:u(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function v(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function m(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",()=>d,"fetchState",()=>p],86491)},12598,e=>{"use strict";var t=e.i(71645),r=e.i(43476),i=t.createContext(void 0),s=e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r},n=({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s}));e.s(["QueryClientProvider",()=>n,"useQueryClient",()=>s])},69230,e=>{"use strict";var t=e.i(75555),r=e.i(40143),i=e.i(86491),s=e.i(15823),n=e.i(93803),a=e.i(19273),o=e.i(80166),u=class extends s.Subscribable{constructor(e,t){super(),this.options=t,this.#c=e,this.#v=null,this.#m=(0,n.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#c;#g=void 0;#y=void 0;#b=void 0;#S;#T;#m;#v;#O;#F;#R;#E;#C;#w;#D=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#g.addObserver(this),l(this.#g,this.options)?this.#I():this.updateResult(),this.#U())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c(this.#g,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c(this.#g,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#x(),this.#P(),this.#g.removeObserver(this)}setOptions(e){let t=this.options,r=this.#g;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,a.resolveEnabled)(this.options.enabled,this.#g))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#M(),this.#g.setOptions(this.options),t._defaulted&&!(0,a.shallowEqualObjects)(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#g,observer:this});let i=this.hasListeners();i&&h(this.#g,r,this.options,t)&&this.#I(),this.updateResult(),i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||(0,a.resolveStaleTime)(this.options.staleTime,this.#g)!==(0,a.resolveStaleTime)(t.staleTime,this.#g))&&this.#_();let s=this.#Q();i&&(this.#g!==r||(0,a.resolveEnabled)(this.options.enabled,this.#g)!==(0,a.resolveEnabled)(t.enabled,this.#g)||s!==this.#w)&&this.#k(s)}getOptimisticResult(e){var t,r;let i=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(i,e);return t=this,r=s,(0,a.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#b=s,this.#T=this.options,this.#S=this.#g.state),s}getCurrentResult(){return this.#b}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#m.status||this.#m.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#D.add(e)}getCurrentQuery(){return this.#g}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#c.defaultQueryOptions(e),r=this.#c.getQueryCache().build(this.#c,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#I({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#b))}#I(e){this.#M();let t=this.#g.fetch(this.options,e);return e?.throwOnError||(t=t.catch(a.noop)),t}#_(){this.#x();let e=(0,a.resolveStaleTime)(this.options.staleTime,this.#g);if(a.isServer||this.#b.isStale||!(0,a.isValidTimeout)(e))return;let t=(0,a.timeUntilStale)(this.#b.dataUpdatedAt,e);this.#E=o.timeoutManager.setTimeout(()=>{this.#b.isStale||this.updateResult()},t+1)}#Q(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#g):this.options.refetchInterval)??!1}#k(e){this.#P(),this.#w=e,!a.isServer&&!1!==(0,a.resolveEnabled)(this.options.enabled,this.#g)&&(0,a.isValidTimeout)(this.#w)&&0!==this.#w&&(this.#C=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#I()},this.#w))}#U(){this.#_(),this.#k(this.#Q())}#x(){this.#E&&(o.timeoutManager.clearTimeout(this.#E),this.#E=void 0)}#P(){this.#C&&(o.timeoutManager.clearInterval(this.#C),this.#C=void 0)}createResult(e,t){let r,s=this.#g,o=this.options,u=this.#b,c=this.#S,d=this.#T,p=e!==s?e.state:this.#y,{state:v}=e,m={...v},g=!1;if(t._optimisticResults){let r=this.hasListeners(),n=!r&&l(e,t),a=r&&h(e,s,t,o);(n||a)&&(m={...m,...(0,i.fetchState)(v.data,e.options)}),"isRestoring"===t._optimisticResults&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:b,status:S}=m;r=m.data;let T=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===S){let e;u?.isPlaceholderData&&t.placeholderData===d?.placeholderData?(e=u.data,T=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#R?.state.data,this.#R):t.placeholderData,void 0!==e&&(S="success",r=(0,a.replaceData)(u?.data,e,t),g=!0)}if(t.select&&void 0!==r&&!T)if(u&&r===c?.data&&t.select===this.#O)r=this.#F;else try{this.#O=t.select,r=t.select(r),r=(0,a.replaceData)(u?.data,r,t),this.#F=r,this.#v=null}catch(e){this.#v=e}this.#v&&(y=this.#v,r=this.#F,b=Date.now(),S="error");let O="fetching"===m.fetchStatus,F="pending"===S,R="error"===S,E=F&&O,C=void 0!==r,w={status:S,fetchStatus:m.fetchStatus,isPending:F,isSuccess:"success"===S,isError:R,isInitialLoading:E,isLoading:E,data:r,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>p.dataUpdateCount||m.errorUpdateCount>p.errorUpdateCount,isFetching:O,isRefetching:O&&!F,isLoadingError:R&&!C,isPaused:"paused"===m.fetchStatus,isPlaceholderData:g,isRefetchError:R&&C,isStale:f(e,t),refetch:this.refetch,promise:this.#m,isEnabled:!1!==(0,a.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==w.data,r="error"===w.status&&!t,i=e=>{r?e.reject(w.error):t&&e.resolve(w.data)},a=()=>{i(this.#m=w.promise=(0,n.pendingThenable)())},o=this.#m;switch(o.status){case"pending":e.queryHash===s.queryHash&&i(o);break;case"fulfilled":(r||w.data!==o.value)&&a();break;case"rejected":r&&w.error===o.reason||a()}}return w}updateResult(){let e=this.#b,t=this.createResult(this.#g,this.options);if(this.#S=this.#g.state,this.#T=this.options,void 0!==this.#S.data&&(this.#R=this.#g),(0,a.shallowEqualObjects)(t,e))return;this.#b=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#D.size)return!0;let i=new Set(r??this.#D);return this.options.throwOnError&&i.add("error"),Object.keys(this.#b).some(t=>this.#b[t]!==e[t]&&i.has(t))};this.#L({listeners:r()})}#M(){let e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#g)return;let t=this.#g;this.#g=e,this.#y=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#U()}#L(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#b)}),this.#c.getQueryCache().notify({query:this.#g,type:"observerResultsUpdated"})})}};function l(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&c(e,t,t.refetchOnMount)}function c(e,t,r){if(!1!==(0,a.resolveEnabled)(t.enabled,e)&&"static"!==(0,a.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&f(e,t)}return!1}function h(e,t,r,i){return(e!==t||!1===(0,a.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&f(e,r)}function f(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,a.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",()=>u])},69637,54440,e=>{"use strict";let t;e.i(47167);var r=e.i(71645),i=e.i(19273),s=e.i(40143),n=e.i(12598);e.i(43476);var a=r.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),o=r.createContext(!1);o.Provider;var u=(e,t)=>void 0===t.state.data,l=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(e??1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>t(r(...e)):t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},c=(e,t)=>e.isLoading&&e.isFetching&&!t,h=(e,t)=>e?.suspense&&t.isPending,f=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function d(e,t,u){let d,p=r.useContext(o),v=r.useContext(a),m=(0,n.useQueryClient)(u),g=m.defaultQueryOptions(e);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);let y=m.getQueryCache().get(g.queryHash);g._optimisticResults=p?"isRestoring":"optimistic",l(g),d=y?.state.error&&"function"==typeof g.throwOnError?(0,i.shouldThrowError)(g.throwOnError,[y.state.error,y]):g.throwOnError,(g.suspense||g.experimental_prefetchInRender||d)&&!v.isReset()&&(g.retryOnMount=!1),r.useEffect(()=>{v.clearReset()},[v]);let b=!m.getQueryCache().get(g.queryHash),[S]=r.useState(()=>new t(m,g)),T=S.getOptimisticResult(g),O=!p&&!1!==e.subscribed;if(r.useSyncExternalStore(r.useCallback(e=>{let t=O?S.subscribe(s.notifyManager.batchCalls(e)):i.noop;return S.updateResult(),t},[S,O]),()=>S.getCurrentResult(),()=>S.getCurrentResult()),r.useEffect(()=>{S.setOptions(g)},[g,S]),h(g,T))throw f(g,S,v);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&void 0===e.data||(0,i.shouldThrowError)(r,[e.error,s])))({result:T,errorResetBoundary:v,throwOnError:g.throwOnError,query:y,suspense:g.suspense}))throw T.error;if(m.getDefaultOptions().queries?._experimental_afterQuery?.(g,T),g.experimental_prefetchInRender&&!i.isServer&&c(T,p)){let e=b?f(g,S,v):y?.promise;e?.catch(i.noop).finally(()=>{S.updateResult()})}return g.notifyOnChangeProps?T:S.trackResult(T)}e.s(["defaultThrowOnError",()=>u,"ensureSuspenseTimers",()=>l,"fetchOptimistic",()=>f,"shouldSuspend",()=>h,"willFetch",()=>c],54440),e.s(["useBaseQuery",()=>d],69637)},51475,e=>{"use strict";var t=e.i(43476),r=e.i(71645),i=e.i(71753);let s=(0,r.createContext)(null);function n({children:e}){let n=(0,r.useRef)(void 0),a=(0,r.useRef)(0),o=(0,r.useRef)(0);(0,i.useFrame)((e,t)=>{for(a.current+=t;a.current>=.03125;)if(a.current-=.03125,o.current++,n.current)for(let e of n.current)e(o.current)});let u=(0,r.useCallback)(e=>(n.current??=new Set,n.current.add(e),()=>{n.current.delete(e)}),[]),l=(0,r.useCallback)(()=>o.current,[]),c=(0,r.useMemo)(()=>({subscribe:u,getTick:l}),[u,l]);return(0,t.jsx)(s.Provider,{value:c,children:e})}function a(e){let t=(0,r.useContext)(s);if(!t)throw Error("useTick must be used within a TickProvider");let i=(0,r.useRef)(e);i.current=e,(0,r.useEffect)(()=>t.subscribe(e=>i.current(e)),[t])}e.s(["TICK_RATE",0,32,"TickProvider",()=>n,"useTick",()=>a])},47071,99143,e=>{"use strict";var t=e.i(71645),r=e.i(90072),i=e.i(15080),s=e.i(40859);e.s(["useLoader",()=>s.G],99143);var s=s;let n=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function a(e,a){let o=(0,i.useThree)(e=>e.gl),u=(0,s.G)(r.TextureLoader,n(e)?Object.values(e):e);return(0,t.useLayoutEffect)(()=>{null==a||a(u)},[a]),(0,t.useEffect)(()=>{if("initTexture"in o){let e=[];Array.isArray(u)?e=u:u instanceof r.Texture?e=[u]:n(u)&&(e=Object.values(u)),e.forEach(e=>{e instanceof r.Texture&&o.initTexture(e)})}},[o,u]),(0,t.useMemo)(()=>{if(!n(e))return u;{let t={},r=0;for(let i in e)t[i]=u[r++];return t}},[e,u])}a.preload=e=>s.G.preload(r.TextureLoader,e),a.clear=e=>s.G.clear(r.TextureLoader,e),e.s(["useTexture",()=>a],47071)},75567,e=>{"use strict";var t=e.i(90072);let r=new t.ImageBitmapLoader,i=new Map;function s(e,s){let n=i.get(e);if(n)return s&&n.image&&s(n),n;let a=new t.Texture;return a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s?.(a)}),a}function n(e){let s=i.get(e);return s?s.image?Promise.resolve(s):new Promise(e=>{let t=()=>{s.image?e(s):setTimeout(t,16)};t()}):new Promise((s,n)=>{let a=new t.Texture;a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s(a)},void 0,n)})}function a(e,r={}){let{repeat:i=[1,1],disableMipmaps:s=!1}=r;return e.wrapS=e.wrapT=t.RepeatWrapping,e.colorSpace=t.SRGBColorSpace,e.repeat.set(...i),e.flipY=!1,e.anisotropy=16,s?(e.generateMipmaps=!1,e.minFilter=t.LinearFilter):(e.generateMipmaps=!0,e.minFilter=t.LinearMipmapLinearFilter),e.magFilter=t.LinearFilter,e.needsUpdate=!0,e}function o(e){let r=new t.DataTexture(e,256,256,t.RedFormat,t.UnsignedByteType);return r.colorSpace=t.NoColorSpace,r.wrapS=r.wrapT=t.RepeatWrapping,r.generateMipmaps=!1,r.minFilter=t.LinearFilter,r.magFilter=t.LinearFilter,r.needsUpdate=!0,r}e.s(["loadTexture",()=>s,"loadTextureAsync",()=>n,"setupMask",()=>o,"setupTexture",()=>a])},47021,e=>{"use strict";var t=e.i(8560);let r=` +#ifdef USE_FOG + // Check fog enabled uniform - allows toggling without shader recompilation + #ifdef USE_VOLUMETRIC_FOG + if (!fogEnabled) { + // Skip all fog calculations when disabled + } else { + #endif + + float dist = vFogDepth; + + // Discard fragments at or beyond visible distance - matches Torque's behavior + // where objects beyond visibleDistance are not rendered at all. + // This prevents fully-fogged geometry from showing as silhouettes against + // the sky's fog-to-sky gradient. + if (dist >= fogFar) { + discard; + } + + // Step 1: Calculate distance-based haze (quadratic falloff) + // Since we discard at fogFar, haze never reaches 1.0 here + float haze = 0.0; + if (dist > fogNear) { + float fogScale = 1.0 / (fogFar - fogNear); + float distFactor = (dist - fogNear) * fogScale - 1.0; + haze = 1.0 - distFactor * distFactor; + } + + // Step 2: Calculate fog volume contributions + // Note: Per-volume colors are NOT used in Tribes 2 ($specialFog defaults to false) + // All fog uses the global fogColor - see Tribes2_Fog_System.md for details + float volumeFog = 0.0; + + #ifdef USE_VOLUMETRIC_FOG + { + #ifdef USE_FOG_WORLD_POSITION + float fragmentHeight = vFogWorldPosition.y; + #else + float fragmentHeight = cameraHeight; + #endif + + float deltaY = fragmentHeight - cameraHeight; + float absDeltaY = abs(deltaY); + + // Determine if we're going up (positive) or down (negative) + if (absDeltaY > 0.01) { + // Non-horizontal ray: ray-march through fog volumes + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + // Skip inactive volumes (visibleDistance = 0) + if (volVisDist <= 0.0) continue; + + // Calculate fog factor for this volume + // From Torque: factor = (1 / (volumeVisDist * visFactor)) * percentage + // where visFactor is smVisibleDistanceMod (a user quality pref, default 1.0) + // Since we don't have quality settings, we use visFactor = 1.0 + float factor = (1.0 / volVisDist) * volPct; + + // Find ray intersection with this volume's height range + float rayMinY = min(cameraHeight, fragmentHeight); + float rayMaxY = max(cameraHeight, fragmentHeight); + + // Check if ray intersects volume height range + if (rayMinY < volMaxH && rayMaxY > volMinH) { + float intersectMin = max(rayMinY, volMinH); + float intersectMax = min(rayMaxY, volMaxH); + float intersectHeight = intersectMax - intersectMin; + + // Calculate distance traveled through this volume using similar triangles: + // subDist / dist = intersectHeight / absDeltaY + float subDist = dist * (intersectHeight / absDeltaY); + + // Accumulate fog: fog += subDist * factor + volumeFog += subDist * factor; + } + } + } else { + // Near-horizontal ray: if camera is inside a volume, apply full fog for that volume + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + if (volVisDist <= 0.0) continue; + + // If camera is inside this volume, apply fog for full distance + if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { + float factor = (1.0 / volVisDist) * volPct; + volumeFog += dist * factor; + } + } + } + } + #endif + + // Step 3: Combine haze and volume fog + // Torque's clamping: if (bandPct + hazePct > 1) hazePct = 1 - bandPct + // This gives fog volumes priority over haze + float volPct = min(volumeFog, 1.0); + float hazePct = haze; + if (volPct + hazePct > 1.0) { + hazePct = 1.0 - volPct; + } + float fogFactor = hazePct + volPct; + + // Apply fog using global fogColor (per-volume colors not used in Tribes 2) + gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor); + + #ifdef USE_VOLUMETRIC_FOG + } // end fogEnabled check + #endif +#endif +`;function i(){t.ShaderChunk.fog_pars_fragment=` +#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif + + // Custom volumetric fog uniforms (only defined when USE_VOLUMETRIC_FOG is set) + // Format: [visDist, minH, maxH, percentage] x 3 volumes = 12 floats + #ifdef USE_VOLUMETRIC_FOG + uniform float fogVolumeData[12]; + uniform float cameraHeight; + #endif + + #ifdef USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; + #endif +#endif +`,t.ShaderChunk.fog_fragment=r,t.ShaderChunk.fog_pars_vertex=` +#ifdef USE_FOG + varying float vFogDepth; + #ifdef USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; + #endif +#endif +`,t.ShaderChunk.fog_vertex=` +#ifdef USE_FOG + // Use Euclidean distance from camera, not view-space z-depth + // This ensures fog doesn't change when rotating the camera + vFogDepth = length(mvPosition.xyz); + #ifdef USE_FOG_WORLD_POSITION + vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; + #endif +#endif +`}function s(e,t){e.uniforms.fogVolumeData=t.fogVolumeData,e.uniforms.cameraHeight=t.cameraHeight,e.uniforms.fogEnabled=t.fogEnabled,e.vertexShader=e.vertexShader.replace("#include ",`#include +#ifdef USE_FOG + #define USE_FOG_WORLD_POSITION + #define USE_VOLUMETRIC_FOG + varying vec3 vFogWorldPosition; +#endif`),e.vertexShader=e.vertexShader.replace("#include ",`#include +#ifdef USE_FOG + vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; +#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include +#ifdef USE_FOG + #define USE_VOLUMETRIC_FOG + uniform float fogVolumeData[12]; + uniform float cameraHeight; + uniform bool fogEnabled; + #define USE_FOG_WORLD_POSITION + varying vec3 vFogWorldPosition; +#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",r)}e.s(["fogFragmentShader",0,r,"injectCustomFog",()=>s,"installCustomFogShader",()=>i])},48066,e=>{"use strict";let t={fogVolumeData:{value:new Float32Array(12)},cameraHeight:{value:0},fogEnabled:{value:!0}};function r(e,i,s=!0){t.cameraHeight.value=e,t.fogVolumeData.value.set(i),t.fogEnabled.value=s}function i(){t.cameraHeight.value=0,t.fogVolumeData.value.fill(0),t.fogEnabled.value=!0}function s(e){let t=new Float32Array(12);for(let r=0;r<3;r++){let i=4*r,s=e[r];s&&(t[i+0]=s.visibleDistance,t[i+1]=s.minHeight,t[i+2]=s.maxHeight,t[i+3]=s.percentage)}return t}e.s(["globalFogUniforms",0,t,"packFogVolumeData",()=>s,"resetGlobalFogUniforms",()=>i,"updateGlobalFogUniforms",()=>r])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/88a5cf0ea7f16af4.js b/docs/_next/static/chunks/88a5cf0ea7f16af4.js new file mode 100644 index 00000000..d59879d0 --- /dev/null +++ b/docs/_next/static/chunks/88a5cf0ea7f16af4.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,85413,e=>{"use strict";var t=Object.defineProperty;class i{constructor(){((e,i,s)=>{let r,n;n=void 0,(r="symbol"!=typeof i?i+"":i)in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let i=this._listeners[e];if(void 0!==i){let e=i.indexOf(t);-1!==e&&i.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let i=t.slice(0);for(let t=0,s=i.length;ti])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/8c435435e00c1d09.js b/docs/_next/static/chunks/8c435435e00c1d09.js deleted file mode 100644 index ece1b98a..00000000 --- a/docs/_next/static/chunks/8c435435e00c1d09.js +++ /dev/null @@ -1,75 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,63724,e=>{"use strict";var r=e.i(43476),t=e.i(932),o=e.i(71645),a=e.i(47071),l=e.i(71753),i=e.i(90072),n=e.i(62395),s=e.i(12979),c=e.i(79123),u=e.i(6112);let f=` -#include - -varying vec2 vUv; - -void main() { - vUv = uv; - vec4 mvPosition = modelViewMatrix * vec4(position, 1.0); - gl_Position = projectionMatrix * mvPosition; - #include -} -`,m=` -#include - -uniform sampler2D frame0; -uniform sampler2D frame1; -uniform sampler2D frame2; -uniform sampler2D frame3; -uniform sampler2D frame4; -uniform int currentFrame; -uniform float vScroll; -uniform vec2 uvScale; -uniform vec3 tintColor; -uniform float opacity; -uniform float opacityFactor; - -varying vec2 vUv; - -void main() { - // Scale and scroll UVs - vec2 scrolledUv = vec2(vUv.x * uvScale.x, vUv.y * uvScale.y + vScroll); - - // Sample the current frame - vec4 texColor; - if (currentFrame == 0) { - texColor = texture2D(frame0, scrolledUv); - } else if (currentFrame == 1) { - texColor = texture2D(frame1, scrolledUv); - } else if (currentFrame == 2) { - texColor = texture2D(frame2, scrolledUv); - } else if (currentFrame == 3) { - texColor = texture2D(frame3, scrolledUv); - } else { - texColor = texture2D(frame4, scrolledUv); - } - - // Tribes 2 GL_MODULATE: output = texture * vertexColor - // No gamma correction - textures use NoColorSpace and values pass through - // directly to display, matching how WaterBlock handles sRGB textures. - vec3 modulatedColor = texColor.rgb * tintColor; - - float adjustedOpacity = opacity * opacityFactor; - - gl_FragColor = vec4(modulatedColor, adjustedOpacity); - - // Custom fog for additive blending: fade out rather than blend to fog color. - // Standard fog (mix toward fogColor) doesn't work with additive blending - // because we'd still be adding fogColor to the framebuffer. - // Uses Torque's quadratic haze formula for consistency. - #ifdef USE_FOG - float dist = vFogDepth; - float fogFactor = 0.0; - if (dist > fogNear) { - if (dist >= fogFar) { - fogFactor = 1.0; - } else { - float fogScale = 1.0 / (fogFar - fogNear); - float distFactor = (dist - fogNear) * fogScale - 1.0; - fogFactor = 1.0 - distFactor * distFactor; - } - } - gl_FragColor.a *= 1.0 - fogFactor; - #endif -} -`;function d(e){let r,a,l,n=(0,t.c)(7),[s,c,u]=e;n[0]!==s||n[1]!==c||n[2]!==u?((r=new i.BoxGeometry(s,c,u)).translate(s/2,c/2,u/2),n[0]=s,n[1]=c,n[2]=u,n[3]=r):r=n[3];let f=r;return n[4]!==f?(a=()=>()=>f.dispose(),l=[f],n[4]=f,n[5]=a,n[6]=l):(a=n[5],l=n[6]),(0,o.useEffect)(a,l),f}function p({scale:e,color:t,baseTranslucency:n,textureUrls:s,numFrames:u,framesPerSec:p,scrollSpeed:v,umapping:g,vmapping:x}){let{animationEnabled:F}=(0,c.useSettings)(),y=d(e),S=(0,a.useTexture)(s,e=>{e.forEach(e=>{e.wrapS=e.wrapT=i.RepeatWrapping,e.colorSpace=i.NoColorSpace,e.flipY=!1,e.needsUpdate=!0})}),h=(0,o.useMemo)(()=>(function({textures:e,scale:r,umapping:t,vmapping:o,color:a,baseTranslucency:l}){let n=[...r].sort((e,r)=>r-e),s=new i.Vector2(n[0]*t,n[1]*o),c=e[0];return new i.ShaderMaterial({uniforms:{frame0:{value:c},frame1:{value:e[1]??c},frame2:{value:e[2]??c},frame3:{value:e[3]??c},frame4:{value:e[4]??c},currentFrame:{value:0},vScroll:{value:0},uvScale:{value:s},tintColor:{value:new i.Color(...a)},opacity:{value:l},opacityFactor:{value:1},fogColor:{value:new i.Color},fogNear:{value:1},fogFar:{value:2e3}},vertexShader:f,fragmentShader:m,transparent:!0,blending:i.AdditiveBlending,side:i.DoubleSide,depthWrite:!1,fog:!0})})({textures:S,scale:e,umapping:g,vmapping:x,color:t,baseTranslucency:n}),[S,e,g,x,t,n]);(0,o.useEffect)(()=>()=>h.dispose(),[h]);let C=(0,o.useRef)(0);return(0,l.useFrame)((e,r)=>{if(!F){C.current=0,h.uniforms.currentFrame.value=0,h.uniforms.vScroll.value=0;return}C.current+=r,h.uniforms.currentFrame.value=Math.floor(C.current*p)%u,h.uniforms.vScroll.value=C.current*v}),(0,r.jsx)("mesh",{geometry:y,material:h,renderOrder:1})}function v(e){let o,a,l,n=(0,t.c)(10),{scale:s,color:c,baseTranslucency:u}=e,f=d(s);n[0]!==c[0]||n[1]!==c[1]||n[2]!==c[2]?(o=new i.Color(c[0],c[1],c[2]),n[0]=c[0],n[1]=c[1],n[2]=c[2],n[3]=o):o=n[3];let m=o,p=+u;return n[4]!==m||n[5]!==p?(a=(0,r.jsx)("meshBasicMaterial",{color:m,transparent:!0,opacity:p,blending:i.AdditiveBlending,side:i.DoubleSide,depthWrite:!1,fog:!1}),n[4]=m,n[5]=p,n[6]=a):a=n[6],n[7]!==f||n[8]!==a?(l=(0,r.jsx)("mesh",{geometry:f,renderOrder:1,children:a}),n[7]=f,n[8]=a,n[9]=l):l=n[9],l}let g=(0,o.memo)(function(e){let a,l,i,c,f,m,d,g,x,F,y,S,h,C,b,U,P,D=(0,t.c)(56),{object:w}=e;D[0]!==w?(a=(0,n.getPosition)(w),D[0]=w,D[1]=a):a=D[1];let T=a;D[2]!==w?(l=(0,n.getRotation)(w),D[2]=w,D[3]=l):l=D[3];let j=l;D[4]!==w?(i=(0,n.getScale)(w),D[4]=w,D[5]=i):i=D[5];let B=i;D[6]!==w?(c=(0,n.getProperty)(w,"dataBlock"),D[6]=w,D[7]=c):c=D[7];let _=(0,u.useDatablock)(c);D[8]!==_?(f=(0,n.getProperty)(_,"color"),D[8]=_,D[9]=f):f=D[9];let O=f;if(D[10]!==O){let e;m=O?[(e=O.split(" ").map(e=>parseFloat(e)))[0]??0,e[1]??0,e[2]??0]:[1,1,1],D[10]=O,D[11]=m}else m=D[11];let M=m;D[12]!==_?(d=parseFloat((0,n.getProperty)(_,"baseTranslucency"))||1,D[12]=_,D[13]=d):d=D[13];let N=d;D[14]!==_?(g=parseInt((0,n.getProperty)(_,"numFrames"),10)||1,D[14]=_,D[15]=g):g=D[15];let R=g;D[16]!==_?(x=parseFloat((0,n.getProperty)(_,"framesPerSec"))||1,D[16]=_,D[17]=x):x=D[17];let k=x;D[18]!==_?(F=parseFloat((0,n.getProperty)(_,"scrollSpeed"))||0,D[18]=_,D[19]=F):F=D[19];let A=F;D[20]!==_?(y=parseFloat((0,n.getProperty)(_,"umapping"))||1,D[20]=_,D[21]=y):y=D[21];let E=y;D[22]!==_?(S=parseFloat((0,n.getProperty)(_,"vmapping"))||1,D[22]=_,D[23]=S):S=D[23];let q=S;D[24]!==_||D[25]!==R?(h=function(e,r){let t=[];for(let o=0;o{"use strict";function t(){return(t=Object.assign.bind()).apply(null,arguments)}e.s(["default",()=>t])},47071,99143,e=>{"use strict";var t=e.i(71645),r=e.i(90072),i=e.i(15080),s=e.i(40859);e.s(["useLoader",()=>s.G],99143);var s=s;let a=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function n(e,n){let o=(0,i.useThree)(e=>e.gl),l=(0,s.G)(r.TextureLoader,a(e)?Object.values(e):e);return(0,t.useLayoutEffect)(()=>{null==n||n(l)},[n]),(0,t.useEffect)(()=>{if("initTexture"in o){let e=[];Array.isArray(l)?e=l:l instanceof r.Texture?e=[l]:a(l)&&(e=Object.values(l)),e.forEach(e=>{e instanceof r.Texture&&o.initTexture(e)})}},[o,l]),(0,t.useMemo)(()=>{if(!a(e))return l;{let t={},r=0;for(let i in e)t[i]=l[r++];return t}},[e,l])}n.preload=e=>s.G.preload(r.TextureLoader,e),n.clear=e=>s.G.clear(r.TextureLoader,e),e.s(["useTexture",()=>n],47071)},75567,e=>{"use strict";var t=e.i(90072);let r=new t.ImageBitmapLoader,i=new Map;function s(e,s){let a=i.get(e);if(a)return s&&a.image&&s(a),a;let n=new t.Texture;return n.flipY=!1,i.set(e,n),r.load(e,e=>{n.image=e,n.needsUpdate=!0,s?.(n)}),n}function a(e){let s=i.get(e);return s?s.image?Promise.resolve(s):new Promise(e=>{let t=()=>{s.image?e(s):setTimeout(t,16)};t()}):new Promise((s,a)=>{let n=new t.Texture;n.flipY=!1,i.set(e,n),r.load(e,e=>{n.image=e,n.needsUpdate=!0,s(n)},void 0,a)})}function n(e,r={}){let{repeat:i=[1,1],disableMipmaps:s=!1}=r;return e.wrapS=e.wrapT=t.RepeatWrapping,e.colorSpace=t.SRGBColorSpace,e.repeat.set(...i),e.flipY=!1,e.anisotropy=16,s?(e.generateMipmaps=!1,e.minFilter=t.LinearFilter):(e.generateMipmaps=!0,e.minFilter=t.LinearMipmapLinearFilter),e.magFilter=t.LinearFilter,e.needsUpdate=!0,e}function o(e){let r=new t.DataTexture(e,256,256,t.RedFormat,t.UnsignedByteType);return r.colorSpace=t.NoColorSpace,r.wrapS=r.wrapT=t.RepeatWrapping,r.generateMipmaps=!1,r.minFilter=t.LinearFilter,r.magFilter=t.LinearFilter,r.needsUpdate=!0,r}e.s(["loadTexture",()=>s,"loadTextureAsync",()=>a,"setupMask",()=>o,"setupTexture",()=>n])},47021,e=>{"use strict";var t=e.i(8560);let r=` -#ifdef USE_FOG - // Check fog enabled uniform - allows toggling without shader recompilation - #ifdef USE_VOLUMETRIC_FOG - if (!fogEnabled) { - // Skip all fog calculations when disabled - } else { - #endif - - float dist = vFogDepth; - - // Discard fragments at or beyond visible distance - matches Torque's behavior - // where objects beyond visibleDistance are not rendered at all. - // This prevents fully-fogged geometry from showing as silhouettes against - // the sky's fog-to-sky gradient. - if (dist >= fogFar) { - discard; - } - - // Step 1: Calculate distance-based haze (quadratic falloff) - // Since we discard at fogFar, haze never reaches 1.0 here - float haze = 0.0; - if (dist > fogNear) { - float fogScale = 1.0 / (fogFar - fogNear); - float distFactor = (dist - fogNear) * fogScale - 1.0; - haze = 1.0 - distFactor * distFactor; - } - - // Step 2: Calculate fog volume contributions - // Note: Per-volume colors are NOT used in Tribes 2 ($specialFog defaults to false) - // All fog uses the global fogColor - see Tribes2_Fog_System.md for details - float volumeFog = 0.0; - - #ifdef USE_VOLUMETRIC_FOG - { - #ifdef USE_FOG_WORLD_POSITION - float fragmentHeight = vFogWorldPosition.y; - #else - float fragmentHeight = cameraHeight; - #endif - - float deltaY = fragmentHeight - cameraHeight; - float absDeltaY = abs(deltaY); - - // Determine if we're going up (positive) or down (negative) - if (absDeltaY > 0.01) { - // Non-horizontal ray: ray-march through fog volumes - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - // Skip inactive volumes (visibleDistance = 0) - if (volVisDist <= 0.0) continue; - - // Calculate fog factor for this volume - // From Torque: factor = (1 / (volumeVisDist * visFactor)) * percentage - // where visFactor is smVisibleDistanceMod (a user quality pref, default 1.0) - // Since we don't have quality settings, we use visFactor = 1.0 - float factor = (1.0 / volVisDist) * volPct; - - // Find ray intersection with this volume's height range - float rayMinY = min(cameraHeight, fragmentHeight); - float rayMaxY = max(cameraHeight, fragmentHeight); - - // Check if ray intersects volume height range - if (rayMinY < volMaxH && rayMaxY > volMinH) { - float intersectMin = max(rayMinY, volMinH); - float intersectMax = min(rayMaxY, volMaxH); - float intersectHeight = intersectMax - intersectMin; - - // Calculate distance traveled through this volume using similar triangles: - // subDist / dist = intersectHeight / absDeltaY - float subDist = dist * (intersectHeight / absDeltaY); - - // Accumulate fog: fog += subDist * factor - volumeFog += subDist * factor; - } - } - } else { - // Near-horizontal ray: if camera is inside a volume, apply full fog for that volume - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - if (volVisDist <= 0.0) continue; - - // If camera is inside this volume, apply fog for full distance - if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { - float factor = (1.0 / volVisDist) * volPct; - volumeFog += dist * factor; - } - } - } - } - #endif - - // Step 3: Combine haze and volume fog - // Torque's clamping: if (bandPct + hazePct > 1) hazePct = 1 - bandPct - // This gives fog volumes priority over haze - float volPct = min(volumeFog, 1.0); - float hazePct = haze; - if (volPct + hazePct > 1.0) { - hazePct = 1.0 - volPct; - } - float fogFactor = hazePct + volPct; - - // Apply fog using global fogColor (per-volume colors not used in Tribes 2) - gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor); - - #ifdef USE_VOLUMETRIC_FOG - } // end fogEnabled check - #endif -#endif -`;function i(){t.ShaderChunk.fog_pars_fragment=` -#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif - - // Custom volumetric fog uniforms (only defined when USE_VOLUMETRIC_FOG is set) - // Format: [visDist, minH, maxH, percentage] x 3 volumes = 12 floats - #ifdef USE_VOLUMETRIC_FOG - uniform float fogVolumeData[12]; - uniform float cameraHeight; - #endif - - #ifdef USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; - #endif -#endif -`,t.ShaderChunk.fog_fragment=r,t.ShaderChunk.fog_pars_vertex=` -#ifdef USE_FOG - varying float vFogDepth; - #ifdef USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; - #endif -#endif -`,t.ShaderChunk.fog_vertex=` -#ifdef USE_FOG - // Use Euclidean distance from camera, not view-space z-depth - // This ensures fog doesn't change when rotating the camera - vFogDepth = length(mvPosition.xyz); - #ifdef USE_FOG_WORLD_POSITION - vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; - #endif -#endif -`}function s(e,t){e.uniforms.fogVolumeData=t.fogVolumeData,e.uniforms.cameraHeight=t.cameraHeight,e.uniforms.fogEnabled=t.fogEnabled,e.vertexShader=e.vertexShader.replace("#include ",`#include -#ifdef USE_FOG - #define USE_FOG_WORLD_POSITION - #define USE_VOLUMETRIC_FOG - varying vec3 vFogWorldPosition; -#endif`),e.vertexShader=e.vertexShader.replace("#include ",`#include -#ifdef USE_FOG - vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; -#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include -#ifdef USE_FOG - #define USE_VOLUMETRIC_FOG - uniform float fogVolumeData[12]; - uniform float cameraHeight; - uniform bool fogEnabled; - #define USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; -#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",r)}e.s(["fogFragmentShader",0,r,"injectCustomFog",()=>s,"installCustomFogShader",()=>i])},48066,e=>{"use strict";let t={fogVolumeData:{value:new Float32Array(12)},cameraHeight:{value:0},fogEnabled:{value:!0}};function r(e,i,s=!0){t.cameraHeight.value=e,t.fogVolumeData.value.set(i),t.fogEnabled.value=s}function i(){t.cameraHeight.value=0,t.fogVolumeData.value.fill(0),t.fogEnabled.value=!0}function s(e){let t=new Float32Array(12);for(let r=0;r<3;r++){let i=4*r,s=e[r];s&&(t[i+0]=s.visibleDistance,t[i+1]=s.minHeight,t[i+2]=s.maxHeight,t[i+3]=s.percentage)}return t}e.s(["globalFogUniforms",0,t,"packFogVolumeData",()=>s,"resetGlobalFogUniforms",()=>i,"updateGlobalFogUniforms",()=>r])},15823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",()=>t])},19273,80166,e=>{"use strict";e.i(47167);var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function i(e){setTimeout(e,0)}e.s(["systemSetTimeoutZero",()=>i,"timeoutManager",()=>r],80166);var s="u"=0&&e!==1/0}function l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function u(e,t){return"function"==typeof e?e(t):e}function c(e,t){return"function"==typeof e?e(t):e}function h(e,t){let{type:r="all",exact:i,fetchStatus:s,predicate:a,queryKey:n,stale:o}=e;if(n){if(i){if(t.queryHash!==d(n,t.options))return!1}else if(!v(t.queryKey,n))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!s||s===t.state.fetchStatus)&&(!a||!!a(t))}function f(e,t){let{exact:r,status:i,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(p(t.options.mutationKey)!==p(a))return!1}else if(!v(t.options.mutationKey,a))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))}function d(e,t){return(t?.queryKeyHashFn||p)(e)}function p(e){return JSON.stringify(e,(e,t)=>b(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function v(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>v(e[r],t[r]))}var m=Object.prototype.hasOwnProperty;function g(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function y(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function b(e){if(!S(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function S(e){return"[object Object]"===Object.prototype.toString.call(e)}function O(e){return new Promise(t=>{r.setTimeout(t,e)})}function T(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?function e(t,r,i=0){if(t===r)return t;if(i>500)return r;let s=y(t)&&y(r);if(!s&&!(b(t)&&b(r)))return r;let a=(s?t:Object.keys(t)).length,n=s?r:Object.keys(r),o=n.length,l=s?Array(o):{},u=0;for(let c=0;cr?i.slice(1):i}function R(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var E=Symbol();function w(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==E?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function C(e,t){return"function"==typeof e?e(...t):!!e}function D(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e}e.s(["addConsumeAwareSignal",()=>D,"addToEnd",()=>F,"addToStart",()=>R,"ensureQueryFn",()=>w,"functionalUpdate",()=>n,"hashKey",()=>p,"hashQueryKeyByOptions",()=>d,"isServer",()=>s,"isValidTimeout",()=>o,"matchMutation",()=>f,"matchQuery",()=>h,"noop",()=>a,"partialMatchKey",()=>v,"replaceData",()=>T,"resolveEnabled",()=>c,"resolveStaleTime",()=>u,"shallowEqualObjects",()=>g,"shouldThrowError",()=>C,"skipToken",()=>E,"sleep",()=>O,"timeUntilStale",()=>l],19273)},75555,e=>{"use strict";var t=e.i(15823),r=e.i(19273),i=new class extends t.Subscribable{#r;#i;#s;constructor(){super(),this.#s=e=>{if(!r.isServer&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",()=>i])},40143,e=>{"use strict";let t,r,i,s,a,n;var o=e.i(80166).systemSetTimeoutZero,l=(t=[],r=0,i=e=>{e()},s=e=>{e()},a=o,{batch:e=>{let n;r++;try{n=e()}finally{let e;--r||(e=t,t=[],e.length&&a(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return n},batchCalls:e=>(...t)=>{n(()=>{e(...t)})},schedule:n=e=>{r?t.push(e):a(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{a=e}});e.s(["notifyManager",()=>l])},86491,14448,93803,36553,88587,e=>{"use strict";e.i(47167);var t=e.i(19273),r=e.i(40143),i=e.i(75555),s=e.i(15823),a=new class extends s.Subscribable{#a=!0;#i;#s;constructor(){super(),this.#s=e=>{if(!t.isServer&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(this.setOnline.bind(this))}setOnline(e){this.#a!==e&&(this.#a=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#a}};function n(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}function o(e){return Math.min(1e3*2**e,3e4)}function l(e){return(e??"online")!=="online"||a.isOnline()}e.s(["onlineManager",()=>a],14448),e.s(["pendingThenable",()=>n],93803);var u=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function c(e){let r,s=!1,c=0,h=n(),f=()=>i.focusManager.isFocused()&&("always"===e.networkMode||a.isOnline())&&e.canRun(),d=()=>l(e.networkMode)&&e.canRun(),p=e=>{"pending"===h.status&&(r?.(),h.resolve(e))},v=e=>{"pending"===h.status&&(r?.(),h.reject(e))},m=()=>new Promise(t=>{r=e=>{("pending"!==h.status||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===h.status&&e.onContinue?.()}),g=()=>{let r;if("pending"!==h.status)return;let i=0===c?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(p).catch(r=>{if("pending"!==h.status)return;let i=e.retry??3*!t.isServer,a=e.retryDelay??o,n="function"==typeof a?a(c,r):a,l=!0===i||"number"==typeof i&&cf()?void 0:m()).then(()=>{s?v(r):g()}))})};return{promise:h,status:()=>h.status,cancel:t=>{if("pending"===h.status){let r=new u(t);v(r),e.onCancel?.(r)}},continue:()=>(r?.(),h),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:d,start:()=>(d()?g():m().then(g),h)}}e.s(["CancelledError",()=>u,"canFetch",()=>l,"createRetryer",()=>c],36553);var h=e.i(80166),f=class{#n;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,t.isValidTimeout)(this.gcTime)&&(this.#n=h.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(t.isServer?1/0:3e5))}clearGcTimeout(){this.#n&&(h.timeoutManager.clearTimeout(this.#n),this.#n=void 0)}};e.s(["Removable",()=>f],88587);var d=class extends f{#o;#l;#u;#c;#h;#f;#d;constructor(e){super(),this.#d=!1,this.#f=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#u=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=m(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#f,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=m(this.options);void 0!==e.data&&(this.setState(v(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,r){let i=(0,t.replaceData)(this.state.data,e,this.options);return this.#p({data:i,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),i}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){let r=this.#h?.promise;return this.#h?.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some(e=>!1!==(0,t.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t.skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,t.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#d?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(e,r){let i;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&r?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let s=new AbortController,a=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#d=!0,s.signal)})},n=()=>{let e,i=(0,t.ensureQueryFn)(this.options,r),s=(a(e={client:this.#c,queryKey:this.queryKey,meta:this.meta}),e);return(this.#d=!1,this.options.persister)?this.options.persister(i,s,this):i(s)},o=(a(i={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:n}),i);this.options.behavior?.onFetch(o,this),this.#l=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#p({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=c({initialPromise:r?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof u&&e.revert&&this.setState({...this.#l,fetchStatus:"idle"}),s.abort()},onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof u){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#p({type:"error",error:e}),this.#u.config.onError?.(e,this),this.#u.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#p(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...p(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...v(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function p(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:l(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function v(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function m(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",()=>d,"fetchState",()=>p],86491)},69230,e=>{"use strict";var t=e.i(75555),r=e.i(40143),i=e.i(86491),s=e.i(15823),a=e.i(93803),n=e.i(19273),o=e.i(80166),l=class extends s.Subscribable{constructor(e,t){super(),this.options=t,this.#c=e,this.#v=null,this.#m=(0,a.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#c;#g=void 0;#y=void 0;#b=void 0;#S;#O;#m;#v;#T;#F;#R;#E;#w;#C;#D=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#g.addObserver(this),u(this.#g,this.options)?this.#I():this.updateResult(),this.#U())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c(this.#g,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c(this.#g,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#P(),this.#x(),this.#g.removeObserver(this)}setOptions(e){let t=this.options,r=this.#g;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,n.resolveEnabled)(this.options.enabled,this.#g))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#M(),this.#g.setOptions(this.options),t._defaulted&&!(0,n.shallowEqualObjects)(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#g,observer:this});let i=this.hasListeners();i&&h(this.#g,r,this.options,t)&&this.#I(),this.updateResult(),i&&(this.#g!==r||(0,n.resolveEnabled)(this.options.enabled,this.#g)!==(0,n.resolveEnabled)(t.enabled,this.#g)||(0,n.resolveStaleTime)(this.options.staleTime,this.#g)!==(0,n.resolveStaleTime)(t.staleTime,this.#g))&&this.#_();let s=this.#Q();i&&(this.#g!==r||(0,n.resolveEnabled)(this.options.enabled,this.#g)!==(0,n.resolveEnabled)(t.enabled,this.#g)||s!==this.#C)&&this.#k(s)}getOptimisticResult(e){var t,r;let i=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(i,e);return t=this,r=s,(0,n.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#b=s,this.#O=this.options,this.#S=this.#g.state),s}getCurrentResult(){return this.#b}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#m.status||this.#m.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#D.add(e)}getCurrentQuery(){return this.#g}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#c.defaultQueryOptions(e),r=this.#c.getQueryCache().build(this.#c,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#I({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#b))}#I(e){this.#M();let t=this.#g.fetch(this.options,e);return e?.throwOnError||(t=t.catch(n.noop)),t}#_(){this.#P();let e=(0,n.resolveStaleTime)(this.options.staleTime,this.#g);if(n.isServer||this.#b.isStale||!(0,n.isValidTimeout)(e))return;let t=(0,n.timeUntilStale)(this.#b.dataUpdatedAt,e);this.#E=o.timeoutManager.setTimeout(()=>{this.#b.isStale||this.updateResult()},t+1)}#Q(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#g):this.options.refetchInterval)??!1}#k(e){this.#x(),this.#C=e,!n.isServer&&!1!==(0,n.resolveEnabled)(this.options.enabled,this.#g)&&(0,n.isValidTimeout)(this.#C)&&0!==this.#C&&(this.#w=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#I()},this.#C))}#U(){this.#_(),this.#k(this.#Q())}#P(){this.#E&&(o.timeoutManager.clearTimeout(this.#E),this.#E=void 0)}#x(){this.#w&&(o.timeoutManager.clearInterval(this.#w),this.#w=void 0)}createResult(e,t){let r,s=this.#g,o=this.options,l=this.#b,c=this.#S,d=this.#O,p=e!==s?e.state:this.#y,{state:v}=e,m={...v},g=!1;if(t._optimisticResults){let r=this.hasListeners(),a=!r&&u(e,t),n=r&&h(e,s,t,o);(a||n)&&(m={...m,...(0,i.fetchState)(v.data,e.options)}),"isRestoring"===t._optimisticResults&&(m.fetchStatus="idle")}let{error:y,errorUpdatedAt:b,status:S}=m;r=m.data;let O=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===S){let e;l?.isPlaceholderData&&t.placeholderData===d?.placeholderData?(e=l.data,O=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#R?.state.data,this.#R):t.placeholderData,void 0!==e&&(S="success",r=(0,n.replaceData)(l?.data,e,t),g=!0)}if(t.select&&void 0!==r&&!O)if(l&&r===c?.data&&t.select===this.#T)r=this.#F;else try{this.#T=t.select,r=t.select(r),r=(0,n.replaceData)(l?.data,r,t),this.#F=r,this.#v=null}catch(e){this.#v=e}this.#v&&(y=this.#v,r=this.#F,b=Date.now(),S="error");let T="fetching"===m.fetchStatus,F="pending"===S,R="error"===S,E=F&&T,w=void 0!==r,C={status:S,fetchStatus:m.fetchStatus,isPending:F,isSuccess:"success"===S,isError:R,isInitialLoading:E,isLoading:E,data:r,dataUpdatedAt:m.dataUpdatedAt,error:y,errorUpdatedAt:b,failureCount:m.fetchFailureCount,failureReason:m.fetchFailureReason,errorUpdateCount:m.errorUpdateCount,isFetched:m.dataUpdateCount>0||m.errorUpdateCount>0,isFetchedAfterMount:m.dataUpdateCount>p.dataUpdateCount||m.errorUpdateCount>p.errorUpdateCount,isFetching:T,isRefetching:T&&!F,isLoadingError:R&&!w,isPaused:"paused"===m.fetchStatus,isPlaceholderData:g,isRefetchError:R&&w,isStale:f(e,t),refetch:this.refetch,promise:this.#m,isEnabled:!1!==(0,n.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==C.data,r="error"===C.status&&!t,i=e=>{r?e.reject(C.error):t&&e.resolve(C.data)},n=()=>{i(this.#m=C.promise=(0,a.pendingThenable)())},o=this.#m;switch(o.status){case"pending":e.queryHash===s.queryHash&&i(o);break;case"fulfilled":(r||C.data!==o.value)&&n();break;case"rejected":r&&C.error===o.reason||n()}}return C}updateResult(){let e=this.#b,t=this.createResult(this.#g,this.options);if(this.#S=this.#g.state,this.#O=this.options,void 0!==this.#S.data&&(this.#R=this.#g),(0,n.shallowEqualObjects)(t,e))return;this.#b=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#D.size)return!0;let i=new Set(r??this.#D);return this.options.throwOnError&&i.add("error"),Object.keys(this.#b).some(t=>this.#b[t]!==e[t]&&i.has(t))};this.#L({listeners:r()})}#M(){let e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#g)return;let t=this.#g;this.#g=e,this.#y=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#U()}#L(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#b)}),this.#c.getQueryCache().notify({query:this.#g,type:"observerResultsUpdated"})})}};function u(e,t){return!1!==(0,n.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&c(e,t,t.refetchOnMount)}function c(e,t,r){if(!1!==(0,n.resolveEnabled)(t.enabled,e)&&"static"!==(0,n.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&f(e,t)}return!1}function h(e,t,r,i){return(e!==t||!1===(0,n.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&f(e,r)}function f(e,t){return!1!==(0,n.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,n.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",()=>l])},12598,e=>{"use strict";var t=e.i(71645),r=e.i(43476),i=t.createContext(void 0),s=e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r},a=({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s}));e.s(["QueryClientProvider",()=>a,"useQueryClient",()=>s])},69637,54440,e=>{"use strict";let t;e.i(47167);var r=e.i(71645),i=e.i(19273),s=e.i(40143),a=e.i(12598);e.i(43476);var n=r.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),o=r.createContext(!1);o.Provider;var l=(e,t)=>void 0===t.state.data,u=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(e??1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>t(r(...e)):t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},c=(e,t)=>e.isLoading&&e.isFetching&&!t,h=(e,t)=>e?.suspense&&t.isPending,f=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function d(e,t,l){let d,p=r.useContext(o),v=r.useContext(n),m=(0,a.useQueryClient)(l),g=m.defaultQueryOptions(e);m.getDefaultOptions().queries?._experimental_beforeQuery?.(g);let y=m.getQueryCache().get(g.queryHash);g._optimisticResults=p?"isRestoring":"optimistic",u(g),d=y?.state.error&&"function"==typeof g.throwOnError?(0,i.shouldThrowError)(g.throwOnError,[y.state.error,y]):g.throwOnError,(g.suspense||g.experimental_prefetchInRender||d)&&!v.isReset()&&(g.retryOnMount=!1),r.useEffect(()=>{v.clearReset()},[v]);let b=!m.getQueryCache().get(g.queryHash),[S]=r.useState(()=>new t(m,g)),O=S.getOptimisticResult(g),T=!p&&!1!==e.subscribed;if(r.useSyncExternalStore(r.useCallback(e=>{let t=T?S.subscribe(s.notifyManager.batchCalls(e)):i.noop;return S.updateResult(),t},[S,T]),()=>S.getCurrentResult(),()=>S.getCurrentResult()),r.useEffect(()=>{S.setOptions(g)},[g,S]),h(g,O))throw f(g,S,v);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&void 0===e.data||(0,i.shouldThrowError)(r,[e.error,s])))({result:O,errorResetBoundary:v,throwOnError:g.throwOnError,query:y,suspense:g.suspense}))throw O.error;if(m.getDefaultOptions().queries?._experimental_afterQuery?.(g,O),g.experimental_prefetchInRender&&!i.isServer&&c(O,p)){let e=b?f(g,S,v):y?.promise;e?.catch(i.noop).finally(()=>{S.updateResult()})}return g.notifyOnChangeProps?O:S.trackResult(O)}e.s(["defaultThrowOnError",()=>l,"ensureSuspenseTimers",()=>u,"fetchOptimistic",()=>f,"shouldSuspend",()=>h,"willFetch",()=>c],54440),e.s(["useBaseQuery",()=>d],69637)},6112,e=>{"use strict";e.i(13876);var t=e.i(58647);function r(e){return(0,t.useDatablockByName)(e)}e.s(["useDatablock",()=>r])},61921,e=>{e.v(e=>Promise.resolve().then(()=>e(29055)))},25147,e=>{e.v(t=>Promise.all(["static/chunks/8c435435e00c1d09.js"].map(t=>e.l(t))).then(()=>t(63724)))},18599,e=>{e.v(t=>Promise.all(["static/chunks/13f8b467e8aa89cb.js"].map(t=>e.l(t))).then(()=>t(42585)))},84968,e=>{e.v(t=>Promise.all(["static/chunks/6e9a6efec350bf8d.js"].map(t=>e.l(t))).then(()=>t(90208)))},59197,e=>{e.v(t=>Promise.all(["static/chunks/0be79f7f5e0597a7.css","static/chunks/1cf33c843f96e1c9.js"].map(t=>e.l(t))).then(()=>t(94247)))}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/91476c9d2f29d071.js b/docs/_next/static/chunks/91476c9d2f29d071.js deleted file mode 100644 index d42887d4..00000000 --- a/docs/_next/static/chunks/91476c9d2f29d071.js +++ /dev/null @@ -1,211 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,31067,e=>{"use strict";function t(){return(t=Object.assign.bind()).apply(null,arguments)}e.s(["default",()=>t])},47071,99143,e=>{"use strict";var t=e.i(71645),r=e.i(90072),i=e.i(15080),s=e.i(40859);e.s(["useLoader",()=>s.G],99143);var s=s;let n=e=>e===Object(e)&&!Array.isArray(e)&&"function"!=typeof e;function a(e,a){let o=(0,i.useThree)(e=>e.gl),l=(0,s.G)(r.TextureLoader,n(e)?Object.values(e):e);return(0,t.useLayoutEffect)(()=>{null==a||a(l)},[a]),(0,t.useEffect)(()=>{if("initTexture"in o){let e=[];Array.isArray(l)?e=l:l instanceof r.Texture?e=[l]:n(l)&&(e=Object.values(l)),e.forEach(e=>{e instanceof r.Texture&&o.initTexture(e)})}},[o,l]),(0,t.useMemo)(()=>{if(!n(e))return l;{let t={},r=0;for(let i in e)t[i]=l[r++];return t}},[e,l])}a.preload=e=>s.G.preload(r.TextureLoader,e),a.clear=e=>s.G.clear(r.TextureLoader,e),e.s(["useTexture",()=>a],47071)},75567,e=>{"use strict";var t=e.i(90072);let r=new t.ImageBitmapLoader,i=new Map;function s(e,s){let n=i.get(e);if(n)return s&&n.image&&s(n),n;let a=new t.Texture;return a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s?.(a)}),a}function n(e){let s=i.get(e);return s?s.image?Promise.resolve(s):new Promise(e=>{let t=()=>{s.image?e(s):setTimeout(t,16)};t()}):new Promise((s,n)=>{let a=new t.Texture;a.flipY=!1,i.set(e,a),r.load(e,e=>{a.image=e,a.needsUpdate=!0,s(a)},void 0,n)})}function a(e,r={}){let{repeat:i=[1,1],disableMipmaps:s=!1}=r;return e.wrapS=e.wrapT=t.RepeatWrapping,e.colorSpace=t.SRGBColorSpace,e.repeat.set(...i),e.flipY=!1,e.anisotropy=16,s?(e.generateMipmaps=!1,e.minFilter=t.LinearFilter):(e.generateMipmaps=!0,e.minFilter=t.LinearMipmapLinearFilter),e.magFilter=t.LinearFilter,e.needsUpdate=!0,e}function o(e){let r=new t.DataTexture(e,256,256,t.RedFormat,t.UnsignedByteType);return r.colorSpace=t.NoColorSpace,r.wrapS=r.wrapT=t.RepeatWrapping,r.generateMipmaps=!1,r.minFilter=t.LinearFilter,r.magFilter=t.LinearFilter,r.needsUpdate=!0,r}e.s(["loadTexture",()=>s,"loadTextureAsync",()=>n,"setupMask",()=>o,"setupTexture",()=>a])},47021,e=>{"use strict";var t=e.i(8560);let r=` -#ifdef USE_FOG - // Check fog enabled uniform - allows toggling without shader recompilation - #ifdef USE_VOLUMETRIC_FOG - if (!fogEnabled) { - // Skip all fog calculations when disabled - } else { - #endif - - float dist = vFogDepth; - - // Discard fragments at or beyond visible distance - matches Torque's behavior - // where objects beyond visibleDistance are not rendered at all. - // This prevents fully-fogged geometry from showing as silhouettes against - // the sky's fog-to-sky gradient. - if (dist >= fogFar) { - discard; - } - - // Step 1: Calculate distance-based haze (quadratic falloff) - // Since we discard at fogFar, haze never reaches 1.0 here - float haze = 0.0; - if (dist > fogNear) { - float fogScale = 1.0 / (fogFar - fogNear); - float distFactor = (dist - fogNear) * fogScale - 1.0; - haze = 1.0 - distFactor * distFactor; - } - - // Step 2: Calculate fog volume contributions - // Note: Per-volume colors are NOT used in Tribes 2 ($specialFog defaults to false) - // All fog uses the global fogColor - see Tribes2_Fog_System.md for details - float volumeFog = 0.0; - - #ifdef USE_VOLUMETRIC_FOG - { - #ifdef USE_FOG_WORLD_POSITION - float fragmentHeight = vFogWorldPosition.y; - #else - float fragmentHeight = cameraHeight; - #endif - - float deltaY = fragmentHeight - cameraHeight; - float absDeltaY = abs(deltaY); - - // Determine if we're going up (positive) or down (negative) - if (absDeltaY > 0.01) { - // Non-horizontal ray: ray-march through fog volumes - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - // Skip inactive volumes (visibleDistance = 0) - if (volVisDist <= 0.0) continue; - - // Calculate fog factor for this volume - // From Torque: factor = (1 / (volumeVisDist * visFactor)) * percentage - // where visFactor is smVisibleDistanceMod (a user quality pref, default 1.0) - // Since we don't have quality settings, we use visFactor = 1.0 - float factor = (1.0 / volVisDist) * volPct; - - // Find ray intersection with this volume's height range - float rayMinY = min(cameraHeight, fragmentHeight); - float rayMaxY = max(cameraHeight, fragmentHeight); - - // Check if ray intersects volume height range - if (rayMinY < volMaxH && rayMaxY > volMinH) { - float intersectMin = max(rayMinY, volMinH); - float intersectMax = min(rayMaxY, volMaxH); - float intersectHeight = intersectMax - intersectMin; - - // Calculate distance traveled through this volume using similar triangles: - // subDist / dist = intersectHeight / absDeltaY - float subDist = dist * (intersectHeight / absDeltaY); - - // Accumulate fog: fog += subDist * factor - volumeFog += subDist * factor; - } - } - } else { - // Near-horizontal ray: if camera is inside a volume, apply full fog for that volume - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - if (volVisDist <= 0.0) continue; - - // If camera is inside this volume, apply fog for full distance - if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { - float factor = (1.0 / volVisDist) * volPct; - volumeFog += dist * factor; - } - } - } - } - #endif - - // Step 3: Combine haze and volume fog - // Torque's clamping: if (bandPct + hazePct > 1) hazePct = 1 - bandPct - // This gives fog volumes priority over haze - float volPct = min(volumeFog, 1.0); - float hazePct = haze; - if (volPct + hazePct > 1.0) { - hazePct = 1.0 - volPct; - } - float fogFactor = hazePct + volPct; - - // Apply fog using global fogColor (per-volume colors not used in Tribes 2) - gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor); - - #ifdef USE_VOLUMETRIC_FOG - } // end fogEnabled check - #endif -#endif -`;function i(){t.ShaderChunk.fog_pars_fragment=` -#ifdef USE_FOG - uniform vec3 fogColor; - varying float vFogDepth; - #ifdef FOG_EXP2 - uniform float fogDensity; - #else - uniform float fogNear; - uniform float fogFar; - #endif - - // Custom volumetric fog uniforms (only defined when USE_VOLUMETRIC_FOG is set) - // Format: [visDist, minH, maxH, percentage] x 3 volumes = 12 floats - #ifdef USE_VOLUMETRIC_FOG - uniform float fogVolumeData[12]; - uniform float cameraHeight; - #endif - - #ifdef USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; - #endif -#endif -`,t.ShaderChunk.fog_fragment=r,t.ShaderChunk.fog_pars_vertex=` -#ifdef USE_FOG - varying float vFogDepth; - #ifdef USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; - #endif -#endif -`,t.ShaderChunk.fog_vertex=` -#ifdef USE_FOG - // Use Euclidean distance from camera, not view-space z-depth - // This ensures fog doesn't change when rotating the camera - vFogDepth = length(mvPosition.xyz); - #ifdef USE_FOG_WORLD_POSITION - vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; - #endif -#endif -`}function s(e,t){e.uniforms.fogVolumeData=t.fogVolumeData,e.uniforms.cameraHeight=t.cameraHeight,e.uniforms.fogEnabled=t.fogEnabled,e.vertexShader=e.vertexShader.replace("#include ",`#include -#ifdef USE_FOG - #define USE_FOG_WORLD_POSITION - #define USE_VOLUMETRIC_FOG - varying vec3 vFogWorldPosition; -#endif`),e.vertexShader=e.vertexShader.replace("#include ",`#include -#ifdef USE_FOG - vFogWorldPosition = (modelMatrix * vec4(transformed, 1.0)).xyz; -#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include -#ifdef USE_FOG - #define USE_VOLUMETRIC_FOG - uniform float fogVolumeData[12]; - uniform float cameraHeight; - uniform bool fogEnabled; - #define USE_FOG_WORLD_POSITION - varying vec3 vFogWorldPosition; -#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",r)}e.s(["fogFragmentShader",0,r,"injectCustomFog",()=>s,"installCustomFogShader",()=>i])},48066,e=>{"use strict";let t={fogVolumeData:{value:new Float32Array(12)},cameraHeight:{value:0},fogEnabled:{value:!0}};function r(e,i,s=!0){t.cameraHeight.value=e,t.fogVolumeData.value.set(i),t.fogEnabled.value=s}function i(){t.cameraHeight.value=0,t.fogVolumeData.value.fill(0),t.fogEnabled.value=!0}function s(e){let t=new Float32Array(12);for(let r=0;r<3;r++){let i=4*r,s=e[r];s&&(t[i+0]=s.visibleDistance,t[i+1]=s.minHeight,t[i+2]=s.maxHeight,t[i+3]=s.percentage)}return t}e.s(["globalFogUniforms",0,t,"packFogVolumeData",()=>s,"resetGlobalFogUniforms",()=>i,"updateGlobalFogUniforms",()=>r])},13876,79473,43595,58647,e=>{"use strict";var t=e.i(932),r=e.i(8155);let i=e=>(t,r,i)=>{let s=i.subscribe;return i.subscribe=(e,t,r)=>{let n=e;if(t){let s=(null==r?void 0:r.equalityFn)||Object.is,a=e(i.getState());n=r=>{let i=e(r);if(!s(a,i)){let e=a;t(a=i,e)}},(null==r?void 0:r.fireImmediately)&&t(a,a)}return s(n)},e(t,r,i)};e.s(["subscribeWithSelector",()=>i],79473);var s=e.i(66748);function n(e){let t=new Map;for(let r of e.state.datablocks.values()){if("tsshapeconstructor"!==r._class)continue;let e=r.baseshape;if("string"!=typeof e)continue;let i=e.toLowerCase(),s=i.replace(/\.dts$/i,"")+"_",n=new Map;for(let e=0;e<=127;e++){let t=r[`sequence${e}`];if("string"!=typeof t)continue;let i=t.indexOf(" ");if(-1===i)continue;let a=t.slice(0,i).toLowerCase(),o=t.slice(i+1).trim().toLowerCase();if(!o||!a.startsWith(s)||!a.endsWith(".dsq"))continue;let l=a.slice(s.length,-4);l&&n.set(o,l)}n.size>0&&t.set(i,n)}return t}function a(e,t,r){let i=new Map;for(let r of e){let e=t.clipAction(r);i.set(r.name.toLowerCase(),e)}if(r)for(let[e,t]of r){let r=i.get(t);r&&!i.has(e)&&i.set(e,r)}return i}function o(e){return e.toLowerCase()}function l(e){let t=o(e.trim());return t.startsWith("$")?t.slice(1):t}e.s(["buildSequenceAliasMap",()=>n,"getAliasedActions",()=>a],43595);let u={runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0},playback:{recording:null,status:"stopped",timeMs:0,rate:1,durationMs:0,streamSnapshot:null}},c=(0,r.createStore)()(i(e=>({...u,setRuntime(t){let r=function(e){let t={},r={},i={},s={};for(let r of e.state.objectsById.values())t[r._id]=0,r._name&&(i[o(r._name)]=r._id,r._isDatablock&&(s[o(r._name)]=r._id));for(let t of e.state.globals.keys())r[l(t)]=0;return{objectVersionById:t,globalVersionByName:r,objectIdsByName:i,datablockIdsByName:s}}(t),i=n(t);e(e=>({...e,runtime:{runtime:t,sequenceAliases:i,objectVersionById:r.objectVersionById,globalVersionByName:r.globalVersionByName,objectIdsByName:r.objectIdsByName,datablockIdsByName:r.datablockIdsByName,lastRuntimeTick:0}}))},clearRuntime(){e(e=>({...e,runtime:{runtime:null,sequenceAliases:new Map,objectVersionById:{},globalVersionByName:{},objectIdsByName:{},datablockIdsByName:{},lastRuntimeTick:0}}))},applyRuntimeBatch(t,r){0!==t.length&&e(e=>{let i={...e.runtime.objectVersionById},s={...e.runtime.globalVersionByName},n={...e.runtime.objectIdsByName},a={...e.runtime.datablockIdsByName},u=e=>{null!=e&&(i[e]=(i[e]??0)+1)};for(let e of t){if("object.created"===e.type){let t=e.object;if(u(e.objectId),t._name){let r=o(t._name);n[r]=e.objectId,t._isDatablock&&(a[r]=e.objectId)}u(t._parent?._id);continue}if("object.deleted"===e.type){let t=e.object;if(delete i[e.objectId],t?._name){let e=o(t._name);delete n[e],t._isDatablock&&delete a[e]}u(t?._parent?._id);continue}if("field.changed"===e.type){u(e.objectId);continue}if("global.changed"===e.type){let t=l(e.name);s[t]=(s[t]??0)+1;continue}}let c=r?.tick??(e.runtime.lastRuntimeTick>0?e.runtime.lastRuntimeTick+1:1);return{...e,runtime:{...e.runtime,objectVersionById:i,globalVersionByName:s,objectIdsByName:n,datablockIdsByName:a,lastRuntimeTick:c}}})},setDemoRecording(t){let r=Math.max(0,(t?.duration??0)*1e3);e(e=>({...e,playback:{recording:t,status:"stopped",timeMs:0,rate:1,durationMs:r,streamSnapshot:null}}))},setPlaybackTime(t){e(e=>{var r,i,s;let n=(r=t,i=0,s=e.playback.durationMs,r<0?0:r>s?s:r);return{...e,playback:{...e.playback,timeMs:n}}})},setPlaybackStatus(t){e(e=>({...e,playback:{...e.playback,status:t}}))},setPlaybackRate(t){var r,i,s;let n=Number.isFinite(t)?(i=.01,s=16,(r=t)<.01?.01:r>16?16:r):1;e(e=>({...e,playback:{...e.playback,rate:n}}))},setPlaybackStreamSnapshot(t){e(e=>({...e,playback:{...e.playback,streamSnapshot:t}}))}}))),h=0;function d(){return h}function f(e,t){h+=e*t*1e3}function p(){return c}function m(e,t){return(0,s.useStoreWithEqualityFn)(c,e,t)}function y(e){let r,i,s,n=(0,t.c)(7),a=m(v);n[0]!==e?(r=t=>null==e?-1:t.runtime.objectVersionById[e]??-1,n[0]=e,n[1]=r):r=n[1];let o=m(r);if(null==e||!a||-1===o)return;n[2]!==e||n[3]!==a.state.objectsById?(i=a.state.objectsById.get(e),n[2]=e,n[3]=a.state.objectsById,n[4]=i):i=n[4];let l=i;return n[5]!==l?(s=l?{...l}:void 0,n[5]=l,n[6]=s):s=n[6],s}function v(e){return e.runtime.runtime}function g(e){let r,i,s,n,a,l=(0,t.c)(11),u=m(b);l[0]!==e?(r=e?o(e):"",l[0]=e,l[1]=r):r=l[1];let c=r;l[2]!==c?(i=e=>c?e.runtime.objectIdsByName[c]:void 0,l[2]=c,l[3]=i):i=l[3];let h=m(i);l[4]!==h?(s=e=>null==h?-1:e.runtime.objectVersionById[h]??-1,l[4]=h,l[5]=s):s=l[5];let d=m(s);if(!u||!c||null==h||-1===d)return;l[6]!==h||l[7]!==u.state.objectsById?(n=u.state.objectsById.get(h),l[6]=h,l[7]=u.state.objectsById,l[8]=n):n=l[8];let f=n;return l[9]!==f?(a=f?{...f}:void 0,l[9]=f,l[10]=a):a=l[10],a}function b(e){return e.runtime.runtime}function S(e){let r,i,s,n,a,l=(0,t.c)(11),u=m(R);l[0]!==e?(r=e?o(e):"",l[0]=e,l[1]=r):r=l[1];let c=r;l[2]!==c?(i=e=>c?e.runtime.datablockIdsByName[c]:void 0,l[2]=c,l[3]=i):i=l[3];let h=m(i);l[4]!==h?(s=e=>null==h?-1:e.runtime.objectVersionById[h]??-1,l[4]=h,l[5]=s):s=l[5];let d=m(s);if(!u||!c||null==h||-1===d)return;l[6]!==h||l[7]!==u.state.objectsById?(n=u.state.objectsById.get(h),l[6]=h,l[7]=u.state.objectsById,l[8]=n):n=l[8];let f=n;return l[9]!==f?(a=f?{...f}:void 0,l[9]=f,l[10]=a):a=l[10],a}function R(e){return e.runtime.runtime}function T(e,r){let i,s,n,a,o=(0,t.c)(13);o[0]!==r?(i=void 0===r?[]:r,o[0]=r,o[1]=i):i=o[1];let l=i,u=m(w);o[2]!==e?(s=t=>null==e?-1:t.runtime.objectVersionById[e]??-1,o[2]=e,o[3]=s):s=o[3];let c=m(s);if(null==e){let e;return o[4]!==l?(e=l.map(x),o[4]=l,o[5]=e):e=o[5],e}if(!u||-1===c){let e;return o[6]!==l?(e=l.map(O),o[6]=l,o[7]=e):e=o[7],e}let h=u.state.objectsById;if(o[8]!==e||o[9]!==u.state.objectsById){a=Symbol.for("react.early_return_sentinel");e:{let t=h.get(e);if(!t?._children){let e;o[12]===Symbol.for("react.memo_cache_sentinel")?(e=[],o[12]=e):e=o[12],a=e;break e}n=t._children.map(F)}o[8]=e,o[9]=u.state.objectsById,o[10]=n,o[11]=a}else n=o[10],a=o[11];return a!==Symbol.for("react.early_return_sentinel")?a:n}function F(e){return e._id}function O(e){return e._id}function x(e){return e._id}function w(e){return e.runtime.runtime}c.subscribe(e=>e.playback.status,e=>{"stopped"===e&&(h=0)}),e.s(["advanceEffectClock",()=>f,"demoEffectNow",()=>d,"engineStore",0,c,"useDatablockByName",()=>S,"useEngineSelector",()=>m,"useEngineStoreApi",()=>p,"useRuntimeChildIds",()=>T,"useRuntimeObjectById",()=>y,"useRuntimeObjectByName",()=>g],58647),e.s([],13876)},67191,e=>{e.v({Label:"FloatingLabel-module__8y09Ka__Label"})},89887,60099,e=>{"use strict";let t,r;var i=e.i(43476),s=e.i(932),n=e.i(71645),a=e.i(90072),o=e.i(71753),l=e.i(31067),u=e.i(88014),c=e.i(15080);let h=new a.Vector3,d=new a.Vector3,f=new a.Vector3,p=new a.Vector2;function m(e,t,r){let i=h.setFromMatrixPosition(e.matrixWorld);i.project(t);let s=r.width/2,n=r.height/2;return[i.x*s+s,-(i.y*n)+n]}let y=e=>1e-10>Math.abs(e)?0:e;function v(e,t,r=""){let i="matrix3d(";for(let r=0;16!==r;r++)i+=y(t[r]*e.elements[r])+(15!==r?",":")");return r+i}let g=(t=[1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1],e=>v(e,t)),b=(r=e=>[1/e,1/e,1/e,1,-1/e,-1/e,-1/e,-1,1/e,1/e,1/e,1,1,1,1,1],(e,t)=>v(e,r(t),"translate(-50%,-50%)")),S=n.forwardRef(({children:e,eps:t=.001,style:r,className:i,prepend:s,center:v,fullscreen:S,portal:R,distanceFactor:T,sprite:F=!1,transform:O=!1,occlude:x,onOcclude:w,castShadow:E,receiveShadow:I,material:M,geometry:C,zIndexRange:_=[0x1000037,0],calculatePosition:P=m,as:D="div",wrapperClass:j,pointerEvents:k="auto",...U},Q)=>{let{gl:L,camera:V,scene:B,size:A,raycaster:H,events:W,viewport:q}=(0,c.useThree)(),[N]=n.useState(()=>document.createElement(D)),G=n.useRef(null),z=n.useRef(null),$=n.useRef(0),K=n.useRef([0,0]),Y=n.useRef(null),Z=n.useRef(null),J=(null==R?void 0:R.current)||W.connected||L.domElement.parentNode,X=n.useRef(null),ee=n.useRef(!1),et=n.useMemo(()=>{var e;return x&&"blending"!==x||Array.isArray(x)&&x.length&&(e=x[0])&&"object"==typeof e&&"current"in e},[x]);n.useLayoutEffect(()=>{let e=L.domElement;x&&"blending"===x?(e.style.zIndex=`${Math.floor(_[0]/2)}`,e.style.position="absolute",e.style.pointerEvents="none"):(e.style.zIndex=null,e.style.position=null,e.style.pointerEvents=null)},[x]),n.useLayoutEffect(()=>{if(z.current){let e=G.current=u.createRoot(N);if(B.updateMatrixWorld(),O)N.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{let e=P(z.current,V,A);N.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${e[0]}px,${e[1]}px,0);transform-origin:0 0;`}return J&&(s?J.prepend(N):J.appendChild(N)),()=>{J&&J.removeChild(N),e.unmount()}}},[J,O]),n.useLayoutEffect(()=>{j&&(N.className=j)},[j]);let er=n.useMemo(()=>O?{position:"absolute",top:0,left:0,width:A.width,height:A.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:v?"translate3d(-50%,-50%,0)":"none",...S&&{top:-A.height/2,left:-A.width/2,width:A.width,height:A.height},...r},[r,v,S,A,O]),ei=n.useMemo(()=>({position:"absolute",pointerEvents:k}),[k]);n.useLayoutEffect(()=>{var t,s;ee.current=!1,O?null==(t=G.current)||t.render(n.createElement("div",{ref:Y,style:er},n.createElement("div",{ref:Z,style:ei},n.createElement("div",{ref:Q,className:i,style:r,children:e})))):null==(s=G.current)||s.render(n.createElement("div",{ref:Q,style:er,className:i,children:e}))});let es=n.useRef(!0);(0,o.useFrame)(e=>{if(z.current){V.updateMatrixWorld(),z.current.updateWorldMatrix(!0,!1);let e=O?K.current:P(z.current,V,A);if(O||Math.abs($.current-V.zoom)>t||Math.abs(K.current[0]-e[0])>t||Math.abs(K.current[1]-e[1])>t){var r;let t,i,s,n,o=(r=z.current,t=h.setFromMatrixPosition(r.matrixWorld),i=d.setFromMatrixPosition(V.matrixWorld),s=t.sub(i),n=V.getWorldDirection(f),s.angleTo(n)>Math.PI/2),l=!1;et&&(Array.isArray(x)?l=x.map(e=>e.current):"blending"!==x&&(l=[B]));let u=es.current;l?es.current=function(e,t,r,i){let s=h.setFromMatrixPosition(e.matrixWorld),n=s.clone();n.project(t),p.set(n.x,n.y),r.setFromCamera(p,t);let a=r.intersectObjects(i,!0);if(a.length){let e=a[0].distance;return s.distanceTo(r.ray.origin)({vertexShader:O?void 0:` - /* - This shader is from the THREE's SpriteMaterial. - We need to turn the backing plane into a Sprite - (make it always face the camera) if "transfrom" - is false. - */ - #include - - void main() { - vec2 center = vec2(0., 1.); - float rotation = 0.0; - - // This is somewhat arbitrary, but it seems to work well - // Need to figure out how to derive this dynamically if it even matters - float size = 0.03; - - vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); - vec2 scale; - scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); - scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); - - bool isPerspective = isPerspectiveMatrix( projectionMatrix ); - if ( isPerspective ) scale *= - mvPosition.z; - - vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size; - vec2 rotatedPosition; - rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; - rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; - mvPosition.xy += rotatedPosition; - - gl_Position = projectionMatrix * mvPosition; - } - `,fragmentShader:` - void main() { - gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); - } - `}),[O]);return n.createElement("group",(0,l.default)({},U,{ref:z}),x&&!et&&n.createElement("mesh",{castShadow:E,receiveShadow:I,ref:X},C||n.createElement("planeGeometry",null),M||n.createElement("shaderMaterial",{side:a.DoubleSide,vertexShader:en.vertexShader,fragmentShader:en.fragmentShader})))});e.s(["Html",()=>S],60099);var R=e.i(67191);let T=[0,0,0],F=new a.Vector3,O=(0,n.memo)(function(e){let t,r,a,l=(0,s.c)(11),{children:u,color:c,position:h,opacity:d}=e,f=void 0===c?"white":c,p=void 0===h?T:h,m=void 0===d?"fadeWithDistance":d,y="fadeWithDistance"===m,v=(0,n.useRef)(null),[g,b]=(0,n.useState)(0!==m),O=(0,n.useRef)(null);return l[0]!==y||l[1]!==g||l[2]!==m?(t=e=>{var t,r,i;let s,{camera:n}=e,a=v.current;if(!a)return;a.getWorldPosition(F);let o=(t=F.x,r=F.y,i=F.z,-((t-(s=n.matrixWorld.elements)[12])*s[8])+-((r-s[13])*s[9])+-((i-s[14])*s[10])<0);if(y){let e=o?1/0:n.position.distanceTo(F),t=e<200;if(g!==t&&b(t),O.current&&t){let t=Math.max(0,Math.min(1,1-e/200));O.current.style.opacity=t.toString()}}else{let e=!o&&0!==m;g!==e&&b(e),O.current&&(O.current.style.opacity=m.toString())}},l[0]=y,l[1]=g,l[2]=m,l[3]=t):t=l[3],(0,o.useFrame)(t),l[4]!==u||l[5]!==f||l[6]!==g||l[7]!==p?(r=g?(0,i.jsx)(S,{position:p,center:!0,children:(0,i.jsx)("div",{ref:O,className:R.default.Label,style:{color:f},children:u})}):null,l[4]=u,l[5]=f,l[6]=g,l[7]=p,l[8]=r):r=l[8],l[9]!==r?(a=(0,i.jsx)("group",{ref:v,children:r}),l[9]=r,l[10]=a):a=l[10],a});e.s(["FloatingLabel",0,O],89887)},19273,80166,e=>{"use strict";e.i(47167);var t={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},r=new class{#e=t;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function i(e){setTimeout(e,0)}e.s(["systemSetTimeoutZero",()=>i,"timeoutManager",()=>r],80166);var s="u"=0&&e!==1/0}function l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function u(e,t){return"function"==typeof e?e(t):e}function c(e,t){return"function"==typeof e?e(t):e}function h(e,t){let{type:r="all",exact:i,fetchStatus:s,predicate:n,queryKey:a,stale:o}=e;if(a){if(i){if(t.queryHash!==f(a,t.options))return!1}else if(!m(t.queryKey,a))return!1}if("all"!==r){let e=t.isActive();if("active"===r&&!e||"inactive"===r&&e)return!1}return("boolean"!=typeof o||t.isStale()===o)&&(!s||s===t.state.fetchStatus)&&(!n||!!n(t))}function d(e,t){let{exact:r,status:i,predicate:s,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(r){if(p(t.options.mutationKey)!==p(n))return!1}else if(!m(t.options.mutationKey,n))return!1}return(!i||t.state.status===i)&&(!s||!!s(t))}function f(e,t){return(t?.queryKeyHashFn||p)(e)}function p(e){return JSON.stringify(e,(e,t)=>b(t)?Object.keys(t).sort().reduce((e,r)=>(e[r]=t[r],e),{}):t)}function m(e,t){return e===t||typeof e==typeof t&&!!e&&!!t&&"object"==typeof e&&"object"==typeof t&&Object.keys(t).every(r=>m(e[r],t[r]))}var y=Object.prototype.hasOwnProperty;function v(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let r in e)if(e[r]!==t[r])return!1;return!0}function g(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function b(e){if(!S(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!!S(r)&&!!r.hasOwnProperty("isPrototypeOf")&&Object.getPrototypeOf(e)===Object.prototype}function S(e){return"[object Object]"===Object.prototype.toString.call(e)}function R(e){return new Promise(t=>{r.setTimeout(t,e)})}function T(e,t,r){return"function"==typeof r.structuralSharing?r.structuralSharing(e,t):!1!==r.structuralSharing?function e(t,r,i=0){if(t===r)return t;if(i>500)return r;let s=g(t)&&g(r);if(!s&&!(b(t)&&b(r)))return r;let n=(s?t:Object.keys(t)).length,a=s?r:Object.keys(r),o=a.length,l=s?Array(o):{},u=0;for(let c=0;cr?i.slice(1):i}function O(e,t,r=0){let i=[t,...e];return r&&i.length>r?i.slice(0,-1):i}var x=Symbol();function w(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:e.queryFn&&e.queryFn!==x?e.queryFn:()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`))}function E(e,t){return"function"==typeof e?e(...t):!!e}function I(e,t,r){let i,s=!1;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),s||(s=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),e}e.s(["addConsumeAwareSignal",()=>I,"addToEnd",()=>F,"addToStart",()=>O,"ensureQueryFn",()=>w,"functionalUpdate",()=>a,"hashKey",()=>p,"hashQueryKeyByOptions",()=>f,"isServer",()=>s,"isValidTimeout",()=>o,"matchMutation",()=>d,"matchQuery",()=>h,"noop",()=>n,"partialMatchKey",()=>m,"replaceData",()=>T,"resolveEnabled",()=>c,"resolveStaleTime",()=>u,"shallowEqualObjects",()=>v,"shouldThrowError",()=>E,"skipToken",()=>x,"sleep",()=>R,"timeUntilStale",()=>l],19273)},40143,e=>{"use strict";let t,r,i,s,n,a;var o=e.i(80166).systemSetTimeoutZero,l=(t=[],r=0,i=e=>{e()},s=e=>{e()},n=o,{batch:e=>{let a;r++;try{a=e()}finally{let e;--r||(e=t,t=[],e.length&&n(()=>{s(()=>{e.forEach(e=>{i(e)})})}))}return a},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a=e=>{r?t.push(e):n(()=>{i(e)})},setNotifyFunction:e=>{i=e},setBatchNotifyFunction:e=>{s=e},setScheduler:e=>{n=e}});e.s(["notifyManager",()=>l])},15823,e=>{"use strict";var t=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};e.s(["Subscribable",()=>t])},75555,e=>{"use strict";var t=e.i(15823),r=e.i(19273),i=new class extends t.Subscribable{#r;#i;#s;constructor(){super(),this.#s=e=>{if(!r.isServer&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(e=>{"boolean"==typeof e?this.setFocused(e):this.onFocus()})}setFocused(e){this.#r!==e&&(this.#r=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return"boolean"==typeof this.#r?this.#r:globalThis.document?.visibilityState!=="hidden"}};e.s(["focusManager",()=>i])},86491,14448,93803,36553,88587,e=>{"use strict";e.i(47167);var t=e.i(19273),r=e.i(40143),i=e.i(75555),s=e.i(15823),n=new class extends s.Subscribable{#n=!0;#i;#s;constructor(){super(),this.#s=e=>{if(!t.isServer&&window.addEventListener){let t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#i||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#i?.(),this.#i=void 0)}setEventListener(e){this.#s=e,this.#i?.(),this.#i=e(this.setOnline.bind(this))}setOnline(e){this.#n!==e&&(this.#n=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#n}};function a(){let e,t,r=new Promise((r,i)=>{e=r,t=i});function i(e){Object.assign(r,e),delete r.resolve,delete r.reject}return r.status="pending",r.catch(()=>{}),r.resolve=t=>{i({status:"fulfilled",value:t}),e(t)},r.reject=e=>{i({status:"rejected",reason:e}),t(e)},r}function o(e){return Math.min(1e3*2**e,3e4)}function l(e){return(e??"online")!=="online"||n.isOnline()}e.s(["onlineManager",()=>n],14448),e.s(["pendingThenable",()=>a],93803);var u=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function c(e){let r,s=!1,c=0,h=a(),d=()=>i.focusManager.isFocused()&&("always"===e.networkMode||n.isOnline())&&e.canRun(),f=()=>l(e.networkMode)&&e.canRun(),p=e=>{"pending"===h.status&&(r?.(),h.resolve(e))},m=e=>{"pending"===h.status&&(r?.(),h.reject(e))},y=()=>new Promise(t=>{r=e=>{("pending"!==h.status||d())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,"pending"===h.status&&e.onContinue?.()}),v=()=>{let r;if("pending"!==h.status)return;let i=0===c?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(p).catch(r=>{if("pending"!==h.status)return;let i=e.retry??3*!t.isServer,n=e.retryDelay??o,a="function"==typeof n?n(c,r):n,l=!0===i||"number"==typeof i&&cd()?void 0:y()).then(()=>{s?m(r):v()}))})};return{promise:h,status:()=>h.status,cancel:t=>{if("pending"===h.status){let r=new u(t);m(r),e.onCancel?.(r)}},continue:()=>(r?.(),h),cancelRetry:()=>{s=!0},continueRetry:()=>{s=!1},canStart:f,start:()=>(f()?v():y().then(v),h)}}e.s(["CancelledError",()=>u,"canFetch",()=>l,"createRetryer",()=>c],36553);var h=e.i(80166),d=class{#a;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),(0,t.isValidTimeout)(this.gcTime)&&(this.#a=h.timeoutManager.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(t.isServer?1/0:3e5))}clearGcTimeout(){this.#a&&(h.timeoutManager.clearTimeout(this.#a),this.#a=void 0)}};e.s(["Removable",()=>d],88587);var f=class extends d{#o;#l;#u;#c;#h;#d;#f;constructor(e){super(),this.#f=!1,this.#d=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#c=e.client,this.#u=this.#c.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#o=y(this.options),this.state=e.state??this.#o,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#h?.promise}setOptions(e){if(this.options={...this.#d,...e},this.updateGcTime(this.options.gcTime),this.state&&void 0===this.state.data){let e=y(this.options);void 0!==e.data&&(this.setState(m(e.data,e.dataUpdatedAt)),this.#o=e)}}optionalRemove(){this.observers.length||"idle"!==this.state.fetchStatus||this.#u.remove(this)}setData(e,r){let i=(0,t.replaceData)(this.state.data,e,this.options);return this.#p({data:i,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),i}setState(e,t){this.#p({type:"setState",state:e,setStateOptions:t})}cancel(e){let r=this.#h?.promise;return this.#h?.cancel(e),r?r.then(t.noop).catch(t.noop):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#o)}isActive(){return this.observers.some(e=>!1!==(0,t.resolveEnabled)(e.options.enabled,this))}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===t.skipToken||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>"static"===(0,t.resolveStaleTime)(e.options.staleTime,this))}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):void 0===this.state.data||this.state.isInvalidated}isStaleByTime(e=0){return void 0===this.state.data||"static"!==e&&(!!this.state.isInvalidated||!(0,t.timeUntilStale)(this.state.dataUpdatedAt,e))}onFocus(){let e=this.observers.find(e=>e.shouldFetchOnWindowFocus());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}onOnline(){let e=this.observers.find(e=>e.shouldFetchOnReconnect());e?.refetch({cancelRefetch:!1}),this.#h?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#u.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#h&&(this.#f?this.#h.cancel({revert:!0}):this.#h.cancelRetry()),this.scheduleGc()),this.#u.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#p({type:"invalidate"})}async fetch(e,r){let i;if("idle"!==this.state.fetchStatus&&this.#h?.status()!=="rejected"){if(void 0!==this.state.data&&r?.cancelRefetch)this.cancel({silent:!0});else if(this.#h)return this.#h.continueRetry(),this.#h.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let s=new AbortController,n=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#f=!0,s.signal)})},a=()=>{let e,i=(0,t.ensureQueryFn)(this.options,r),s=(n(e={client:this.#c,queryKey:this.queryKey,meta:this.meta}),e);return(this.#f=!1,this.options.persister)?this.options.persister(i,s,this):i(s)},o=(n(i={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:this.#c,state:this.state,fetchFn:a}),i);this.options.behavior?.onFetch(o,this),this.#l=this.state,("idle"===this.state.fetchStatus||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#p({type:"fetch",meta:o.fetchOptions?.meta}),this.#h=c({initialPromise:r?.initialPromise,fn:o.fetchFn,onCancel:e=>{e instanceof u&&e.revert&&this.setState({...this.#l,fetchStatus:"idle"}),s.abort()},onFail:(e,t)=>{this.#p({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#p({type:"pause"})},onContinue:()=>{this.#p({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let e=await this.#h.start();if(void 0===e)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#u.config.onSuccess?.(e,this),this.#u.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof u){if(e.silent)return this.#h.promise;else if(e.revert){if(void 0===this.state.data)throw e;return this.state.data}}throw this.#p({type:"error",error:e}),this.#u.config.onError?.(e,this),this.#u.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#p(e){let t=t=>{switch(e.type){case"failed":return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...t,fetchStatus:"paused"};case"continue":return{...t,fetchStatus:"fetching"};case"fetch":return{...t,...p(t.data,this.options),fetchMeta:e.meta??null};case"success":let r={...t,...m(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#l=e.manual?r:void 0,r;case"error":let i=e.error;return{...t,error:i,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...t,isInvalidated:!0};case"setState":return{...t,...e.state}}};this.state=t(this.state),r.notifyManager.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#u.notify({query:this,type:"updated",action:e})})}};function p(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:l(t.networkMode)?"fetching":"paused",...void 0===e&&{error:null,status:"pending"}}}function m(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function y(e){let t="function"==typeof e.initialData?e.initialData():e.initialData,r=void 0!==t,i=r?"function"==typeof e.initialDataUpdatedAt?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}e.s(["Query",()=>f,"fetchState",()=>p],86491)},12598,e=>{"use strict";var t=e.i(71645),r=e.i(43476),i=t.createContext(void 0),s=e=>{let r=t.useContext(i);if(e)return e;if(!r)throw Error("No QueryClient set, use QueryClientProvider to set one");return r},n=({client:e,children:s})=>(t.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,r.jsx)(i.Provider,{value:e,children:s}));e.s(["QueryClientProvider",()=>n,"useQueryClient",()=>s])},69230,e=>{"use strict";var t=e.i(75555),r=e.i(40143),i=e.i(86491),s=e.i(15823),n=e.i(93803),a=e.i(19273),o=e.i(80166),l=class extends s.Subscribable{constructor(e,t){super(),this.options=t,this.#c=e,this.#m=null,this.#y=(0,n.pendingThenable)(),this.bindMethods(),this.setOptions(t)}#c;#v=void 0;#g=void 0;#b=void 0;#S;#R;#y;#m;#T;#F;#O;#x;#w;#E;#I=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){1===this.listeners.size&&(this.#v.addObserver(this),u(this.#v,this.options)?this.#M():this.updateResult(),this.#C())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return c(this.#v,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return c(this.#v,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#_(),this.#P(),this.#v.removeObserver(this)}setOptions(e){let t=this.options,r=this.#v;if(this.options=this.#c.defaultQueryOptions(e),void 0!==this.options.enabled&&"boolean"!=typeof this.options.enabled&&"function"!=typeof this.options.enabled&&"boolean"!=typeof(0,a.resolveEnabled)(this.options.enabled,this.#v))throw Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#D(),this.#v.setOptions(this.options),t._defaulted&&!(0,a.shallowEqualObjects)(this.options,t)&&this.#c.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#v,observer:this});let i=this.hasListeners();i&&h(this.#v,r,this.options,t)&&this.#M(),this.updateResult(),i&&(this.#v!==r||(0,a.resolveEnabled)(this.options.enabled,this.#v)!==(0,a.resolveEnabled)(t.enabled,this.#v)||(0,a.resolveStaleTime)(this.options.staleTime,this.#v)!==(0,a.resolveStaleTime)(t.staleTime,this.#v))&&this.#j();let s=this.#k();i&&(this.#v!==r||(0,a.resolveEnabled)(this.options.enabled,this.#v)!==(0,a.resolveEnabled)(t.enabled,this.#v)||s!==this.#E)&&this.#U(s)}getOptimisticResult(e){var t,r;let i=this.#c.getQueryCache().build(this.#c,e),s=this.createResult(i,e);return t=this,r=s,(0,a.shallowEqualObjects)(t.getCurrentResult(),r)||(this.#b=s,this.#R=this.options,this.#S=this.#v.state),s}getCurrentResult(){return this.#b}trackResult(e,t){return new Proxy(e,{get:(e,r)=>(this.trackProp(r),t?.(r),"promise"===r&&(this.trackProp("data"),this.options.experimental_prefetchInRender||"pending"!==this.#y.status||this.#y.reject(Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(e,r))})}trackProp(e){this.#I.add(e)}getCurrentQuery(){return this.#v}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#c.defaultQueryOptions(e),r=this.#c.getQueryCache().build(this.#c,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#M({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#b))}#M(e){this.#D();let t=this.#v.fetch(this.options,e);return e?.throwOnError||(t=t.catch(a.noop)),t}#j(){this.#_();let e=(0,a.resolveStaleTime)(this.options.staleTime,this.#v);if(a.isServer||this.#b.isStale||!(0,a.isValidTimeout)(e))return;let t=(0,a.timeUntilStale)(this.#b.dataUpdatedAt,e);this.#x=o.timeoutManager.setTimeout(()=>{this.#b.isStale||this.updateResult()},t+1)}#k(){return("function"==typeof this.options.refetchInterval?this.options.refetchInterval(this.#v):this.options.refetchInterval)??!1}#U(e){this.#P(),this.#E=e,!a.isServer&&!1!==(0,a.resolveEnabled)(this.options.enabled,this.#v)&&(0,a.isValidTimeout)(this.#E)&&0!==this.#E&&(this.#w=o.timeoutManager.setInterval(()=>{(this.options.refetchIntervalInBackground||t.focusManager.isFocused())&&this.#M()},this.#E))}#C(){this.#j(),this.#U(this.#k())}#_(){this.#x&&(o.timeoutManager.clearTimeout(this.#x),this.#x=void 0)}#P(){this.#w&&(o.timeoutManager.clearInterval(this.#w),this.#w=void 0)}createResult(e,t){let r,s=this.#v,o=this.options,l=this.#b,c=this.#S,f=this.#R,p=e!==s?e.state:this.#g,{state:m}=e,y={...m},v=!1;if(t._optimisticResults){let r=this.hasListeners(),n=!r&&u(e,t),a=r&&h(e,s,t,o);(n||a)&&(y={...y,...(0,i.fetchState)(m.data,e.options)}),"isRestoring"===t._optimisticResults&&(y.fetchStatus="idle")}let{error:g,errorUpdatedAt:b,status:S}=y;r=y.data;let R=!1;if(void 0!==t.placeholderData&&void 0===r&&"pending"===S){let e;l?.isPlaceholderData&&t.placeholderData===f?.placeholderData?(e=l.data,R=!0):e="function"==typeof t.placeholderData?t.placeholderData(this.#O?.state.data,this.#O):t.placeholderData,void 0!==e&&(S="success",r=(0,a.replaceData)(l?.data,e,t),v=!0)}if(t.select&&void 0!==r&&!R)if(l&&r===c?.data&&t.select===this.#T)r=this.#F;else try{this.#T=t.select,r=t.select(r),r=(0,a.replaceData)(l?.data,r,t),this.#F=r,this.#m=null}catch(e){this.#m=e}this.#m&&(g=this.#m,r=this.#F,b=Date.now(),S="error");let T="fetching"===y.fetchStatus,F="pending"===S,O="error"===S,x=F&&T,w=void 0!==r,E={status:S,fetchStatus:y.fetchStatus,isPending:F,isSuccess:"success"===S,isError:O,isInitialLoading:x,isLoading:x,data:r,dataUpdatedAt:y.dataUpdatedAt,error:g,errorUpdatedAt:b,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:y.dataUpdateCount>0||y.errorUpdateCount>0,isFetchedAfterMount:y.dataUpdateCount>p.dataUpdateCount||y.errorUpdateCount>p.errorUpdateCount,isFetching:T,isRefetching:T&&!F,isLoadingError:O&&!w,isPaused:"paused"===y.fetchStatus,isPlaceholderData:v,isRefetchError:O&&w,isStale:d(e,t),refetch:this.refetch,promise:this.#y,isEnabled:!1!==(0,a.resolveEnabled)(t.enabled,e)};if(this.options.experimental_prefetchInRender){let t=void 0!==E.data,r="error"===E.status&&!t,i=e=>{r?e.reject(E.error):t&&e.resolve(E.data)},a=()=>{i(this.#y=E.promise=(0,n.pendingThenable)())},o=this.#y;switch(o.status){case"pending":e.queryHash===s.queryHash&&i(o);break;case"fulfilled":(r||E.data!==o.value)&&a();break;case"rejected":r&&E.error===o.reason||a()}}return E}updateResult(){let e=this.#b,t=this.createResult(this.#v,this.options);if(this.#S=this.#v.state,this.#R=this.options,void 0!==this.#S.data&&(this.#O=this.#v),(0,a.shallowEqualObjects)(t,e))return;this.#b=t;let r=()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,r="function"==typeof t?t():t;if("all"===r||!r&&!this.#I.size)return!0;let i=new Set(r??this.#I);return this.options.throwOnError&&i.add("error"),Object.keys(this.#b).some(t=>this.#b[t]!==e[t]&&i.has(t))};this.#Q({listeners:r()})}#D(){let e=this.#c.getQueryCache().build(this.#c,this.options);if(e===this.#v)return;let t=this.#v;this.#v=e,this.#g=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#C()}#Q(e){r.notifyManager.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#b)}),this.#c.getQueryCache().notify({query:this.#v,type:"observerResultsUpdated"})})}};function u(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&void 0===e.state.data&&("error"!==e.state.status||!1!==t.retryOnMount)||void 0!==e.state.data&&c(e,t,t.refetchOnMount)}function c(e,t,r){if(!1!==(0,a.resolveEnabled)(t.enabled,e)&&"static"!==(0,a.resolveStaleTime)(t.staleTime,e)){let i="function"==typeof r?r(e):r;return"always"===i||!1!==i&&d(e,t)}return!1}function h(e,t,r,i){return(e!==t||!1===(0,a.resolveEnabled)(i.enabled,e))&&(!r.suspense||"error"!==e.state.status)&&d(e,r)}function d(e,t){return!1!==(0,a.resolveEnabled)(t.enabled,e)&&e.isStaleByTime((0,a.resolveStaleTime)(t.staleTime,e))}e.s(["QueryObserver",()=>l])},69637,54440,e=>{"use strict";let t;e.i(47167);var r=e.i(71645),i=e.i(19273),s=e.i(40143),n=e.i(12598);e.i(43476);var a=r.createContext((t=!1,{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t})),o=r.createContext(!1);o.Provider;var l=(e,t)=>void 0===t.state.data,u=e=>{if(e.suspense){let t=e=>"static"===e?e:Math.max(e??1e3,1e3),r=e.staleTime;e.staleTime="function"==typeof r?(...e)=>t(r(...e)):t(r),"number"==typeof e.gcTime&&(e.gcTime=Math.max(e.gcTime,1e3))}},c=(e,t)=>e.isLoading&&e.isFetching&&!t,h=(e,t)=>e?.suspense&&t.isPending,d=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function f(e,t,l){let f,p=r.useContext(o),m=r.useContext(a),y=(0,n.useQueryClient)(l),v=y.defaultQueryOptions(e);y.getDefaultOptions().queries?._experimental_beforeQuery?.(v);let g=y.getQueryCache().get(v.queryHash);v._optimisticResults=p?"isRestoring":"optimistic",u(v),f=g?.state.error&&"function"==typeof v.throwOnError?(0,i.shouldThrowError)(v.throwOnError,[g.state.error,g]):v.throwOnError,(v.suspense||v.experimental_prefetchInRender||f)&&!m.isReset()&&(v.retryOnMount=!1),r.useEffect(()=>{m.clearReset()},[m]);let b=!y.getQueryCache().get(v.queryHash),[S]=r.useState(()=>new t(y,v)),R=S.getOptimisticResult(v),T=!p&&!1!==e.subscribed;if(r.useSyncExternalStore(r.useCallback(e=>{let t=T?S.subscribe(s.notifyManager.batchCalls(e)):i.noop;return S.updateResult(),t},[S,T]),()=>S.getCurrentResult(),()=>S.getCurrentResult()),r.useEffect(()=>{S.setOptions(v)},[v,S]),h(v,R))throw d(v,S,m);if((({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(n&&void 0===e.data||(0,i.shouldThrowError)(r,[e.error,s])))({result:R,errorResetBoundary:m,throwOnError:v.throwOnError,query:g,suspense:v.suspense}))throw R.error;if(y.getDefaultOptions().queries?._experimental_afterQuery?.(v,R),v.experimental_prefetchInRender&&!i.isServer&&c(R,p)){let e=b?d(v,S,m):g?.promise;e?.catch(i.noop).finally(()=>{S.updateResult()})}return v.notifyOnChangeProps?R:S.trackResult(R)}e.s(["defaultThrowOnError",()=>l,"ensureSuspenseTimers",()=>u,"fetchOptimistic",()=>d,"shouldSuspend",()=>h,"willFetch",()=>c],54440),e.s(["useBaseQuery",()=>f],69637)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/94212136ebe55507.js b/docs/_next/static/chunks/94212136ebe55507.js deleted file mode 100644 index 9081698d..00000000 --- a/docs/_next/static/chunks/94212136ebe55507.js +++ /dev/null @@ -1,52 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,79474,(t,e,i)=>{"use strict";var s=t.r(71645).__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;i.c=function(t){return s.H.useMemoCache(t)}},932,(t,e,i)=>{"use strict";e.exports=t.r(79474)},90072,t=>{"use strict";let e,i,s,r,n,a,o,h,l,u={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},c={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},p="attached",d="detached",m="srgb",f="srgb-linear",g="linear",y="srgb",x={COMPUTE:"compute",RENDER:"render"},b={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},v={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function w(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}let M={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function S(t,e){return new M[t](e)}function A(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function _(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function C(){let t=_("canvas");return t.style.display="block",t}let T={},I=null;function z(t){I=t}function k(){return I}function B(...t){let e="THREE."+t.shift();I?I("log",e,...t):console.log(e,...t)}function R(...t){let e="THREE."+t.shift();I?I("warn",e,...t):console.warn(e,...t)}function O(...t){let e="THREE."+t.shift();I?I("error",e,...t):console.error(e,...t)}function E(...t){let e=t.join(" ");e in T||(T[e]=!0,R(...t))}function P(t,e,i){return new Promise(function(s,r){setTimeout(function n(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:r();break;case t.TIMEOUT_EXPIRED:setTimeout(n,i);break;default:s()}},i)})}class L{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});let i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){let i=this._listeners;return void 0!==i&&void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){let i=this._listeners;if(void 0===i)return;let s=i[t];if(void 0!==s){let t=s.indexOf(e);-1!==t&&s.splice(t,1)}}dispatchEvent(t){let e=this._listeners;if(void 0===e)return;let i=e[t.type];if(void 0!==i){t.target=this;let e=i.slice(0);for(let i=0,s=e.length;i>8&255]+N[t>>16&255]+N[t>>24&255]+"-"+N[255&e]+N[e>>8&255]+"-"+N[e>>16&15|64]+N[e>>24&255]+"-"+N[63&i|128]+N[i>>8&255]+"-"+N[i>>16&255]+N[i>>24&255]+N[255&s]+N[s>>8&255]+N[s>>16&255]+N[s>>24&255]).toLowerCase()}function j(t,e,i){return Math.max(e,Math.min(i,t))}function U(t,e){return(t%e+e)%e}function W(t,e,i){return(1-i)*t+i*e}function G(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/0xffffffff;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/0x7fffffff,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw Error("Invalid component type.")}}function q(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(0xffffffff*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(0x7fffffff*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw Error("Invalid component type.")}}let H={DEG2RAD:$,RAD2DEG:V,generateUUID:D,clamp:j,euclideanModulo:U,mapLinear:function(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:W,damp:function(t,e,i,s){return W(t,e,1-Math.exp(-i*s))},pingpong:function(t,e=1){return e-Math.abs(U(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function(t,e){return t+Math.random()*(e-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(F=t);let e=F+=0x6d2b79f5;return e=Math.imul(e^e>>>15,1|e),(((e^=e+Math.imul(e^e>>>7,61|e))^e>>>14)>>>0)/0x100000000},degToRad:function(t){return t*$},radToDeg:function(t){return t*V},isPowerOfTwo:function(t){return(t&t-1)==0&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,e,i,s,r){let n=Math.cos,a=Math.sin,o=n(i/2),h=a(i/2),l=n((e+s)/2),u=a((e+s)/2),c=n((e-s)/2),p=a((e-s)/2),d=n((s-e)/2),m=a((s-e)/2);switch(r){case"XYX":t.set(o*u,h*c,h*p,o*l);break;case"YZY":t.set(h*p,o*u,h*c,o*l);break;case"ZXZ":t.set(h*c,h*p,o*u,o*l);break;case"XZX":t.set(o*u,h*m,h*d,o*l);break;case"YXY":t.set(h*d,o*u,h*m,o*l);break;case"ZYZ":t.set(h*m,h*d,o*u,o*l);break;default:R("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:q,denormalize:G};class J{constructor(t=0,e=0){J.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){let e=this.x,i=this.y,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());return 0===e?Math.PI/2:Math.acos(j(this.dot(t)/e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){let i=Math.cos(e),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class X{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,a){let o=i[s+0],h=i[s+1],l=i[s+2],u=i[s+3],c=r[n+0],p=r[n+1],d=r[n+2],m=r[n+3];if(a<=0){t[e+0]=o,t[e+1]=h,t[e+2]=l,t[e+3]=u;return}if(a>=1){t[e+0]=c,t[e+1]=p,t[e+2]=d,t[e+3]=m;return}if(u!==m||o!==c||h!==p||l!==d){let t=o*c+h*p+l*d+u*m;t<0&&(c=-c,p=-p,d=-d,m=-m,t=-t);let e=1-a;if(t<.9995){let i=Math.acos(t),s=Math.sin(i);o=o*(e=Math.sin(e*i)/s)+c*(a=Math.sin(a*i)/s),h=h*e+p*a,l=l*e+d*a,u=u*e+m*a}else{let t=1/Math.sqrt((o=o*e+c*a)*o+(h=h*e+p*a)*h+(l=l*e+d*a)*l+(u=u*e+m*a)*u);o*=t,h*=t,l*=t,u*=t}}t[e]=o,t[e+1]=h,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,s,r,n){let a=i[s],o=i[s+1],h=i[s+2],l=i[s+3],u=r[n],c=r[n+1],p=r[n+2],d=r[n+3];return t[e]=a*d+l*u+o*p-h*c,t[e+1]=o*d+l*c+h*u-a*p,t[e+2]=h*d+l*p+a*c-o*u,t[e+3]=l*d-a*u-o*c-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){let i=t._x,s=t._y,r=t._z,n=t._order,a=Math.cos,o=Math.sin,h=a(i/2),l=a(s/2),u=a(r/2),c=o(i/2),p=o(s/2),d=o(r/2);switch(n){case"XYZ":this._x=c*l*u+h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u-c*p*d;break;case"YXZ":this._x=c*l*u+h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u+c*p*d;break;case"ZXY":this._x=c*l*u-h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u-c*p*d;break;case"ZYX":this._x=c*l*u-h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u+c*p*d;break;case"YZX":this._x=c*l*u+h*p*d,this._y=h*p*u+c*l*d,this._z=h*l*d-c*p*u,this._w=h*l*u-c*p*d;break;case"XZY":this._x=c*l*u-h*p*d,this._y=h*p*u-c*l*d,this._z=h*l*d+c*p*u,this._w=h*l*u+c*p*d;break;default:R("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){let i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){let e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],a=e[5],o=e[9],h=e[2],l=e[6],u=e[10],c=i+a+u;if(c>0){let t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(l-o)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>a&&i>u){let t=2*Math.sqrt(1+i-a-u);this._w=(l-o)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(a>u){let t=2*Math.sqrt(1+a-i-u);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(o+l)/t}else{let t=2*Math.sqrt(1+u-i-a);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(o+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0):(this._x=0,this._y=-t.z,this._z=t.y)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x),this._w=i,this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(j(this.dot(t),-1,1)))}rotateTowards(t,e){let i=this.angleTo(t);if(0===i)return this;let s=Math.min(1,e/i);return this.slerp(t,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){let i=t._x,s=t._y,r=t._z,n=t._w,a=e._x,o=e._y,h=e._z,l=e._w;return this._x=i*l+n*a+s*h-r*o,this._y=s*l+n*o+r*a-i*h,this._z=r*l+n*h+i*o-s*a,this._w=n*l-i*a-s*o-r*h,this._onChangeCallback(),this}slerp(t,e){if(e<=0)return this;if(e>=1)return this.copy(t);let i=t._x,s=t._y,r=t._z,n=t._w,a=this.dot(t);a<0&&(i=-i,s=-s,r=-r,n=-n,a=-a);let o=1-e;if(a<.9995){let t=Math.acos(a),h=Math.sin(t);o=Math.sin(o*t)/h,e=Math.sin(e*t)/h,this._x=this._x*o+i*e,this._y=this._y*o+s*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this._onChangeCallback()}else this._x=this._x*o+i*e,this._y=this._y*o+s*e,this._z=this._z*o+r*e,this._w=this._w*o+n*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){let t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Z{constructor(t=0,e=0,i=0){Z.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Q.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Q.setFromAxisAngle(t,e))}applyMatrix3(t){let e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){let e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){let e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,a=t.z,o=t.w,h=2*(n*s-a*i),l=2*(a*e-r*s),u=2*(r*i-n*e);return this.x=e+o*h+n*u-a*l,this.y=i+o*l+a*h-r*u,this.z=s+o*u+r*l-n*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){let e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){let i=t.x,s=t.y,r=t.z,n=e.x,a=e.y,o=e.z;return this.x=s*o-r*a,this.y=r*n-i*o,this.z=i*a-s*n,this}projectOnVector(t){let e=t.lengthSq();if(0===e)return this.set(0,0,0);let i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Y.copy(this).projectOnVector(t),this.sub(Y)}reflect(t){return this.sub(Y.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){let e=Math.sqrt(this.lengthSq()*t.lengthSq());return 0===e?Math.PI/2:Math.acos(j(this.dot(t)/e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){let e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){let s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){let e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}let Y=new Z,Q=new X;class K{constructor(t,e,i,s,r,n,a,o,h){K.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h)}set(t,e,i,s,r,n,a,o,h){let l=this.elements;return l[0]=t,l[1]=s,l[2]=a,l[3]=e,l[4]=r,l[5]=o,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){let e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[3],o=i[6],h=i[1],l=i[4],u=i[7],c=i[2],p=i[5],d=i[8],m=s[0],f=s[3],g=s[6],y=s[1],x=s[4],b=s[7],v=s[2],w=s[5],M=s[8];return r[0]=n*m+a*y+o*v,r[3]=n*f+a*x+o*w,r[6]=n*g+a*b+o*M,r[1]=h*m+l*y+u*v,r[4]=h*f+l*x+u*w,r[7]=h*g+l*b+u*M,r[2]=c*m+p*y+d*v,r[5]=c*f+p*x+d*w,r[8]=c*g+p*b+d*M,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8];return e*n*l-e*a*h-i*r*l+i*a*o+s*r*h-s*n*o}invert(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],u=l*n-a*h,c=a*o-l*r,p=h*r-n*o,d=e*u+i*c+s*p;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);let m=1/d;return t[0]=u*m,t[1]=(s*h-l*i)*m,t[2]=(a*i-s*n)*m,t[3]=c*m,t[4]=(l*e-s*o)*m,t[5]=(s*r-a*e)*m,t[6]=p*m,t[7]=(i*o-h*e)*m,t[8]=(n*e-i*r)*m,this}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){let e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,r,n,a){let o=Math.cos(r),h=Math.sin(r);return this.set(i*o,i*h,-i*(o*n+h*a)+n+t,-s*h,s*o,-s*(-h*n+o*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(tt.makeScale(t,e)),this}rotate(t){return this.premultiply(tt.makeRotation(-t)),this}translate(t,e){return this.premultiply(tt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){let e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}let tt=new K,te=new K().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ti=new K().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715),ts=(o=[.64,.33,.3,.6,.15,.06],h=[.2126,.7152,.0722],l=[.3127,.329],(a={enabled:!0,workingColorSpace:f,spaces:{},convert:function(t,e,i){return!1!==this.enabled&&e!==i&&e&&i&&(this.spaces[e].transfer===y&&(t.r=tr(t.r),t.g=tr(t.g),t.b=tr(t.b)),this.spaces[e].primaries!==this.spaces[i].primaries&&(t.applyMatrix3(this.spaces[e].toXYZ),t.applyMatrix3(this.spaces[i].fromXYZ)),this.spaces[i].transfer===y&&(t.r=tn(t.r),t.g=tn(t.g),t.b=tn(t.b))),t},workingToColorSpace:function(t,e){return this.convert(t,this.workingColorSpace,e)},colorSpaceToWorking:function(t,e){return this.convert(t,e,this.workingColorSpace)},getPrimaries:function(t){return this.spaces[t].primaries},getTransfer:function(t){return""===t?g:this.spaces[t].transfer},getToneMappingMode:function(t){return this.spaces[t].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(t,e=this.workingColorSpace){return t.fromArray(this.spaces[e].luminanceCoefficients)},define:function(t){Object.assign(this.spaces,t)},_getMatrix:function(t,e,i){return t.copy(this.spaces[e].toXYZ).multiply(this.spaces[i].fromXYZ)},_getDrawingBufferColorSpace:function(t){return this.spaces[t].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(t=this.workingColorSpace){return this.spaces[t].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(t,e){return E("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(t,e)},toWorkingColorSpace:function(t,e){return E("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(t,e)}}).define({[f]:{primaries:o,whitePoint:l,transfer:g,toXYZ:te,fromXYZ:ti,luminanceCoefficients:h,workingColorSpaceConfig:{unpackColorSpace:m},outputColorSpaceConfig:{drawingBufferColorSpace:m}},[m]:{primaries:o,whitePoint:l,transfer:y,toXYZ:te,fromXYZ:ti,luminanceCoefficients:h,outputColorSpaceConfig:{drawingBufferColorSpace:m}}}),a);function tr(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function tn(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class ta{static getDataURL(t,i="image/png"){let s;if(/^data:/i.test(t.src)||"u"typeof HTMLImageElement&&t instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&t instanceof ImageBitmap){let e=_("canvas");e.width=t.width,e.height=t.height;let i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);let s=i.getImageData(0,0,t.width,t.height),r=s.data;for(let t=0;ttypeof HTMLVideoElement&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):"u">typeof VideoFrame&&e instanceof VideoFrame?t.set(e.displayHeight,e.displayWidth,0):null!==e?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){!0===t&&this.version++}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.images[this.uuid])return t.images[this.uuid];let i={uuid:this.uuid,url:""},s=this.data;if(null!==s){let t;if(Array.isArray(s)){t=[];for(let e=0,i=s.length;etypeof HTMLImageElement&&t instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&t instanceof ImageBitmap?ta.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(R("Texture: Unable to serialize Texture."),{})}let tu=0,tc=new Z;class tp extends L{constructor(t=tp.DEFAULT_IMAGE,e=tp.DEFAULT_MAPPING,i=1001,s=1001,r=1006,n=1008,a=1023,o=1009,h=tp.DEFAULT_ANISOTROPY,l=""){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:tu++}),this.uuid=D(),this.name="",this.source=new th(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=s,this.magFilter=r,this.minFilter=n,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=o,this.offset=new J(0,0),this.repeat=new J(1,1),this.center=new J(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new K,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!t&&!!t.depth&&t.depth>1,this.pmremVersion=0}get width(){return this.source.getSize(tc).x}get height(){return this.source.getSize(tc).y}get depth(){return this.source.getSize(tc).z}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(let e in t){let i=t[e];if(void 0===i){R(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}let s=this[e];if(void 0===s){R(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[e]=i}}toJSON(t){let e=void 0===t||"string"==typeof t;if(!e&&void 0!==t.textures[this.uuid])return t.textures[this.uuid];let i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(300!==this.mapping)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case 1e3:t.x=t.x-Math.floor(t.x);break;case 1001:t.x=t.x<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.x)%2)?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x)}if(t.y<0||t.y>1)switch(this.wrapT){case 1e3:t.y=t.y-Math.floor(t.y);break;case 1001:t.y=t.y<0?0:1;break;case 1002:1===Math.abs(Math.floor(t.y)%2)?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y)}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){!0===t&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){!0===t&&this.pmremVersion++}}tp.DEFAULT_IMAGE=null,tp.DEFAULT_MAPPING=300,tp.DEFAULT_ANISOTROPY=1;class td{constructor(t=0,e=0,i=0,s=1){td.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,s){return this.x=t,this.y=e,this.z=i,this.w=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){let e=this.x,i=this.y,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);let e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,s,r,n=t.elements,a=n[0],o=n[4],h=n[8],l=n[1],u=n[5],c=n[9],p=n[2],d=n[6],m=n[10];if(.01>Math.abs(o-l)&&.01>Math.abs(h-p)&&.01>Math.abs(c-d)){if(.1>Math.abs(o+l)&&.1>Math.abs(h+p)&&.1>Math.abs(c+d)&&.1>Math.abs(a+u+m-3))return this.set(1,0,0,0),this;e=Math.PI;let t=(a+1)/2,n=(u+1)/2,f=(m+1)/2,g=(o+l)/4,y=(h+p)/4,x=(c+d)/4;return t>n&&t>f?t<.01?(i=0,s=.707106781,r=.707106781):(s=g/(i=Math.sqrt(t)),r=y/i):n>f?n<.01?(i=.707106781,s=0,r=.707106781):(i=g/(s=Math.sqrt(n)),r=x/s):f<.01?(i=.707106781,s=.707106781,r=0):(i=y/(r=Math.sqrt(f)),s=x/r),this.set(i,s,r,e),this}let f=Math.sqrt((d-c)*(d-c)+(h-p)*(h-p)+(l-o)*(l-o));return .001>Math.abs(f)&&(f=1),this.x=(d-c)/f,this.y=(h-p)/f,this.z=(l-o)/f,this.w=Math.acos((a+u+m-1)/2),this}setFromMatrixPosition(t){let e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=j(this.x,t.x,e.x),this.y=j(this.y,t.y,e.y),this.z=j(this.z,t.z,e.z),this.w=j(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=j(this.x,t,e),this.y=j(this.y,t,e),this.z=j(this.z,t,e),this.w=j(this.w,t,e),this}clampLength(t,e){let i=this.length();return this.divideScalar(i||1).multiplyScalar(j(i,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class tm extends L{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new td(0,0,t,e),this.scissorTest=!1,this.viewport=new td(0,0,t,e);const s=new tp({width:t,height:e,depth:i.depth});this.textures=[];const r=i.count;for(let t=0;t1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,i=t.textures.length;e=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,tM),tM.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(tk),tB.subVectors(this.max,tk),tA.subVectors(t.a,tk),t_.subVectors(t.b,tk),tC.subVectors(t.c,tk),tT.subVectors(t_,tA),tI.subVectors(tC,t_),tz.subVectors(tA,tC);let e=[0,-tT.z,tT.y,0,-tI.z,tI.y,0,-tz.z,tz.y,tT.z,0,-tT.x,tI.z,0,-tI.x,tz.z,0,-tz.x,-tT.y,tT.x,0,-tI.y,tI.x,0,-tz.y,tz.x,0];return!!tE(e,tA,t_,tC,tB)&&!!tE(e=[1,0,0,0,1,0,0,0,1],tA,t_,tC,tB)&&(tR.crossVectors(tT,tI),tE(e=[tR.x,tR.y,tR.z],tA,t_,tC,tB))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,tM).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=.5*this.getSize(tM).length()),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()||(tw[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),tw[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),tw[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),tw[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),tw[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),tw[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),tw[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),tw[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(tw)),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}let tw=[new Z,new Z,new Z,new Z,new Z,new Z,new Z,new Z],tM=new Z,tS=new tv,tA=new Z,t_=new Z,tC=new Z,tT=new Z,tI=new Z,tz=new Z,tk=new Z,tB=new Z,tR=new Z,tO=new Z;function tE(t,e,i,s,r){for(let n=0,a=t.length-3;n<=a;n+=3){tO.fromArray(t,n);let a=r.x*Math.abs(tO.x)+r.y*Math.abs(tO.y)+r.z*Math.abs(tO.z),o=e.dot(tO),h=i.dot(tO),l=s.dot(tO);if(Math.max(-Math.max(o,h,l),Math.min(o,h,l))>a)return!1}return!0}let tP=new tv,tL=new Z,tN=new Z;class tF{constructor(t=new Z,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){let i=this.center;void 0!==e?i.copy(e):tP.setFromPoints(t).getCenter(i);let s=0;for(let e=0,r=t.length;ethis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?t.makeEmpty():(t.set(this.center,this.center),t.expandByScalar(this.radius)),t}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;tL.subVectors(t,this.center);let e=tL.lengthSq();if(e>this.radius*this.radius){let t=Math.sqrt(e),i=(t-this.radius)*.5;this.center.addScaledVector(tL,i/t),this.radius+=i}return this}union(t){return t.isEmpty()||(this.isEmpty()?this.copy(t):!0===this.center.equals(t.center)?this.radius=Math.max(this.radius,t.radius):(tN.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(tL.copy(t.center).add(tN)),this.expandByPoint(tL.copy(t.center).sub(tN)))),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let t$=new Z,tV=new Z,tD=new Z,tj=new Z,tU=new Z,tW=new Z,tG=new Z;class tq{constructor(t=new Z,e=new Z(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,t$)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);let i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){let e=t$.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(t$.copy(this.origin).addScaledVector(this.direction,e),t$.distanceToSquared(t))}distanceSqToSegment(t,e,i,s){let r,n,a,o;tV.copy(t).add(e).multiplyScalar(.5),tD.copy(e).sub(t).normalize(),tj.copy(this.origin).sub(tV);let h=.5*t.distanceTo(e),l=-this.direction.dot(tD),u=tj.dot(this.direction),c=-tj.dot(tD),p=tj.lengthSq(),d=Math.abs(1-l*l);if(d>0)if(r=l*c-u,n=l*u-c,o=h*d,r>=0)if(n>=-o)if(n<=o){let t=1/d;r*=t,n*=t,a=r*(r+l*n+2*u)+n*(l*r+n+2*c)+p}else a=-(r=Math.max(0,-(l*(n=h)+u)))*r+n*(n+2*c)+p;else a=-(r=Math.max(0,-(l*(n=-h)+u)))*r+n*(n+2*c)+p;else n<=-o?(n=(r=Math.max(0,-(-l*h+u)))>0?-h:Math.min(Math.max(-h,-c),h),a=-r*r+n*(n+2*c)+p):n<=o?(r=0,a=(n=Math.min(Math.max(-h,-c),h))*(n+2*c)+p):(n=(r=Math.max(0,-(l*h+u)))>0?h:Math.min(Math.max(-h,-c),h),a=-r*r+n*(n+2*c)+p);else n=l>0?-h:h,a=-(r=Math.max(0,-(l*n+u)))*r+n*(n+2*c)+p;return i&&i.copy(this.origin).addScaledVector(this.direction,r),s&&s.copy(tV).addScaledVector(tD,n),a}intersectSphere(t,e){t$.subVectors(t.center,this.origin);let i=t$.dot(this.direction),s=t$.dot(t$)-i*i,r=t.radius*t.radius;if(s>r)return null;let n=Math.sqrt(r-s),a=i-n,o=i+n;return o<0?null:a<0?this.at(o,e):this.at(a,e)}intersectsSphere(t){return!(t.radius<0)&&this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){let e=t.normal.dot(this.direction);if(0===e)return 0===t.distanceToPoint(this.origin)?0:null;let i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){let i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){let e=t.distanceToPoint(this.origin);return!!(0===e||t.normal.dot(this.direction)*e<0)}intersectBox(t,e){let i,s,r,n,a,o,h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return(h>=0?(i=(t.min.x-c.x)*h,s=(t.max.x-c.x)*h):(i=(t.max.x-c.x)*h,s=(t.min.x-c.x)*h),l>=0?(r=(t.min.y-c.y)*l,n=(t.max.y-c.y)*l):(r=(t.max.y-c.y)*l,n=(t.min.y-c.y)*l),i>n||r>s||((r>i||isNaN(i))&&(i=r),(n=0?(a=(t.min.z-c.z)*u,o=(t.max.z-c.z)*u):(a=(t.max.z-c.z)*u,o=(t.min.z-c.z)*u),i>o||a>s||((a>i||i!=i)&&(i=a),(o=0?i:s,e)}intersectsBox(t){return null!==this.intersectBox(t,t$)}intersectTriangle(t,e,i,s,r){let n;tU.subVectors(e,t),tW.subVectors(i,t),tG.crossVectors(tU,tW);let a=this.direction.dot(tG);if(a>0){if(s)return null;n=1}else{if(!(a<0))return null;n=-1,a=-a}tj.subVectors(this.origin,t);let o=n*this.direction.dot(tW.crossVectors(tj,tW));if(o<0)return null;let h=n*this.direction.dot(tU.cross(tj));if(h<0||o+h>a)return null;let l=-n*tj.dot(tG);return l<0?null:this.at(l/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class tH{constructor(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f){tH.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f)}set(t,e,i,s,r,n,a,o,h,l,u,c,p,d,m,f){let g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=s,g[1]=r,g[5]=n,g[9]=a,g[13]=o,g[2]=h,g[6]=l,g[10]=u,g[14]=c,g[3]=p,g[7]=d,g[11]=m,g[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new tH().fromArray(this.elements)}copy(t){let e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){let e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){let e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return 0===this.determinant()?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1)):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2)),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinant())return this.identity();let e=this.elements,i=t.elements,s=1/tJ.setFromMatrixColumn(t,0).length(),r=1/tJ.setFromMatrixColumn(t,1).length(),n=1/tJ.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){let e=this.elements,i=t.x,s=t.y,r=t.z,n=Math.cos(i),a=Math.sin(i),o=Math.cos(s),h=Math.sin(s),l=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){let t=n*l,i=n*u,s=a*l,r=a*u;e[0]=o*l,e[4]=-o*u,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-a*o,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*o}else if("YXZ"===t.order){let t=o*l,i=o*u,s=h*l,r=h*u;e[0]=t+r*a,e[4]=s*a-i,e[8]=n*h,e[1]=n*u,e[5]=n*l,e[9]=-a,e[2]=i*a-s,e[6]=r+t*a,e[10]=n*o}else if("ZXY"===t.order){let t=o*l,i=o*u,s=h*l,r=h*u;e[0]=t-r*a,e[4]=-n*u,e[8]=s+i*a,e[1]=i+s*a,e[5]=n*l,e[9]=r-t*a,e[2]=-n*h,e[6]=a,e[10]=n*o}else if("ZYX"===t.order){let t=n*l,i=n*u,s=a*l,r=a*u;e[0]=o*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=o*u,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=a*o,e[10]=n*o}else if("YZX"===t.order){let t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=r-t*u,e[8]=s*u+i,e[1]=u,e[5]=n*l,e[9]=-a*l,e[2]=-h*l,e[6]=i*u+s,e[10]=t-r*u}else if("XZY"===t.order){let t=n*o,i=n*h,s=a*o,r=a*h;e[0]=o*l,e[4]=-u,e[8]=h*l,e[1]=t*u+r,e[5]=n*l,e[9]=i*u-s,e[2]=s*u-i,e[6]=a*l,e[10]=r*u+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(tZ,t,tY)}lookAt(t,e,i){let s=this.elements;return t0.subVectors(t,e),0===t0.lengthSq()&&(t0.z=1),t0.normalize(),tQ.crossVectors(i,t0),0===tQ.lengthSq()&&(1===Math.abs(i.z)?t0.x+=1e-4:t0.z+=1e-4,t0.normalize(),tQ.crossVectors(i,t0)),tQ.normalize(),tK.crossVectors(t0,tQ),s[0]=tQ.x,s[4]=tK.x,s[8]=t0.x,s[1]=tQ.y,s[5]=tK.y,s[9]=t0.y,s[2]=tQ.z,s[6]=tK.z,s[10]=t0.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){let i=t.elements,s=e.elements,r=this.elements,n=i[0],a=i[4],o=i[8],h=i[12],l=i[1],u=i[5],c=i[9],p=i[13],d=i[2],m=i[6],f=i[10],g=i[14],y=i[3],x=i[7],b=i[11],v=i[15],w=s[0],M=s[4],S=s[8],A=s[12],_=s[1],C=s[5],T=s[9],I=s[13],z=s[2],k=s[6],B=s[10],R=s[14],O=s[3],E=s[7],P=s[11],L=s[15];return r[0]=n*w+a*_+o*z+h*O,r[4]=n*M+a*C+o*k+h*E,r[8]=n*S+a*T+o*B+h*P,r[12]=n*A+a*I+o*R+h*L,r[1]=l*w+u*_+c*z+p*O,r[5]=l*M+u*C+c*k+p*E,r[9]=l*S+u*T+c*B+p*P,r[13]=l*A+u*I+c*R+p*L,r[2]=d*w+m*_+f*z+g*O,r[6]=d*M+m*C+f*k+g*E,r[10]=d*S+m*T+f*B+g*P,r[14]=d*A+m*I+f*R+g*L,r[3]=y*w+x*_+b*z+v*O,r[7]=y*M+x*C+b*k+v*E,r[11]=y*S+x*T+b*B+v*P,r[15]=y*A+x*I+b*R+v*L,this}multiplyScalar(t){let e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){let t=this.elements,e=t[0],i=t[4],s=t[8],r=t[12],n=t[1],a=t[5],o=t[9],h=t[13],l=t[2],u=t[6],c=t[10],p=t[14],d=t[3],m=t[7],f=t[11],g=t[15],y=o*p-h*c,x=a*p-h*u,b=a*c-o*u,v=n*p-h*l,w=n*c-o*l,M=n*u-a*l;return e*(m*y-f*x+g*b)-i*(d*y-f*v+g*w)+s*(d*x-m*v+g*M)-r*(d*b-m*w+f*M)}transpose(){let t,e=this.elements;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(t,e,i){let s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){let t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],a=t[5],o=t[6],h=t[7],l=t[8],u=t[9],c=t[10],p=t[11],d=t[12],m=t[13],f=t[14],g=t[15],y=u*f*h-m*c*h+m*o*p-a*f*p-u*o*g+a*c*g,x=d*c*h-l*f*h-d*o*p+n*f*p+l*o*g-n*c*g,b=l*m*h-d*u*h+d*a*p-n*m*p-l*a*g+n*u*g,v=d*u*o-l*m*o-d*a*c+n*m*c+l*a*f-n*u*f,w=e*y+i*x+s*b+r*v;if(0===w)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let M=1/w;return t[0]=y*M,t[1]=(m*c*r-u*f*r-m*s*p+i*f*p+u*s*g-i*c*g)*M,t[2]=(a*f*r-m*o*r+m*s*h-i*f*h-a*s*g+i*o*g)*M,t[3]=(u*o*r-a*c*r-u*s*h+i*c*h+a*s*p-i*o*p)*M,t[4]=x*M,t[5]=(l*f*r-d*c*r+d*s*p-e*f*p-l*s*g+e*c*g)*M,t[6]=(d*o*r-n*f*r-d*s*h+e*f*h+n*s*g-e*o*g)*M,t[7]=(n*c*r-l*o*r+l*s*h-e*c*h-n*s*p+e*o*p)*M,t[8]=b*M,t[9]=(d*u*r-l*m*r-d*i*p+e*m*p+l*i*g-e*u*g)*M,t[10]=(n*m*r-d*a*r+d*i*h-e*m*h-n*i*g+e*a*g)*M,t[11]=(l*a*r-n*u*r-l*i*h+e*u*h+n*i*p-e*a*p)*M,t[12]=v*M,t[13]=(l*m*s-d*u*s+d*i*c-e*m*c-l*i*f+e*u*f)*M,t[14]=(d*a*s-n*m*s-d*i*o+e*m*o+n*i*f-e*a*f)*M,t[15]=(n*u*s-l*a*s+l*i*o-e*u*o-n*i*c+e*a*c)*M,this}scale(t){let e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,this}getMaxScaleOnAxis(){let t=this.elements;return Math.sqrt(Math.max(t[0]*t[0]+t[1]*t[1]+t[2]*t[2],t[4]*t[4]+t[5]*t[5]+t[6]*t[6],t[8]*t[8]+t[9]*t[9]+t[10]*t[10]))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){let e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){let e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){let i=Math.cos(e),s=Math.sin(e),r=1-i,n=t.x,a=t.y,o=t.z,h=r*n,l=r*a;return this.set(h*n+i,h*a-s*o,h*o+s*a,0,h*a+s*o,l*a+i,l*o-s*n,0,h*o-s*a,l*o+s*n,r*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){let s=this.elements,r=e._x,n=e._y,a=e._z,o=e._w,h=r+r,l=n+n,u=a+a,c=r*h,p=r*l,d=r*u,m=n*l,f=n*u,g=a*u,y=o*h,x=o*l,b=o*u,v=i.x,w=i.y,M=i.z;return s[0]=(1-(m+g))*v,s[1]=(p+b)*v,s[2]=(d-x)*v,s[3]=0,s[4]=(p-b)*w,s[5]=(1-(c+g))*w,s[6]=(f+y)*w,s[7]=0,s[8]=(d+x)*M,s[9]=(f-y)*M,s[10]=(1-(c+m))*M,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){let s=this.elements;if(t.x=s[12],t.y=s[13],t.z=s[14],0===this.determinant())return i.set(1,1,1),e.identity(),this;let r=tJ.set(s[0],s[1],s[2]).length(),n=tJ.set(s[4],s[5],s[6]).length(),a=tJ.set(s[8],s[9],s[10]).length();0>this.determinant()&&(r=-r),tX.copy(this);let o=1/r,h=1/n,l=1/a;return tX.elements[0]*=o,tX.elements[1]*=o,tX.elements[2]*=o,tX.elements[4]*=h,tX.elements[5]*=h,tX.elements[6]*=h,tX.elements[8]*=l,tX.elements[9]*=l,tX.elements[10]*=l,e.setFromRotationMatrix(tX),i.x=r,i.y=n,i.z=a,this}makePerspective(t,e,i,s,r,n,a=2e3,o=!1){let h,l,u=this.elements;if(o)h=r/(n-r),l=n*r/(n-r);else if(2e3===a)h=-(n+r)/(n-r),l=-2*n*r/(n-r);else if(2001===a)h=-n/(n-r),l=-n*r/(n-r);else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return u[0]=2*r/(e-t),u[4]=0,u[8]=(e+t)/(e-t),u[12]=0,u[1]=0,u[5]=2*r/(i-s),u[9]=(i+s)/(i-s),u[13]=0,u[2]=0,u[6]=0,u[10]=h,u[14]=l,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(t,e,i,s,r,n,a=2e3,o=!1){let h,l,u=this.elements;if(o)h=1/(n-r),l=n/(n-r);else if(2e3===a)h=-2/(n-r),l=-(n+r)/(n-r);else if(2001===a)h=-1/(n-r),l=-r/(n-r);else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return u[0]=2/(e-t),u[4]=0,u[8]=0,u[12]=-(e+t)/(e-t),u[1]=0,u[5]=2/(i-s),u[9]=0,u[13]=-(i+s)/(i-s),u[2]=0,u[6]=0,u[10]=h,u[14]=l,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(t){let e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){let i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}let tJ=new Z,tX=new tH,tZ=new Z(0,0,0),tY=new Z(1,1,1),tQ=new Z,tK=new Z,t0=new Z,t1=new tH,t2=new X;class t3{constructor(t=0,e=0,i=0,s=t3.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){let s=t.elements,r=s[0],n=s[4],a=s[8],o=s[1],h=s[5],l=s[9],u=s[2],c=s[6],p=s[10];switch(e){case"XYZ":this._y=Math.asin(j(a,-1,1)),.9999999>Math.abs(a)?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(c,h),this._z=0);break;case"YXZ":this._x=Math.asin(-j(l,-1,1)),.9999999>Math.abs(l)?(this._y=Math.atan2(a,p),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(j(c,-1,1)),.9999999>Math.abs(c)?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-j(u,-1,1)),.9999999>Math.abs(u)?(this._x=Math.atan2(c,p),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(j(o,-1,1)),.9999999>Math.abs(o)?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-j(n,-1,1)),.9999999>Math.abs(n)?(this._x=Math.atan2(c,h),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-l,p),this._y=0);break;default:R("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return t1.makeRotationFromQuaternion(t),this.setFromRotationMatrix(t1,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return t2.setFromEuler(this),this.setFromQuaternion(t2,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}t3.DEFAULT_ORDER="XYZ";class t5{constructor(){this.mask=1}set(t){this.mask=1<>>0}enable(t){this.mask|=1<1){for(let t=0;t1){for(let t=0;t0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(s.matrixAutoUpdate=!1),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(t=>({...t,boundingBox:t.boundingBox?t.boundingBox.toJSON():void 0,boundingSphere:t.boundingSphere?t.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(t=>({...t})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),null!==this._colorsTexture&&(s.colorsTexture=this._colorsTexture.toJSON(t)),null!==this.boundingSphere&&(s.boundingSphere=this.boundingSphere.toJSON()),null!==this.boundingBox&&(s.boundingBox=this.boundingBox.toJSON())),this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(t.geometries,this.geometry);let e=this.geometry.parameters;if(void 0!==e&&void 0!==e.shapes){let i=e.shapes;if(Array.isArray(i))for(let e=0,s=i.length;e0){s.children=[];for(let e=0;e0){s.animations=[];for(let e=0;e0&&(i.geometries=e),s.length>0&&(i.materials=s),r.length>0&&(i.textures=r),a.length>0&&(i.images=a),o.length>0&&(i.shapes=o),h.length>0&&(i.skeletons=h),l.length>0&&(i.animations=l),u.length>0&&(i.nodes=u)}return i.object=s,i;function n(t){let e=[];for(let i in t){let s=t[i];delete s.metadata,e.push(s)}return e}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),!0===e)for(let e=0;e0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,i,s,r){ec.subVectors(s,e),ep.subVectors(i,e),ed.subVectors(t,e);let n=ec.dot(ec),a=ec.dot(ep),o=ec.dot(ed),h=ep.dot(ep),l=ep.dot(ed),u=n*h-a*a;if(0===u)return r.set(0,0,0),null;let c=1/u,p=(h*o-a*l)*c,d=(n*l-a*o)*c;return r.set(1-p-d,d,p)}static containsPoint(t,e,i,s){return null!==this.getBarycoord(t,e,i,s,em)&&em.x>=0&&em.y>=0&&em.x+em.y<=1}static getInterpolation(t,e,i,s,r,n,a,o){return null===this.getBarycoord(t,e,i,s,em)?(o.x=0,o.y=0,"z"in o&&(o.z=0),"w"in o&&(o.w=0),null):(o.setScalar(0),o.addScaledVector(r,em.x),o.addScaledVector(n,em.y),o.addScaledVector(a,em.z),o)}static getInterpolatedAttribute(t,e,i,s,r,n){return ew.setScalar(0),eM.setScalar(0),eS.setScalar(0),ew.fromBufferAttribute(t,e),eM.fromBufferAttribute(t,i),eS.fromBufferAttribute(t,s),n.setScalar(0),n.addScaledVector(ew,r.x),n.addScaledVector(eM,r.y),n.addScaledVector(eS,r.z),n}static isFrontFacing(t,e,i,s){return ec.subVectors(i,e),ep.subVectors(t,e),0>ec.cross(ep).dot(s)}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,s){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,i,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,s),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return ec.subVectors(this.c,this.b),ep.subVectors(this.a,this.b),.5*ec.cross(ep).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return eA.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return eA.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,s,r){return eA.getInterpolation(t,this.a,this.b,this.c,e,i,s,r)}containsPoint(t){return eA.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return eA.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){let i,s,r=this.a,n=this.b,a=this.c;ef.subVectors(n,r),eg.subVectors(a,r),ex.subVectors(t,r);let o=ef.dot(ex),h=eg.dot(ex);if(o<=0&&h<=0)return e.copy(r);eb.subVectors(t,n);let l=ef.dot(eb),u=eg.dot(eb);if(l>=0&&u<=l)return e.copy(n);let c=o*u-l*h;if(c<=0&&o>=0&&l<=0)return i=o/(o-l),e.copy(r).addScaledVector(ef,i);ev.subVectors(t,a);let p=ef.dot(ev),d=eg.dot(ev);if(d>=0&&p<=d)return e.copy(a);let m=p*h-o*d;if(m<=0&&h>=0&&d<=0)return s=h/(h-d),e.copy(r).addScaledVector(eg,s);let f=l*d-p*u;if(f<=0&&u-l>=0&&p-d>=0)return ey.subVectors(a,n),s=(u-l)/(u-l+(p-d)),e.copy(n).addScaledVector(ey,s);let g=1/(f+m+c);return i=m*g,s=c*g,e.copy(r).addScaledVector(ef,i).addScaledVector(eg,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let e_={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32},eC={h:0,s:0,l:0},eT={h:0,s:0,l:0};function eI(t,e,i){return(i<0&&(i+=1),i>1&&(i-=1),i<1/6)?t+(e-t)*6*i:i<.5?e:i<2/3?t+(e-t)*6*(2/3-i):t}class ez{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){return void 0===e&&void 0===i?t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t):this.setRGB(t,e,i),this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=m){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(255&t)/255,ts.colorSpaceToWorking(this,e),this}setRGB(t,e,i,s=ts.workingColorSpace){return this.r=t,this.g=e,this.b=i,ts.colorSpaceToWorking(this,s),this}setHSL(t,e,i,s=ts.workingColorSpace){if(t=U(t,1),e=j(e,0,1),i=j(i,0,1),0===e)this.r=this.g=this.b=i;else{let s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=eI(r,s,t+1/3),this.g=eI(r,s,t),this.b=eI(r,s,t-1/3)}return ts.colorSpaceToWorking(this,s),this}setStyle(t,e=m){let i;function s(e){void 0!==e&&1>parseFloat(e)&&R("Color: Alpha component of "+t+" will be ignored.")}if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r,n=i[1],a=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:R("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){let s=i[1],r=s.length;if(3===r)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(6===r)return this.setHex(parseInt(s,16),e);R("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=m){let i=e_[t.toLowerCase()];return void 0!==i?this.setHex(i,e):R("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=tr(t.r),this.g=tr(t.g),this.b=tr(t.b),this}copyLinearToSRGB(t){return this.r=tn(t.r),this.g=tn(t.g),this.b=tn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=m){return ts.workingToColorSpace(ek.copy(this),t),65536*Math.round(j(255*ek.r,0,255))+256*Math.round(j(255*ek.g,0,255))+Math.round(j(255*ek.b,0,255))}getHexString(t=m){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ts.workingColorSpace){let i,s;ts.workingToColorSpace(ek.copy(this),e);let r=ek.r,n=ek.g,a=ek.b,o=Math.max(r,n,a),h=Math.min(r,n,a),l=(h+o)/2;if(h===o)i=0,s=0;else{let t=o-h;switch(s=l<=.5?t/(o+h):t/(2-o-h),o){case r:i=(n-a)/t+6*(n0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(void 0!==t)for(let e in t){let i=t[e];if(void 0===i){R(`Material: parameter '${e}' has value of undefined.`);continue}let s=this[e];if(void 0===s){R(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[e]=i}}toJSON(t){let e=void 0===t||"string"==typeof t;e&&(t={textures:{},images:{}});let i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};function s(t){let e=[];for(let i in t){let s=t[i];delete s.metadata,e.push(s)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),void 0!==this.sheen&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),void 0!==this.dispersion&&(i.dispersion=this.dispersion),void 0!==this.iridescence&&(i.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(i.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),void 0!==this.anisotropy&&(i.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapRotation&&(i.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(i.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),!0===this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),!0===this.transparent&&(i.transparent=!0),204!==this.blendSrc&&(i.blendSrc=this.blendSrc),205!==this.blendDst&&(i.blendDst=this.blendDst),100!==this.blendEquation&&(i.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(i.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(i.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(i.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(i.depthFunc=this.depthFunc),!1===this.depthTest&&(i.depthTest=this.depthTest),!1===this.depthWrite&&(i.depthWrite=this.depthWrite),!1===this.colorWrite&&(i.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(i.stencilWriteMask=this.stencilWriteMask),519!==this.stencilFunc&&(i.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(i.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(i.stencilFuncMask=this.stencilFuncMask),7680!==this.stencilFail&&(i.stencilFail=this.stencilFail),7680!==this.stencilZFail&&(i.stencilZFail=this.stencilZFail),7680!==this.stencilZPass&&(i.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(i.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaHash&&(i.alphaHash=!0),!0===this.alphaToCoverage&&(i.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=!0),!0===this.forceSinglePass&&(i.forceSinglePass=!0),!1===this.allowOverride&&(i.allowOverride=!1),!0===this.wireframe&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=!0),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),!1===this.fog&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData),e){let e=s(t.textures),r=s(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;let e=t.clippingPlanes,i=null;if(null!==e){let t=e.length;i=Array(t);for(let s=0;s!==t;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){!0===t&&this.version++}}class eO extends eR{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ez(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}let eE=function(){let t=new ArrayBuffer(4),e=new Float32Array(t),i=new Uint32Array(t),s=new Uint32Array(512),r=new Uint32Array(512);for(let t=0;t<256;++t){let e=t-127;e<-27?(s[t]=0,s[256|t]=32768,r[t]=24,r[256|t]=24):e<-14?(s[t]=1024>>-e-14,s[256|t]=1024>>-e-14|32768,r[t]=-e-1,r[256|t]=-e-1):e<=15?(s[t]=e+15<<10,s[256|t]=e+15<<10|32768,r[t]=13,r[256|t]=13):e<128?(s[t]=31744,s[256|t]=64512,r[t]=24,r[256|t]=24):(s[t]=31744,s[256|t]=64512,r[t]=13,r[256|t]=13)}let n=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let t=1;t<1024;++t){let e=t<<13,i=0;for(;(8388608&e)==0;)e<<=1,i-=8388608;e&=-8388609,i+=0x38800000,n[t]=e|i}for(let t=1024;t<2048;++t)n[t]=0x38000000+(t-1024<<13);for(let t=1;t<31;++t)a[t]=t<<23;a[31]=0x47800000,a[32]=0x80000000;for(let t=33;t<63;++t)a[t]=0x80000000+(t-32<<23);a[63]=0xc7800000;for(let t=1;t<64;++t)32!==t&&(o[t]=1024);return{floatView:e,uint32View:i,baseTable:s,shiftTable:r,mantissaTable:n,exponentTable:a,offsetTable:o}}();function eP(t){Math.abs(t)>65504&&R("DataUtils.toHalfFloat(): Value out of range."),t=j(t,-65504,65504),eE.floatView[0]=t;let e=eE.uint32View[0],i=e>>23&511;return eE.baseTable[i]+((8388607&e)>>eE.shiftTable[i])}function eL(t){let e=t>>10;return eE.uint32View[0]=eE.mantissaTable[eE.offsetTable[e]+(1023&t)]+eE.exponentTable[e],eE.floatView[0]}class eN{static toHalfFloat(t){return eP(t)}static fromHalfFloat(t){return eL(t)}}let eF=new Z,e$=new J,eV=0;class eD{constructor(t,e,i=!1){if(Array.isArray(t))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:eV++}),this.name="",this.array=t,this.itemSize=e,this.count=void 0!==t?t.length/e:0,this.normalized=i,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let s=0,r=this.itemSize;se.count&&R("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tv);let t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){O("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new Z(-1/0,-1/0,-1/0),new Z(Infinity,Infinity,Infinity));return}if(void 0!==t){if(this.boundingBox.setFromBufferAttribute(t),e)for(let t=0,i=e.length;t0&&(t.userData=this.userData),void 0!==this.parameters){let e=this.parameters;for(let i in e)void 0!==e[i]&&(t[i]=e[i]);return t}t.data={attributes:{}};let e=this.index;null!==e&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});let i=this.attributes;for(let e in i){let s=i[e];t.data.attributes[e]=s.toJSON(t.data)}let s={},r=!1;for(let e in this.morphAttributes){let i=this.morphAttributes[e],n=[];for(let e=0,s=i.length;e0&&(s[e]=n,r=!0)}r&&(t.data.morphAttributes=s,t.data.morphTargetsRelative=this.morphTargetsRelative);let n=this.groups;n.length>0&&(t.data.groups=JSON.parse(JSON.stringify(n)));let a=this.boundingSphere;return null!==a&&(t.data.boundingSphere=a.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let e={};this.name=t.name;let i=t.index;null!==i&&this.setIndex(i.clone());let s=t.attributes;for(let t in s){let i=s[t];this.setAttribute(t,i.clone(e))}let r=t.morphAttributes;for(let t in r){let i=[],s=r[t];for(let t=0,r=s.length;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;t(t.far-t.near)**2)||(e4.copy(r).invert(),e6.copy(t.ray).applyMatrix4(e4),(null===i.boundingBox||!1!==e6.intersectsBox(i.boundingBox))&&this._computeIntersections(t,e,e6)))}_computeIntersections(t,e,i){let s,r=this.geometry,n=this.material,a=r.index,o=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,c=r.groups,p=r.drawRange;if(null!==a)if(Array.isArray(n))for(let r=0,o=c.length;ri.far?null:{distance:h,point:ia.clone(),object:t}}(t,e,i,s,e7,it,ie,ir);if(u){let t=new Z;eA.getBarycoord(ir,e7,it,ie,t),r&&(u.uv=eA.getInterpolatedAttribute(r,o,h,l,t,new J)),n&&(u.uv1=eA.getInterpolatedAttribute(n,o,h,l,t,new J)),a&&(u.normal=eA.getInterpolatedAttribute(a,o,h,l,t,new Z),u.normal.dot(s.direction)>0&&u.normal.multiplyScalar(-1));let e={a:o,b:h,c:l,normal:new Z,materialIndex:0};eA.getNormal(e7,it,ie,e.normal),u.face=e,u.barycoord=t}return u}class il extends e5{constructor(t=1,e=1,i=1,s=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:s,heightSegments:r,depthSegments:n};const a=this;s=Math.floor(s),r=Math.floor(r);const o=[],h=[],l=[],u=[];let c=0,p=0;function d(t,e,i,s,r,n,d,m,f,g,y){let x=n/f,b=d/g,v=n/2,w=d/2,M=m/2,S=f+1,A=g+1,_=0,C=0,T=new Z;for(let n=0;n0?1:-1,l.push(T.x,T.y,T.z),u.push(o/f),u.push(1-n/g),_+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;let i={};for(let t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}class ig extends eu{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new tH,this.projectionMatrix=new tH,this.projectionMatrixInverse=new tH,this.coordinateSystem=2e3,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}let iy=new Z,ix=new J,ib=new J;class iv extends ig{constructor(t=50,e=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=null===t.view?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){let e=.5*this.getFilmHeight()/t;this.fov=2*V*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){let t=Math.tan(.5*$*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*V*Math.atan(Math.tan(.5*$*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){iy.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(iy.x,iy.y).multiplyScalar(-t/iy.z),iy.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(iy.x,iy.y).multiplyScalar(-t/iy.z)}getViewSize(t,e){return this.getViewBounds(t,ix,ib),e.subVectors(ib,ix)}setViewOffset(t,e,i,s,r,n){this.aspect=t/e,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let t=this.near,e=t*Math.tan(.5*$*this.fov)/this.zoom,i=2*e,s=this.aspect*i,r=-.5*s,n=this.view;if(null!==this.view&&this.view.enabled){let t=n.fullWidth,a=n.fullHeight;r+=n.offsetX*s/t,e-=n.offsetY*i/a,s*=n.width/t,i*=n.height/a}let a=this.filmOffset;0!==a&&(r+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,e,e-i,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){let e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,null!==this.view&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class iw extends eu{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new iv(-90,1,t,e);s.layers=this.layers,this.add(s);const r=new iv(-90,1,t,e);r.layers=this.layers,this.add(r);const n=new iv(-90,1,t,e);n.layers=this.layers,this.add(n);const a=new iv(-90,1,t,e);a.layers=this.layers,this.add(a);const o=new iv(-90,1,t,e);o.layers=this.layers,this.add(o);const h=new iv(-90,1,t,e);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){let t=this.coordinateSystem,e=this.children.concat(),[i,s,r,n,a,o]=e;for(let t of e)this.remove(t);if(2e3===t)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else if(2001===t)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(let t of e)this.add(t),t.updateMatrixWorld()}update(t,e){null===this.parent&&this.updateMatrixWorld();let{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());let[r,n,a,o,h,l]=this.children,u=t.getRenderTarget(),c=t.getActiveCubeFace(),p=t.getActiveMipmapLevel(),d=t.xr.enabled;t.xr.enabled=!1;let m=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0,s),t.render(e,r),t.setRenderTarget(i,1,s),t.render(e,n),t.setRenderTarget(i,2,s),t.render(e,a),t.setRenderTarget(i,3,s),t.render(e,o),t.setRenderTarget(i,4,s),t.render(e,h),i.texture.generateMipmaps=m,t.setRenderTarget(i,5,s),t.render(e,l),t.setRenderTarget(u,c,p),t.xr.enabled=d,i.texture.needsPMREMUpdate=!0}}class iM extends tp{constructor(t=[],e=301,i,s,r,n,a,o,h,l){super(t,e,i,s,r,n,a,o,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class iS extends tf{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const i={width:t,height:t,depth:1};this.texture=new iM([i,i,i,i,i,i]),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;let i={uniforms:{tEquirect:{value:null}},vertexShader:` - - varying vec3 vWorldDirection; - - vec3 transformDirection( in vec3 dir, in mat4 matrix ) { - - return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); - - } - - void main() { - - vWorldDirection = transformDirection( position, modelMatrix ); - - #include - #include - - } - `,fragmentShader:` - - uniform sampler2D tEquirect; - - varying vec3 vWorldDirection; - - #include - - void main() { - - vec3 direction = normalize( vWorldDirection ); - - vec2 sampleUV = equirectUv( direction ); - - gl_FragColor = texture2D( tEquirect, sampleUV ); - - } - `},s=new il(5,5,5),r=new im({name:"CubemapFromEquirect",uniforms:iu(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;let n=new io(s,r),a=e.minFilter;return 1008===e.minFilter&&(e.minFilter=1006),new iw(1,10,this).update(t,n),e.minFilter=a,n.geometry.dispose(),n.material.dispose(),this}clear(t,e=!0,i=!0,s=!0){let r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,s);t.setRenderTarget(r)}}class iA extends eu{constructor(){super(),this.isGroup=!0,this.type="Group"}}let i_={type:"move"};class iC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new iA,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return null===this._targetRay&&(this._targetRay=new iA,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Z,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Z),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new iA,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Z,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Z),this._grip}dispatchEvent(t){return null!==this._targetRay&&this._targetRay.dispatchEvent(t),null!==this._grip&&this._grip.dispatchEvent(t),null!==this._hand&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let i of t.hand.values())this._getHandJoint(e,i)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(t,e,i){let s=null,r=null,n=null,a=this._targetRay,o=this._grip,h=this._hand;if(t&&"visible-blurred"!==e.session.visibilityState){if(h&&t.hand){for(let s of(n=!0,t.hand.values())){let t=e.getJointPose(s,i),r=this._getHandJoint(h,s);null!==t&&(r.matrix.fromArray(t.transform.matrix),r.matrix.decompose(r.position,r.rotation,r.scale),r.matrixWorldNeedsUpdate=!0,r.jointRadius=t.radius),r.visible=null!==t}let s=h.joints["index-finger-tip"],r=h.joints["thumb-tip"],a=s.position.distanceTo(r.position);h.inputState.pinching&&a>.025?(h.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!h.inputState.pinching&&a<=.015&&(h.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==o&&t.gripSpace&&null!==(r=e.getPose(t.gripSpace,i))&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1);null!==a&&(null===(s=e.getPose(t.targetRaySpace,i))&&null!==r&&(s=r),null!==s&&(a.matrix.fromArray(s.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,s.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(s.linearVelocity)):a.hasLinearVelocity=!1,s.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(s.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(i_)))}return null!==a&&(a.visible=null!==s),null!==o&&(o.visible=null!==r),null!==h&&(h.visible=null!==n),this}_getHandJoint(t,e){if(void 0===t.joints[e.jointName]){let i=new iA;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}class iT{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ez(t),this.density=e}clone(){return new iT(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class iI{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new ez(t),this.near=e,this.far=i}clone(){return new iI(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class iz extends eu{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new t3,this.environmentIntensity=1,this.environmentRotation=new t3,this.overrideMaterial=null,"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),null!==t.background&&(this.background=t.background.clone()),null!==t.environment&&(this.environment=t.environment.clone()),null!==t.fog&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),null!==t.overrideMaterial&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){let e=super.toJSON(t);return null!==this.fog&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class ik{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=35044,this.updateRanges=[],this.version=0,this.uuid=D()}onUploadCallback(){}set needsUpdate(t){!0===t&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,i){t*=this.stride,i*=e.stride;for(let s=0,r=this.stride;st.far||e.push({distance:o,point:iE.clone(),uv:eA.getInterpolation(iE,iV,iD,ij,iU,iW,iG,new J),face:null,object:this})}copy(t,e){return super.copy(t,e),void 0!==t.center&&this.center.copy(t.center),this.material=t.material,this}}function iH(t,e,i,s,r,n){iN.subVectors(t,i).addScalar(.5).multiply(s),void 0!==r?(iF.x=n*iN.x-r*iN.y,iF.y=r*iN.x+n*iN.y):iF.copy(iN),t.copy(e),t.x+=iF.x,t.y+=iF.y,t.applyMatrix4(i$)}let iJ=new Z,iX=new Z;class iZ extends eu{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);let e=t.levels;for(let t=0,i=e.length;t0){let i,s;for(i=1,s=e.length;i0){iJ.setFromMatrixPosition(this.matrixWorld);let i=t.ray.origin.distanceTo(iJ);this.getObjectForDistance(i).raycast(t,e)}}update(t){let e=this.levels;if(e.length>1){let i,s;iJ.setFromMatrixPosition(t.matrixWorld),iX.setFromMatrixPosition(this.matrixWorld);let r=iJ.distanceTo(iX)/t.zoom;for(i=1,e[0].object.visible=!0,s=e.length;i=t)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i1?null:e.copy(t.start).addScaledVector(i,r)}intersectsLine(t){let e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){let i=e||sd.getNormalMatrix(t),s=this.coplanarPoint(sc).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}let sf=new tF,sg=new J(.5,.5),sy=new Z;class sx{constructor(t=new sm,e=new sm,i=new sm,s=new sm,r=new sm,n=new sm){this.planes=[t,e,i,s,r,n]}set(t,e,i,s,r,n){let a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(s),a[4].copy(r),a[5].copy(n),this}copy(t){let e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=2e3,i=!1){let s=this.planes,r=t.elements,n=r[0],a=r[1],o=r[2],h=r[3],l=r[4],u=r[5],c=r[6],p=r[7],d=r[8],m=r[9],f=r[10],g=r[11],y=r[12],x=r[13],b=r[14],v=r[15];if(s[0].setComponents(h-n,p-l,g-d,v-y).normalize(),s[1].setComponents(h+n,p+l,g+d,v+y).normalize(),s[2].setComponents(h+a,p+u,g+m,v+x).normalize(),s[3].setComponents(h-a,p-u,g-m,v-x).normalize(),i)s[4].setComponents(o,c,f,b).normalize(),s[5].setComponents(h-o,p-c,g-f,v-b).normalize();else if(s[4].setComponents(h-o,p-c,g-f,v-b).normalize(),2e3===e)s[5].setComponents(h+o,p+c,g+f,v+b).normalize();else if(2001===e)s[5].setComponents(o,c,f,b).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(void 0!==t.boundingSphere)null===t.boundingSphere&&t.computeBoundingSphere(),sf.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{let e=t.geometry;null===e.boundingSphere&&e.computeBoundingSphere(),sf.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(sf)}intersectsSprite(t){return sf.center.set(0,0,0),sf.radius=.7071067811865476+sg.distanceTo(t.center),sf.applyMatrix4(t.matrixWorld),this.intersectsSphere(sf)}intersectsSphere(t){let e=this.planes,i=t.center,s=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,sy.y=s.normal.y>0?t.max.y:t.min.y,sy.z=s.normal.z>0?t.max.z:t.min.z,0>s.distanceToPoint(sy))return!1}return!0}containsPoint(t){let e=this.planes;for(let i=0;i<6;i++)if(0>e[i].distanceToPoint(t))return!1;return!0}clone(){return new this.constructor().copy(this)}}let sb=new tH,sv=new sx;class sw{constructor(){this.coordinateSystem=2e3}intersectsObject(t,e){if(!e.isArrayCamera||0===e.cameras.length)return!1;for(let i=0;i=r.length&&r.push({start:-1,count:-1,z:-1,index:-1});let a=r[this.index];n.push(a),this.index++,a.start=t,a.count=e,a.z=i,a.index=s}reset(){this.list.length=0,this.index=0}},sP=new io,sL=[];function sN(t,e){if(t.constructor!==e.constructor){let i=Math.min(t.length,e.length);for(let s=0;s65535?new Uint32Array(s):new Uint16Array(s);e.setIndex(new eD(t,1))}this._geometryInitialized=!0}}_validateGeometry(t){let e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(let i in e.attributes){if(!t.hasAttribute(i))throw Error(`THREE.BatchedMesh: Added geometry missing "${i}". All geometries must have consistent attributes.`);let s=t.getAttribute(i),r=e.getAttribute(i);if(s.itemSize!==r.itemSize||s.normalized!==r.normalized)throw Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(t){let e=this._instanceInfo;if(t<0||t>=e.length||!1===e[t].active)throw Error(`THREE.BatchedMesh: Invalid instanceId ${t}. Instance is either out of range or has been deleted.`)}validateGeometryId(t){let e=this._geometryInfo;if(t<0||t>=e.length||!1===e[t].active)throw Error(`THREE.BatchedMesh: Invalid geometryId ${t}. Geometry is either out of range or has been deleted.`)}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new tv);let t=this.boundingBox,e=this._instanceInfo;t.makeEmpty();for(let i=0,s=e.length;i=this.maxInstanceCount&&0===this._availableInstanceIds.length)throw Error("THREE.BatchedMesh: Maximum item count reached.");let e={visible:!0,active:!0,geometryIndex:t},i=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(sM),i=this._availableInstanceIds.shift(),this._instanceInfo[i]=e):(i=this._instanceInfo.length,this._instanceInfo.push(e));let s=this._matricesTexture;s_.identity().toArray(s.image.data,16*i),s.needsUpdate=!0;let r=this._colorsTexture;return r&&(sC.toArray(r.image.data,4*i),r.needsUpdate=!0),this._visibilityChanged=!0,i}addGeometry(t,e=-1,i=-1){let s;this._initializeGeometry(t),this._validateGeometry(t);let r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},n=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=-1===e?t.getAttribute("position").count:e;let a=t.getIndex();if(null!==a&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=-1===i?a.count:i),-1!==r.indexStart&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(sM),n[s=this._availableGeometryIds.shift()]=r):(s=this._geometryCount,this._geometryCount++,n.push(r)),this.setGeometryAt(s,t),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,s}setGeometryAt(t,e){if(t>=this._geometryCount)throw Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);let i=this.geometry,s=null!==i.getIndex(),r=i.getIndex(),n=e.getIndex(),a=this._geometryInfo[t];if(s&&n.count>a.reservedIndexCount||e.attributes.position.count>a.reservedVertexCount)throw Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");let o=a.vertexStart,h=a.reservedVertexCount;for(let t in a.vertexCount=e.getAttribute("position").count,i.attributes){let s=e.getAttribute(t),r=i.getAttribute(t);!function(t,e,i=0){let s=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){let r=t.count;for(let n=0;n=e.length||!1===e[t].active)return this;let i=this._instanceInfo;for(let e=0,s=i.length;ee).sort((t,e)=>i[t].vertexStart-i[e].vertexStart),r=this.geometry;for(let n=0,a=i.length;n=this._geometryCount)return null;let i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingBox){let t=new tv,e=i.index,r=i.attributes.position;for(let i=s.start,n=s.start+s.count;i=this._geometryCount)return null;let i=this.geometry,s=this._geometryInfo[t];if(null===s.boundingSphere){let e=new tF;this.getBoundingBoxAt(t,sz),sz.getCenter(e.center);let r=i.index,n=i.attributes.position,a=0;for(let t=s.start,i=s.start+s.count;tt.active);if(Math.max(...i.map(t=>t.vertexStart+t.reservedVertexCount))>t)throw Error(`BatchedMesh: Geometry vertex values are being used outside the range ${e}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...i.map(t=>t.indexStart+t.reservedIndexCount))>e)throw Error(`BatchedMesh: Geometry index values are being used outside the range ${e}. Cannot shrink further.`);let s=this.geometry;s.dispose(),this._maxVertexCount=t,this._maxIndexCount=e,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new e5,this._initializeGeometry(s));let r=this.geometry;for(let t in s.index&&sN(s.index.array,r.index.array),s.attributes)sN(s.attributes[t].array,r.attributes[t].array)}raycast(t,e){let i=this._instanceInfo,s=this._geometryInfo,r=this.matrixWorld,n=this.geometry;sP.material=this.material,sP.geometry.index=n.index,sP.geometry.attributes=n.attributes,null===sP.geometry.boundingBox&&(sP.geometry.boundingBox=new tv),null===sP.geometry.boundingSphere&&(sP.geometry.boundingSphere=new tF);for(let n=0,a=i.length;n({...t,boundingBox:null!==t.boundingBox?t.boundingBox.clone():null,boundingSphere:null!==t.boundingSphere?t.boundingSphere.clone():null})),this._instanceInfo=t._instanceInfo.map(t=>({...t})),this._availableInstanceIds=t._availableInstanceIds.slice(),this._availableGeometryIds=t._availableGeometryIds.slice(),this._nextIndexStart=t._nextIndexStart,this._nextVertexStart=t._nextVertexStart,this._geometryCount=t._geometryCount,this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._indirectTexture=t._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(t,e,i,s,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let n=s.getIndex(),a=null===n?1:n.array.BYTES_PER_ELEMENT,o=this._instanceInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,u=this._geometryInfo,c=this.perObjectFrustumCulled,p=this._indirectTexture,d=p.image.data,m=i.isArrayCamera?sI:sT;c&&!i.isArrayCamera&&(s_.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse).multiply(this.matrixWorld),sT.setFromProjectionMatrix(s_,i.coordinateSystem,i.reversedDepth));let f=0;if(this.sortObjects){s_.copy(this.matrixWorld).invert(),sB.setFromMatrixPosition(i.matrixWorld).applyMatrix4(s_),sR.set(0,0,-1).transformDirection(i.matrixWorld).transformDirection(s_);for(let t=0,e=o.length;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;ts)return;sG.applyMatrix4(t.matrixWorld);let h=e.ray.origin.distanceTo(sG);if(!(he.far))return{distance:h,point:sq.clone().applyMatrix4(t.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:t}}let sX=new Z,sZ=new Z;class sY extends sH{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let t=this.geometry;if(null===t.index){let e=t.attributes.position,i=[];for(let t=0,s=e.count;t0){let i=t[e[0]];if(void 0!==i){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,e=i.length;tr.far)return;n.push({distance:h,distanceToRay:Math.sqrt(o),point:i,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class s6 extends tp{constructor(t,e,i,s,r=1006,n=1006,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const l=this;"requestVideoFrameCallback"in t&&(this._requestVideoFrameCallbackId=t.requestVideoFrameCallback(function e(){l.needsUpdate=!0,l._requestVideoFrameCallbackId=t.requestVideoFrameCallback(e)}))}clone(){return new this.constructor(this.image).copy(this)}update(){let t=this.image;!1=="requestVideoFrameCallback"in t&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){0!==this._requestVideoFrameCallbackId&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class s8 extends s6{constructor(t,e,i,s,r,n,a,o){super({},t,e,i,s,r,n,a,o),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(t){this.image=t,this.needsUpdate=!0}}class s9 extends tp{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=1003,this.minFilter=1003,this.generateMipmaps=!1,this.needsUpdate=!0}}class s7 extends tp{constructor(t,e,i,s,r,n,a,o,h,l,u,c){super(null,n,a,o,h,l,s,r,u,c),this.isCompressedTexture=!0,this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class rt extends s7{constructor(t,e,i,s,r,n){super(t,e,i,r,n),this.isCompressedArrayTexture=!0,this.image.depth=s,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class re extends s7{constructor(t,e,i){super(void 0,t[0].width,t[0].height,e,i,301),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class ri extends tp{constructor(t,e,i,s,r,n,a,o,h){super(t,e,i,s,r,n,a,o,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class rs extends tp{constructor(t,e,i=1014,s,r,n,a=1003,o=1003,h,l=1026,u=1){if(1026!==l&&1027!==l)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");super({width:t,height:e,depth:u},s,r,n,a,o,l,i,h),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new th(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return null!==this.compareFunction&&(e.compareFunction=this.compareFunction),e}}class rr extends rs{constructor(t,e=1014,i=301,s,r,n=1003,a=1003,o,h=1026){const l={width:t,height:t,depth:1};super(t,t,e,i,s,r,n,a,o,h),this.image=[l,l,l,l,l,l],this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class rn extends tp{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class ra extends e5{constructor(t=1,e=1,i=4,s=8,r=1){super(),this.type="CapsuleGeometry",this.parameters={radius:t,height:e,capSegments:i,radialSegments:s,heightSegments:r},e=Math.max(0,e),i=Math.max(1,Math.floor(i)),s=Math.max(3,Math.floor(s));const n=[],a=[],o=[],h=[],l=e/2,u=Math.PI/2*t,c=e,p=2*u+c,d=2*i+(r=Math.max(1,Math.floor(r))),m=s+1,f=new Z,g=new Z;for(let y=0;y<=d;y++){let x=0,b=0,v=0,w=0;if(y<=i){const e=y/i,s=e*Math.PI/2;b=-l-t*Math.cos(s),v=t*Math.sin(s),w=-t*Math.cos(s),x=e*u}else if(y<=i+r){const s=(y-i)/r;b=-l+s*e,v=t,w=0,x=u+s*c}else{const e=(y-i-r)/i,s=e*Math.PI/2;b=l+t*Math.sin(s),v=t*Math.cos(s),w=t*Math.sin(s),x=u+c+e*u}const M=Math.max(0,Math.min(1,x/p));let S=0;0===y?S=.5/s:y===d&&(S=-.5/s);for(let t=0;t<=s;t++){const e=t/s,i=e*Math.PI*2,r=Math.sin(i),n=Math.cos(i);g.x=-v*n,g.y=b,g.z=v*r,a.push(g.x,g.y,g.z),f.set(-v*n,w,v*r),f.normalize(),o.push(f.x,f.y,f.z),h.push(e+S,M)}if(y>0){const t=(y-1)*m;for(let e=0;e0||0!==s)&&(l.push(n,a,h),x+=3),(e>0||s!==r-1)&&(l.push(a,o,h),x+=3)}h.addGroup(g,x,0),g+=x})(),!1===n&&(t>0&&y(!0),e>0&&y(!1)),this.setIndex(l),this.setAttribute("position",new eZ(u,3)),this.setAttribute("normal",new eZ(c,3)),this.setAttribute("uv",new eZ(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new rh(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class rl extends rh{constructor(t=1,e=1,i=32,s=1,r=!1,n=0,a=2*Math.PI){super(0,t,e,i,s,r,n,a),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:s,openEnded:r,thetaStart:n,thetaLength:a}}static fromJSON(t){return new rl(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ru extends e5{constructor(t=[],e=[],i=1,s=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:s};const r=[],n=[];function a(t){r.push(t.x,t.y,t.z)}function o(e,i){let s=3*e;i.x=t[s+0],i.y=t[s+1],i.z=t[s+2]}function h(t,e,i,s){s<0&&1===t.x&&(n[e]=t.x-1),0===i.x&&0===i.z&&(n[e]=s/2/Math.PI+.5)}function l(t){return Math.atan2(t.z,-t.x)}(function(t){let i=new Z,s=new Z,r=new Z;for(let n=0;n.9&&a<.1&&(e<.2&&(n[t+0]+=1),i<.2&&(n[t+2]+=1),s<.2&&(n[t+4]+=1))}}()}(),this.setAttribute("position",new eZ(r,3)),this.setAttribute("normal",new eZ(r.slice(),3)),this.setAttribute("uv",new eZ(n,2)),0===s?this.computeVertexNormals():this.normalizeNormals()}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ru(t.vertices,t.indices,t.radius,t.detail)}}class rc extends ru{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,s=1/i;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-s,-i,0,-s,i,0,s,-i,0,s,i,-s,-i,0,-s,i,0,s,-i,0,s,i,0,-i,0,-s,i,0,-s,-i,0,s,i,0,s],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],t,e),this.type="DodecahedronGeometry",this.parameters={radius:t,detail:e}}static fromJSON(t){return new rc(t.radius,t.detail)}}let rp=new Z,rd=new Z,rm=new Z,rf=new eA;class rg extends e5{constructor(t=null,e=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:t,thresholdAngle:e},null!==t){const i=Math.cos($*e),s=t.getIndex(),r=t.getAttribute("position"),n=s?s.count:r.count,a=[0,0,0],o=["a","b","c"],h=[,,,],l={},u=[];for(let t=0;t0)o=r-1;else{o=r;break}if(s[r=o]===i)return r/(n-1);let l=s[r],u=s[r+1];return(r+(i-l)/(u-l))/(n-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);let r=this.getPoint(i),n=this.getPoint(s),a=e||(r.isVector2?new J:new Z);return a.copy(n).sub(r).normalize(),a}getTangentAt(t,e){let i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e=!1){let i=new Z,s=[],r=[],n=[],a=new Z,o=new tH;for(let e=0;e<=t;e++){let i=e/t;s[e]=this.getTangentAt(i,new Z)}r[0]=new Z,n[0]=new Z;let h=Number.MAX_VALUE,l=Math.abs(s[0].x),u=Math.abs(s[0].y),c=Math.abs(s[0].z);l<=h&&(h=l,i.set(1,0,0)),u<=h&&(h=u,i.set(0,1,0)),c<=h&&i.set(0,0,1),a.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],a),n[0].crossVectors(s[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),n[e]=n[e-1].clone(),a.crossVectors(s[e-1],s[e]),a.length()>Number.EPSILON){a.normalize();let t=Math.acos(j(s[e-1].dot(s[e]),-1,1));r[e].applyMatrix4(o.makeRotationAxis(a,t))}n[e].crossVectors(s[e],r[e])}if(!0===e){let e=Math.acos(j(r[0].dot(r[t]),-1,1));e/=t,s[0].dot(a.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(o.makeRotationAxis(s[i],e*i)),n[i].crossVectors(s[i],r[i])}return{tangents:s,normals:r,binormals:n}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){let t={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class rx extends ry{constructor(t=0,e=0,i=1,s=1,r=0,n=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=a,this.aRotation=o}getPoint(t,e=new J){let i=2*Math.PI,s=this.aEndAngle-this.aStartAngle,r=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/n)+1)*n:0===h&&o===n-1&&(o=n-2,h=1),this.closed||o>0?i=r[(o-1)%n]:(rw.subVectors(r[0],r[1]).add(r[0]),i=rw);let l=r[o%n],u=r[(o+1)%n];if(this.closed||o+2i.length-2?i.length-1:r+1],l=i[r>i.length-3?i.length-1:r+2];return e.set(rC(n,a.x,o.x,h.x,l.x),rC(n,a.y,o.y,h.y,l.y)),e}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e=i){let t=s[r]-i,n=this.curves[r],a=n.getLength(),o=0===a?0:1-t/a;return n.getPointAt(o,e)}r++}return null}getLength(){let t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;let t=[],e=0;for(let i=0,s=this.curves.length;i1&&!i[i.length-1].equals(i[0])&&i.push(i[0]),i}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){let t=h.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(h);let l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){let t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class r$ extends rF{constructor(t){super(t),this.uuid=D(),this.type="Shape",this.holes=[]}getPointsHoles(t){let e=[];for(let i=0,s=this.holes.length;i0)for(let r=e;r=e;r-=s)n=rK(r/s|0,t[r],t[r+1],n);return n&&rH(n,n.next)&&(r0(n),n=n.next),n}function rD(t,e){if(!t)return t;e||(e=t);let i=t,s;do if(s=!1,!i.steiner&&(rH(i,i.next)||0===rq(i.prev,i,i.next))){if(r0(i),(i=e=i.prev)===i.next)break;s=!0}else i=i.next;while(s||i!==e)return e}function rj(t,e){let i=t.x-e.x;return 0===i&&0==(i=t.y-e.y)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function rU(t,e,i,s,r){return(t=((t=((t=((t=((t=(t-i)*r|0)|t<<8)&0xff00ff)|t<<4)&0xf0f0f0f)|t<<2)&0x33333333)|t<<1)&0x55555555)|(e=((e=((e=((e=((e=(e-s)*r|0)|e<<8)&0xff00ff)|e<<4)&0xf0f0f0f)|e<<2)&0x33333333)|e<<1)&0x55555555)<<1}function rW(t,e,i,s,r,n,a,o){return(r-a)*(e-o)>=(t-a)*(n-o)&&(t-a)*(s-o)>=(i-a)*(e-o)&&(i-a)*(n-o)>=(r-a)*(s-o)}function rG(t,e,i,s,r,n,a,o){return(t!==a||e!==o)&&rW(t,e,i,s,r,n,a,o)}function rq(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function rH(t,e){return t.x===e.x&&t.y===e.y}function rJ(t,e,i,s){let r=rZ(rq(t,e,i)),n=rZ(rq(t,e,s)),a=rZ(rq(i,s,t)),o=rZ(rq(i,s,e));return!!(r!==n&&a!==o||0===r&&rX(t,i,e)||0===n&&rX(t,s,e)||0===a&&rX(i,t,s)||0===o&&rX(i,e,s))}function rX(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function rZ(t){return t>0?1:t<0?-1:0}function rY(t,e){return 0>rq(t.prev,t,t.next)?rq(t,e,t.next)>=0&&rq(t,t.prev,e)>=0:0>rq(t,e,t.prev)||0>rq(t,t.next,e)}function rQ(t,e){let i=r1(t.i,t.x,t.y),s=r1(e.i,e.x,e.y),r=t.next,n=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,s.next=i,i.prev=s,n.next=s,s.prev=n,s}function rK(t,e,i,s){let r=r1(t,e,i);return s?(r.next=s.next,r.prev=s,s.next.prev=r,s.next=r):(r.prev=r,r.next=r),r}function r0(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function r1(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class r2{static triangulate(t,e,i=2){return function(t,e,i=2){let s,r,n,a=e&&e.length,o=a?e[0]*i:t.length,h=rV(t,0,o,i,!0),l=[];if(!h||h.next===h.prev)return l;if(a&&(h=function(t,e,i,s){let r=[];for(let i=0,n=e.length;i=s.next.y&&s.next.y!==s.y){let t=s.x+(n-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(t<=r&&t>a&&(a=t,i=s.x=s.x&&s.x>=h&&r!==s.x&&rW(ni.x||s.x===i.x&&(c=i,p=s,0>rq(c.prev,c,p.prev)&&0>rq(p.next,c,c.next))))&&(i=s,u=e)}s=s.next}while(s!==o)return i}(t,e);if(!i)return e;let s=rQ(i,t);return rD(s,s.next),rD(i,i.next)}(r[t],i);return i}(t,e,h,i)),t.length>80*i){s=t[0],r=t[1];let e=s,a=r;for(let n=i;ne&&(e=i),o>a&&(a=o)}n=0!==(n=Math.max(e-s,a-r))?32767/n:0}return function t(e,i,s,r,n,a,o){if(!e)return;!o&&a&&function(t,e,i,s){let r=t;do 0===r.z&&(r.z=rU(r.x,r.y,e,i,s)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==t)r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i=1;do{let s,r=t;t=null;let n=null;for(e=0;r;){e++;let a=r,o=0;for(let t=0;t0||h>0&&a;)0!==o&&(0===h||!a||r.z<=a.z)?(s=r,r=r.nextZ,o--):(s=a,a=a.nextZ,h--),n?n.nextZ=s:t=s,s.prevZ=n,n=s;r=a}n.nextZ=null,i*=2}while(e>1)}(r)}(e,r,n,a);let h=e;for(;e.prev!==e.next;){let l=e.prev,u=e.next;if(a?function(t,e,i,s){let r=t.prev,n=t.next;if(rq(r,t,n)>=0)return!1;let a=r.x,o=t.x,h=n.x,l=r.y,u=t.y,c=n.y,p=Math.min(a,o,h),d=Math.min(l,u,c),m=Math.max(a,o,h),f=Math.max(l,u,c),g=rU(p,d,e,i,s),y=rU(m,f,e,i,s),x=t.prevZ,b=t.nextZ;for(;x&&x.z>=g&&b&&b.z<=y;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=f&&x!==r&&x!==n&&rG(a,l,o,u,h,c,x.x,x.y)&&rq(x.prev,x,x.next)>=0||(x=x.prevZ,b.x>=p&&b.x<=m&&b.y>=d&&b.y<=f&&b!==r&&b!==n&&rG(a,l,o,u,h,c,b.x,b.y)&&rq(b.prev,b,b.next)>=0))return!1;b=b.nextZ}for(;x&&x.z>=g;){if(x.x>=p&&x.x<=m&&x.y>=d&&x.y<=f&&x!==r&&x!==n&&rG(a,l,o,u,h,c,x.x,x.y)&&rq(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;b&&b.z<=y;){if(b.x>=p&&b.x<=m&&b.y>=d&&b.y<=f&&b!==r&&b!==n&&rG(a,l,o,u,h,c,b.x,b.y)&&rq(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}(e,r,n,a):function(t){let e=t.prev,i=t.next;if(rq(e,t,i)>=0)return!1;let s=e.x,r=t.x,n=i.x,a=e.y,o=t.y,h=i.y,l=Math.min(s,r,n),u=Math.min(a,o,h),c=Math.max(s,r,n),p=Math.max(a,o,h),d=i.next;for(;d!==e;){if(d.x>=l&&d.x<=c&&d.y>=u&&d.y<=p&&rG(s,a,r,o,n,h,d.x,d.y)&&rq(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}(e)){i.push(l.i,e.i,u.i),r0(e),e=u.next,h=u.next;continue}if((e=u)===h){o?1===o?t(e=function(t,e){let i=t;do{let s=i.prev,r=i.next.next;!rH(s,r)&&rJ(s,i,i.next,r)&&rY(s,r)&&rY(r,s)&&(e.push(s.i,i.i,r.i),r0(i),r0(i.next),i=t=r),i=i.next}while(i!==t)return rD(i)}(rD(e),i),i,s,r,n,a,2):2===o&&function(e,i,s,r,n,a){let o=e;do{let e=o.next.next;for(;e!==o.prev;){var h,l;if(o.i!==e.i&&(h=o,l=e,h.next.i!==l.i&&h.prev.i!==l.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&rJ(i,i.next,t,e))return!0;i=i.next}while(i!==t)return!1}(h,l)&&(rY(h,l)&&rY(l,h)&&function(t,e){let i=t,s=!1,r=(t.x+e.x)/2,n=(t.y+e.y)/2;do i.y>n!=i.next.y>n&&i.next.y!==i.y&&r<(i.next.x-i.x)*(n-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next;while(i!==t)return s}(h,l)&&(rq(h.prev,h,l.prev)||rq(h,l.prev,l))||rH(h,l)&&rq(h.prev,h,h.next)>0&&rq(l.prev,l,l.next)>0))){let h=rQ(o,e);o=rD(o,o.next),h=rD(h,h.next),t(o,i,s,r,n,a,0),t(h,i,s,r,n,a,0);return}e=e.next}o=o.next}while(o!==e)}(e,i,s,r,n,a):t(rD(e),i,s,r,n,a,1);break}}}(h,l,i,s,r,n,0),l}(t,e,i)}}class r3{static area(t){let e=t.length,i=0;for(let s=e-1,r=0;rr3.area(t)}static triangulateShape(t,e){let i=[],s=[],r=[];r5(t),r4(i,t);let n=t.length;e.forEach(r5);for(let t=0;t2&&t[e-1].equals(t[0])&&t.pop()}function r4(t,e){for(let i=0;iNumber.EPSILON){let c=Math.sqrt(u),p=Math.sqrt(h*h+l*l),d=e.x-o/c,m=e.y+a/c,f=((i.x-l/p-d)*l-(i.y+h/p-m)*h)/(a*l-o*h),g=(s=d+a*f-t.x)*s+(r=m+o*f-t.y)*r;if(g<=2)return new J(s,r);n=Math.sqrt(g/2)}else{let t=!1;a>Number.EPSILON?h>Number.EPSILON&&(t=!0):a<-Number.EPSILON?h<-Number.EPSILON&&(t=!0):Math.sign(o)===Math.sign(l)&&(t=!0),t?(s=-o,r=a,n=Math.sqrt(u)):(s=a,r=o,n=Math.sqrt(u/2))}return new J(s/n,r/n)}let R=[];for(let t=0,e=I.length,i=e-1,s=t+1;t=0;t--){let e=t/x,i=f*Math.cos(e*Math.PI/2),s=g*Math.sin(e*Math.PI/2)+y;for(let t=0,e=I.length;t=0;){let n=r,a=r-1;a<0&&(a=t.length-1);for(let t=0,r=p+2*x;t0)&&p.push(e,r,h),(t!==i-1||o0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class ng extends eR{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ez(0xffffff),this.specular=new ez(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class ny extends eR{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ez(0xffffff),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class nx extends eR{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class nb extends eR{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ez(0xffffff),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ez(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new t3,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nv extends eR{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class nw extends eR{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}class nM extends eR{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ez(0xffffff),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new J(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this.fog=t.fog,this}}class nS extends s${constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function nA(t,e){return t&&t.constructor!==e?"number"==typeof e.BYTES_PER_ELEMENT?new e(t):Array.prototype.slice.call(t):t}function n_(t){let e=t.length,i=Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort(function(e,i){return t[e]-t[i]}),i}function nC(t,e,i){let s=t.length,r=new t.constructor(s);for(let n=0,a=0;a!==s;++n){let s=i[n]*e;for(let i=0;i!==e;++i)r[a++]=t[s+i]}return r}function nT(t,e,i,s){let r=1,n=t[0];for(;void 0!==n&&void 0===n[s];)n=t[r++];if(void 0===n)return;let a=n[s];if(void 0!==a)if(Array.isArray(a))do void 0!==(a=n[s])&&(e.push(n.time),i.push(...a)),n=t[r++];while(void 0!==n)else if(void 0!==a.toArray)do void 0!==(a=n[s])&&(e.push(n.time),a.toArray(i,i.length)),n=t[r++];while(void 0!==n)else do void 0!==(a=n[s])&&(e.push(n.time),i.push(a)),n=t[r++];while(void 0!==n)}class nI{static convertArray(t,e){return nA(t,e)}static isTypedArray(t){return A(t)}static getKeyframeOrder(t){return n_(t)}static sortedArray(t,e,i){return nC(t,e,i)}static flattenJSON(t,e,i,s){nT(t,e,i,s)}static subclip(t,e,i,s,r=30){return function(t,e,i,s,r=30){let n=t.clone();n.name=e;let a=[];for(let t=0;t=s)){h.push(e.times[t]);for(let i=0;in.tracks[t].times[0]&&(o=n.tracks[t].times[0]);for(let t=0;t=r.times[p]){let t=p*l+h,e=t+l-h;s=r.values.slice(t,e)}else{let t=r.createInterpolant(),e=h,i=l-h;t.evaluate(n),s=t.resultBuffer.slice(e,i)}"quaternion"===a&&new X().fromArray(s).normalize().conjugate().toArray(s);let d=o.times.length;for(let t=0;t=r)){let a=e[1];t=(r=e[--i-1]))break e}n=i,i=0;break i}break t}for(;i>>1;te;)--n;if(++n,0!==r||n!==s){r>=n&&(r=(n=Math.max(n,1))-1);let t=this.getValueSize();this.times=i.slice(r,n),this.values=this.values.slice(r*t,n*t)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!=0&&(O("KeyframeTrack: Invalid value size in track.",this),t=!1);let i=this.times,s=this.values,r=i.length;0===r&&(O("KeyframeTrack: Track is empty.",this),t=!1);let n=null;for(let e=0;e!==r;e++){let s=i[e];if("number"==typeof s&&isNaN(s)){O("KeyframeTrack: Time is not a valid number.",this,e,s),t=!1;break}if(null!==n&&n>s){O("KeyframeTrack: Out of order keys.",this,e,s,n),t=!1;break}n=s}if(void 0!==s&&A(s))for(let e=0,i=s.length;e!==i;++e){let i=s[e];if(isNaN(i)){O("KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),s=2302===this.getInterpolation(),r=t.length-1,n=1;for(let a=1;a0){t[n]=t[r];for(let t=r*i,s=n*i,a=0;a!==i;++a)e[s+a]=e[t+a];++n}return n!==t.length?(this.times=t.slice(0,n),this.values=e.slice(0,n*i)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),i=new this.constructor(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}nO.prototype.ValueTypeName="",nO.prototype.TimeBufferType=Float32Array,nO.prototype.ValueBufferType=Float32Array,nO.prototype.DefaultInterpolation=2301;class nE extends nO{constructor(t,e,i){super(t,e,i)}}nE.prototype.ValueTypeName="bool",nE.prototype.ValueBufferType=Array,nE.prototype.DefaultInterpolation=2300,nE.prototype.InterpolantFactoryMethodLinear=void 0,nE.prototype.InterpolantFactoryMethodSmooth=void 0;class nP extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nP.prototype.ValueTypeName="color";class nL extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nL.prototype.ValueTypeName="number";class nN extends nz{constructor(t,e,i,s){super(t,e,i,s)}interpolate_(t,e,i,s){let r=this.resultBuffer,n=this.sampleValues,a=this.valueSize,o=(i-e)/(s-e),h=t*a;for(let t=h+a;h!==t;h+=4)X.slerpFlat(r,0,n,h-a,n,h,o);return r}}class nF extends nO{constructor(t,e,i,s){super(t,e,i,s)}InterpolantFactoryMethodLinear(t){return new nN(this.times,this.values,this.getValueSize(),t)}}nF.prototype.ValueTypeName="quaternion",nF.prototype.InterpolantFactoryMethodSmooth=void 0;class n$ extends nO{constructor(t,e,i){super(t,e,i)}}n$.prototype.ValueTypeName="string",n$.prototype.ValueBufferType=Array,n$.prototype.DefaultInterpolation=2300,n$.prototype.InterpolantFactoryMethodLinear=void 0,n$.prototype.InterpolantFactoryMethodSmooth=void 0;class nV extends nO{constructor(t,e,i,s){super(t,e,i,s)}}nV.prototype.ValueTypeName="vector";class nD{constructor(t="",e=-1,i=[],s=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=s,this.uuid=D(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){let e=[],i=t.tracks,s=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push((function(t){if(void 0===t.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");let e=function(t){switch(t.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return nL;case"vector":case"vector2":case"vector3":case"vector4":return nV;case"color":return nP;case"quaternion":return nF;case"bool":case"boolean":return nE;case"string":return n$}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+t)}(t.type);if(void 0===t.times){let e=[],i=[];nT(t.keys,e,i,"value"),t.times=e,t.values=i}return void 0!==e.parse?e.parse(t):new e(t.name,t.times,t.values,t.interpolation)})(i[t]).scale(s));let r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){let e=[],i=t.tracks,s={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let t=0,s=i.length;t!==s;++t)e.push(nO.toJSON(i[t]));return s}static CreateFromMorphTargetSequence(t,e,i,s){let r=e.length,n=[];for(let t=0;t1){let t=n[1],e=s[t];e||(s[t]=e=[]),e.push(i)}}let n=[];for(let t in s)n.push(this.CreateFromMorphTargetSequence(t,s[t],e,i));return n}static parseAnimation(t,e){if(R("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!t)return O("AnimationClip: No animation in JSONLoader data."),null;let i=function(t,e,i,s,r){if(0!==i.length){let n=[],a=[];nT(i,n,a,s),0!==n.length&&r.push(new t(e,n,a))}},s=[],r=t.name||"default",n=t.fps||30,a=t.blendMode,o=t.length||-1,h=t.hierarchy||[];for(let t=0;t{e&&e(r),this.manager.itemEnd(t)},0),r;if(void 0!==nq[t])return void nq[t].push({onLoad:e,onProgress:i,onError:s});nq[t]=[],nq[t].push({onLoad:e,onProgress:i,onError:s});let n=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:"function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),a=this.mimeType,o=this.responseType;fetch(n).then(e=>{if(200===e.status||0===e.status){if(0===e.status&&R("FileLoader: HTTP Status 0 received."),"u"{if(s)t.close();else{let s=new ProgressEvent("progress",{lengthComputable:a,loaded:o+=r.byteLength,total:n});for(let t=0,e=i.length;t{t.error(e)})}()}}))}throw new nH(`fetch for "${e.url}" responded with ${e.status}: ${e.statusText}`,e)}).then(t=>{switch(o){case"arraybuffer":return t.arrayBuffer();case"blob":return t.blob();case"document":return t.text().then(t=>new DOMParser().parseFromString(t,a));case"json":return t.json();default:if(""===a)return t.text();{let e=/charset="?([^;"\s]*)"?/i.exec(a),i=new TextDecoder(e&&e[1]?e[1].toLowerCase():void 0);return t.arrayBuffer().then(t=>i.decode(t))}}}).then(e=>{nj.add(`file:${t}`,e);let i=nq[t];delete nq[t];for(let t=0,s=i.length;t{let i=nq[t];if(void 0===i)throw this.manager.itemError(t),e;delete nq[t];for(let t=0,s=i.length;t{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class nX extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):O(e),r.manager.itemError(t)}},i,s)}parse(t){let e=[];for(let i=0;i0:s.vertexColors=t.vertexColors),void 0!==t.uniforms)for(let e in t.uniforms){let r=t.uniforms[e];switch(s.uniforms[e]={},r.type){case"t":s.uniforms[e].value=i(r.value);break;case"c":s.uniforms[e].value=new ez().setHex(r.value);break;case"v2":s.uniforms[e].value=new J().fromArray(r.value);break;case"v3":s.uniforms[e].value=new Z().fromArray(r.value);break;case"v4":s.uniforms[e].value=new td().fromArray(r.value);break;case"m3":s.uniforms[e].value=new K().fromArray(r.value);break;case"m4":s.uniforms[e].value=new tH().fromArray(r.value);break;default:s.uniforms[e].value=r.value}}if(void 0!==t.defines&&(s.defines=t.defines),void 0!==t.vertexShader&&(s.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(s.fragmentShader=t.fragmentShader),void 0!==t.glslVersion&&(s.glslVersion=t.glslVersion),void 0!==t.extensions)for(let e in t.extensions)s.extensions[e]=t.extensions[e];if(void 0!==t.lights&&(s.lights=t.lights),void 0!==t.clipping&&(s.clipping=t.clipping),void 0!==t.size&&(s.size=t.size),void 0!==t.sizeAttenuation&&(s.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(s.map=i(t.map)),void 0!==t.matcap&&(s.matcap=i(t.matcap)),void 0!==t.alphaMap&&(s.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(s.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(s.bumpScale=t.bumpScale),void 0!==t.normalMap&&(s.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(s.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),s.normalScale=new J().fromArray(e)}return void 0!==t.displacementMap&&(s.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(s.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(s.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(s.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(s.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(s.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(s.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(s.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(s.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularColorMap&&(s.specularColorMap=i(t.specularColorMap)),void 0!==t.envMap&&(s.envMap=i(t.envMap)),void 0!==t.envMapRotation&&s.envMapRotation.fromArray(t.envMapRotation),void 0!==t.envMapIntensity&&(s.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(s.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(s.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(s.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(s.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(s.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(s.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(s.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(s.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(s.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(s.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(s.clearcoatNormalScale=new J().fromArray(t.clearcoatNormalScale)),void 0!==t.iridescenceMap&&(s.iridescenceMap=i(t.iridescenceMap)),void 0!==t.iridescenceThicknessMap&&(s.iridescenceThicknessMap=i(t.iridescenceThicknessMap)),void 0!==t.transmissionMap&&(s.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(s.thicknessMap=i(t.thicknessMap)),void 0!==t.anisotropyMap&&(s.anisotropyMap=i(t.anisotropyMap)),void 0!==t.sheenColorMap&&(s.sheenColorMap=i(t.sheenColorMap)),void 0!==t.sheenRoughnessMap&&(s.sheenRoughnessMap=i(t.sheenRoughnessMap)),s}setTextures(t){return this.textures=t,this}createMaterialFromType(t){return al.createMaterialFromType(t)}static createMaterialFromType(t){return new({ShadowMaterial:np,SpriteMaterial:iO,RawShaderMaterial:nd,ShaderMaterial:im,PointsMaterial:sK,MeshPhysicalMaterial:nf,MeshStandardMaterial:nm,MeshPhongMaterial:ng,MeshToonMaterial:ny,MeshNormalMaterial:nx,MeshLambertMaterial:nb,MeshDepthMaterial:nv,MeshDistanceMaterial:nw,MeshBasicMaterial:eO,MeshMatcapMaterial:nM,LineDashedMaterial:nS,LineBasicMaterial:s$,Material:eR})[t]}}class au{static extractUrlBase(t){let e=t.lastIndexOf("/");return -1===e?"./":t.slice(0,e+1)}static resolveURL(t,e){return"string"!=typeof t||""===t?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t))?t:e+t}}class ac extends e5{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(t){return super.copy(t),this.instanceCount=t.instanceCount,this}toJSON(){let t=super.toJSON();return t.instanceCount=this.instanceCount,t.isInstancedBufferGeometry=!0,t}}class ap extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(r.manager);n.setPath(r.path),n.setRequestHeader(r.requestHeader),n.setWithCredentials(r.withCredentials),n.load(t,function(i){try{e(r.parse(JSON.parse(i)))}catch(e){s?s(e):O(e),r.manager.itemError(t)}},i,s)}parse(t){let e={},i={};function s(t,s){if(void 0!==e[s])return e[s];let r=t.interleavedBuffers[s],n=function(t,e){if(void 0!==i[e])return i[e];let s=new Uint32Array(t.arrayBuffers[e]).buffer;return i[e]=s,s}(t,r.buffer),a=new ik(S(r.type,n),r.stride);return a.uuid=r.uuid,e[s]=a,a}let r=t.isInstancedBufferGeometry?new ac:new e5,n=t.data.index;if(void 0!==n){let t=S(n.type,n.array);r.setIndex(new eD(t,1))}let a=t.data.attributes;for(let e in a){let i,n=a[e];if(n.isInterleavedBufferAttribute)i=new iR(s(t.data,n.data),n.itemSize,n.offset,n.normalized);else{let t=S(n.type,n.array);i=new(n.isInstancedBufferAttribute?si:eD)(t,n.itemSize,n.normalized)}void 0!==n.name&&(i.name=n.name),void 0!==n.usage&&i.setUsage(n.usage),r.setAttribute(e,i)}let o=t.data.morphAttributes;if(o)for(let e in o){let i=o[e],n=[];for(let e=0,r=i.length;e0){(i=new nQ(new nU(e))).setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){(e=new nQ(this.manager)).setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e{let e=null,i=null;return void 0!==t.boundingBox&&(e=new tv().fromJSON(t.boundingBox)),void 0!==t.boundingSphere&&(i=new tF().fromJSON(t.boundingSphere)),{...t,boundingBox:e,boundingSphere:i}}),n._instanceInfo=t.instanceInfo,n._availableInstanceIds=t._availableInstanceIds,n._availableGeometryIds=t._availableGeometryIds,n._nextIndexStart=t.nextIndexStart,n._nextVertexStart=t.nextVertexStart,n._geometryCount=t.geometryCount,n._maxInstanceCount=t.maxInstanceCount,n._maxVertexCount=t.maxVertexCount,n._maxIndexCount=t.maxIndexCount,n._geometryInitialized=t.geometryInitialized,n._matricesTexture=u(t.matricesTexture.uuid),n._indirectTexture=u(t.indirectTexture.uuid),void 0!==t.colorsTexture&&(n._colorsTexture=u(t.colorsTexture.uuid)),void 0!==t.boundingSphere&&(n.boundingSphere=new tF().fromJSON(t.boundingSphere)),void 0!==t.boundingBox&&(n.boundingBox=new tv().fromJSON(t.boundingBox));break;case"LOD":n=new iZ;break;case"Line":n=new sH(h(t.geometry),l(t.material));break;case"LineLoop":n=new sQ(h(t.geometry),l(t.material));break;case"LineSegments":n=new sY(h(t.geometry),l(t.material));break;case"PointCloud":case"Points":n=new s5(h(t.geometry),l(t.material));break;case"Sprite":n=new iq(l(t.material));break;case"Group":n=new iA;break;case"Bone":n=new i8;break;default:n=new eu}if(n.uuid=t.uuid,void 0!==t.name&&(n.name=t.name),void 0!==t.matrix?(n.matrix.fromArray(t.matrix),void 0!==t.matrixAutoUpdate&&(n.matrixAutoUpdate=t.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==t.position&&n.position.fromArray(t.position),void 0!==t.rotation&&n.rotation.fromArray(t.rotation),void 0!==t.quaternion&&n.quaternion.fromArray(t.quaternion),void 0!==t.scale&&n.scale.fromArray(t.scale)),void 0!==t.up&&n.up.fromArray(t.up),void 0!==t.castShadow&&(n.castShadow=t.castShadow),void 0!==t.receiveShadow&&(n.receiveShadow=t.receiveShadow),t.shadow&&(void 0!==t.shadow.intensity&&(n.shadow.intensity=t.shadow.intensity),void 0!==t.shadow.bias&&(n.shadow.bias=t.shadow.bias),void 0!==t.shadow.normalBias&&(n.shadow.normalBias=t.shadow.normalBias),void 0!==t.shadow.radius&&(n.shadow.radius=t.shadow.radius),void 0!==t.shadow.mapSize&&n.shadow.mapSize.fromArray(t.shadow.mapSize),void 0!==t.shadow.camera&&(n.shadow.camera=this.parseObject(t.shadow.camera))),void 0!==t.visible&&(n.visible=t.visible),void 0!==t.frustumCulled&&(n.frustumCulled=t.frustumCulled),void 0!==t.renderOrder&&(n.renderOrder=t.renderOrder),void 0!==t.userData&&(n.userData=t.userData),void 0!==t.layers&&(n.layers.mask=t.layers),void 0!==t.children){let a=t.children;for(let t=0;t{if(!0!==ay.has(n))return e&&e(i),r.manager.itemEnd(t),i;s&&s(ay.get(n)),r.manager.itemError(t),r.manager.itemEnd(t)}):(setTimeout(function(){e&&e(n),r.manager.itemEnd(t)},0),n);let a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,a.signal="function"==typeof AbortSignal.any?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let o=fetch(t,a).then(function(t){return t.blob()}).then(function(t){return createImageBitmap(t,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(i){return nj.add(`image-bitmap:${t}`,i),e&&e(i),r.manager.itemEnd(t),i}).catch(function(e){s&&s(e),ay.set(o,e),nj.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});nj.add(`image-bitmap:${t}`,o),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class ab{static getContext(){return void 0===s&&(s=new(window.AudioContext||window.webkitAudioContext)),s}static setContext(t){s=t}}class av extends nG{constructor(t){super(t)}load(t,e,i,s){let r=this,n=new nJ(this.manager);function a(e){s?s(e):O(e),r.manager.itemError(t)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(t,function(t){try{let i=t.slice(0);ab.getContext().decodeAudioData(i,function(t){e(t)}).catch(a)}catch(t){a(t)}},i,s)}}let aw=new tH,aM=new tH,aS=new tH;class aA{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new iv,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new iv,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){let e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){let i,s;e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,aS.copy(t.projectionMatrix);let r=e.eyeSep/2,n=r*e.near/e.focus,a=e.near*Math.tan($*e.fov*.5)/e.zoom;aM.elements[12]=-r,aw.elements[12]=r,i=-a*e.aspect+n,s=a*e.aspect+n,aS.elements[0]=2*e.near/(s-i),aS.elements[8]=(s+i)/(s-i),this.cameraL.projectionMatrix.copy(aS),i=-a*e.aspect-n,s=a*e.aspect-n,aS.elements[0]=2*e.near/(s-i),aS.elements[8]=(s+i)/(s-i),this.cameraR.projectionMatrix.copy(aS)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(aM),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(aw)}}class a_ extends iv{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class aC{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){let e=performance.now();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}let aT=new Z,aI=new X,az=new Z,ak=new Z,aB=new Z;class aR extends eu{constructor(){super(),this.type="AudioListener",this.context=ab.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new aC}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);let e=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(aT,aI,az),ak.set(0,0,-1).applyQuaternion(aI),aB.set(0,1,0).applyQuaternion(aI),e.positionX){let t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(aT.x,t),e.positionY.linearRampToValueAtTime(aT.y,t),e.positionZ.linearRampToValueAtTime(aT.z,t),e.forwardX.linearRampToValueAtTime(ak.x,t),e.forwardY.linearRampToValueAtTime(ak.y,t),e.forwardZ.linearRampToValueAtTime(ak.z,t),e.upX.linearRampToValueAtTime(aB.x,t),e.upY.linearRampToValueAtTime(aB.y,t),e.upZ.linearRampToValueAtTime(aB.z,t)}else e.setPosition(aT.x,aT.y,aT.z),e.setOrientation(ak.x,ak.y,ak.z,aB.x,aB.y,aB.z)}}class aO extends eu{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(!0===this.isPlaying)return void R("Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void R("Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+t;let e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){return!1===this.hasPlaybackControl?void R("Audio: this Audio has no playback control."):(!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this)}stop(t=0){return!1===this.hasPlaybackControl?void R("Audio: this Audio has no playback control."):(this._progress=0,null!==this.source&&(this.source.stop(this.context.currentTime+t),this.source.onended=null),this.isPlaying=!1,this)}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,s,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){a.setValue(i,s);break}}saveOriginalState(){let t=this.binding,e=this.buffer,i=this.valueSize,s=i*this._origIndex;t.getValue(e,s);for(let t=i;t!==s;++t)e[t]=e[s+t%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){let t=3*this.valueSize;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){let t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i=.5)for(let s=0;s!==r;++s)t[e+s]=t[i+s]}_slerp(t,e,i,s){X.slerpFlat(t,e,t,e,t,i,s)}_slerpAdditive(t,e,i,s,r){let n=this._workIndex*r;X.multiplyQuaternionsFlat(t,n,t,e,t,i),X.slerpFlat(t,e,t,e,t,n,s)}_lerp(t,e,i,s,r){let n=1-s;for(let a=0;a!==r;++a){let r=e+a;t[r]=t[r]*n+t[i+a]*s}}_lerpAdditive(t,e,i,s,r){for(let n=0;n!==r;++n){let r=e+n;t[r]=t[r]+t[i+n]*s}}}let aD="\\[\\]\\.:\\/",aj=RegExp("["+aD+"]","g"),aU="[^"+aD+"]",aW="[^"+aD.replace("\\.","")+"]",aG=RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",aU)+/(WCOD+)?/.source.replace("WCOD",aW)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",aU)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",aU)+"$"),aq=["material","materials","bones","map"];class aH{constructor(t,e,i){this.path=e,this.parsedPath=i||aH.parseTrackName(e),this.node=aH.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new aH.Composite(t,e,i):new aH(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(aj,"")}static parseTrackName(t){let e=aG.exec(t);if(null===e)throw Error("PropertyBinding: Cannot parse trackName: "+t);let i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},s=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==s&&-1!==s){let t=i.nodeName.substring(s+1);-1!==aq.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,s),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(void 0===e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){let i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){let i=function(t){for(let s=0;s=r){let n=r++,l=t[n];e[l.uuid]=h,t[h]=l,e[o]=n,t[n]=a;for(let t=0;t!==s;++t){let e=i[t],s=e[n],r=e[h];e[h]=s,e[n]=r}}}this.nCachedObjects_=r}uncache(){let t=this._objects,e=this._indicesByUUID,i=this._bindings,s=i.length,r=this.nCachedObjects_,n=t.length;for(let a=0,o=arguments.length;a!==o;++a){let o=arguments[a],h=o.uuid,l=e[h];if(void 0!==l)if(delete e[h],l0&&(e[a.uuid]=l),t[l]=a,t.pop();for(let t=0;t!==s;++t){let e=i[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){let i=this._bindingsIndicesByPath,s=i[t],r=this._bindings;if(void 0!==s)return r[s];let n=this._paths,a=this._parsedPaths,o=this._objects,h=o.length,l=this.nCachedObjects_,u=Array(h);s=r.length,i[t]=s,n.push(t),a.push(e),r.push(u);for(let i=l,s=o.length;i!==s;++i){let s=o[i];u[i]=new aH(s,t,e)}return u}unsubscribe_(t){let e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){let s=this._paths,r=this._parsedPaths,n=this._bindings,a=n.length-1,o=n[a];e[t[a]]=i,n[i]=o,n.pop(),r[i]=r[a],r.pop(),s[i]=s[a],s.pop()}}}class aX{constructor(t,e,i=null,s=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=s;const r=e.tracks,n=r.length,a=Array(n),o={endingStart:2400,endingEnd:2400};for(let t=0;t!==n;++t){const e=r[t].createInterpolant(null);a[t]=e,e.settings=o}this._interpolantSettings=o,this._interpolants=a,this._propertyBindings=Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),!0===i){let i=this._clip.duration,s=t._clip.duration;t.warp(1,s/i,e),this.warp(i/s,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){let t=this._weightInterpolant;return null!==t&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){let s=this._mixer,r=s.time,n=this.timeScale,a=this._timeScaleInterpolant;null===a&&(a=s._lendControlInterpolant(),this._timeScaleInterpolant=a);let o=a.parameterPositions,h=a.sampleValues;return o[0]=r,o[1]=r+i,h[0]=t/n,h[1]=e/n,this}stopWarping(){let t=this._timeScaleInterpolant;return null!==t&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,s){if(!this.enabled)return void this._updateWeight(t);let r=this._startTime;if(null!==r){let s=(t-r)*i;s<0||0===i?e=0:(this._startTime=null,e=i*s)}e*=this._updateTimeScale(t);let n=this._updateTime(e),a=this._updateWeight(t);if(a>0){let t=this._interpolants,e=this._propertyBindings;if(2501===this.blendMode)for(let i=0,s=t.length;i!==s;++i)t[i].evaluate(n),e[i].accumulateAdditive(a);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(n),e[i].accumulate(s,a)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;let i=this._weightInterpolant;if(null!==i){let s=i.evaluate(t)[0];e*=s,t>i.parameterPositions[1]&&(this.stopFading(),0===s&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;let i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){let e=this._clip.duration,i=this.loop,s=this.time+t,r=this._loopCount,n=2202===i;if(0===t)return -1===r?s:n&&(1&r)==1?e-s:s;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));r:{if(s>=e)s=e;else if(s<0)s=0;else{this.time=s;break r}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),s>=e||s<0){let i=Math.floor(s/e);s-=e*i,r+=Math.abs(i);let a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,s=t>0?e:0,this.time=s,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===a){let e=t<0;this._setEndings(e,!e,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=s,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=s;if(n&&(1&r)==1)return e-s}return s}_setEndings(t,e,i){let s=this._interpolantSettings;i?(s.endingStart=2401,s.endingEnd=2401):(t?s.endingStart=this.zeroSlopeAtStart?2401:2400:s.endingStart=2402,e?s.endingEnd=this.zeroSlopeAtEnd?2401:2400:s.endingEnd=2402)}_scheduleFading(t,e,i){let s=this._mixer,r=s.time,n=this._weightInterpolant;null===n&&(n=s._lendControlInterpolant(),this._weightInterpolant=n);let a=n.parameterPositions,o=n.sampleValues;return a[0]=r,o[0]=e,a[1]=r+t,o[1]=i,this}}let aZ=new Float32Array(1);class aY extends L{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){let i=t._localRoot||this._root,s=t._clip.tracks,r=s.length,n=t._propertyBindings,a=t._interpolants,o=i.uuid,h=this._bindingsByRootAndName,l=h[o];void 0===l&&(l={},h[o]=l);for(let t=0;t!==r;++t){let r=s[t],h=r.name,u=l[h];if(void 0!==u)++u.referenceCount,n[t]=u;else{if(void 0!==(u=n[t])){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,o,h));continue}let s=e&&e._propertyBindings[t].binding.parsedPath;u=new aV(aH.create(i,h,s),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,o,h),n[t]=u}a[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){let e=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,e)}let e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){let i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){let e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){let i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;let t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){let e=t._cacheIndex;return null!==e&&e=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;let e=this._actions,i=this._nActiveActions,s=this.time+=t,r=Math.sign(t),n=this._accuIndex^=1;for(let a=0;a!==i;++a)e[a]._update(s,t,r,n);let a=this._bindings,o=this._nActiveBindings;for(let t=0;t!==o;++t)a[t].apply(n);return this}setTime(t){this.time=0;for(let t=0;t=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,os).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}let on=new Z,oa=new Z,oo=new Z,oh=new Z,ol=new Z,ou=new Z,oc=new Z;class op{constructor(t=new Z,e=new Z){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){on.subVectors(t,this.start),oa.subVectors(this.end,this.start);let i=oa.dot(oa),s=oa.dot(on)/i;return e&&(s=j(s,0,1)),s}closestPointToPoint(t,e,i){let s=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(s).add(this.start)}distanceSqToLine3(t,e=ou,i=oc){let s,r,n=1e-8*1e-8,a=this.start,o=t.start,h=this.end,l=t.end;oo.subVectors(h,a),oh.subVectors(l,o),ol.subVectors(a,o);let u=oo.dot(oo),c=oh.dot(oh),p=oh.dot(ol);if(u<=n&&c<=n)return e.copy(a),i.copy(o),e.sub(i),e.dot(e);if(u<=n)s=0,r=j(r=p/c,0,1);else{let t=oo.dot(ol);if(c<=n)r=0,s=j(-t/u,0,1);else{let e=oo.dot(oh),i=u*c-e*e;s=0!==i?j((e*p-t*c)/i,0,1):0,(r=(e*s+p)/c)<0?(r=0,s=j(-t/u,0,1)):r>1&&(r=1,s=j((e-t)/u,0,1))}}return e.copy(a).add(oo.multiplyScalar(s)),i.copy(o).add(oh.multiplyScalar(r)),e.sub(i),e.dot(e)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}let od=new Z;class om extends eu{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const i=new e5,s=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let t=0,e=1;t<32;t++,e++){const i=t/32*Math.PI*2,r=e/32*Math.PI*2;s.push(Math.cos(i),Math.sin(i),1,Math.cos(r),Math.sin(r),1)}i.setAttribute("position",new eZ(s,3));const r=new s$({fog:!1,toneMapped:!1});this.cone=new sY(i,r),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);let t=this.light.distance?this.light.distance:1e3,e=t*Math.tan(this.light.angle);this.cone.scale.set(e,e,t),od.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(od),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}let of=new Z,og=new tH,oy=new tH;class ox extends sY{constructor(t){const e=function t(e){let i=[];!0===e.isBone&&i.push(e);for(let s=0;s1)for(let i=0;i.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{oF.set(t.z,0,-t.x).normalize();let e=Math.acos(t.y);this.quaternion.setFromAxisAngle(oF,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class oV extends sY{constructor(t=1){const e=new e5;e.setAttribute("position",new eZ([0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],3)),e.setAttribute("color",new eZ([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3)),super(e,new s$({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(t,e,i){let s=new ez,r=this.geometry.attributes.color.array;return s.set(t),s.toArray(r,0),s.toArray(r,3),s.set(e),s.toArray(r,6),s.toArray(r,9),s.set(i),s.toArray(r,12),s.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class oD{constructor(){this.type="ShapePath",this.color=new ez,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new rF,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,i,s){return this.currentPath.quadraticCurveTo(t,e,i,s),this}bezierCurveTo(t,e,i,s,r,n){return this.currentPath.bezierCurveTo(t,e,i,s,r,n),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){let e,i,s,r,n,a=r3.isClockWise,o=this.subPaths;if(0===o.length)return[];let h=[];if(1===o.length)return i=o[0],(s=new r$).curves=i.curves,h.push(s),h;let l=!a(o[0].getPoints());l=t?!l:l;let u=[],c=[],p=[],d=0;c[0]=void 0,p[d]=[];for(let s=0,n=o.length;s1){let t=!1,e=0;for(let t=0,e=c.length;tNumber.EPSILON){if(h<0&&(i=e[n],o=-o,a=e[r],h=-h),t.ya.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{let e=h*(t.x-i.x)-o*(t.y-i.y);if(0===e)return!0;if(e<0)continue;s=!s}}else{if(t.y!==i.y)continue;if(a.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=a.x)return!0}}return s})(n.p,c[s].p)&&(i!==s&&e++,a?(a=!1,u[s].push(n)):t=!0);a&&u[i].push(n)}}e>0&&!1===t&&(p=u)}for(let t=0,e=c.length;te?(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2):(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0),t}static cover(t,e){let i;return(i=t.image&&t.image.width?t.image.width/t.image.height:1)>e?(t.repeat.x=e/i,t.repeat.y=1,t.offset.x=(1-t.repeat.x)/2,t.offset.y=0):(t.repeat.x=1,t.repeat.y=i/e,t.offset.x=0,t.offset.y=(1-t.repeat.y)/2),t}static fill(t){return t.repeat.x=1,t.repeat.y=1,t.offset.x=0,t.offset.y=0,t}static getByteLength(t,e,i,s){return oU(t,e,i,s)}}"u">typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"182"}})),"u">typeof window&&(window.__THREE__?R("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="182"),t.s(["ACESFilmicToneMapping",()=>4,"AddEquation",()=>100,"AddOperation",()=>2,"AdditiveAnimationBlendMode",()=>2501,"AdditiveBlending",()=>2,"AgXToneMapping",()=>6,"AlphaFormat",()=>1021,"AlwaysCompare",()=>519,"AlwaysDepth",()=>1,"AlwaysStencilFunc",()=>519,"AmbientLight",()=>an,"AnimationAction",()=>aX,"AnimationClip",()=>nD,"AnimationLoader",()=>nX,"AnimationMixer",()=>aY,"AnimationObjectGroup",()=>aJ,"AnimationUtils",()=>nI,"ArcCurve",()=>rb,"ArrayCamera",()=>a_,"ArrowHelper",()=>o$,"AttachedBindMode",()=>p,"Audio",()=>aO,"AudioAnalyser",()=>a$,"AudioContext",()=>ab,"AudioListener",()=>aR,"AudioLoader",()=>av,"AxesHelper",()=>oV,"BackSide",()=>1,"BasicDepthPacking",()=>3200,"BasicShadowMap",()=>0,"BatchedMesh",()=>sF,"Bone",()=>i8,"BooleanKeyframeTrack",()=>nE,"Box2",()=>or,"Box3",()=>tv,"Box3Helper",()=>oL,"BoxGeometry",()=>il,"BoxHelper",()=>oP,"BufferAttribute",()=>eD,"BufferGeometry",()=>e5,"BufferGeometryLoader",()=>ap,"ByteType",()=>1010,"Cache",()=>nj,"Camera",()=>ig,"CameraHelper",()=>oR,"CanvasTexture",()=>ri,"CapsuleGeometry",()=>ra,"CatmullRomCurve3",()=>r_,"CineonToneMapping",()=>3,"CircleGeometry",()=>ro,"ClampToEdgeWrapping",()=>1001,"Clock",()=>aC,"Color",()=>ez,"ColorKeyframeTrack",()=>nP,"ColorManagement",()=>ts,"CompressedArrayTexture",()=>rt,"CompressedCubeTexture",()=>re,"CompressedTexture",()=>s7,"CompressedTextureLoader",()=>nZ,"ConeGeometry",()=>rl,"ConstantAlphaFactor",()=>213,"ConstantColorFactor",()=>211,"Controls",()=>oj,"CubeCamera",()=>iw,"CubeDepthTexture",()=>rr,"CubeReflectionMapping",()=>301,"CubeRefractionMapping",()=>302,"CubeTexture",()=>iM,"CubeTextureLoader",()=>nK,"CubeUVReflectionMapping",()=>306,"CubicBezierCurve",()=>rz,"CubicBezierCurve3",()=>rk,"CubicInterpolant",()=>nk,"CullFaceBack",()=>1,"CullFaceFront",()=>2,"CullFaceFrontBack",()=>3,"CullFaceNone",()=>0,"Curve",()=>ry,"CurvePath",()=>rN,"CustomBlending",()=>5,"CustomToneMapping",()=>5,"CylinderGeometry",()=>rh,"Cylindrical",()=>oe,"Data3DTexture",()=>tx,"DataArrayTexture",()=>tg,"DataTexture",()=>i9,"DataTextureLoader",()=>n0,"DataUtils",()=>eN,"DecrementStencilOp",()=>7683,"DecrementWrapStencilOp",()=>34056,"DefaultLoadingManager",()=>nW,"DepthFormat",()=>1026,"DepthStencilFormat",()=>1027,"DepthTexture",()=>rs,"DetachedBindMode",()=>d,"DirectionalLight",()=>ar,"DirectionalLightHelper",()=>oz,"DiscreteInterpolant",()=>nR,"DodecahedronGeometry",()=>rc,"DoubleSide",()=>2,"DstAlphaFactor",()=>206,"DstColorFactor",()=>208,"DynamicCopyUsage",()=>35050,"DynamicDrawUsage",()=>35048,"DynamicReadUsage",()=>35049,"EdgesGeometry",()=>rg,"EllipseCurve",()=>rx,"EqualCompare",()=>514,"EqualDepth",()=>4,"EqualStencilFunc",()=>514,"EquirectangularReflectionMapping",()=>303,"EquirectangularRefractionMapping",()=>304,"Euler",()=>t3,"EventDispatcher",()=>L,"ExternalTexture",()=>rn,"ExtrudeGeometry",()=>r6,"FileLoader",()=>nJ,"Float16BufferAttribute",()=>eX,"Float32BufferAttribute",()=>eZ,"FloatType",()=>1015,"Fog",()=>iI,"FogExp2",()=>iT,"FramebufferTexture",()=>s9,"FrontSide",()=>0,"Frustum",()=>sx,"FrustumArray",()=>sw,"GLBufferAttribute",()=>a3,"GLSL1",()=>"100","GLSL3",()=>"300 es","GreaterCompare",()=>516,"GreaterDepth",()=>6,"GreaterEqualCompare",()=>518,"GreaterEqualDepth",()=>5,"GreaterEqualStencilFunc",()=>518,"GreaterStencilFunc",()=>516,"GridHelper",()=>oA,"Group",()=>iA,"HalfFloatType",()=>1016,"HemisphereLight",()=>n3,"HemisphereLightHelper",()=>oS,"IcosahedronGeometry",()=>r9,"ImageBitmapLoader",()=>ax,"ImageLoader",()=>nQ,"ImageUtils",()=>ta,"IncrementStencilOp",()=>7682,"IncrementWrapStencilOp",()=>34055,"InstancedBufferAttribute",()=>si,"InstancedBufferGeometry",()=>ac,"InstancedInterleavedBuffer",()=>a2,"InstancedMesh",()=>su,"Int16BufferAttribute",()=>eG,"Int32BufferAttribute",()=>eH,"Int8BufferAttribute",()=>ej,"IntType",()=>1013,"InterleavedBuffer",()=>ik,"InterleavedBufferAttribute",()=>iR,"Interpolant",()=>nz,"InterpolateDiscrete",()=>2300,"InterpolateLinear",()=>2301,"InterpolateSmooth",()=>2302,"InterpolationSamplingMode",()=>v,"InterpolationSamplingType",()=>b,"InvertStencilOp",()=>5386,"KeepStencilOp",()=>7680,"KeyframeTrack",()=>nO,"LOD",()=>iZ,"LatheGeometry",()=>r7,"Layers",()=>t5,"LessCompare",()=>513,"LessDepth",()=>2,"LessEqualCompare",()=>515,"LessEqualDepth",()=>3,"LessEqualStencilFunc",()=>515,"LessStencilFunc",()=>513,"Light",()=>n2,"LightProbe",()=>ah,"Line",()=>sH,"Line3",()=>op,"LineBasicMaterial",()=>s$,"LineCurve",()=>rB,"LineCurve3",()=>rR,"LineDashedMaterial",()=>nS,"LineLoop",()=>sQ,"LineSegments",()=>sY,"LinearFilter",()=>1006,"LinearInterpolant",()=>nB,"LinearMipMapLinearFilter",()=>1008,"LinearMipMapNearestFilter",()=>1007,"LinearMipmapLinearFilter",()=>1008,"LinearMipmapNearestFilter",()=>1007,"LinearSRGBColorSpace",()=>f,"LinearToneMapping",()=>1,"LinearTransfer",()=>g,"Loader",()=>nG,"LoaderUtils",()=>au,"LoadingManager",()=>nU,"LoopOnce",()=>2200,"LoopPingPong",()=>2202,"LoopRepeat",()=>2201,"MOUSE",()=>u,"Material",()=>eR,"MaterialLoader",()=>al,"MathUtils",()=>H,"Matrix2",()=>oi,"Matrix3",()=>K,"Matrix4",()=>tH,"MaxEquation",()=>104,"Mesh",()=>io,"MeshBasicMaterial",()=>eO,"MeshDepthMaterial",()=>nv,"MeshDistanceMaterial",()=>nw,"MeshLambertMaterial",()=>nb,"MeshMatcapMaterial",()=>nM,"MeshNormalMaterial",()=>nx,"MeshPhongMaterial",()=>ng,"MeshPhysicalMaterial",()=>nf,"MeshStandardMaterial",()=>nm,"MeshToonMaterial",()=>ny,"MinEquation",()=>103,"MirroredRepeatWrapping",()=>1002,"MixOperation",()=>1,"MultiplyBlending",()=>4,"MultiplyOperation",()=>0,"NearestFilter",()=>1003,"NearestMipMapLinearFilter",()=>1005,"NearestMipMapNearestFilter",()=>1004,"NearestMipmapLinearFilter",()=>1005,"NearestMipmapNearestFilter",()=>1004,"NeutralToneMapping",()=>7,"NeverCompare",()=>512,"NeverDepth",()=>0,"NeverStencilFunc",()=>512,"NoBlending",()=>0,"NoColorSpace",()=>"","NoNormalPacking",()=>"","NoToneMapping",()=>0,"NormalAnimationBlendMode",()=>2500,"NormalBlending",()=>1,"NormalGAPacking",()=>"ga","NormalRGPacking",()=>"rg","NotEqualCompare",()=>517,"NotEqualDepth",()=>7,"NotEqualStencilFunc",()=>517,"NumberKeyframeTrack",()=>nL,"Object3D",()=>eu,"ObjectLoader",()=>ad,"ObjectSpaceNormalMap",()=>1,"OctahedronGeometry",()=>nt,"OneFactor",()=>201,"OneMinusConstantAlphaFactor",()=>214,"OneMinusConstantColorFactor",()=>212,"OneMinusDstAlphaFactor",()=>207,"OneMinusDstColorFactor",()=>209,"OneMinusSrcAlphaFactor",()=>205,"OneMinusSrcColorFactor",()=>203,"OrthographicCamera",()=>ai,"PCFShadowMap",()=>1,"PCFSoftShadowMap",()=>2,"Path",()=>rF,"PerspectiveCamera",()=>iv,"Plane",()=>sm,"PlaneGeometry",()=>ne,"PlaneHelper",()=>oN,"PointLight",()=>ae,"PointLightHelper",()=>ob,"Points",()=>s5,"PointsMaterial",()=>sK,"PolarGridHelper",()=>o_,"PolyhedronGeometry",()=>ru,"PositionalAudio",()=>aF,"PropertyBinding",()=>aH,"PropertyMixer",()=>aV,"QuadraticBezierCurve",()=>rO,"QuadraticBezierCurve3",()=>rE,"Quaternion",()=>X,"QuaternionKeyframeTrack",()=>nF,"QuaternionLinearInterpolant",()=>nN,"R11_EAC_Format",()=>37488,"RAD2DEG",()=>V,"RED_GREEN_RGTC2_Format",()=>36285,"RED_RGTC1_Format",()=>36283,"REVISION",()=>"182","RG11_EAC_Format",()=>37490,"RGBADepthPacking",()=>3201,"RGBAFormat",()=>1023,"RGBAIntegerFormat",()=>1033,"RGBA_ASTC_10x10_Format",()=>37819,"RGBA_ASTC_10x5_Format",()=>37816,"RGBA_ASTC_10x6_Format",()=>37817,"RGBA_ASTC_10x8_Format",()=>37818,"RGBA_ASTC_12x10_Format",()=>37820,"RGBA_ASTC_12x12_Format",()=>37821,"RGBA_ASTC_4x4_Format",()=>37808,"RGBA_ASTC_5x4_Format",()=>37809,"RGBA_ASTC_5x5_Format",()=>37810,"RGBA_ASTC_6x5_Format",()=>37811,"RGBA_ASTC_6x6_Format",()=>37812,"RGBA_ASTC_8x5_Format",()=>37813,"RGBA_ASTC_8x6_Format",()=>37814,"RGBA_ASTC_8x8_Format",()=>37815,"RGBA_BPTC_Format",()=>36492,"RGBA_ETC2_EAC_Format",()=>37496,"RGBA_PVRTC_2BPPV1_Format",()=>35843,"RGBA_PVRTC_4BPPV1_Format",()=>35842,"RGBA_S3TC_DXT1_Format",()=>33777,"RGBA_S3TC_DXT3_Format",()=>33778,"RGBA_S3TC_DXT5_Format",()=>33779,"RGBDepthPacking",()=>3202,"RGBFormat",()=>1022,"RGBIntegerFormat",()=>1032,"RGB_BPTC_SIGNED_Format",()=>36494,"RGB_BPTC_UNSIGNED_Format",()=>36495,"RGB_ETC1_Format",()=>36196,"RGB_ETC2_Format",()=>37492,"RGB_PVRTC_2BPPV1_Format",()=>35841,"RGB_PVRTC_4BPPV1_Format",()=>35840,"RGB_S3TC_DXT1_Format",()=>33776,"RGDepthPacking",()=>3203,"RGFormat",()=>1030,"RGIntegerFormat",()=>1031,"RawShaderMaterial",()=>nd,"Ray",()=>tq,"Raycaster",()=>a4,"RectAreaLight",()=>aa,"RedFormat",()=>1028,"RedIntegerFormat",()=>1029,"ReinhardToneMapping",()=>2,"RenderTarget",()=>tm,"RenderTarget3D",()=>aQ,"RepeatWrapping",()=>1e3,"ReplaceStencilOp",()=>7681,"ReverseSubtractEquation",()=>102,"RingGeometry",()=>ni,"SIGNED_R11_EAC_Format",()=>37489,"SIGNED_RED_GREEN_RGTC2_Format",()=>36286,"SIGNED_RED_RGTC1_Format",()=>36284,"SIGNED_RG11_EAC_Format",()=>37491,"SRGBColorSpace",()=>m,"SRGBTransfer",()=>y,"Scene",()=>iz,"ShaderMaterial",()=>im,"ShadowMaterial",()=>np,"Shape",()=>r$,"ShapeGeometry",()=>ns,"ShapePath",()=>oD,"ShapeUtils",()=>r3,"ShortType",()=>1011,"Skeleton",()=>se,"SkeletonHelper",()=>ox,"SkinnedMesh",()=>i6,"Source",()=>th,"Sphere",()=>tF,"SphereGeometry",()=>nr,"Spherical",()=>ot,"SphericalHarmonics3",()=>ao,"SplineCurve",()=>rP,"SpotLight",()=>n7,"SpotLightHelper",()=>om,"Sprite",()=>iq,"SpriteMaterial",()=>iO,"SrcAlphaFactor",()=>204,"SrcAlphaSaturateFactor",()=>210,"SrcColorFactor",()=>202,"StaticCopyUsage",()=>35046,"StaticDrawUsage",()=>35044,"StaticReadUsage",()=>35045,"StereoCamera",()=>aA,"StreamCopyUsage",()=>35042,"StreamDrawUsage",()=>35040,"StreamReadUsage",()=>35041,"StringKeyframeTrack",()=>n$,"SubtractEquation",()=>101,"SubtractiveBlending",()=>3,"TOUCH",()=>c,"TangentSpaceNormalMap",()=>0,"TetrahedronGeometry",()=>nn,"Texture",()=>tp,"TextureLoader",()=>n1,"TextureUtils",()=>oW,"Timer",()=>a9,"TimestampQuery",()=>x,"TorusGeometry",()=>na,"TorusKnotGeometry",()=>no,"Triangle",()=>eA,"TriangleFanDrawMode",()=>2,"TriangleStripDrawMode",()=>1,"TrianglesDrawMode",()=>0,"TubeGeometry",()=>nh,"UVMapping",()=>300,"Uint16BufferAttribute",()=>eq,"Uint32BufferAttribute",()=>eJ,"Uint8BufferAttribute",()=>eU,"Uint8ClampedBufferAttribute",()=>eW,"Uniform",()=>aK,"UniformsGroup",()=>a1,"UniformsUtils",()=>id,"UnsignedByteType",()=>1009,"UnsignedInt101111Type",()=>35899,"UnsignedInt248Type",()=>1020,"UnsignedInt5999Type",()=>35902,"UnsignedIntType",()=>1014,"UnsignedShort4444Type",()=>1017,"UnsignedShort5551Type",()=>1018,"UnsignedShortType",()=>1012,"VSMShadowMap",()=>3,"Vector2",()=>J,"Vector3",()=>Z,"Vector4",()=>td,"VectorKeyframeTrack",()=>nV,"VideoFrameTexture",()=>s8,"VideoTexture",()=>s6,"WebGL3DRenderTarget",()=>tb,"WebGLArrayRenderTarget",()=>ty,"WebGLCoordinateSystem",()=>2e3,"WebGLCubeRenderTarget",()=>iS,"WebGLRenderTarget",()=>tf,"WebGPUCoordinateSystem",()=>2001,"WebXRController",()=>iC,"WireframeGeometry",()=>nl,"WrapAroundEnding",()=>2402,"ZeroCurvatureEnding",()=>2400,"ZeroFactor",()=>200,"ZeroSlopeEnding",()=>2401,"ZeroStencilOp",()=>0,"arrayNeedsUint32",()=>w,"cloneUniforms",()=>iu,"createCanvasElement",()=>C,"createElementNS",()=>_,"error",()=>O,"getByteLength",()=>oU,"getConsoleFunction",()=>k,"getUnlitUniformColorSpace",()=>ip,"log",()=>B,"mergeUniforms",()=>ic,"probeAsync",()=>P,"setConsoleFunction",()=>z,"warn",()=>R,"warnOnce",()=>E])},53487,(t,e,i)=>{"use strict";let s="[^\\\\/]",r="[^/]",n="(?:\\/|$)",a="(?:^|\\/)",o=`\\.{1,2}${n}`,h=`(?!${a}${o})`,l=`(?!\\.{0,1}${n})`,u=`(?!${o})`,c=`${r}*?`,p={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:r,END_ANCHOR:n,DOTS_SLASH:o,NO_DOT:"(?!\\.)",NO_DOTS:h,NO_DOT_SLASH:l,NO_DOTS_SLASH:u,QMARK_NO_DOT:"[^.\\/]",STAR:c,START_ANCHOR:a,SEP:"/"},d={...p,SLASH_LITERAL:"[\\\\/]",QMARK:s,STAR:`${s}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"};e.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars:t=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:t=>!0===t?d:p}},19241,(t,e,i)=>{"use strict";var s=t.i(47167);let{REGEX_BACKSLASH:r,REGEX_REMOVE_BACKSLASH:n,REGEX_SPECIAL_CHARS:a,REGEX_SPECIAL_CHARS_GLOBAL:o}=t.r(53487);i.isObject=t=>null!==t&&"object"==typeof t&&!Array.isArray(t),i.hasRegexChars=t=>a.test(t),i.isRegexChar=t=>1===t.length&&i.hasRegexChars(t),i.escapeRegex=t=>t.replace(o,"\\$1"),i.toPosixSlashes=t=>t.replace(r,"/"),i.isWindows=()=>{if("u">typeof navigator&&navigator.platform){let t=navigator.platform.toLowerCase();return"win32"===t||"windows"===t}return void 0!==s.default&&!!s.default.platform&&"win32"===s.default.platform},i.removeBackslashes=t=>t.replace(n,t=>"\\"===t?"":t),i.escapeLast=(t,e,s)=>{let r=t.lastIndexOf(e,s);return -1===r?t:"\\"===t[r-1]?i.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`},i.removePrefix=(t,e={})=>{let i=t;return i.startsWith("./")&&(i=i.slice(2),e.prefix="./"),i},i.wrapOutput=(t,e={},i={})=>{let s=i.contains?"":"^",r=i.contains?"":"$",n=`${s}(?:${t})${r}`;return!0===e.negated&&(n=`(?:^(?!${n}).*$)`),n},i.basename=(t,{windows:e}={})=>{let i=t.split(e?/[\\/]/:"/"),s=i[i.length-1];return""===s?i[i.length-2]:s}},26094,(t,e,i)=>{"use strict";let s=t.r(19241),{CHAR_ASTERISK:r,CHAR_AT:n,CHAR_BACKWARD_SLASH:a,CHAR_COMMA:o,CHAR_DOT:h,CHAR_EXCLAMATION_MARK:l,CHAR_FORWARD_SLASH:u,CHAR_LEFT_CURLY_BRACE:c,CHAR_LEFT_PARENTHESES:p,CHAR_LEFT_SQUARE_BRACKET:d,CHAR_PLUS:m,CHAR_QUESTION_MARK:f,CHAR_RIGHT_CURLY_BRACE:g,CHAR_RIGHT_PARENTHESES:y,CHAR_RIGHT_SQUARE_BRACKET:x}=t.r(53487),b=t=>t===u||t===a,v=t=>{!0!==t.isPrefix&&(t.depth=t.isGlobstar?1/0:1)};e.exports=(t,e)=>{let i,w,M=e||{},S=t.length-1,A=!0===M.parts||!0===M.scanToEnd,_=[],C=[],T=[],I=t,z=-1,k=0,B=0,R=!1,O=!1,E=!1,P=!1,L=!1,N=!1,F=!1,$=!1,V=!1,D=!1,j=0,U={value:"",depth:0,isGlob:!1},W=()=>z>=S,G=()=>I.charCodeAt(z+1),q=()=>(i=w,I.charCodeAt(++z));for(;z0&&(J=I.slice(0,k),I=I.slice(k),B-=k),H&&!0===E&&B>0?(H=I.slice(0,B),X=I.slice(B)):!0===E?(H="",X=I):H=I,H&&""!==H&&"/"!==H&&H!==I&&b(H.charCodeAt(H.length-1))&&(H=H.slice(0,-1)),!0===M.unescape&&(X&&(X=s.removeBackslashes(X)),H&&!0===F&&(H=s.removeBackslashes(H)));let Z={prefix:J,input:t,start:k,base:H,glob:X,isBrace:R,isBracket:O,isGlob:E,isExtglob:P,isGlobstar:L,negated:$,negatedExtglob:V};if(!0===M.tokens&&(Z.maxDepth=0,b(w)||C.push(U),Z.tokens=C),!0===M.parts||!0===M.tokens){let e;for(let i=0;i<_.length;i++){let s=e?e+1:k,r=_[i],n=t.slice(s,r);M.tokens&&(0===i&&0!==k?(C[i].isPrefix=!0,C[i].value=J):C[i].value=n,v(C[i]),Z.maxDepth+=C[i].depth),(0!==i||""!==n)&&T.push(n),e=r}if(e&&e+1{"use strict";let s=t.r(53487),r=t.r(19241),{MAX_LENGTH:n,POSIX_REGEX_SOURCE:a,REGEX_NON_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_BACKREF:h,REPLACEMENTS:l}=s,u=(t,e)=>{if("function"==typeof e.expandRange)return e.expandRange(...t,e);t.sort();let i=`[${t.join("-")}]`;try{new RegExp(i)}catch(e){return t.map(t=>r.escapeRegex(t)).join("..")}return i},c=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,p=(t,e)=>{let i;if("string"!=typeof t)throw TypeError("Expected a string");t=l[t]||t;let d={...e},m="number"==typeof d.maxLength?Math.min(n,d.maxLength):n,f=t.length;if(f>m)throw SyntaxError(`Input length: ${f}, exceeds maximum allowed length: ${m}`);let g={type:"bos",value:"",output:d.prepend||""},y=[g],x=d.capture?"":"?:",b=s.globChars(d.windows),v=s.extglobChars(b),{DOT_LITERAL:w,PLUS_LITERAL:M,SLASH_LITERAL:S,ONE_CHAR:A,DOTS_SLASH:_,NO_DOT:C,NO_DOT_SLASH:T,NO_DOTS_SLASH:I,QMARK:z,QMARK_NO_DOT:k,STAR:B,START_ANCHOR:R}=b,O=t=>`(${x}(?:(?!${R}${t.dot?_:w}).)*?)`,E=d.dot?"":C,P=d.dot?z:k,L=!0===d.bash?O(d):B;d.capture&&(L=`(${L})`),"boolean"==typeof d.noext&&(d.noextglob=d.noext);let N={input:t,index:-1,start:0,dot:!0===d.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:y};f=(t=r.removePrefix(t,N)).length;let F=[],$=[],V=[],D=g,j=()=>N.index===f-1,U=N.peek=(e=1)=>t[N.index+e],W=N.advance=()=>t[++N.index]||"",G=()=>t.slice(N.index+1),q=(t="",e=0)=>{N.consumed+=t,N.index+=e},H=t=>{N.output+=null!=t.output?t.output:t.value,q(t.value)},J=()=>{let t=1;for(;"!"===U()&&("("!==U(2)||"?"===U(3));)W(),N.start++,t++;return t%2!=0&&(N.negated=!0,N.start++,!0)},X=t=>{N[t]++,V.push(t)},Z=t=>{N[t]--,V.pop()},Y=t=>{if("globstar"===D.type){let e=N.braces>0&&("comma"===t.type||"brace"===t.type),i=!0===t.extglob||F.length&&("pipe"===t.type||"paren"===t.type);"slash"===t.type||"paren"===t.type||e||i||(N.output=N.output.slice(0,-D.output.length),D.type="star",D.value="*",D.output=L,N.output+=D.output)}if(F.length&&"paren"!==t.type&&(F[F.length-1].inner+=t.value),(t.value||t.output)&&H(t),D&&"text"===D.type&&"text"===t.type){D.output=(D.output||D.value)+t.value,D.value+=t.value;return}t.prev=D,y.push(t),D=t},Q=(t,e)=>{let i={...v[e],conditions:1,inner:""};i.prev=D,i.parens=N.parens,i.output=N.output;let s=(d.capture?"(":"")+i.open;X("parens"),Y({type:t,value:e,output:N.output?"":A}),Y({type:"paren",extglob:!0,value:W(),output:s}),F.push(i)},K=t=>{let s,r=t.close+(d.capture?")":"");if("negate"===t.type){let i=L;if(t.inner&&t.inner.length>1&&t.inner.includes("/")&&(i=O(d)),(i!==L||j()||/^\)+$/.test(G()))&&(r=t.close=`)$))${i}`),t.inner.includes("*")&&(s=G())&&/^\.[^\\/.]+$/.test(s)){let n=p(s,{...e,fastpaths:!1}).output;r=t.close=`)${n})${i})`}"bos"===t.prev.type&&(N.negatedExtglob=!0)}Y({type:"paren",extglob:!0,value:i,output:r}),Z("parens")};if(!1!==d.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(t)){let i=!1,s=t.replace(h,(t,e,s,r,n,a)=>"\\"===r?(i=!0,t):"?"===r?e?e+r+(n?z.repeat(n.length):""):0===a?P+(n?z.repeat(n.length):""):z.repeat(s.length):"."===r?w.repeat(s.length):"*"===r?e?e+r+(n?L:""):L:e?t:`\\${t}`);return(!0===i&&(s=!0===d.unescape?s.replace(/\\/g,""):s.replace(/\\+/g,t=>t.length%2==0?"\\\\":t?"\\":"")),s===t&&!0===d.contains)?N.output=t:N.output=r.wrapOutput(s,N,e),N}for(;!j();){if("\0"===(i=W()))continue;if("\\"===i){let t=U();if("/"===t&&!0!==d.bash||"."===t||";"===t)continue;if(!t){Y({type:"text",value:i+="\\"});continue}let e=/^\\+/.exec(G()),s=0;if(e&&e[0].length>2&&(s=e[0].length,N.index+=s,s%2!=0&&(i+="\\")),!0===d.unescape?i=W():i+=W(),0===N.brackets){Y({type:"text",value:i});continue}}if(N.brackets>0&&("]"!==i||"["===D.value||"[^"===D.value)){if(!1!==d.posix&&":"===i){let t=D.value.slice(1);if(t.includes("[")&&(D.posix=!0,t.includes(":"))){let t=D.value.lastIndexOf("["),e=D.value.slice(0,t),i=a[D.value.slice(t+2)];if(i){D.value=e+i,N.backtrack=!0,W(),g.output||1!==y.indexOf(D)||(g.output=A);continue}}}("["===i&&":"!==U()||"-"===i&&"]"===U())&&(i=`\\${i}`),"]"===i&&("["===D.value||"[^"===D.value)&&(i=`\\${i}`),!0===d.posix&&"!"===i&&"["===D.value&&(i="^"),D.value+=i,H({value:i});continue}if(1===N.quotes&&'"'!==i){i=r.escapeRegex(i),D.value+=i,H({value:i});continue}if('"'===i){N.quotes=+(1!==N.quotes),!0===d.keepQuotes&&Y({type:"text",value:i});continue}if("("===i){X("parens"),Y({type:"paren",value:i});continue}if(")"===i){if(0===N.parens&&!0===d.strictBrackets)throw SyntaxError(c("opening","("));let t=F[F.length-1];if(t&&N.parens===t.parens+1){K(F.pop());continue}Y({type:"paren",value:i,output:N.parens?")":"\\)"}),Z("parens");continue}if("["===i){if(!0!==d.nobracket&&G().includes("]"))X("brackets");else{if(!0!==d.nobracket&&!0===d.strictBrackets)throw SyntaxError(c("closing","]"));i=`\\${i}`}Y({type:"bracket",value:i});continue}if("]"===i){if(!0===d.nobracket||D&&"bracket"===D.type&&1===D.value.length){Y({type:"text",value:i,output:`\\${i}`});continue}if(0===N.brackets){if(!0===d.strictBrackets)throw SyntaxError(c("opening","["));Y({type:"text",value:i,output:`\\${i}`});continue}Z("brackets");let t=D.value.slice(1);if(!0===D.posix||"^"!==t[0]||t.includes("/")||(i=`/${i}`),D.value+=i,H({value:i}),!1===d.literalBrackets||r.hasRegexChars(t))continue;let e=r.escapeRegex(D.value);if(N.output=N.output.slice(0,-D.value.length),!0===d.literalBrackets){N.output+=e,D.value=e;continue}D.value=`(${x}${e}|${D.value})`,N.output+=D.value;continue}if("{"===i&&!0!==d.nobrace){X("braces");let t={type:"brace",value:i,output:"(",outputIndex:N.output.length,tokensIndex:N.tokens.length};$.push(t),Y(t);continue}if("}"===i){let t=$[$.length-1];if(!0===d.nobrace||!t){Y({type:"text",value:i,output:i});continue}let e=")";if(!0===t.dots){let t=y.slice(),i=[];for(let e=t.length-1;e>=0&&(y.pop(),"brace"!==t[e].type);e--)"dots"!==t[e].type&&i.unshift(t[e].value);e=u(i,d),N.backtrack=!0}if(!0!==t.comma&&!0!==t.dots){let s=N.output.slice(0,t.outputIndex),r=N.tokens.slice(t.tokensIndex);for(let n of(t.value=t.output="\\{",i=e="\\}",N.output=s,r))N.output+=n.output||n.value}Y({type:"brace",value:i,output:e}),Z("braces"),$.pop();continue}if("|"===i){F.length>0&&F[F.length-1].conditions++,Y({type:"text",value:i});continue}if(","===i){let t=i,e=$[$.length-1];e&&"braces"===V[V.length-1]&&(e.comma=!0,t="|"),Y({type:"comma",value:i,output:t});continue}if("/"===i){if("dot"===D.type&&N.index===N.start+1){N.start=N.index+1,N.consumed="",N.output="",y.pop(),D=g;continue}Y({type:"slash",value:i,output:S});continue}if("."===i){if(N.braces>0&&"dot"===D.type){"."===D.value&&(D.output=w);let t=$[$.length-1];D.type="dots",D.output+=i,D.value+=i,t.dots=!0;continue}if(N.braces+N.parens===0&&"bos"!==D.type&&"slash"!==D.type){Y({type:"text",value:i,output:w});continue}Y({type:"dot",value:i,output:w});continue}if("?"===i){if(!(D&&"("===D.value)&&!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Q("qmark",i);continue}if(D&&"paren"===D.type){let t=U(),e=i;("("!==D.value||/[!=<:]/.test(t))&&("<"!==t||/<([!=]|\w+>)/.test(G()))||(e=`\\${i}`),Y({type:"text",value:i,output:e});continue}if(!0!==d.dot&&("slash"===D.type||"bos"===D.type)){Y({type:"qmark",value:i,output:k});continue}Y({type:"qmark",value:i,output:z});continue}if("!"===i){if(!0!==d.noextglob&&"("===U()&&("?"!==U(2)||!/[!=<:]/.test(U(3)))){Q("negate",i);continue}if(!0!==d.nonegate&&0===N.index){J();continue}}if("+"===i){if(!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Q("plus",i);continue}if(D&&"("===D.value||!1===d.regex){Y({type:"plus",value:i,output:M});continue}if(D&&("bracket"===D.type||"paren"===D.type||"brace"===D.type)||N.parens>0){Y({type:"plus",value:i});continue}Y({type:"plus",value:M});continue}if("@"===i){if(!0!==d.noextglob&&"("===U()&&"?"!==U(2)){Y({type:"at",extglob:!0,value:i,output:""});continue}Y({type:"text",value:i});continue}if("*"!==i){("$"===i||"^"===i)&&(i=`\\${i}`);let t=o.exec(G());t&&(i+=t[0],N.index+=t[0].length),Y({type:"text",value:i});continue}if(D&&("globstar"===D.type||!0===D.star)){D.type="star",D.star=!0,D.value+=i,D.output=L,N.backtrack=!0,N.globstar=!0,q(i);continue}let e=G();if(!0!==d.noextglob&&/^\([^?]/.test(e)){Q("star",i);continue}if("star"===D.type){if(!0===d.noglobstar){q(i);continue}let s=D.prev,r=s.prev,n="slash"===s.type||"bos"===s.type,a=r&&("star"===r.type||"globstar"===r.type);if(!0===d.bash&&(!n||e[0]&&"/"!==e[0])){Y({type:"star",value:i,output:""});continue}let o=N.braces>0&&("comma"===s.type||"brace"===s.type),h=F.length&&("pipe"===s.type||"paren"===s.type);if(!n&&"paren"!==s.type&&!o&&!h){Y({type:"star",value:i,output:""});continue}for(;"/**"===e.slice(0,3);){let i=t[N.index+4];if(i&&"/"!==i)break;e=e.slice(3),q("/**",3)}if("bos"===s.type&&j()){D.type="globstar",D.value+=i,D.output=O(d),N.output=D.output,N.globstar=!0,q(i);continue}if("slash"===s.type&&"bos"!==s.prev.type&&!a&&j()){N.output=N.output.slice(0,-(s.output+D.output).length),s.output=`(?:${s.output}`,D.type="globstar",D.output=O(d)+(d.strictSlashes?")":"|$)"),D.value+=i,N.globstar=!0,N.output+=s.output+D.output,q(i);continue}if("slash"===s.type&&"bos"!==s.prev.type&&"/"===e[0]){let t=void 0!==e[1]?"|$":"";N.output=N.output.slice(0,-(s.output+D.output).length),s.output=`(?:${s.output}`,D.type="globstar",D.output=`${O(d)}${S}|${S}${t})`,D.value+=i,N.output+=s.output+D.output,N.globstar=!0,q(i+W()),Y({type:"slash",value:"/",output:""});continue}if("bos"===s.type&&"/"===e[0]){D.type="globstar",D.value+=i,D.output=`(?:^|${S}|${O(d)}${S})`,N.output=D.output,N.globstar=!0,q(i+W()),Y({type:"slash",value:"/",output:""});continue}N.output=N.output.slice(0,-D.output.length),D.type="globstar",D.output=O(d),D.value+=i,N.output+=D.output,N.globstar=!0,q(i);continue}let s={type:"star",value:i,output:L};if(!0===d.bash){s.output=".*?",("bos"===D.type||"slash"===D.type)&&(s.output=E+s.output),Y(s);continue}if(D&&("bracket"===D.type||"paren"===D.type)&&!0===d.regex){s.output=i,Y(s);continue}(N.index===N.start||"slash"===D.type||"dot"===D.type)&&("dot"===D.type?(N.output+=T,D.output+=T):!0===d.dot?(N.output+=I,D.output+=I):(N.output+=E,D.output+=E),"*"!==U()&&(N.output+=A,D.output+=A)),Y(s)}for(;N.brackets>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing","]"));N.output=r.escapeLast(N.output,"["),Z("brackets")}for(;N.parens>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing",")"));N.output=r.escapeLast(N.output,"("),Z("parens")}for(;N.braces>0;){if(!0===d.strictBrackets)throw SyntaxError(c("closing","}"));N.output=r.escapeLast(N.output,"{"),Z("braces")}if(!0!==d.strictSlashes&&("star"===D.type||"bracket"===D.type)&&Y({type:"maybe_slash",value:"",output:`${S}?`}),!0===N.backtrack)for(let t of(N.output="",N.tokens))N.output+=null!=t.output?t.output:t.value,t.suffix&&(N.output+=t.suffix);return N};p.fastpaths=(t,e)=>{let i={...e},a="number"==typeof i.maxLength?Math.min(n,i.maxLength):n,o=t.length;if(o>a)throw SyntaxError(`Input length: ${o}, exceeds maximum allowed length: ${a}`);t=l[t]||t;let{DOT_LITERAL:h,SLASH_LITERAL:u,ONE_CHAR:c,DOTS_SLASH:p,NO_DOT:d,NO_DOTS:m,NO_DOTS_SLASH:f,STAR:g,START_ANCHOR:y}=s.globChars(i.windows),x=i.dot?m:d,b=i.dot?f:d,v=i.capture?"":"?:",w=!0===i.bash?".*?":g;i.capture&&(w=`(${w})`);let M=t=>!0===t.noglobstar?w:`(${v}(?:(?!${y}${t.dot?p:h}).)*?)`,S=t=>{switch(t){case"*":return`${x}${c}${w}`;case".*":return`${h}${c}${w}`;case"*.*":return`${x}${w}${h}${c}${w}`;case"*/*":return`${x}${w}${u}${c}${b}${w}`;case"**":return x+M(i);case"**/*":return`(?:${x}${M(i)}${u})?${b}${c}${w}`;case"**/*.*":return`(?:${x}${M(i)}${u})?${b}${w}${h}${c}${w}`;case"**/.*":return`(?:${x}${M(i)}${u})?${h}${c}${w}`;default:{let e=/^(.*?)\.(\w+)$/.exec(t);if(!e)return;let i=S(e[1]);if(!i)return;return i+h+e[2]}}},A=S(r.removePrefix(t,{negated:!1,prefix:""}));return A&&!0!==i.strictSlashes&&(A+=`${u}?`),A},e.exports=p},53174,(t,e,i)=>{"use strict";let s=t.r(26094),r=t.r(17932),n=t.r(19241),a=t.r(53487),o=(t,e,i=!1)=>{if(Array.isArray(t)){let s=t.map(t=>o(t,e,i));return t=>{for(let e of s){let i=e(t);if(i)return i}return!1}}let s=t&&"object"==typeof t&&!Array.isArray(t)&&t.tokens&&t.input;if(""===t||"string"!=typeof t&&!s)throw TypeError("Expected pattern to be a non-empty string");let r=e||{},n=r.windows,a=s?o.compileRe(t,e):o.makeRe(t,e,!1,!0),h=a.state;delete a.state;let l=()=>!1;if(r.ignore){let t={...e,ignore:null,onMatch:null,onResult:null};l=o(r.ignore,t,i)}let u=(i,s=!1)=>{let{isMatch:u,match:c,output:p}=o.test(i,a,e,{glob:t,posix:n}),d={glob:t,state:h,regex:a,posix:n,input:i,output:p,match:c,isMatch:u};return("function"==typeof r.onResult&&r.onResult(d),!1===u)?(d.isMatch=!1,!!s&&d):l(i)?("function"==typeof r.onIgnore&&r.onIgnore(d),d.isMatch=!1,!!s&&d):("function"==typeof r.onMatch&&r.onMatch(d),!s||d)};return i&&(u.state=h),u};o.test=(t,e,i,{glob:s,posix:r}={})=>{if("string"!=typeof t)throw TypeError("Expected input to be a string");if(""===t)return{isMatch:!1,output:""};let a=i||{},h=a.format||(r?n.toPosixSlashes:null),l=t===s,u=l&&h?h(t):t;return!1===l&&(l=(u=h?h(t):t)===s),(!1===l||!0===a.capture)&&(l=!0===a.matchBase||!0===a.basename?o.matchBase(t,e,i,r):e.exec(u)),{isMatch:!!l,match:l,output:u}},o.matchBase=(t,e,i)=>(e instanceof RegExp?e:o.makeRe(e,i)).test(n.basename(t)),o.isMatch=(t,e,i)=>o(e,i)(t),o.parse=(t,e)=>Array.isArray(t)?t.map(t=>o.parse(t,e)):r(t,{...e,fastpaths:!1}),o.scan=(t,e)=>s(t,e),o.compileRe=(t,e,i=!1,s=!1)=>{if(!0===i)return t.output;let r=e||{},n=r.contains?"":"^",a=r.contains?"":"$",h=`${n}(?:${t.output})${a}`;t&&!0===t.negated&&(h=`^(?!${h}).*$`);let l=o.toRegex(h,e);return!0===s&&(l.state=t),l},o.makeRe=(t,e={},i=!1,s=!1)=>{if(!t||"string"!=typeof t)throw TypeError("Expected a non-empty string");let n={negated:!1,fastpaths:!0};return!1!==e.fastpaths&&("."===t[0]||"*"===t[0])&&(n.output=r.fastpaths(t,e)),n.output||(n=r(t,e)),o.compileRe(n,e,i,s)},o.toRegex=(t,e)=>{try{let i=e||{};return new RegExp(t,i.flags||(i.nocase?"i":""))}catch(t){if(e&&!0===e.debug)throw t;return/$^/}},o.constants=a,e.exports=o},54970,(t,e,i)=>{"use strict";let s=t.r(53174),r=t.r(19241);function n(t,e,i=!1){return e&&(null===e.windows||void 0===e.windows)&&(e={...e,windows:r.isWindows()}),s(t,e,i)}Object.assign(n,s),e.exports=n},98223,71726,91996,t=>{"use strict";function e(t){return t.split(/(?:\r\n|\r|\n)/g).map(t=>t.trim()).filter(Boolean).filter(t=>!t.startsWith(";")).map(t=>{let e=t.match(/^(.+)\s(\d+)$/);if(!e)return{name:t,frameCount:1};{let t=parseInt(e[2],10);return{name:e[1],frameCount:t}}})}t.s(["parseImageFileList",()=>e],98223);var i=t.i(87447);function s(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/")}t.s(["normalizePath",()=>s],71726);let r=i.default;function n(t){return s(t).toLowerCase()}function a(){return r.resources}function o(t){let[e,...i]=r.resources[t],[s,n]=i[i.length-1];return[s,n??e]}function h(t){let e=n(t);if(r.resources[e])return e;let i=e.replace(/\d+(\.(png))$/i,"$1");if(r.resources[i])return i;throw Error(`Resource not found in manifest: ${t}`)}function l(){return Object.keys(r.resources)}let u=["",".jpg",".png",".gif",".bmp"];function c(t){let e=n(t);for(let t of u){let i=`${e}${t}`;if(r.resources[i])return i}return e}function p(t){let e=r.missions[t];if(!e)throw Error(`Mission not found: ${t}`);return e}function d(){return Object.keys(r.missions)}let m=new Map(Object.keys(r.missions).map(t=>[t.toLowerCase(),t]));function f(t){let e=t.replace(/-/g,"_").toLowerCase();return m.get(e)??null}t.s(["findMissionByDemoName",()=>f,"getActualResourceKey",()=>h,"getMissionInfo",()=>p,"getMissionList",()=>d,"getResourceKey",()=>n,"getResourceList",()=>l,"getResourceMap",()=>a,"getSourceAndPath",()=>o,"getStandardTextureResourceKey",()=>c],91996)},92552,(t,e,i)=>{"use strict";let s,r;function n(t,e){return e.reduce((t,[e,i])=>({type:"BinaryExpression",operator:e,left:t,right:i}),t)}function a(t,e){return{type:"UnaryExpression",operator:t,argument:e}}class o extends SyntaxError{constructor(t,e,i,s){super(t),this.expected=e,this.found=i,this.location=s,this.name="SyntaxError"}format(t){let e="Error: "+this.message;if(this.location){let i=null,s=t.find(t=>t.source===this.location.source);s&&(i=s.text.split(/\r\n|\n|\r/g));let r=this.location.start,n=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(r):r,a=this.location.source+":"+n.line+":"+n.column;if(i){let t=this.location.end,s="".padEnd(n.line.toString().length," "),o=i[r.line-1],h=(r.line===t.line?t.column:o.length+1)-r.column||1;e+="\n --> "+a+"\n"+s+" |\n"+n.line+" | "+o+"\n"+s+" | "+"".padEnd(r.column-1," ")+"".padEnd(h,"^")}else e+="\n at "+a}return e}static buildMessage(t,e){function i(t){return t.codePointAt(0).toString(16).toUpperCase()}let s=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function r(t){return s?t.replace(s,t=>"\\u{"+i(t)+"}"):t}function n(t){return r(t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+i(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+i(t)))}function a(t){return r(t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+i(t)).replace(/[\x10-\x1F\x7F-\x9F]/g,t=>"\\x"+i(t)))}let o={literal:t=>'"'+n(t.text)+'"',class(t){let e=t.parts.map(t=>Array.isArray(t)?a(t[0])+"-"+a(t[1]):a(t));return"["+(t.inverted?"^":"")+e.join("")+"]"+(t.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:t=>t.description};function h(t){return o[t.type](t)}return"Expected "+function(t){let e=t.map(h);if(e.sort(),e.length>0){let t=1;for(let i=1;i]/,I=/^[+\-]/,z=/^[%*\/]/,k=/^[!\-~]/,B=/^[a-zA-Z_]/,R=/^[a-zA-Z0-9_]/,O=/^[ \t]/,E=/^[^"\\\n\r]/,P=/^[^'\\\n\r]/,L=/^[0-9a-fA-F]/,N=/^[0-9]/,F=/^[xX]/,$=/^[^\n\r]/,V=/^[\n\r]/,D=/^[ \t\n\r]/,j=eC(";",!1),U=eC("package",!1),W=eC("{",!1),G=eC("}",!1),q=eC("function",!1),H=eC("(",!1),J=eC(")",!1),X=eC("::",!1),Z=eC(",",!1),Y=eC("datablock",!1),Q=eC(":",!1),K=eC("new",!1),tt=eC("[",!1),te=eC("]",!1),ti=eC("=",!1),ts=eC(".",!1),tr=eC("if",!1),tn=eC("else",!1),ta=eC("for",!1),to=eC("while",!1),th=eC("do",!1),tl=eC("switch$",!1),tu=eC("switch",!1),tc=eC("case",!1),tp=eC("default",!1),td=eC("or",!1),tm=eC("return",!1),tf=eC("break",!1),tg=eC("continue",!1),ty=eC("+=",!1),tx=eC("-=",!1),tb=eC("*=",!1),tv=eC("/=",!1),tw=eC("%=",!1),tM=eC("<<=",!1),tS=eC(">>=",!1),tA=eC("&=",!1),t_=eC("|=",!1),tC=eC("^=",!1),tT=eC("?",!1),tI=eC("||",!1),tz=eC("&&",!1),tk=eC("|",!1),tB=eC("^",!1),tR=eC("&",!1),tO=eC("==",!1),tE=eC("!=",!1),tP=eC("<=",!1),tL=eC(">=",!1),tN=eT(["<",">"],!1,!1,!1),tF=eC("$=",!1),t$=eC("!$=",!1),tV=eC("@",!1),tD=eC("NL",!1),tj=eC("TAB",!1),tU=eC("SPC",!1),tW=eC("<<",!1),tG=eC(">>",!1),tq=eT(["+","-"],!1,!1,!1),tH=eT(["%","*","/"],!1,!1,!1),tJ=eT(["!","-","~"],!1,!1,!1),tX=eC("++",!1),tZ=eC("--",!1),tY=eC("*",!1),tQ=eC("%",!1),tK=eT([["a","z"],["A","Z"],"_"],!1,!1,!1),t0=eT([["a","z"],["A","Z"],["0","9"],"_"],!1,!1,!1),t1=eC("$",!1),t2=eC("parent",!1),t3=eT([" "," "],!1,!1,!1),t5=eC('"',!1),t4=eC("'",!1),t6=eC("\\",!1),t8=eT(['"',"\\","\n","\r"],!0,!1,!1),t9=eT(["'","\\","\n","\r"],!0,!1,!1),t7=eC("n",!1),et=eC("r",!1),ee=eC("t",!1),ei=eC("x",!1),es=eT([["0","9"],["a","f"],["A","F"]],!1,!1,!1),er=eC("cr",!1),en=eC("cp",!1),ea=eC("co",!1),eo=eC("c",!1),eh=eT([["0","9"]],!1,!1,!1),el={type:"any"},eu=eC("0",!1),ec=eT(["x","X"],!1,!1,!1),ep=eC("-",!1),ed=eC("true",!1),em=eC("false",!1),ef=eC("//",!1),eg=eT(["\n","\r"],!0,!1,!1),ey=eT(["\n","\r"],!1,!1,!1),ex=eC("/*",!1),eb=eC("*/",!1),ev=eT([" "," ","\n","\r"],!1,!1,!1),ew=0|e.peg$currPos,eM=[{line:1,column:1}],eS=ew,eA=e.peg$maxFailExpected||[],e_=0|e.peg$silentFails;if(e.startRule){if(!(e.startRule in u))throw Error("Can't start parsing from rule \""+e.startRule+'".');c=u[e.startRule]}function eC(t,e){return{type:"literal",text:t,ignoreCase:e}}function eT(t,e,i,s){return{type:"class",parts:t,inverted:e,ignoreCase:i,unicode:s}}function eI(e){let i,s=eM[e];if(s)return s;if(e>=eM.length)i=eM.length-1;else for(i=e;!eM[--i];);for(s={line:(s=eM[i]).line,column:s.column};ieS&&(eS=ew,eA=[]),eA.push(t))}function eB(){let t,e,i;for(ip(),t=[],e=ew,(i=il())===h&&(i=eR()),i!==h?e=i=[i,ip()]:(ew=e,e=h);e!==h;)t.push(e),e=ew,(i=il())===h&&(i=eR()),i!==h?e=i=[i,ip()]:(ew=e,e=h);return{type:"Program",body:t.map(([t])=>t).filter(Boolean),execScriptPaths:Array.from(s),hasDynamicExec:r}}function eR(){let e,i,s,r,n,a,o,l,u,c,m,b,v,A,_,C,T;return(e=function(){let e,i,s,r,n,a,o,l;if(e=ew,t.substr(ew,7)===p?(i=p,ew+=7):(i=h,0===e_&&ek(U)),i!==h)if(ic()!==h)if((s=is())!==h)if(iu(),123===t.charCodeAt(ew)?(r="{",ew++):(r=h,0===e_&&ek(W)),r!==h){for(ip(),n=[],a=ew,(o=il())===h&&(o=eR()),o!==h?a=o=[o,l=ip()]:(ew=a,a=h);a!==h;)n.push(a),a=ew,(o=il())===h&&(o=eR()),o!==h?a=o=[o,l=ip()]:(ew=a,a=h);(125===t.charCodeAt(ew)?(a="}",ew++):(a=h,0===e_&&ek(G)),a!==h)?(o=iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),e={type:"PackageDeclaration",name:s,body:n.map(([t])=>t).filter(Boolean)}):(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o;if(e=ew,t.substr(ew,8)===d?(i=d,ew+=8):(i=h,0===e_&&ek(q)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r;if(e=ew,(i=is())!==h)if("::"===t.substr(ew,2)?(s="::",ew+=2):(s=h,0===e_&&ek(X)),s!==h)if((r=is())!==h)e={type:"MethodName",namespace:i,method:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=is()),e}())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=function(){let e,i,s,r,n,a,o,l;if(e=ew,(i=is())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=is())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=is())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=[i,...s.map(([,,,t])=>t)]}else ew=e,e=h;return e}())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h)if(iu(),(o=eD())!==h)e={type:"FunctionDeclaration",name:s,params:n||[],body:o};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&((s=ew,(r=eO())!==h)?(iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n===h&&(n=null),iu(),s=r):(ew=s,s=h),(e=s)===h&&((a=ew,(o=eE())!==h)?(iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),iu(),a=o):(ew=a,a=h),(e=a)===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c,p;if(e=ew,"if"===t.substr(ew,2)?(i="if",ew+=2):(i=h,0===e_&&ek(tr)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),(a=eR())!==h){var d;o=ew,l=iu(),t.substr(ew,4)===f?(u=f,ew+=4):(u=h,0===e_&&ek(tn)),u!==h?(c=iu(),(p=eR())!==h?o=l=[l,u,c,p]:(ew=o,o=h)):(ew=o,o=h),o===h&&(o=null),e={type:"IfStatement",test:r,consequent:a,alternate:(d=o)?d[3]:null}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c;if(e=ew,"for"===t.substr(ew,3)?(i="for",ew+=3):(i=h,0===e_&&ek(ta)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())===h&&(r=null),iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n!==h)if(iu(),(a=ej())===h&&(a=null),iu(),59===t.charCodeAt(ew)?(o=";",ew++):(o=h,0===e_&&ek(j)),o!==h)if(iu(),(l=ej())===h&&(l=null),iu(),41===t.charCodeAt(ew)?(u=")",ew++):(u=h,0===e_&&ek(J)),u!==h)if(iu(),(c=eR())!==h){var p,d;p=r,d=a,e={type:"ForStatement",init:p,test:d,update:l,body:c}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l;if(e=ew,"do"===t.substr(ew,2)?(i="do",ew+=2):(i=h,0===e_&&ek(th)),i!==h)if(iu(),(s=eR())!==h)if(iu(),t.substr(ew,5)===g?(r=g,ew+=5):(r=h,0===e_&&ek(to)),r!==h)if(iu(),40===t.charCodeAt(ew)?(n="(",ew++):(n=h,0===e_&&ek(H)),n!==h)if(iu(),(a=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(o=")",ew++):(o=h,0===e_&&ek(J)),o!==h)iu(),59===t.charCodeAt(ew)?(l=";",ew++):(l=h,0===e_&&ek(j)),l===h&&(l=null),e={type:"DoWhileStatement",test:a,body:s};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a;if(e=ew,t.substr(ew,5)===g?(i=g,ew+=5):(i=h,0===e_&&ek(to)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),(a=eR())!==h)e={type:"WhileStatement",test:r,body:a};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o,l,u,c;if(e=ew,t.substr(ew,7)===y?(i=y,ew+=7):(i=h,0===e_&&ek(tl)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),123===t.charCodeAt(ew)?(a="{",ew++):(a=h,0===e_&&ek(W)),a!==h){for(ip(),o=[],l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);l!==h;)o.push(l),l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);(125===t.charCodeAt(ew)?(l="}",ew++):(l=h,0===e_&&ek(G)),l!==h)?e={type:"SwitchStatement",stringMode:!0,discriminant:r,cases:o.map(([t])=>t).filter(t=>t&&"SwitchCase"===t.type)}:(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;if(e===h)if(e=ew,t.substr(ew,6)===x?(i=x,ew+=6):(i=h,0===e_&&ek(tu)),i!==h)if(iu(),40===t.charCodeAt(ew)?(s="(",ew++):(s=h,0===e_&&ek(H)),s!==h)if(iu(),(r=ej())!==h)if(iu(),41===t.charCodeAt(ew)?(n=")",ew++):(n=h,0===e_&&ek(J)),n!==h)if(iu(),123===t.charCodeAt(ew)?(a="{",ew++):(a=h,0===e_&&ek(W)),a!==h){for(ip(),o=[],l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);l!==h;)o.push(l),l=ew,(u=il())===h&&(u=eV()),u!==h?l=u=[u,c=ip()]:(ew=l,l=h);(125===t.charCodeAt(ew)?(l="}",ew++):(l=h,0===e_&&ek(G)),l!==h)?e={type:"SwitchStatement",stringMode:!1,discriminant:r,cases:o.map(([t])=>t).filter(t=>t&&"SwitchCase"===t.type)}:(ew=e,e=h)}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n;if(e=ew,t.substr(ew,6)===w?(i=w,ew+=6):(i=h,0===e_&&ek(tm)),i!==h)if(s=ew,(r=ic())!==h&&(n=ej())!==h?s=r=[r,n]:(ew=s,s=h),s===h&&(s=null),r=iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n!==h){var a;e={type:"ReturnStatement",value:(a=s)?a[1]:null}}else ew=e,e=h;else ew=e,e=h;return e}())===h&&(u=ew,t.substr(ew,5)===M?(c=M,ew+=5):(c=h,0===e_&&ek(tf)),c!==h?(iu(),59===t.charCodeAt(ew)?(m=";",ew++):(m=h,0===e_&&ek(j)),m!==h?u={type:"BreakStatement"}:(ew=u,u=h)):(ew=u,u=h),(e=u)===h&&(b=ew,t.substr(ew,8)===S?(v=S,ew+=8):(v=h,0===e_&&ek(tg)),v!==h?(iu(),59===t.charCodeAt(ew)?(A=";",ew++):(A=h,0===e_&&ek(j)),A!==h?b={type:"ContinueStatement"}:(ew=b,b=h)):(ew=b,b=h),(e=b)===h&&((_=ew,(C=ej())!==h&&(iu(),59===t.charCodeAt(ew)?(T=";",ew++):(T=h,0===e_&&ek(j)),T!==h))?_={type:"ExpressionStatement",expression:C}:(ew=_,_=h),(e=_)===h&&(e=eD())===h&&(e=il())===h)))))&&(e=ew,iu(),59===t.charCodeAt(ew)?(i=";",ew++):(i=h,0===e_&&ek(j)),i!==h?(iu(),e=null):(ew=e,e=h)),e}function eO(){let e,i,s,r,n,a,o,l,u,c,p,d,f,g;if(e=ew,t.substr(ew,9)===m?(i=m,ew+=9):(i=h,0===e_&&ek(Y)),i!==h)if(ic()!==h)if((s=is())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=eL())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h){var y,x,b;if(iu(),o=ew,58===t.charCodeAt(ew)?(l=":",ew++):(l=h,0===e_&&ek(Q)),l!==h?(u=iu(),(c=is())!==h?o=l=[l,u,c]:(ew=o,o=h)):(ew=o,o=h),o===h&&(o=null),l=iu(),u=ew,123===t.charCodeAt(ew)?(c="{",ew++):(c=h,0===e_&&ek(W)),c!==h){for(p=iu(),d=[],f=eP();f!==h;)d.push(f),f=eP();f=iu(),125===t.charCodeAt(ew)?(g="}",ew++):(g=h,0===e_&&ek(G)),g!==h?u=c=[c,p,d,f,g,iu()]:(ew=u,u=h)}else ew=u,u=h;u===h&&(u=null),y=n,x=o,b=u,e={type:"DatablockDeclaration",className:s,instanceName:y,parent:x?x[2]:null,body:b?b[2].filter(Boolean):[]}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}function eE(){let e,i,s,r,n,a,o,l,u,c,p,d;if(e=ew,"new"===t.substr(ew,3)?(i="new",ew+=3):(i=h,0===e_&&ek(K)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r,n,a,o,l,u,c;if((e=ew,40===t.charCodeAt(ew)?(i="(",ew++):(i=h,0===e_&&ek(H)),i!==h&&(s=iu(),(r=ej())!==h&&(n=iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h)))?e=r:(ew=e,e=h),e===h)if(e=ew,(i=is())!==h){var p;for(s=[],r=ew,n=iu(),91===t.charCodeAt(ew)?(a="[",ew++):(a=h,0===e_&&ek(tt)),a!==h?(o=iu(),(l=e$())!==h?(u=iu(),93===t.charCodeAt(ew)?(c="]",ew++):(c=h,0===e_&&ek(te)),c!==h?r=n=[n,a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),91===t.charCodeAt(ew)?(a="[",ew++):(a=h,0===e_&&ek(tt)),a!==h?(o=iu(),(l=e$())!==h?(u=iu(),93===t.charCodeAt(ew)?(c="]",ew++):(c=h,0===e_&&ek(te)),c!==h?r=n=[n,a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);p=i,e=s.reduce((t,[,,,e])=>({type:"IndexExpression",object:t,index:e}),p)}else ew=e,e=h;return e}())!==h)if(iu(),40===t.charCodeAt(ew)?(r="(",ew++):(r=h,0===e_&&ek(H)),r!==h)if(iu(),(n=eL())===h&&(n=null),iu(),41===t.charCodeAt(ew)?(a=")",ew++):(a=h,0===e_&&ek(J)),a!==h){var m;if(iu(),o=ew,123===t.charCodeAt(ew)?(l="{",ew++):(l=h,0===e_&&ek(W)),l!==h){for(u=iu(),c=[],p=eP();p!==h;)c.push(p),p=eP();p=iu(),125===t.charCodeAt(ew)?(d="}",ew++):(d=h,0===e_&&ek(G)),d!==h?o=l=[l,u,c,p,d,iu()]:(ew=o,o=h)}else ew=o,o=h;o===h&&(o=null),e={type:"ObjectDeclaration",className:s,instanceName:n,body:(m=o)?m[2].filter(Boolean):[]}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}function eP(){let e,i,s;return(e=ew,(i=eE())!==h)?(iu(),59===t.charCodeAt(ew)?(s=";",ew++):(s=h,0===e_&&ek(j)),s===h&&(s=null),iu(),e=i):(ew=e,e=h),e===h&&((e=ew,(i=eO())!==h)?(iu(),59===t.charCodeAt(ew)?(s=";",ew++):(s=h,0===e_&&ek(j)),s===h&&(s=null),iu(),e=i):(ew=e,e=h),e===h&&(e=function(){let e,i,s,r,n;if(e=ew,iu(),(i=eN())!==h)if(iu(),61===t.charCodeAt(ew)?(s="=",ew++):(s=h,0===e_&&ek(ti)),s!==h)if(iu(),(r=ej())!==h)iu(),59===t.charCodeAt(ew)?(n=";",ew++):(n=h,0===e_&&ek(j)),n===h&&(n=null),iu(),e={type:"Assignment",target:i,value:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e}())===h&&(e=il())===h&&(e=function(){let e,i;if(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i!==h)for(;i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));else e=h;return e!==h&&(e=null),e}())),e}function eL(){let t;return(t=eK())===h&&(t=is())===h&&(t=ih()),t}function eN(){let t,e,i,s;if(t=ew,(e=e9())!==h){for(i=[],s=eF();s!==h;)i.push(s),s=eF();t=i.reduce((t,e)=>"property"===e.type?{type:"MemberExpression",object:t,property:e.value}:{type:"IndexExpression",object:t,index:e.value},e)}else ew=t,t=h;return t}function eF(){let e,i,s,r;return(e=ew,46===t.charCodeAt(ew)?(i=".",ew++):(i=h,0===e_&&ek(ts)),i!==h&&(iu(),(s=is())!==h))?e={type:"property",value:s}:(ew=e,e=h),e===h&&((e=ew,91===t.charCodeAt(ew)?(i="[",ew++):(i=h,0===e_&&ek(tt)),i!==h&&(iu(),(s=e$())!==h&&(iu(),93===t.charCodeAt(ew)?(r="]",ew++):(r=h,0===e_&&ek(te)),r!==h)))?e={type:"index",value:s}:(ew=e,e=h)),e}function e$(){let e,i,s,r,n,a,o,l;if(e=ew,(i=ej())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=s.length>0?[i,...s.map(([,,,t])=>t)]:i}else ew=e,e=h;return e}function eV(){let e,i,s,r,n,a,o,l,u;if(e=ew,t.substr(ew,4)===b?(i=b,ew+=4):(i=h,0===e_&&ek(tc)),i!==h)if(ic()!==h)if((s=function(){let e,i,s,r,n,a,o,l;if(e=ew,(i=e5())!==h){for(s=[],r=ew,n=iu(),"or"===t.substr(ew,2)?(a="or",ew+=2):(a=h,0===e_&&ek(td)),a!==h&&(o=ic())!==h&&(l=e5())!==h?r=n=[n,a,o,l]:(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),"or"===t.substr(ew,2)?(a="or",ew+=2):(a=h,0===e_&&ek(td)),a!==h&&(o=ic())!==h&&(l=e5())!==h?r=n=[n,a,o,l]:(ew=r,r=h);e=s.length>0?[i,...s.map(([,,,t])=>t)]:i}else ew=e,e=h;return e}())!==h)if(iu(),58===t.charCodeAt(ew)?(r=":",ew++):(r=h,0===e_&&ek(Q)),r!==h){for(n=ip(),a=[],o=ew,(l=il())===h&&(l=eR()),l!==h?o=l=[l,u=ip()]:(ew=o,o=h);o!==h;)a.push(o),o=ew,(l=il())===h&&(l=eR()),l!==h?o=l=[l,u=ip()]:(ew=o,o=h);e={type:"SwitchCase",test:s,consequent:a.map(([t])=>t).filter(Boolean)}}else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;if(e===h)if(e=ew,t.substr(ew,7)===v?(i=v,ew+=7):(i=h,0===e_&&ek(tp)),i!==h)if(iu(),58===t.charCodeAt(ew)?(s=":",ew++):(s=h,0===e_&&ek(Q)),s!==h){for(ip(),r=[],n=ew,(a=il())===h&&(a=eR()),a!==h?n=a=[a,o=ip()]:(ew=n,n=h);n!==h;)r.push(n),n=ew,(a=il())===h&&(a=eR()),a!==h?n=a=[a,o=ip()]:(ew=n,n=h);e={type:"SwitchCase",test:null,consequent:r.map(([t])=>t).filter(Boolean)}}else ew=e,e=h;else ew=e,e=h;return e}function eD(){let e,i,s,r,n,a;if(e=ew,123===t.charCodeAt(ew)?(i="{",ew++):(i=h,0===e_&&ek(W)),i!==h){for(ip(),s=[],r=ew,(n=il())===h&&(n=eR()),n!==h?r=n=[n,a=ip()]:(ew=r,r=h);r!==h;)s.push(r),r=ew,(n=il())===h&&(n=eR()),n!==h?r=n=[n,a=ip()]:(ew=r,r=h);(125===t.charCodeAt(ew)?(r="}",ew++):(r=h,0===e_&&ek(G)),r!==h)?e={type:"BlockStatement",body:s.map(([t])=>t).filter(Boolean)}:(ew=e,e=h)}else ew=e,e=h;return e}function ej(){let e,i,s,r;if(e=ew,(i=eN())!==h)if(iu(),(s=eU())!==h)if(iu(),(r=ej())!==h)e={type:"AssignmentExpression",operator:s,target:i,value:r};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=function(){let e,i,s,r,n,a;if(e=ew,(i=eW())!==h)if(iu(),63===t.charCodeAt(ew)?(s="?",ew++):(s=h,0===e_&&ek(tT)),s!==h)if(iu(),(r=ej())!==h)if(iu(),58===t.charCodeAt(ew)?(n=":",ew++):(n=h,0===e_&&ek(Q)),n!==h)if(iu(),(a=ej())!==h)e={type:"ConditionalExpression",test:i,consequent:r,alternate:a};else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;else ew=e,e=h;return e===h&&(e=eW()),e}()),e}function eU(){let e;return 61===t.charCodeAt(ew)?(e="=",ew++):(e=h,0===e_&&ek(ti)),e===h&&("+="===t.substr(ew,2)?(e="+=",ew+=2):(e=h,0===e_&&ek(ty)),e===h&&("-="===t.substr(ew,2)?(e="-=",ew+=2):(e=h,0===e_&&ek(tx)),e===h&&("*="===t.substr(ew,2)?(e="*=",ew+=2):(e=h,0===e_&&ek(tb)),e===h&&("/="===t.substr(ew,2)?(e="/=",ew+=2):(e=h,0===e_&&ek(tv)),e===h&&("%="===t.substr(ew,2)?(e="%=",ew+=2):(e=h,0===e_&&ek(tw)),e===h&&("<<="===t.substr(ew,3)?(e="<<=",ew+=3):(e=h,0===e_&&ek(tM)),e===h&&(">>="===t.substr(ew,3)?(e=">>=",ew+=3):(e=h,0===e_&&ek(tS)),e===h&&("&="===t.substr(ew,2)?(e="&=",ew+=2):(e=h,0===e_&&ek(tA)),e===h&&("|="===t.substr(ew,2)?(e="|=",ew+=2):(e=h,0===e_&&ek(t_)),e===h&&("^="===t.substr(ew,2)?(e="^=",ew+=2):(e=h,0===e_&&ek(tC)))))))))))),e}function eW(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eG())!==h){for(s=[],r=ew,a=iu(),"||"===t.substr(ew,2)?(o="||",ew+=2):(o=h,0===e_&&ek(tI)),o!==h?(l=iu(),(u=eG())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),"||"===t.substr(ew,2)?(o="||",ew+=2):(o=h,0===e_&&ek(tI)),o!==h?(l=iu(),(u=eG())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eG(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eq())!==h){for(s=[],r=ew,a=iu(),"&&"===t.substr(ew,2)?(o="&&",ew+=2):(o=h,0===e_&&ek(tz)),o!==h?(l=iu(),(u=eq())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),"&&"===t.substr(ew,2)?(o="&&",ew+=2):(o=h,0===e_&&ek(tz)),o!==h?(l=iu(),(u=eq())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eq(){let e,i,s,r,a,o,l,u,c;if(e=ew,(i=eH())!==h){for(s=[],r=ew,a=iu(),124===t.charCodeAt(ew)?(o="|",ew++):(o=h,0===e_&&ek(tk)),o!==h?(l=ew,e_++,124===t.charCodeAt(ew)?(u="|",ew++):(u=h,0===e_&&ek(tk)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eH())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),124===t.charCodeAt(ew)?(o="|",ew++):(o=h,0===e_&&ek(tk)),o!==h?(l=ew,e_++,124===t.charCodeAt(ew)?(u="|",ew++):(u=h,0===e_&&ek(tk)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eH())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,,e])=>[t,e]))}else ew=e,e=h;return e}function eH(){let e,i,s,r,a,o,l,u;if(e=ew,(i=eJ())!==h){for(s=[],r=ew,a=iu(),94===t.charCodeAt(ew)?(o="^",ew++):(o=h,0===e_&&ek(tB)),o!==h?(l=iu(),(u=eJ())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),94===t.charCodeAt(ew)?(o="^",ew++):(o=h,0===e_&&ek(tB)),o!==h?(l=iu(),(u=eJ())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function eJ(){let e,i,s,r,a,o,l,u,c;if(e=ew,(i=eX())!==h){for(s=[],r=ew,a=iu(),38===t.charCodeAt(ew)?(o="&",ew++):(o=h,0===e_&&ek(tR)),o!==h?(l=ew,e_++,38===t.charCodeAt(ew)?(u="&",ew++):(u=h,0===e_&&ek(tR)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eX())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),38===t.charCodeAt(ew)?(o="&",ew++):(o=h,0===e_&&ek(tR)),o!==h?(l=ew,e_++,38===t.charCodeAt(ew)?(u="&",ew++):(u=h,0===e_&&ek(tR)),e_--,u===h?l=void 0:(ew=l,l=h),l!==h?(u=iu(),(c=eX())!==h?r=a=[a,o,l,u,c]:(ew=r,r=h)):(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,,e])=>[t,e]))}else ew=e,e=h;return e}function eX(){let t,e,i,s,r,a,o,l;if(t=ew,(e=eY())!==h){for(i=[],s=ew,r=iu(),(a=eZ())!==h?(o=iu(),(l=eY())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=eZ())!==h?(o=iu(),(l=eY())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function eZ(){let e;return"=="===t.substr(ew,2)?(e="==",ew+=2):(e=h,0===e_&&ek(tO)),e===h&&("!="===t.substr(ew,2)?(e="!=",ew+=2):(e=h,0===e_&&ek(tE))),e}function eY(){let t,e,i,s,r,a,o,l;if(t=ew,(e=eK())!==h){for(i=[],s=ew,r=iu(),(a=eQ())!==h?(o=iu(),(l=eK())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=eQ())!==h?(o=iu(),(l=eK())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function eQ(){let e;return"<="===t.substr(ew,2)?(e="<=",ew+=2):(e=h,0===e_&&ek(tP)),e===h&&(">="===t.substr(ew,2)?(e=">=",ew+=2):(e=h,0===e_&&ek(tL)),e===h&&(e=t.charAt(ew),T.test(e)?ew++:(e=h,0===e_&&ek(tN)))),e}function eK(){let t,e,i,s,r,a,o,l;if(t=ew,(e=e2())!==h){for(i=[],s=ew,r=iu(),(a=e1())!==h?(o=iu(),(l=e0())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=e1())!==h?(o=iu(),(l=e0())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function e0(){let t,e,i,s;if(t=ew,(e=eN())!==h)if(iu(),(i=eU())!==h)if(iu(),(s=ej())!==h)t={type:"AssignmentExpression",operator:i,target:e,value:s};else ew=t,t=h;else ew=t,t=h;else ew=t,t=h;return t===h&&(t=e2()),t}function e1(){let e;return"$="===t.substr(ew,2)?(e="$=",ew+=2):(e=h,0===e_&&ek(tF)),e===h&&("!$="===t.substr(ew,3)?(e="!$=",ew+=3):(e=h,0===e_&&ek(t$)),e===h&&(64===t.charCodeAt(ew)?(e="@",ew++):(e=h,0===e_&&ek(tV)),e===h&&("NL"===t.substr(ew,2)?(e="NL",ew+=2):(e=h,0===e_&&ek(tD)),e===h&&("TAB"===t.substr(ew,3)?(e="TAB",ew+=3):(e=h,0===e_&&ek(tj)),e===h&&("SPC"===t.substr(ew,3)?(e="SPC",ew+=3):(e=h,0===e_&&ek(tU))))))),e}function e2(){let t,e,i,s,r,a,o,l;if(t=ew,(e=e5())!==h){for(i=[],s=ew,r=iu(),(a=e3())!==h?(o=iu(),(l=e5())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);s!==h;)i.push(s),s=ew,r=iu(),(a=e3())!==h?(o=iu(),(l=e5())!==h?s=r=[r,a,o,l]:(ew=s,s=h)):(ew=s,s=h);t=n(e,i.map(([,t,,e])=>[t,e]))}else ew=t,t=h;return t}function e3(){let e;return"<<"===t.substr(ew,2)?(e="<<",ew+=2):(e=h,0===e_&&ek(tW)),e===h&&(">>"===t.substr(ew,2)?(e=">>",ew+=2):(e=h,0===e_&&ek(tG))),e}function e5(){let e,i,s,r,a,o,l,u;if(e=ew,(i=e4())!==h){for(s=[],r=ew,a=iu(),o=t.charAt(ew),I.test(o)?ew++:(o=h,0===e_&&ek(tq)),o!==h?(l=iu(),(u=e4())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),o=t.charAt(ew),I.test(o)?ew++:(o=h,0===e_&&ek(tq)),o!==h?(l=iu(),(u=e4())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function e4(){let e,i,s,r,a,o,l,u;if(e=ew,(i=e6())!==h){for(s=[],r=ew,a=iu(),o=t.charAt(ew),z.test(o)?ew++:(o=h,0===e_&&ek(tH)),o!==h?(l=iu(),(u=e6())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,a=iu(),o=t.charAt(ew),z.test(o)?ew++:(o=h,0===e_&&ek(tH)),o!==h?(l=iu(),(u=e6())!==h?r=a=[a,o,l,u]:(ew=r,r=h)):(ew=r,r=h);e=n(i,s.map(([,t,,e])=>[t,e]))}else ew=e,e=h;return e}function e6(){let e,i,s;return(e=ew,i=t.charAt(ew),k.test(i)?ew++:(i=h,0===e_&&ek(tJ)),i!==h&&(iu(),(s=e8())!==h))?e=a(i,s):(ew=e,e=h),e===h&&((e=ew,"++"===t.substr(ew,2)?(i="++",ew+=2):(i=h,0===e_&&ek(tX)),i===h&&("--"===t.substr(ew,2)?(i="--",ew+=2):(i=h,0===e_&&ek(tZ))),i!==h&&(iu(),(s=e8())!==h))?e=a(i,s):(ew=e,e=h),e===h&&((e=ew,42===t.charCodeAt(ew)?(i="*",ew++):(i=h,0===e_&&ek(tY)),i!==h&&(iu(),(s=e8())!==h))?e={type:"TagDereferenceExpression",argument:s}:(ew=e,e=h),e===h&&(e=function(){let e,i,s;if(e=ew,(i=e9())!==h)if(iu(),"++"===t.substr(ew,2)?(s="++",ew+=2):(s=h,0===e_&&ek(tX)),s===h&&("--"===t.substr(ew,2)?(s="--",ew+=2):(s=h,0===e_&&ek(tZ))),s!==h)e={type:"PostfixExpression",operator:s,argument:i};else ew=e,e=h;else ew=e,e=h;return e===h&&(e=e9()),e}()))),e}function e8(){let t,e,i,s;if(t=ew,(e=eN())!==h)if(iu(),(i=eU())!==h)if(iu(),(s=ej())!==h)t={type:"AssignmentExpression",operator:i,target:e,value:s};else ew=t,t=h;else ew=t,t=h;else ew=t,t=h;return t===h&&(t=e6()),t}function e9(){let e,i,n,a,o,l,u,c,p,d;if(e=ew,(i=function(){let e,i,s,r,n,a,o,l,u,c,p,d,m,f,g,y;if(e=ew,(o=eE())===h&&(o=eO())===h&&(o=function(){let e,i,s,r;if(e=ew,34===t.charCodeAt(ew)?(i='"',ew++):(i=h,0===e_&&ek(t5)),i!==h){for(s=[],r=ir();r!==h;)s.push(r),r=ir();(34===t.charCodeAt(ew)?(r='"',ew++):(r=h,0===e_&&ek(t5)),r!==h)?e={type:"StringLiteral",value:s.join("")}:(ew=e,e=h)}else ew=e,e=h;if(e===h)if(e=ew,39===t.charCodeAt(ew)?(i="'",ew++):(i=h,0===e_&&ek(t4)),i!==h){for(s=[],r=ia();r!==h;)s.push(r),r=ia();(39===t.charCodeAt(ew)?(r="'",ew++):(r=h,0===e_&&ek(t4)),r!==h)?e={type:"StringLiteral",value:s.join(""),tagged:!0}:(ew=e,e=h)}else ew=e,e=h;return e}())===h&&(o=ih())===h&&((l=ew,t.substr(ew,4)===_?(u=_,ew+=4):(u=h,0===e_&&ek(ed)),u===h&&(t.substr(ew,5)===C?(u=C,ew+=5):(u=h,0===e_&&ek(em))),u!==h&&(c=ew,e_++,p=im(),e_--,p===h?c=void 0:(ew=c,c=h),c!==h))?l={type:"BooleanLiteral",value:"true"===u}:(ew=l,l=h),(o=l)===h&&((d=it())===h&&(d=ie())===h&&(d=ii()),(o=d)===h))&&((m=ew,40===t.charCodeAt(ew)?(f="(",ew++):(f=h,0===e_&&ek(H)),f!==h&&(iu(),(g=ej())!==h&&(iu(),41===t.charCodeAt(ew)?(y=")",ew++):(y=h,0===e_&&ek(J)),y!==h)))?m=g:(ew=m,m=h),o=m),(i=o)!==h){for(s=[],r=ew,n=iu(),(a=eF())!==h?r=n=[n,a]:(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),(a=eF())!==h?r=n=[n,a]:(ew=r,r=h);e=s.reduce((t,[,e])=>"property"===e.type?{type:"MemberExpression",object:t,property:e.value}:{type:"IndexExpression",object:t,index:e.value},i)}else ew=e,e=h;return e}())!==h){for(n=[],a=ew,o=iu(),40===t.charCodeAt(ew)?(l="(",ew++):(l=h,0===e_&&ek(H)),l!==h?(u=iu(),(c=e7())===h&&(c=null),p=iu(),41===t.charCodeAt(ew)?(d=")",ew++):(d=h,0===e_&&ek(J)),d!==h?a=o=[o,l,u,c,p,d]:(ew=a,a=h)):(ew=a,a=h),a===h&&(a=ew,o=iu(),(l=eF())!==h?a=o=[o,l]:(ew=a,a=h));a!==h;)n.push(a),a=ew,o=iu(),40===t.charCodeAt(ew)?(l="(",ew++):(l=h,0===e_&&ek(H)),l!==h?(u=iu(),(c=e7())===h&&(c=null),p=iu(),41===t.charCodeAt(ew)?(d=")",ew++):(d=h,0===e_&&ek(J)),d!==h?a=o=[o,l,u,c,p,d]:(ew=a,a=h)):(ew=a,a=h),a===h&&(a=ew,o=iu(),(l=eF())!==h?a=o=[o,l]:(ew=a,a=h));e=n.reduce((t,e)=>{if("("===e[1]){var i;let[,,,n]=e;return i=n||[],"Identifier"===t.type&&"exec"===t.name.toLowerCase()&&(i.length>0&&"StringLiteral"===i[0].type?s.add(i[0].value):r=!0),{type:"CallExpression",callee:t,arguments:i}}let n=e[1];return"property"===n.type?{type:"MemberExpression",object:t,property:n.value}:{type:"IndexExpression",object:t,index:n.value}},i)}else ew=e,e=h;return e}function e7(){let e,i,s,r,n,a,o,l;if(e=ew,(i=ej())!==h){for(s=[],r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=iu(),44===t.charCodeAt(ew)?(a=",",ew++):(a=h,0===e_&&ek(Z)),a!==h?(o=iu(),(l=ej())!==h?r=n=[n,a,o,l]:(ew=r,r=h)):(ew=r,r=h);e=[i,...s.map(([,,,t])=>t)]}else ew=e,e=h;return e}function it(){let e,i,s,r,n,a,o;if(e=ew,37===t.charCodeAt(ew)?(i="%",ew++):(i=h,0===e_&&ek(tQ)),i!==h){if(s=ew,r=ew,n=t.charAt(ew),B.test(n)?ew++:(n=h,0===e_&&ek(tK)),n!==h){for(a=[],o=t.charAt(ew),R.test(o)?ew++:(o=h,0===e_&&ek(t0));o!==h;)a.push(o),o=t.charAt(ew),R.test(o)?ew++:(o=h,0===e_&&ek(t0));r=n=[n,a]}else ew=r,r=h;(s=r!==h?t.substring(s,ew):r)!==h?e={type:"Variable",scope:"local",name:s}:(ew=e,e=h)}else ew=e,e=h;return e}function ie(){let e,i,s,r,n,a,o,l,u,c,p,d,m;if(e=ew,36===t.charCodeAt(ew)?(i="$",ew++):(i=h,0===e_&&ek(t1)),i!==h){if(s=ew,r=ew,"::"===t.substr(ew,2)?(n="::",ew+=2):(n=h,0===e_&&ek(X)),n===h&&(n=null),a=t.charAt(ew),B.test(a)?ew++:(a=h,0===e_&&ek(tK)),a!==h){for(o=[],l=t.charAt(ew),R.test(l)?ew++:(l=h,0===e_&&ek(t0));l!==h;)o.push(l),l=t.charAt(ew),R.test(l)?ew++:(l=h,0===e_&&ek(t0));if(l=[],u=ew,"::"===t.substr(ew,2)?(c="::",ew+=2):(c=h,0===e_&&ek(X)),c!==h)if(p=t.charAt(ew),B.test(p)?ew++:(p=h,0===e_&&ek(tK)),p!==h){for(d=[],m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));m!==h;)d.push(m),m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));u=c=[c,p,d]}else ew=u,u=h;else ew=u,u=h;for(;u!==h;)if(l.push(u),u=ew,"::"===t.substr(ew,2)?(c="::",ew+=2):(c=h,0===e_&&ek(X)),c!==h)if(p=t.charAt(ew),B.test(p)?ew++:(p=h,0===e_&&ek(tK)),p!==h){for(d=[],m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));m!==h;)d.push(m),m=t.charAt(ew),R.test(m)?ew++:(m=h,0===e_&&ek(t0));u=c=[c,p,d]}else ew=u,u=h;else ew=u,u=h;r=n=[n,a,o,l]}else ew=r,r=h;(s=r!==h?t.substring(s,ew):r)!==h?e={type:"Variable",scope:"global",name:s}:(ew=e,e=h)}else ew=e,e=h;return e}function ii(){let e,i,s,r,n,a,o,l,u,c,p;if(e=ew,i=ew,s=ew,t.substr(ew,6)===A?(r=A,ew+=6):(r=h,0===e_&&ek(t2)),r!==h){for(n=[],a=t.charAt(ew),O.test(a)?ew++:(a=h,0===e_&&ek(t3));a!==h;)n.push(a),a=t.charAt(ew),O.test(a)?ew++:(a=h,0===e_&&ek(t3));if("::"===t.substr(ew,2)?(a="::",ew+=2):(a=h,0===e_&&ek(X)),a!==h){for(o=[],l=t.charAt(ew),O.test(l)?ew++:(l=h,0===e_&&ek(t3));l!==h;)o.push(l),l=t.charAt(ew),O.test(l)?ew++:(l=h,0===e_&&ek(t3));if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));s=r=[r,n,a,o,l,u]}else ew=s,s=h}else ew=s,s=h}else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i.replace(/\s+/g,"")}),(e=i)===h){if(e=ew,i=ew,s=ew,t.substr(ew,6)===A?(r=A,ew+=6):(r=h,0===e_&&ek(t2)),r!==h){if(n=[],a=ew,"::"===t.substr(ew,2)?(o="::",ew+=2):(o=h,0===e_&&ek(X)),o!==h)if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));a=o=[o,l,u]}else ew=a,a=h;else ew=a,a=h;if(a!==h)for(;a!==h;)if(n.push(a),a=ew,"::"===t.substr(ew,2)?(o="::",ew+=2):(o=h,0===e_&&ek(X)),o!==h)if(l=t.charAt(ew),B.test(l)?ew++:(l=h,0===e_&&ek(tK)),l!==h){for(u=[],c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));c!==h;)u.push(c),c=t.charAt(ew),R.test(c)?ew++:(c=h,0===e_&&ek(t0));a=o=[o,l,u]}else ew=a,a=h;else ew=a,a=h;else n=h;n!==h?s=r=[r,n]:(ew=s,s=h)}else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i}),(e=i)===h){if(e=ew,i=ew,s=ew,r=t.charAt(ew),B.test(r)?ew++:(r=h,0===e_&&ek(tK)),r!==h){for(n=[],a=t.charAt(ew),R.test(a)?ew++:(a=h,0===e_&&ek(t0));a!==h;)n.push(a),a=t.charAt(ew),R.test(a)?ew++:(a=h,0===e_&&ek(t0));if(a=[],o=ew,"::"===t.substr(ew,2)?(l="::",ew+=2):(l=h,0===e_&&ek(X)),l!==h)if(u=t.charAt(ew),B.test(u)?ew++:(u=h,0===e_&&ek(tK)),u!==h){for(c=[],p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));p!==h;)c.push(p),p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));o=l=[l,u,c]}else ew=o,o=h;else ew=o,o=h;for(;o!==h;)if(a.push(o),o=ew,"::"===t.substr(ew,2)?(l="::",ew+=2):(l=h,0===e_&&ek(X)),l!==h)if(u=t.charAt(ew),B.test(u)?ew++:(u=h,0===e_&&ek(tK)),u!==h){for(c=[],p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));p!==h;)c.push(p),p=t.charAt(ew),R.test(p)?ew++:(p=h,0===e_&&ek(t0));o=l=[l,u,c]}else ew=o,o=h;else ew=o,o=h;s=r=[r,n,a]}else ew=s,s=h;(i=s!==h?t.substring(i,ew):s)!==h&&(i={type:"Identifier",name:i}),e=i}}return e}function is(){let t;return(t=it())===h&&(t=ie())===h&&(t=ii()),t}function ir(){let e,i,s;return(e=ew,92===t.charCodeAt(ew)?(i="\\",ew++):(i=h,0===e_&&ek(t6)),i!==h&&(s=io())!==h)?e=s:(ew=e,e=h),e===h&&(e=t.charAt(ew),E.test(e)?ew++:(e=h,0===e_&&ek(t8))),e}function ia(){let e,i,s;return(e=ew,92===t.charCodeAt(ew)?(i="\\",ew++):(i=h,0===e_&&ek(t6)),i!==h&&(s=io())!==h)?e=s:(ew=e,e=h),e===h&&(e=t.charAt(ew),P.test(e)?ew++:(e=h,0===e_&&ek(t9))),e}function io(){let e,i,s,r,n,a;return e=ew,110===t.charCodeAt(ew)?(i="n",ew++):(i=h,0===e_&&ek(t7)),i!==h&&(i="\n"),(e=i)===h&&(e=ew,114===t.charCodeAt(ew)?(i="r",ew++):(i=h,0===e_&&ek(et)),i!==h&&(i="\r"),(e=i)===h)&&(e=ew,116===t.charCodeAt(ew)?(i="t",ew++):(i=h,0===e_&&ek(ee)),i!==h&&(i=" "),(e=i)===h)&&((e=ew,120===t.charCodeAt(ew)?(i="x",ew++):(i=h,0===e_&&ek(ei)),i!==h&&(s=ew,r=ew,n=t.charAt(ew),L.test(n)?ew++:(n=h,0===e_&&ek(es)),n!==h?(a=t.charAt(ew),L.test(a)?ew++:(a=h,0===e_&&ek(es)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h),(s=r!==h?t.substring(s,ew):r)!==h))?e=String.fromCharCode(parseInt(s,16)):(ew=e,e=h),e===h&&(e=ew,"cr"===t.substr(ew,2)?(i="cr",ew+=2):(i=h,0===e_&&ek(er)),i!==h&&(i="\x0f"),(e=i)===h&&(e=ew,"cp"===t.substr(ew,2)?(i="cp",ew+=2):(i=h,0===e_&&ek(en)),i!==h&&(i="\x10"),(e=i)===h))&&(e=ew,"co"===t.substr(ew,2)?(i="co",ew+=2):(i=h,0===e_&&ek(ea)),i!==h&&(i="\x11"),(e=i)===h)&&((e=ew,99===t.charCodeAt(ew)?(i="c",ew++):(i=h,0===e_&&ek(eo)),i!==h&&(s=t.charAt(ew),N.test(s)?ew++:(s=h,0===e_&&ek(eh)),s!==h))?e=String.fromCharCode([2,3,4,5,6,7,8,11,12,14][parseInt(s,10)]):(ew=e,e=h),e===h&&(e=ew,t.length>ew?(i=t.charAt(ew),ew++):(i=h,0===e_&&ek(el)),e=i))),e}function ih(){let e,i,s,r,n,a,o,l,u;if(e=ew,i=ew,s=ew,48===t.charCodeAt(ew)?(r="0",ew++):(r=h,0===e_&&ek(eu)),r!==h)if(n=t.charAt(ew),F.test(n)?ew++:(n=h,0===e_&&ek(ec)),n!==h){if(a=[],o=t.charAt(ew),L.test(o)?ew++:(o=h,0===e_&&ek(es)),o!==h)for(;o!==h;)a.push(o),o=t.charAt(ew),L.test(o)?ew++:(o=h,0===e_&&ek(es));else a=h;a!==h?s=r=[r,n,a]:(ew=s,s=h)}else ew=s,s=h;else ew=s,s=h;if((i=s!==h?t.substring(i,ew):s)!==h&&(s=ew,e_++,r=im(),e_--,r===h?s=void 0:(ew=s,s=h),s!==h)?e={type:"NumberLiteral",value:parseInt(i,16)}:(ew=e,e=h),e===h){if(e=ew,i=ew,s=ew,45===t.charCodeAt(ew)?(r="-",ew++):(r=h,0===e_&&ek(ep)),r===h&&(r=null),n=[],a=t.charAt(ew),N.test(a)?ew++:(a=h,0===e_&&ek(eh)),a!==h)for(;a!==h;)n.push(a),a=t.charAt(ew),N.test(a)?ew++:(a=h,0===e_&&ek(eh));else n=h;if(n!==h){if(a=ew,46===t.charCodeAt(ew)?(o=".",ew++):(o=h,0===e_&&ek(ts)),o!==h){if(l=[],u=t.charAt(ew),N.test(u)?ew++:(u=h,0===e_&&ek(eh)),u!==h)for(;u!==h;)l.push(u),u=t.charAt(ew),N.test(u)?ew++:(u=h,0===e_&&ek(eh));else l=h;l!==h?a=o=[o,l]:(ew=a,a=h)}else ew=a,a=h;a===h&&(a=null),s=r=[r,n,a]}else ew=s,s=h;if(s===h)if(s=ew,45===t.charCodeAt(ew)?(r="-",ew++):(r=h,0===e_&&ek(ep)),r===h&&(r=null),46===t.charCodeAt(ew)?(n=".",ew++):(n=h,0===e_&&ek(ts)),n!==h){if(a=[],o=t.charAt(ew),N.test(o)?ew++:(o=h,0===e_&&ek(eh)),o!==h)for(;o!==h;)a.push(o),o=t.charAt(ew),N.test(o)?ew++:(o=h,0===e_&&ek(eh));else a=h;a!==h?s=r=[r,n,a]:(ew=s,s=h)}else ew=s,s=h;(i=s!==h?t.substring(i,ew):s)!==h&&(s=ew,e_++,r=im(),e_--,r===h?s=void 0:(ew=s,s=h),s!==h)?e={type:"NumberLiteral",value:parseFloat(i)}:(ew=e,e=h)}return e}function il(){let e;return(e=function(){let e,i,s,r,n;if(e=ew,"//"===t.substr(ew,2)?(i="//",ew+=2):(i=h,0===e_&&ek(ef)),i!==h){for(s=ew,r=[],n=t.charAt(ew),$.test(n)?ew++:(n=h,0===e_&&ek(eg));n!==h;)r.push(n),n=t.charAt(ew),$.test(n)?ew++:(n=h,0===e_&&ek(eg));s=t.substring(s,ew),r=t.charAt(ew),V.test(r)?ew++:(r=h,0===e_&&ek(ey)),r===h&&(r=null),e={type:"Comment",value:s}}else ew=e,e=h;return e}())===h&&(e=function(){let e,i,s,r,n,a,o;if(e=ew,"/*"===t.substr(ew,2)?(i="/*",ew+=2):(i=h,0===e_&&ek(ex)),i!==h){for(s=ew,r=[],n=ew,a=ew,e_++,"*/"===t.substr(ew,2)?(o="*/",ew+=2):(o=h,0===e_&&ek(eb)),e_--,o===h?a=void 0:(ew=a,a=h),a!==h?(t.length>ew?(o=t.charAt(ew),ew++):(o=h,0===e_&&ek(el)),o!==h?n=a=[a,o]:(ew=n,n=h)):(ew=n,n=h);n!==h;)r.push(n),n=ew,a=ew,e_++,"*/"===t.substr(ew,2)?(o="*/",ew+=2):(o=h,0===e_&&ek(eb)),e_--,o===h?a=void 0:(ew=a,a=h),a!==h?(t.length>ew?(o=t.charAt(ew),ew++):(o=h,0===e_&&ek(el)),o!==h?n=a=[a,o]:(ew=n,n=h)):(ew=n,n=h);(s=t.substring(s,ew),"*/"===t.substr(ew,2)?(r="*/",ew+=2):(r=h,0===e_&&ek(eb)),r!==h)?e={type:"Comment",value:s}:(ew=e,e=h)}else ew=e,e=h;return e}()),e}function iu(){let e,i;for(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i===h&&(i=id());i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev)),i===h&&(i=id());return e}function ic(){let e,i,s,r;if(e=ew,i=[],s=t.charAt(ew),D.test(s)?ew++:(s=h,0===e_&&ek(ev)),s!==h)for(;s!==h;)i.push(s),s=t.charAt(ew),D.test(s)?ew++:(s=h,0===e_&&ek(ev));else i=h;if(i!==h){for(s=[],r=t.charAt(ew),D.test(r)?ew++:(r=h,0===e_&&ek(ev)),r===h&&(r=id());r!==h;)s.push(r),r=t.charAt(ew),D.test(r)?ew++:(r=h,0===e_&&ek(ev)),r===h&&(r=id());e=i=[i,s]}else ew=e,e=h;return e}function ip(){let e,i;for(e=[],i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));i!==h;)e.push(i),i=t.charAt(ew),D.test(i)?ew++:(i=h,0===e_&&ek(ev));return e}function id(){let e,i,s,r,n,a;if(e=ew,"//"===t.substr(ew,2)?(i="//",ew+=2):(i=h,0===e_&&ek(ef)),i!==h){for(s=[],r=t.charAt(ew),$.test(r)?ew++:(r=h,0===e_&&ek(eg));r!==h;)s.push(r),r=t.charAt(ew),$.test(r)?ew++:(r=h,0===e_&&ek(eg));r=t.charAt(ew),V.test(r)?ew++:(r=h,0===e_&&ek(ey)),r===h&&(r=null),e=i=[i,s,r]}else ew=e,e=h;if(e===h)if(e=ew,"/*"===t.substr(ew,2)?(i="/*",ew+=2):(i=h,0===e_&&ek(ex)),i!==h){for(s=[],r=ew,n=ew,e_++,"*/"===t.substr(ew,2)?(a="*/",ew+=2):(a=h,0===e_&&ek(eb)),e_--,a===h?n=void 0:(ew=n,n=h),n!==h?(t.length>ew?(a=t.charAt(ew),ew++):(a=h,0===e_&&ek(el)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h);r!==h;)s.push(r),r=ew,n=ew,e_++,"*/"===t.substr(ew,2)?(a="*/",ew+=2):(a=h,0===e_&&ek(eb)),e_--,a===h?n=void 0:(ew=n,n=h),n!==h?(t.length>ew?(a=t.charAt(ew),ew++):(a=h,0===e_&&ek(el)),a!==h?r=n=[n,a]:(ew=r,r=h)):(ew=r,r=h);"*/"===t.substr(ew,2)?(r="*/",ew+=2):(r=h,0===e_&&ek(eb)),r!==h?e=i=[i,s,r]:(ew=e,e=h)}else ew=e,e=h;return e}function im(){let e;return e=t.charAt(ew),R.test(e)?ew++:(e=h,0===e_&&ek(t0)),e}s=new Set,r=!1;let ig=(i=c())!==h&&ew===t.length;function iy(){var e,s,r;throw i!==h&&ew{"use strict";var e=t.i(90072);t.s(["parse",()=>E,"runServer",()=>N],86608);var i=t.i(92552);function s(t){let e=t.indexOf("::");return -1===e?null:{namespace:t.slice(0,e),method:t.slice(e+2)}}let r={"+":"$.add","-":"$.sub","*":"$.mul","/":"$.div","<":"$.lt","<=":"$.le",">":"$.gt",">=":"$.ge","==":"$.eq","!=":"$.ne","%":"$.mod","&":"$.bitand","|":"$.bitor","^":"$.bitxor","<<":"$.shl",">>":"$.shr"};class n{indent;runtime;functions;globals;locals;indentLevel=0;currentClass=null;currentFunction=null;constructor(t={}){this.indent=t.indent??" ",this.runtime=t.runtime??"$",this.functions=t.functions??"$f",this.globals=t.globals??"$g",this.locals=t.locals??"$l"}getAccessInfo(t){if("Variable"===t.type){let e=JSON.stringify(t.name),i="global"===t.scope?this.globals:this.locals;return{getter:`${i}.get(${e})`,setter:t=>`${i}.set(${e}, ${t})`,postIncHelper:`${i}.postInc(${e})`,postDecHelper:`${i}.postDec(${e})`}}if("MemberExpression"===t.type){let e=this.expression(t.object),i="Identifier"===t.property.type?JSON.stringify(t.property.name):this.expression(t.property);return{getter:`${this.runtime}.prop(${e}, ${i})`,setter:t=>`${this.runtime}.setProp(${e}, ${i}, ${t})`,postIncHelper:`${this.runtime}.propPostInc(${e}, ${i})`,postDecHelper:`${this.runtime}.propPostDec(${e}, ${i})`}}if("IndexExpression"===t.type){let e=Array.isArray(t.index)?t.index.map(t=>this.expression(t)):[this.expression(t.index)];if("Variable"===t.object.type){let i=JSON.stringify(t.object.name),s="global"===t.object.scope?this.globals:this.locals,r=e.join(", ");return{getter:`${s}.get(${i}, ${r})`,setter:t=>`${s}.set(${i}, ${r}, ${t})`,postIncHelper:`${s}.postInc(${i}, ${r})`,postDecHelper:`${s}.postDec(${i}, ${r})`}}if("MemberExpression"===t.object.type){let i=t.object,s=this.expression(i.object),r="Identifier"===i.property.type?JSON.stringify(i.property.name):this.expression(i.property),n=`${this.runtime}.key(${r}, ${e.join(", ")})`;return{getter:`${this.runtime}.prop(${s}, ${n})`,setter:t=>`${this.runtime}.setProp(${s}, ${n}, ${t})`,postIncHelper:`${this.runtime}.propPostInc(${s}, ${n})`,postDecHelper:`${this.runtime}.propPostDec(${s}, ${n})`}}let i=this.expression(t.object),s=1===e.length?e[0]:`${this.runtime}.key(${e.join(", ")})`;return{getter:`${this.runtime}.getIndex(${i}, ${s})`,setter:t=>`${this.runtime}.setIndex(${i}, ${s}, ${t})`,postIncHelper:`${this.runtime}.indexPostInc(${i}, ${s})`,postDecHelper:`${this.runtime}.indexPostDec(${i}, ${s})`}}return null}generate(t){let e=[];for(let i of t.body){let t=this.statement(i);t&&e.push(t)}return e.join("\n\n")}statement(t){switch(t.type){case"Comment":return"";case"ExpressionStatement":return this.line(`${this.expression(t.expression)};`);case"FunctionDeclaration":return this.functionDeclaration(t);case"PackageDeclaration":return this.packageDeclaration(t);case"DatablockDeclaration":return this.datablockDeclaration(t);case"ObjectDeclaration":return this.line(`${this.objectDeclaration(t)};`);case"IfStatement":return this.ifStatement(t);case"ForStatement":return this.forStatement(t);case"WhileStatement":return this.whileStatement(t);case"DoWhileStatement":return this.doWhileStatement(t);case"SwitchStatement":return this.switchStatement(t);case"ReturnStatement":return this.returnStatement(t);case"BreakStatement":return this.line("break;");case"ContinueStatement":return this.line("continue;");case"BlockStatement":return this.blockStatement(t);default:throw Error(`Unknown statement type: ${t.type}`)}}functionDeclaration(t){let e=s(t.name.name);if(e){let i=e.namespace,s=e.method;this.currentClass=i.toLowerCase(),this.currentFunction=s.toLowerCase();let r=this.functionBody(t.body,t.params);return this.currentClass=null,this.currentFunction=null,`${this.line(`${this.runtime}.registerMethod(${JSON.stringify(i)}, ${JSON.stringify(s)}, function() {`)} -${r} -${this.line("});")}`}{let e=t.name.name;this.currentFunction=e.toLowerCase();let i=this.functionBody(t.body,t.params);return this.currentFunction=null,`${this.line(`${this.runtime}.registerFunction(${JSON.stringify(e)}, function() {`)} -${i} -${this.line("});")}`}}functionBody(t,e){this.indentLevel++;let i=[];i.push(this.line(`const ${this.locals} = ${this.runtime}.locals();`));for(let t=0;tthis.statement(t)).join("\n\n");return this.indentLevel--,`${this.line(`${this.runtime}.package(${e}, function() {`)} -${i} -${this.line("});")}`}datablockDeclaration(t){let e=JSON.stringify(t.className.name),i=t.instanceName?JSON.stringify(t.instanceName.name):"null",s=t.parent?JSON.stringify(t.parent.name):"null",r=this.objectBody(t.body);return this.line(`${this.runtime}.datablock(${e}, ${i}, ${s}, ${r});`)}objectDeclaration(t){let e="Identifier"===t.className.type?JSON.stringify(t.className.name):this.expression(t.className),i=null===t.instanceName?"null":"Identifier"===t.instanceName.type?JSON.stringify(t.instanceName.name):this.expression(t.instanceName),s=[],r=[];for(let e of t.body)"Assignment"===e.type?s.push(e):r.push(e);let n=this.objectBody(s);if(r.length>0){let t=r.map(t=>this.objectDeclaration(t)).join(",\n");return`${this.runtime}.create(${e}, ${i}, ${n}, [ -${t} -])`}return`${this.runtime}.create(${e}, ${i}, ${n})`}objectBody(t){if(0===t.length)return"{}";let e=[];for(let i of t)if("Assignment"===i.type){let t=this.expression(i.value);if("Identifier"===i.target.type){let s=i.target.name;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?e.push(`${s}: ${t}`):e.push(`[${JSON.stringify(s)}]: ${t}`)}else if("IndexExpression"===i.target.type){let s=this.objectPropertyKey(i.target);e.push(`[${s}]: ${t}`)}else{let s=this.expression(i.target);e.push(`[${s}]: ${t}`)}}if(e.length<=1)return`{ ${e.join(", ")} }`;let i=this.indent.repeat(this.indentLevel+1),s=this.indent.repeat(this.indentLevel);return`{ -${i}${e.join(",\n"+i)} -${s}}`}objectPropertyKey(t){let e="Identifier"===t.object.type?JSON.stringify(t.object.name):this.expression(t.object),i=Array.isArray(t.index)?t.index.map(t=>this.expression(t)).join(", "):this.expression(t.index);return`${this.runtime}.key(${e}, ${i})`}ifStatement(t){let e=this.expression(t.test),i=this.statementAsBlock(t.consequent);if(t.alternate)if("IfStatement"===t.alternate.type){let s=this.ifStatement(t.alternate).replace(/^\s*/,"");return this.line(`if (${e}) ${i} else ${s}`)}else{let s=this.statementAsBlock(t.alternate);return this.line(`if (${e}) ${i} else ${s}`)}return this.line(`if (${e}) ${i}`)}forStatement(t){let e=t.init?this.expression(t.init):"",i=t.test?this.expression(t.test):"",s=t.update?this.expression(t.update):"",r=this.statementAsBlock(t.body);return this.line(`for (${e}; ${i}; ${s}) ${r}`)}whileStatement(t){let e=this.expression(t.test),i=this.statementAsBlock(t.body);return this.line(`while (${e}) ${i}`)}doWhileStatement(t){let e=this.statementAsBlock(t.body),i=this.expression(t.test);return this.line(`do ${e} while (${i});`)}switchStatement(t){if(t.stringMode)return this.switchStringStatement(t);let e=this.expression(t.discriminant);this.indentLevel++;let i=[];for(let e of t.cases)i.push(this.switchCase(e));return this.indentLevel--,`${this.line(`switch (${e}) {`)} -${i.join("\n")} -${this.line("}")}`}switchCase(t){let e=[];if(null===t.test)e.push(this.line("default:"));else if(Array.isArray(t.test))for(let i of t.test)e.push(this.line(`case ${this.expression(i)}:`));else e.push(this.line(`case ${this.expression(t.test)}:`));for(let i of(this.indentLevel++,t.consequent))e.push(this.statement(i));return e.push(this.line("break;")),this.indentLevel--,e.join("\n")}switchStringStatement(t){let e=this.expression(t.discriminant),i=[];for(let e of t.cases)if(null===e.test)i.push(`default: () => { ${this.blockContent(e.consequent)} }`);else if(Array.isArray(e.test))for(let t of e.test)i.push(`${this.expression(t)}: () => { ${this.blockContent(e.consequent)} }`);else i.push(`${this.expression(e.test)}: () => { ${this.blockContent(e.consequent)} }`);return this.line(`${this.runtime}.switchStr(${e}, { ${i.join(", ")} });`)}returnStatement(t){return t.value?this.line(`return ${this.expression(t.value)};`):this.line("return;")}blockStatement(t){this.indentLevel++;let e=t.body.map(t=>this.statement(t)).join("\n");return this.indentLevel--,`{ -${e} -${this.line("}")}`}statementAsBlock(t){if("BlockStatement"===t.type)return this.blockStatement(t);this.indentLevel++;let e=this.statement(t);return this.indentLevel--,`{ -${e} -${this.line("}")}`}blockContent(t){return t.map(t=>this.statement(t).trim()).join(" ")}expression(t){switch(t.type){case"Identifier":return this.identifier(t);case"Variable":return this.variable(t);case"NumberLiteral":case"BooleanLiteral":return String(t.value);case"StringLiteral":return JSON.stringify(t.value);case"BinaryExpression":return this.binaryExpression(t);case"UnaryExpression":return this.unaryExpression(t);case"PostfixExpression":return this.postfixExpression(t);case"AssignmentExpression":return this.assignmentExpression(t);case"ConditionalExpression":return`(${this.expression(t.test)} ? ${this.expression(t.consequent)} : ${this.expression(t.alternate)})`;case"CallExpression":return this.callExpression(t);case"MemberExpression":return this.memberExpression(t);case"IndexExpression":return this.indexExpression(t);case"TagDereferenceExpression":return`${this.runtime}.deref(${this.expression(t.argument)})`;case"ObjectDeclaration":return this.objectDeclaration(t);case"DatablockDeclaration":return`${this.runtime}.datablock(${JSON.stringify(t.className.name)}, ${t.instanceName?JSON.stringify(t.instanceName.name):"null"}, ${t.parent?JSON.stringify(t.parent.name):"null"}, ${this.objectBody(t.body)})`;default:throw Error(`Unknown expression type: ${t.type}`)}}identifier(t){let e=s(t.name);return e&&"parent"===e.namespace.toLowerCase()?t.name:e?`${this.runtime}.nsRef(${JSON.stringify(e.namespace)}, ${JSON.stringify(e.method)})`:JSON.stringify(t.name)}variable(t){return"global"===t.scope?`${this.globals}.get(${JSON.stringify(t.name)})`:`${this.locals}.get(${JSON.stringify(t.name)})`}binaryExpression(t){let e=this.expression(t.left),i=this.expression(t.right),s=t.operator,n=this.concatExpression(e,s,i);if(n)return n;if("$="===s)return`${this.runtime}.streq(${e}, ${i})`;if("!$="===s)return`!${this.runtime}.streq(${e}, ${i})`;if("&&"===s||"||"===s)return`(${e} ${s} ${i})`;let a=r[s];return a?`${a}(${e}, ${i})`:`(${e} ${s} ${i})`}unaryExpression(t){if("++"===t.operator||"--"===t.operator){let e=this.getAccessInfo(t.argument);if(e){let i="++"===t.operator?1:-1;return e.setter(`${this.runtime}.add(${e.getter}, ${i})`)}}let e=this.expression(t.argument);return"~"===t.operator?`${this.runtime}.bitnot(${e})`:"-"===t.operator?`${this.runtime}.neg(${e})`:`${t.operator}${e}`}postfixExpression(t){let e=this.getAccessInfo(t.argument);if(e){let i="++"===t.operator?e.postIncHelper:e.postDecHelper;if(i)return i}return`${this.expression(t.argument)}${t.operator}`}assignmentExpression(t){let e=this.expression(t.value),i=t.operator,s=this.getAccessInfo(t.target);if(!s)throw Error(`Unhandled assignment target type: ${t.target.type}`);if("="===i)return s.setter(e);{let t=i.slice(0,-1),r=this.compoundAssignmentValue(s.getter,t,e);return s.setter(r)}}callExpression(t){let e=t.arguments.map(t=>this.expression(t)).join(", ");if("Identifier"===t.callee.type){let i=t.callee.name,r=s(i);if(r&&"parent"===r.namespace.toLowerCase())if(this.currentClass)return`${this.runtime}.parent(${JSON.stringify(this.currentClass)}, ${JSON.stringify(r.method)}, arguments[0]${e?", "+e:""})`;else if(this.currentFunction)return`${this.runtime}.parentFunc(${JSON.stringify(this.currentFunction)}${e?", "+e:""})`;else throw Error("Parent:: call outside of function context");return r?`${this.runtime}.nsCall(${JSON.stringify(r.namespace)}, ${JSON.stringify(r.method)}${e?", "+e:""})`:`${this.functions}.call(${JSON.stringify(i)}${e?", "+e:""})`}if("MemberExpression"===t.callee.type){let i=this.expression(t.callee.object),s="Identifier"===t.callee.property.type?JSON.stringify(t.callee.property.name):this.expression(t.callee.property);return`${this.runtime}.call(${i}, ${s}${e?", "+e:""})`}let i=this.expression(t.callee);return`${i}(${e})`}memberExpression(t){let e=this.expression(t.object);return t.computed||"Identifier"!==t.property.type?`${this.runtime}.prop(${e}, ${this.expression(t.property)})`:`${this.runtime}.prop(${e}, ${JSON.stringify(t.property.name)})`}indexExpression(t){let e=Array.isArray(t.index)?t.index.map(t=>this.expression(t)):[this.expression(t.index)];if("Variable"===t.object.type){let i=JSON.stringify(t.object.name),s="global"===t.object.scope?this.globals:this.locals;return`${s}.get(${i}, ${e.join(", ")})`}if("MemberExpression"===t.object.type){let i=t.object,s=this.expression(i.object),r="Identifier"===i.property.type?JSON.stringify(i.property.name):this.expression(i.property),n=`${this.runtime}.key(${r}, ${e.join(", ")})`;return`${this.runtime}.prop(${s}, ${n})`}let i=this.expression(t.object);return 1===e.length?`${this.runtime}.getIndex(${i}, ${e[0]})`:`${this.runtime}.getIndex(${i}, ${this.runtime}.key(${e.join(", ")}))`}line(t){return this.indent.repeat(this.indentLevel)+t}concatExpression(t,e,i){switch(e){case"@":return`${this.runtime}.concat(${t}, ${i})`;case"SPC":return`${this.runtime}.concat(${t}, " ", ${i})`;case"TAB":return`${this.runtime}.concat(${t}, "\\t", ${i})`;case"NL":return`${this.runtime}.concat(${t}, "\\n", ${i})`;default:return null}}compoundAssignmentValue(t,e,i){let s=this.concatExpression(t,e,i);if(s)return s;let n=r[e];return n?`${n}(${t}, ${i})`:`(${t} ${e} ${i})`}}t.s(["createRuntime",()=>R,"createScriptCache",()=>I],33870);var a=t.i(54970);class o{map=new Map;keyLookup=new Map;constructor(t){if(t)for(const[e,i]of t)this.set(e,i)}get size(){return this.map.size}get(t){let e=this.keyLookup.get(t.toLowerCase());return void 0!==e?this.map.get(e):void 0}set(t,e){let i=t.toLowerCase(),s=this.keyLookup.get(i);return void 0!==s?this.map.set(s,e):(this.keyLookup.set(i,t),this.map.set(t,e)),this}has(t){return this.keyLookup.has(t.toLowerCase())}delete(t){let e=t.toLowerCase(),i=this.keyLookup.get(e);return void 0!==i&&(this.keyLookup.delete(e),this.map.delete(i))}clear(){this.map.clear(),this.keyLookup.clear()}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}forEach(t){for(let[e,i]of this.map)t(i,e,this)}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}getOriginalKey(t){return this.keyLookup.get(t.toLowerCase())}}class h{set=new Set;constructor(t){if(t)for(const e of t)this.add(e)}get size(){return this.set.size}add(t){return this.set.add(t.toLowerCase()),this}has(t){return this.set.has(t.toLowerCase())}delete(t){return this.set.delete(t.toLowerCase())}clear(){this.set.clear()}[Symbol.iterator](){return this.set[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}function l(t){return t.replace(/\\/g,"/").toLowerCase()}function u(t){return String(t??"")}function c(t){return Number(t)||0}function p(t){let e=u(t||"0 0 0").split(" ").map(Number);return[e[0]||0,e[1]||0,e[2]||0]}function d(t,e,i){let s=0;for(;e+s0;){if(s>=t.length)return"";let r=d(t,s,i);if(s+r>=t.length)return"";s+=r+1,e--}let r=d(t,s,i);return 0===r?"":t.substring(s,s+r)}function f(t,e,i,s){let r=0,n=e;for(;n>0;){if(r>=t.length)return"";let e=d(t,r,s);if(r+e>=t.length)return"";r+=e+1,n--}let a=r,o=i-e+1;for(;o>0;){let e=d(t,r,s);if((r+=e)>=t.length)break;r++,o--}let h=r;return h>a&&s.includes(t[h-1])&&h--,t.substring(a,h)}function g(t,e){if(""===t)return 0;let i=0;for(let s=0;se&&a>=t.length)break}return n.join(r)}function x(t,e,i,s){let r=[],n=0,a=0;for(;ne().$f.call(u(t),...i),eval(t){throw Error("eval() not implemented: requires runtime parsing and execution")},collapseescape:t=>u(t).replace(/\\([ntr\\])/g,(t,e)=>"n"===e?"\n":"t"===e?" ":"r"===e?"\r":"\\"),expandescape:t=>u(t).replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r"),export(t,e,i){console.warn(`export(${t}): not implemented`)},quit(){console.warn("quit(): not implemented in browser")},trace(t){},isobject:t=>e().$.isObject(t),nametoid:t=>e().$.nameToId(t),strlen:t=>u(t).length,strchr(t,e){let i=u(t),s=u(e)[0]??"",r=i.indexOf(s);return r>=0?i.substring(r):""},strpos:(t,e,i)=>u(t).indexOf(u(e),c(i)),strcmp(t,e){let i=u(t),s=u(e);return is)},stricmp(t,e){let i=u(t).toLowerCase(),s=u(e).toLowerCase();return is)},strstr:(t,e)=>u(t).indexOf(u(e)),getsubstr(t,e,i){let s=u(t),r=c(e);return void 0===i?s.substring(r):s.substring(r,r+c(i))},getword:(t,e)=>m(u(t),c(e)," \n"),getwordcount:t=>g(u(t)," \n"),getfield:(t,e)=>m(u(t),c(e)," \n"),getfieldcount:t=>g(u(t)," \n"),setword:(t,e,i)=>y(u(t),c(e),u(i)," \n"," "),setfield:(t,e,i)=>y(u(t),c(e),u(i)," \n"," "),firstword:t=>m(u(t),0," \n"),restwords:t=>f(u(t),1,1e6," \n"),trim:t=>u(t).trim(),ltrim:t=>u(t).replace(/^\s+/,""),rtrim:t=>u(t).replace(/\s+$/,""),strupr:t=>u(t).toUpperCase(),strlwr:t=>u(t).toLowerCase(),strreplace:(t,e,i)=>u(t).split(u(e)).join(u(i)),filterstring:(t,e)=>u(t),stripchars(t,e){let i=u(t),s=new Set(u(e).split(""));return i.split("").filter(t=>!s.has(t)).join("")},getfields(t,e,i){let s=void 0!==i?Number(i):1e6;return f(u(t),c(e),s," \n")},getwords(t,e,i){let s=void 0!==i?Number(i):1e6;return f(u(t),c(e),s," \n")},removeword:(t,e)=>x(u(t),c(e)," \n"," "),removefield:(t,e)=>x(u(t),c(e)," \n"," "),getrecord:(t,e)=>m(u(t),c(e),"\n"),getrecordcount:t=>g(u(t),"\n"),setrecord:(t,e,i)=>y(u(t),c(e),u(i),"\n","\n"),removerecord:(t,e)=>x(u(t),c(e),"\n","\n"),nexttoken(t,e,i){throw Error("nextToken() is not implemented: it requires variable mutation")},strtoplayername:t=>u(t).replace(/[^\w\s-]/g,"").trim(),mabs:t=>Math.abs(c(t)),mfloor:t=>Math.floor(c(t)),mceil:t=>Math.ceil(c(t)),msqrt:t=>Math.sqrt(c(t)),mpow:(t,e)=>Math.pow(c(t),c(e)),msin:t=>Math.sin(c(t)),mcos:t=>Math.cos(c(t)),mtan:t=>Math.tan(c(t)),masin:t=>Math.asin(c(t)),macos:t=>Math.acos(c(t)),matan:(t,e)=>Math.atan2(c(t),c(e)),mlog:t=>Math.log(c(t)),getrandom(t,e){if(void 0===t)return Math.random();if(void 0===e)return Math.floor(Math.random()*(c(t)+1));let i=c(t);return Math.floor(Math.random()*(c(e)-i+1))+i},mdegtorad:t=>c(t)*(Math.PI/180),mradtodeg:t=>c(t)*(180/Math.PI),mfloatlength:(t,e)=>c(t).toFixed(c(e)),getboxcenter(t){let e=u(t).split(" ").map(Number),i=e[0]||0,s=e[1]||0,r=e[2]||0,n=e[3]||0,a=e[4]||0,o=e[5]||0;return`${(i+n)/2} ${(s+a)/2} ${(r+o)/2}`},vectoradd(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${i+n} ${s+a} ${r+o}`},vectorsub(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${i-n} ${s-a} ${r-o}`},vectorscale(t,e){let[i,s,r]=p(t),n=c(e);return`${i*n} ${s*n} ${r*n}`},vectordot(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return i*n+s*a+r*o},vectorcross(t,e){let[i,s,r]=p(t),[n,a,o]=p(e);return`${s*o-r*a} ${r*n-i*o} ${i*a-s*n}`},vectorlen(t){let[e,i,s]=p(t);return Math.sqrt(e*e+i*i+s*s)},vectornormalize(t){let[e,i,s]=p(t),r=Math.sqrt(e*e+i*i+s*s);return 0===r?"0 0 0":`${e/r} ${i/r} ${s/r}`},vectordist(t,e){let[i,s,r]=p(t),[n,a,o]=p(e),h=i-n,l=s-a,u=r-o;return Math.sqrt(h*h+l*l+u*u)},matrixcreate(t,e){throw Error("MatrixCreate() not implemented: requires axis-angle rotation math")},matrixcreatefromeuler(t){throw Error("MatrixCreateFromEuler() not implemented: requires Euler→Quaternion→AxisAngle conversion")},matrixmultiply(t,e){throw Error("MatrixMultiply() not implemented: requires full 4x4 matrix multiplication")},matrixmulpoint(t,e){throw Error("MatrixMulPoint() not implemented: requires full transform application")},matrixmulvector(t,e){throw Error("MatrixMulVector() not implemented: requires rotation matrix application")},getsimtime:()=>Date.now()-e().state.startTime,getrealtime:()=>Date.now(),schedule(t,i,s,...r){let n=Number(t)||0,a=e(),o=setTimeout(()=>{a.state.pendingTimeouts.delete(o);try{a.$f.call(String(s),...r)}catch(t){throw console.error(`schedule: error calling ${s}:`,t),t}},n);return a.state.pendingTimeouts.add(o),o},cancel(t){clearTimeout(t),e().state.pendingTimeouts.delete(t)},iseventpending:t=>e().state.pendingTimeouts.has(t),exec(t){let i=String(t??"");if(console.debug(`exec(${JSON.stringify(i)}): preparing to execute…`),!i.includes("."))return console.error(`exec: invalid script file name ${JSON.stringify(i)}.`),!1;let s=l(i),r=e(),{executedScripts:n,scripts:a}=r.state;if(n.has(s))return console.debug(`exec(${JSON.stringify(i)}): skipping (already executed)`),!0;let o=a.get(s);return null==o?(console.warn(`exec(${JSON.stringify(i)}): script not found`),!1):(n.add(s),console.debug(`exec(${JSON.stringify(i)}): executing!`),r.executeAST(o),!0)},compile(t){throw Error("compile() not implemented: requires DSO bytecode compiler")},isdemo:()=>!1,isfile:t=>i?i.isFile(u(t)):(console.warn("isFile(): no fileSystem handler configured"),!1),fileext(t){let e=u(t),i=e.lastIndexOf(".");return i>=0?e.substring(i):""},filebase(t){let e=u(t),i=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),s=e.lastIndexOf("."),r=i>=0?i+1:0,n=s>r?s:e.length;return e.substring(r,n)},filepath(t){let e=u(t),i=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));return i>=0?e.substring(0,i):""},expandfilename(t){throw Error("expandFilename() not implemented: requires filesystem path expansion")},findfirstfile:t=>i?(n=u(t),s=i.findFiles(n),r=0,s[r++]??""):(console.warn("findFirstFile(): no fileSystem handler configured"),""),findnextfile(t){let e=u(t);if(e!==n){if(!i)return"";n=e,s=i.findFiles(e)}return s[r++]??""},getfilecrc:t=>u(t),iswriteablefilename:t=>!1,activatepackage(t){e().$.activatePackage(u(t))},deactivatepackage(t){e().$.deactivatePackage(u(t))},ispackage:t=>e().$.isPackage(u(t)),isactivepackage:t=>e().$.isActivePackage(u(t)),getpackagelist:()=>e().$.getPackageList(),addmessagecallback(t,e){},alxcreatesource:(...t)=>0,alxgetwavelen:t=>0,alxlistenerf(t,e){},alxplay:(...t)=>0,alxsetchannelvolume(t,e){},alxsourcef(t,e,i){},alxstop(t){},alxstopall(){},activatedirectinput(){},activatekeyboard(){},deactivatedirectinput(){},deactivatekeyboard(){},disablejoystick(){},enablejoystick(){},enablewinconsole(t){},isjoystickdetected:()=>!1,lockmouse(t){},addmaterialmapping(t,e){},flushtexturecache(){},getdesktopresolution:()=>"1920 1080 32",getdisplaydevicelist:()=>"OpenGL",getresolutionlist:t=>"640 480 800 600 1024 768 1280 720 1920 1080",getvideodriverinfo:()=>"WebGL",isdevicefullscreenonly:t=>!1,isfullscreen:()=>!1,screenshot(t){},setdisplaydevice:t=>!0,setfov(t){},setinteriorrendermode(t){},setopenglanisotropy(t){},setopenglmipreduction(t){},setopenglskymipreduction(t){},setopengltexturecompressionhint(t){},setscreenmode(t,e,i,s){},setverticalsync(t){},setzoomspeed(t){},togglefullscreen(){},videosetgammacorrection(t){},snaptoggle(){},addtaggedstring:t=>0,buildtaggedstring:(t,...e)=>"",detag:t=>u(t),gettag:t=>0,gettaggedstring:t=>"",removetaggedstring(t){},commandtoclient(t,e){},commandtoserver(t){},cancelserverquery(){},querymasterserver(){},querysingleserver(){},setnetport:t=>!0,allowconnections(t){},startheartbeat(){},stopheartbeat(){},gotowebpage(t){},deletedatablocks(){},preloaddatablock:t=>!0,containerboxempty:(...t)=>!0,containerraycast:(...t)=>"",containersearchcurrdist:()=>0,containersearchnext:()=>0,initcontainerradiussearch(){},calcexplosioncoverage:(...t)=>1,getcontrolobjectaltitude:()=>0,getcontrolobjectspeed:()=>0,getterrainheight:t=>0,lightscene(){},pathonmissionloaddone(){}}}function v(t){return t.toLowerCase()}function w(t){let e=t.trim();return v(e.startsWith("$")?e.slice(1):e)}function M(t,e){let i=t.get(e);return i||(i=new Set,t.set(e,i)),i}function S(t,e){for(let i of e)t.add(v(i))}function A(t,e,i){if(t.anyClassValues.has("*")||t.anyClassValues.has(i))return!0;for(let s of e){let e=t.valuesByClass.get(v(s));if(e&&(e.has("*")||e.has(i)))return!0}return!1}let _=[{classNames:["SceneObject","GameBase","ShapeBase","Item","Player"],fields:["position","rotation","scale","transform","hidden","renderingdistance","datablock","shapename","shapefile","initialbarrel","skin","team","health","energy","energylevel","damagelevel","damageflash","damagepercent","damagestate","mountobject","mountedimage","targetposition","targetrotation","targetscale","missiontypeslist","renderenabled","vis","velocity","name"]},{classNames:["*"],fields:["position","rotation","scale","hidden","shapefile","datablock"]}],C=[{classNames:["SceneObject","GameBase","ShapeBase","SimObject"],methods:["settransform","setposition","setrotation","setscale","sethidden","setdatablock","setshapename","mountimage","unmountimage","mountobject","unmountobject","setdamagelevel","setenergylevel","schedule","delete","deleteallobjects","add","remove","playthread","stopthread","setthreaddir","pausethread"]},{classNames:["*"],methods:["settransform","setscale","delete","add","remove"]}],T=["missionrunning","loadingmission"];function I(){return{scripts:new Map,generatedCode:new WeakMap}}function z(t){return t.toLowerCase()}function k(t){return Number(t)>>>0}function B(t){if(null==t)return null;if("string"==typeof t)return t||null;if("number"==typeof t)return String(t);throw Error(`Invalid instance name type: ${typeof t}`)}function R(t={}){let e,i,s,r=t.reactiveFieldRules??_,u=t.reactiveMethodRules??C,c=t.reactiveGlobalNames??T,p=(e=function(t){let e=new Set,i=new Map;for(let s of t)for(let t of s.classNames){let r=v(t);if("*"===r){S(e,s.fields);continue}S(M(i,r),s.fields)}return{anyClassValues:e,valuesByClass:i}}(r),(t,i)=>A(e,t,v(i))),d=(i=function(t){let e=new Set,i=new Map;for(let s of t)for(let t of s.classNames){let r=v(t);if("*"===r){S(e,s.methods);continue}S(M(i,r),s.methods)}return{anyClassValues:e,valuesByClass:i}}(u),(t,e)=>A(i,t,v(e))),m=(s=function(t){let e=new Set;for(let i of t)e.add(w(i));return e}(c),t=>{let e=w(t);return s.has("*")||s.has(e)}),f=new o,g=new o,y=new o,x=[],O=new h,P=3,L=1027,N=new Map,F=new o,$=new o,V=new o,D=new o,j=new o,U=new Set,W=[],G=!1,q=0;if(t.globals)for(let[e,i]of Object.entries(t.globals)){if(!e.startsWith("$"))throw Error(`Global variable "${e}" must start with $, e.g. "$${e}"`);V.set(e.slice(1),i)}let H=new Set,J=new Set,X=t.ignoreScripts&&t.ignoreScripts.length>0?(0,a.default)(t.ignoreScripts,{nocase:!0}):null,Z=t.cache??I(),Y=Z.scripts,Q=Z.generatedCode,K=new Map;function tt(t){let e=K.get(t);return e&&e.length>0?e[e.length-1]:void 0}function te(t,e,i){let s;(s=K.get(t))||(s=[],K.set(t,s)),s.push(e);try{return i()}finally{let e;(e=K.get(t))&&e.pop()}}function ti(t,e){return`${t.toLowerCase()}::${e.toLowerCase()}`}function ts(t,e){return f.get(t)?.get(e)??null}function tr(t){if(!t)return[];let e=[],i=new Set,s=t.class||t._className||t._class,r=s?z(String(s)):"";for(;r&&!i.has(r);)e.push(r),i.add(r),r=j.get(r)??"";return t._superClass&&!i.has(t._superClass)&&e.push(t._superClass),e}function tn(){if(G=!1,0===W.length)return;let t=W.splice(0,W.length);for(let e of(q+=1,U))e({type:"batch.flushed",tick:q,events:t})}function ta(t){for(let e of(W.push(t),U))e(t);G||(G=!0,queueMicrotask(tn))}function to(t){ta({type:"object.created",objectId:t._id,object:t})}function th(t,e,i,s){let r=z(e);Object.is(i,s)||p(tr(t),r)&&ta({type:"field.changed",objectId:t._id,field:r,value:i,previousValue:s,object:t})}let tl=new Set,tu=null,tc=null,tp=(t.builtins??b)({runtime:()=>tc,fileSystem:t.fileSystem??null});function td(t){let e=y.get(t);if(!e)return void O.add(t);if(!e.active){for(let[t,i]of(e.active=!0,x.push(e.name),e.methods)){f.has(t)||f.set(t,new o);let e=f.get(t);for(let[t,s]of i)e.has(t)||e.set(t,[]),e.get(t).push(s)}for(let[t,i]of e.functions)g.has(t)||g.set(t,[]),g.get(t).push(i)}}function tm(t){return null==t||""===t?null:"object"==typeof t&&null!=t._id?t:"string"==typeof t?F.get(t)??null:"number"==typeof t?N.get(t)??null:null}function tf(t,e,i){let s=tm(t);if(null==s)return 0;let r=tb(s[e]);return s[e]=r+i,th(s,e,s[e],r),r}function tg(t,e){let i=ts(t,e);return i&&i.length>0?i[i.length-1]:null}function ty(t,e,i,s){let r=ts(t,e);return r&&0!==r.length?{found:!0,result:te(ti(t,e),r.length-1,()=>r[r.length-1](i,...s))}:{found:!1}}function tx(t,e,i,s){let r;d((r=tr(i)).length?r:[t],e)&&ta({type:"method.called",className:z(t),methodName:z(e),objectId:i._id,args:[...s]});let n=D.get(t);if(n){let t=n.get(e);if(t)for(let e of t)e(i,...s)}}function tb(t){if(null==t||""===t)return 0;let e=Number(t);return isNaN(e)?0:e}function tv(t){if(!t||""===t)return null;t.startsWith("/")&&(t=t.slice(1));let e=t.split("/"),i=null;for(let t=0;te._name?.toLowerCase()===t)??null}if(!i)return null}}return i}function tw(t){return null==t||""===t?null:tv(String(t))}function tM(t,e){function i(t,e){return t+e.join("_")}return{get:(e,...s)=>t.get(i(e,s))??"",set(s,...r){if(0===r.length)throw Error("set() requires at least a value argument");if(1===r.length){let i=t.get(s);return t.set(s,r[0]),e?.onSet?.(s,r[0],i),r[0]}let n=r[r.length-1],a=i(s,r.slice(0,-1)),o=t.get(a);return t.set(a,n),e?.onSet?.(a,n,o),n},postInc(s,...r){let n=i(s,r),a=tb(t.get(n)),o=a+1;return t.set(n,o),e?.onSet?.(n,o,a),a},postDec(s,...r){let n=i(s,r),a=tb(t.get(n)),o=a-1;return t.set(n,o),e?.onSet?.(n,o,a),a}}}function tS(){return tM(new o)}let tA={registerMethod:function(t,e,i){if(tu)tu.methods.has(t)||tu.methods.set(t,new o),tu.methods.get(t).set(e,i);else{f.has(t)||f.set(t,new o);let s=f.get(t);s.has(e)||s.set(e,[]),s.get(e).push(i)}},registerFunction:function(t,e){tu?tu.functions.set(t,e):(g.has(t)||g.set(t,[]),g.get(t).push(e))},package:function(t,e){let i=y.get(t);i||(i={name:t,active:!1,methods:new o,functions:new o},y.set(t,i));let s=tu;tu=i,e(),tu=s,O.has(t)&&(O.delete(t),td(t))},activatePackage:td,deactivatePackage:function(t){let e=y.get(t);if(!e||!e.active)return;e.active=!1;let i=x.findIndex(e=>e.toLowerCase()===t.toLowerCase());for(let[t,s]of(-1!==i&&x.splice(i,1),e.methods)){let e=f.get(t);if(e)for(let[t,i]of s){let s=e.get(t);if(s){let t=s.indexOf(i);-1!==t&&s.splice(t,1)}}}for(let[t,i]of e.functions){let e=g.get(t);if(e){let t=e.indexOf(i);-1!==t&&e.splice(t,1)}}},create:function(t,e,i,s){let r=z(t),n=function(){for(;N.has(L);)L+=1;let t=L;return L+=1,t}(),a={_class:r,_className:t,_id:n};for(let[t,e]of Object.entries(i))a[z(t)]=e;a.superclass&&(a._superClass=z(String(a.superclass)),a.class&&j.set(z(String(a.class)),a._superClass)),N.set(n,a);let o=B(e);if(o&&(a._name=o,F.set(o,a)),s){for(let t of s)t._parent=a;a._children=s}let h=tg(t,"onAdd");return h&&h(a),to(a),a},datablock:function(t,e,i,s){let r=z(t),n=function(){for(;N.has(P);)P+=1;let t=P;return P+=1,t}(),a={_class:r,_className:t,_id:n,_isDatablock:!0},o=B(i);if(o){let t=$.get(o);if(t){for(let[e,i]of Object.entries(t))e.startsWith("_")||(a[e]=i);a._parent=t}}for(let[t,e]of Object.entries(s))a[z(t)]=e;N.set(n,a);let h=B(e);return h&&(a._name=h,F.set(h,a),$.set(h,a)),to(a),a},deleteObject:function t(e){var i;let s;if(null==e||("number"==typeof e?s=N.get(e):"string"==typeof e?s=F.get(e):"object"==typeof e&&e._id&&(s=e),!s))return!1;let r=tg(s._className,"onRemove");if(r&&r(s),N.delete(s._id),s._name&&F.delete(s._name),s._isDatablock&&s._name&&$.delete(s._name),s._parent&&s._parent._children){let t=s._parent._children.indexOf(s);-1!==t&&s._parent._children.splice(t,1)}if(s._children)for(let e of[...s._children])t(e);return ta({type:"object.deleted",objectId:(i=s)._id,object:i}),!0},prop:function(t,e){let i=tm(t);return null==i?"":i[z(e)]??""},setProp:function(t,e,i){let s=tm(t);if(null==s)return i;let r=z(e),n=s[r];return s[r]=i,th(s,r,i,n),i},getIndex:function(t,e){let i=tm(t);return null==i?"":i[String(e)]??""},setIndex:function(t,e,i){let s=tm(t);if(null==s)return i;let r=String(e),n=s[r];return s[r]=i,th(s,r,i,n),i},propPostInc:function(t,e){return tf(t,z(e),1)},propPostDec:function(t,e){return tf(t,z(e),-1)},indexPostInc:function(t,e){return tf(t,String(e),1)},indexPostDec:function(t,e){return tf(t,String(e),-1)},key:function(t,...e){return t+e.join("_")},call:function(t,e,...i){if(null==t||("string"==typeof t||"number"==typeof t)&&null==(t=tw(t)))return"";let s=t.class||t._className||t._class;if(s){let r=ty(s,e,t,i);if(r.found)return tx(s,e,t,i),r.result}let r=t._superClass||j.get(s);for(;r;){let s=ty(r,e,t,i);if(s.found)return tx(r,e,t,i),s.result;r=j.get(r)}return""},nsCall:function(t,e,...i){let s=ts(t,e);if(!s||0===s.length)return"";let r=ti(t,e),n=s[s.length-1],a=te(r,s.length-1,()=>n(...i)),o=i[0];return o&&"object"==typeof o&&tx(t,e,o,i.slice(1)),a},nsRef:function(t,e){let i=ts(t,e);if(!i||0===i.length)return null;let s=ti(t,e),r=i[i.length-1];return(...t)=>te(s,i.length-1,()=>r(...t))},parent:function(t,e,i,...s){let r=ts(t,e),n=ti(t,e),a=tt(n);if(r&&void 0!==a&&a>=1){let o=a-1,h=te(n,o,()=>r[o](i,...s));return i&&"object"==typeof i&&tx(t,e,i,s),h}let o=j.get(t);for(;o;){let t=ts(o,e);if(t&&t.length>0){let r=te(ti(o,e),t.length-1,()=>t[t.length-1](i,...s));return i&&"object"==typeof i&&tx(o,e,i,s),r}o=j.get(o)}return""},parentFunc:function(t,...e){let i=g.get(t);if(!i)return"";let s=t.toLowerCase(),r=tt(s);if(void 0===r||r<1)return"";let n=r-1;return te(s,n,()=>i[n](...e))},add:function(t,e){return tb(t)+tb(e)},sub:function(t,e){return tb(t)-tb(e)},mul:function(t,e){return tb(t)*tb(e)},div:function(t,e){return tb(t)/tb(e)},neg:function(t){return-tb(t)},lt:function(t,e){return tb(t)tb(e)},ge:function(t,e){return tb(t)>=tb(e)},eq:function(t,e){return tb(t)===tb(e)},ne:function(t,e){return tb(t)!==tb(e)},mod:function(t,e){let i=0|Number(e);return 0===i?0:(0|Number(t))%i},bitand:function(t,e){return k(t)&k(e)},bitor:function(t,e){return k(t)|k(e)},bitxor:function(t,e){return k(t)^k(e)},shl:function(t,e){return k(k(t)<<(31&k(e)))},shr:function(t,e){return k(t)>>>(31&k(e))},bitnot:function(t){return~k(t)>>>0},concat:function(...t){return t.map(t=>String(t??"")).join("")},streq:function(t,e){return String(t??"").toLowerCase()===String(e??"").toLowerCase()},switchStr:function(t,e){let i=String(t??"").toLowerCase();for(let[t,s]of Object.entries(e))if("default"!==t&&z(t)===i)return void s();e.default&&e.default()},deref:tw,nameToId:function(t){let e=tv(t);return e?e._id:-1},isObject:function(t){return null!=t&&("object"==typeof t&&!!t._id||("number"==typeof t?N.has(t):"string"==typeof t&&F.has(t)))},isFunction:function(t){return g.has(t)||t.toLowerCase()in tp},isPackage:function(t){return y.has(t)},isActivePackage:function(t){let e=y.get(t);return e?.active??!1},getPackageList:function(){return x.join(" ")},locals:tS,onMethodCalled(t,e,i){let s=D.get(t);s||(s=new o,D.set(t,s));let r=s.get(e);return r||(r=[],s.set(e,r)),r.push(i),()=>{let t=r.indexOf(i);-1!==t&&r.splice(t,1)}}},t_={call(t,...e){let i=g.get(t);if(i&&i.length>0)return te(t.toLowerCase(),i.length-1,()=>i[i.length-1](...e));let s=tp[t.toLowerCase()];return s?s(...e):(console.warn(`Unknown function: ${t}(${e.map(t=>JSON.stringify(t)).join(", ")})`),"")}},tC=tM(V,{onSet:function(t,e,i){let s=z(t.startsWith("$")?t.slice(1):t);Object.is(e,i)||m(s)&&ta({type:"global.changed",name:s,value:e,previousValue:i})}}),tT={methods:f,functions:g,packages:y,activePackages:x,objectsById:N,objectsByName:F,datablocks:$,globals:V,executedScripts:H,failedScripts:J,scripts:Y,generatedCode:Q,pendingTimeouts:tl,startTime:Date.now()};function tI(t){let e=function(t){let e=Q.get(t);null==e&&(e=new n(void 0).generate(t),Q.set(t,e));return e}(t),i=tS();Function("$","$f","$g","$l",e)(tA,t_,tC,i)}function tz(t,e){return{execute(){if(e){let t=l(e);tT.executedScripts.add(t)}tI(t)}}}async function tk(e,i,s){let r=t.loadScript;if(!r){e.length>0&&console.warn("Script has exec() calls but no loadScript provided:",e);return}async function n(e){t.signal?.throwIfAborted();let n=l(e);if(tT.scripts.has(n)||tT.failedScripts.has(n))return;if(X&&X(n)){console.warn(`Ignoring script: ${e}`),tT.failedScripts.add(n);return}if(s.has(n))return;let a=i.get(n);if(a)return void await a;t.progress?.addItem(e);let o=(async()=>{let a,o=await r(e);if(null==o){console.warn(`Script not found: ${e}`),tT.failedScripts.add(n),t.progress?.completeItem();return}try{a=E(o,{filename:e})}catch(i){console.warn(`Failed to parse script: ${e}`,i),tT.failedScripts.add(n),t.progress?.completeItem();return}let h=new Set(s);h.add(n),await tk(a.execScriptPaths,i,h),tT.scripts.set(n,a),t.progress?.completeItem()})();i.set(n,o),await o}await Promise.all(e.map(n))}async function tB(e){let i=t.loadScript;if(!i)throw Error("loadFromPath requires loadScript option to be set");let s=l(e);if(tT.scripts.has(s))return tz(tT.scripts.get(s),e);t.progress?.addItem(e);let r=await i(e);if(null==r)throw t.progress?.completeItem(),Error(`Script not found: ${e}`);let n=await tR(r,{path:e});return t.progress?.completeItem(),n}async function tR(t,e){if(e?.path){let t=l(e.path);if(tT.scripts.has(t))return tz(tT.scripts.get(t),e.path)}return tO(E(t,{filename:e?.path}),e)}async function tO(e,i){let s=new Map,r=new Set;if(i?.path){let t=l(i.path);tT.scripts.set(t,e),r.add(t)}let n=[...e.execScriptPaths,...t.preloadScripts??[]];return await tk(n,s,r),tz(e,i?.path)}return tc={$:tA,$f:t_,$g:tC,state:tT,destroy:function(){for(let t of(W.length>0&&tn(),tT.pendingTimeouts))clearTimeout(t);tT.pendingTimeouts.clear(),U.clear()},executeAST:tI,loadFromPath:tB,loadFromSource:tR,loadFromAST:tO,call:(t,...e)=>t_.call(t,...e),getObjectByName:t=>F.get(t),subscribeRuntimeEvents:t=>(U.add(t),()=>{U.delete(t)})}}function O(){let t=new Set,e=0,i=0,s=null;function r(){for(let e of t)e()}return{get total(){return e},get loaded(){return i},get current(){return s},get progress(){return 0===e?0:i/e},on(e,i){t.add(i)},off(e,i){t.delete(i)},addItem(t){e++,s=t,r()},completeItem(){i++,s=null,r()},setCurrent(t){s=t,r()}}}function E(t,e){try{return i.default.parse(t)}catch(t){if(e?.filename&&t.location)throw Error(`${e.filename}:${t.location.start.line}:${t.location.start.column}: ${t.message}`,{cause:t});throw t}}function P(t){if("boolean"==typeof t)return t;if("number"==typeof t)return 0!==t;if("string"==typeof t){let e=t.trim().toLowerCase();return""!==e&&"0"!==e&&"false"!==e}return!!t}function L(){let t=Error("Operation aborted");return t.name="AbortError",t}function N(t){let e,{missionName:i,missionType:s,runtimeOptions:r,onMissionLoadDone:n}=t,{signal:a,fileSystem:o,globals:h={},preloadScripts:l=[],reactiveGlobalNames:u}=r??{},c=o?.findFiles("scripts/*Game.cs")??[],p=u?Array.from(new Set([...u,"missionRunning"])):void 0,d=R({...r,reactiveGlobalNames:p,globals:{...h,"$Host::Map":i,"$Host::MissionType":s},preloadScripts:[...l,...c]});(e=d.$.registerMethod.bind(d.$))("ShapeBase","playThread",(t,e,i)=>{t._threads||(t._threads={}),t._threads[Number(e)]={sequence:String(i),playing:!0,direction:!0}}),e("ShapeBase","stopThread",(t,e)=>{t._threads&&delete t._threads[Number(e)]}),e("ShapeBase","setThreadDir",(t,e,i)=>{t._threads||(t._threads={});let s=Number(e);t._threads[s]?t._threads[s].direction=!!Number(i):t._threads[s]={sequence:"",playing:!1,direction:!!Number(i)}}),e("ShapeBase","pauseThread",(t,e)=>{t._threads?.[Number(e)]&&(t._threads[Number(e)].playing=!1)}),e("ShapeBase","playAudio",()=>{}),e("ShapeBase","stopAudio",()=>{}),e("SimObject","getDatablock",t=>{let e=t.datablock;return e?d.getObjectByName(String(e))??"":""}),e("SimObject","getGroup",t=>t._parent??""),e("SimObject","getName",t=>t._name??""),e("SimObject","getType",()=>16384),e("SimGroup","getCount",t=>t._children?t._children.length:0),e("SimGroup","getObject",(t,e)=>{let i=t._children;return i?i[Number(e)]??"":""}),e("GameBase","isEnabled",()=>!0),e("GameBase","isDisabled",()=>!1),e("GameBase","setPoweredState",()=>{}),e("GameBase","setRechargeRate",()=>{}),e("GameBase","getRechargeRate",()=>0),e("GameBase","setEnergyLevel",()=>{}),e("GameBase","getEnergyLevel",()=>0),e("ShapeBase","getDamageLevel",()=>0),e("ShapeBase","setDamageLevel",()=>{}),e("ShapeBase","getRepairRate",()=>0),e("ShapeBase","setRepairRate",()=>{}),e("ShapeBase","getDamagePercent",()=>0),e("GameBase","getControllingClient",()=>0),e("SimObject","schedule",(t,e,i,...s)=>{let r=setTimeout(()=>{d.state.pendingTimeouts.delete(r);try{d.$.call(t,String(i),...s)}catch(e){console.error(`schedule: error calling ${i} on ${t._id}:`,e)}},Number(e)||0);return d.state.pendingTimeouts.add(r),r});let m=async function(){try{let t=await d.loadFromPath("scripts/server.cs");a?.throwIfAborted(),await d.loadFromPath(`missions/${i}.mis`),a?.throwIfAborted(),t.execute();let e=function(t,e){let{signal:i,onMissionLoadDone:s}=e;return new Promise((e,r)=>{let n=!1,a=!1,o=()=>P(t.$g.get("missionRunning")),h=()=>{n||(n=!0,d(),e())},l=t=>{n||(n=!0,d(),r(t))},u=e=>{if(!s||a)return;let i=e??t.getObjectByName("Game");i&&(a=!0,s(i))},c=()=>l(L()),p=t.subscribeRuntimeEvents(t=>{if("global.changed"===t.type&&"missionrunning"===t.name){P(t.value)&&(u(),h());return}"batch.flushed"===t.type&&o()&&(u(),h())});function d(){p(),i?.removeEventListener("abort",c)}if(i){if(i.aborted)return void l(L());i.addEventListener("abort",c,{once:!0})}o()&&(u(),h())})}(d,{signal:a,onMissionLoadDone:n}),s=await d.loadFromSource("CreateServer($Host::Map, $Host::MissionType);");a?.throwIfAborted(),s.execute(),await e}catch(t){if(t instanceof Error&&"AbortError"===t.name)return;throw t}}();return{runtime:d,ready:m}}t.s(["createProgressTracker",()=>O],38433);let F=/^[ \t]*(DisplayName|MissionTypes|BriefingWAV|Bitmap|PlanetName)[ \t]*=[ \t]*(.+)$/i,$=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+BEGIN[ \t]*-+$/i,V=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+END[ \t]*-+$/i,D={arena:"Arena",bounty:"Bounty",cnh:"CnH",ctf:"CTF",dm:"DM",dnd:"DnD",hunters:"Hunters",lakrabbit:"LakRabbit",lakzm:"LakZM",lctf:"LCTF",none:"None",rabbit:"Rabbit",sctf:"SCtF",siege:"Siege",singleplayer:"SinglePlayer",tdm:"TDM",teamhunters:"TeamHunters",teamlak:"TeamLak",tr2:"TR2"};function j(t){let e=E(t),{pragma:i,sections:s}=function(t){let e={},i=[],s={name:null,comments:[]};for(let r of t.body)if("Comment"===r.type){let t=function(t){let e;return(e=t.match($))?{type:"sectionBegin",name:e[1]}:(e=t.match(V))?{type:"sectionEnd",name:e[1]}:(e=t.match(F))?{type:"definition",identifier:e[1],value:e[2]}:null}(r.value);if(t)switch(t.type){case"definition":null===s.name?e[t.identifier.toLowerCase()]=t.value:s.comments.push(r.value);break;case"sectionBegin":(null!==s.name||s.comments.length>0)&&i.push(s),s={name:t.name.toUpperCase(),comments:[]};break;case"sectionEnd":null!==s.name&&i.push(s),s={name:null,comments:[]}}else s.comments.push(r.value)}return(null!==s.name||s.comments.length>0)&&i.push(s),{pragma:e,sections:i}}(e);function r(t){return s.find(e=>e.name===t)?.comments.map(t=>t.trimStart()).join("\n")??null}return{displayName:i.displayname??null,missionTypes:i.missiontypes?.split(/\s+/).filter(Boolean).map(t=>D[t.toLowerCase()]??t)??[],missionBriefing:r("MISSION BRIEFING"),briefingWav:i.briefingwav??null,bitmap:i.bitmap??null,planetName:i.planetname??null,missionBlurb:r("MISSION BLURB"),missionQuote:r("MISSION QUOTE"),missionString:r("MISSION STRING"),execScriptPaths:e.execScriptPaths,hasDynamicExec:e.hasDynamicExec,ast:e}}function U(t,e){if(t)return t[e.toLowerCase()]}function W(t,e){let i=t[e.toLowerCase()];return null==i?i:parseFloat(i)}function G(t,e){let i=t[e.toLowerCase()];return null==i?i:parseInt(i,10)}function q(t){let[e,i,s]=(t.position??"0 0 0").split(" ").map(t=>parseFloat(t));return[i||0,s||0,e||0]}function H(t){let[e,i,s]=(t.scale??"1 1 1").split(" ").map(t=>parseFloat(t));return[i||0,s||0,e||0]}function J(t){let[i,s,r,n]=(t.rotation??"1 0 0 0").split(" ").map(t=>parseFloat(t)),a=new e.Vector3(s,r,i).normalize(),o=-(Math.PI/180*n);return new e.Quaternion().setFromAxisAngle(a,o)}t.s(["getFloat",()=>W,"getInt",()=>G,"getPosition",()=>q,"getProperty",()=>U,"getRotation",()=>J,"getScale",()=>H,"parseMissionScript",()=>j],62395)},12979,t=>{"use strict";var e=t.i(98223),i=t.i(91996),s=t.i(62395),r=t.i(71726);let n="/t2-mapper",a=`${n}/base/`,o=`${n}/magenta.png`;function h(t,e){let s;try{s=(0,i.getActualResourceKey)(t)}catch(i){if(e)return console.warn(`Resource "${t}" not found - rendering fallback.`),e;throw i}let[r,n]=(0,i.getSourceAndPath)(s);return r?`${a}@vl2/${r}/${n}`:`${a}${n}`}function l(t){return h(`interiors/${t}`).replace(/\.dif$/i,".glb")}function u(t){return h(`shapes/${t}`).replace(/\.dts$/i,".glb")}function c(t){return t=t.replace(/^terrain\./,""),h((0,i.getStandardTextureResourceKey)(`textures/terrain/${t}`),o)}function p(t,e){let s=(0,r.normalizePath)(e).split("/"),n=s.length>1?s.slice(0,-1).join("/")+"/":"",a=`${n}${t}`;return h((0,i.getStandardTextureResourceKey)(a),o)}function d(t){return h((0,i.getStandardTextureResourceKey)(`textures/${t}`),o)}function m(t){return h(`audio/${t}`).replace(/\.wav$/i,".ogg")}async function f(t){let e=h(`textures/${t}`),i=await fetch(e);return(await i.text()).split(/(?:\r\n|\r|\n)/).map(t=>{if(!(t=t.trim()).startsWith(";"))return t}).filter(Boolean)}async function g(t){let e,r=(0,i.getMissionInfo)(t),n=await fetch(h(r.resourcePath)),a=await n.arrayBuffer();try{e=new TextDecoder("utf-8",{fatal:!0}).decode(a)}catch{e=new TextDecoder("windows-1252").decode(a)}return e=e.replaceAll("�","'"),(0,s.parseMissionScript)(e)}async function y(t){let e=await fetch(h(`terrains/${t}`));return function(t){let e=new DataView(t),i=0,s=e.getUint8(i++),r=new Uint16Array(65536),n=[],a=t=>{let s="";for(let r=0;r0&&n.push(r)}let o=[];for(let t of n){let t=new Uint8Array(65536);for(let s=0;s<65536;s++){let r=e.getUint8(i++);t[s]=r}o.push(t)}return{version:s,textureNames:n,heightMap:r,alphaMaps:o}}(await e.arrayBuffer())}async function x(t){let i=h(t),s=await fetch(i),r=await s.text();return(0,e.parseImageFileList)(r)}t.s(["FALLBACK_TEXTURE_URL",0,o,"RESOURCE_ROOT_URL",0,a,"audioToUrl",()=>m,"getUrlForPath",()=>h,"iflTextureToUrl",()=>p,"interiorToUrl",()=>l,"loadDetailMapList",()=>f,"loadImageFrameList",()=>x,"loadMission",()=>g,"loadTerrain",()=>y,"shapeToUrl",()=>u,"terrainTextureToUrl",()=>c,"textureToUrl",()=>d],12979)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/99bc9f3ae93187f1.css b/docs/_next/static/chunks/99bc9f3ae93187f1.css new file mode 100644 index 00000000..a2253092 --- /dev/null +++ b/docs/_next/static/chunks/99bc9f3ae93187f1.css @@ -0,0 +1 @@ +.DemoPlaybackControls-module__A_AHSq__Root{color:#fff;z-index:2;background:#000000b3;align-items:center;gap:10px;padding:8px 12px;font-size:13px;display:flex;position:fixed;bottom:0;left:0;right:0}.DemoPlaybackControls-module__A_AHSq__PlayPause{color:#fff;cursor:pointer;background:#03529399;border:1px solid #ffffff4d;border-radius:4px;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;padding:0;font-size:14px;display:flex}@media (hover:hover){.DemoPlaybackControls-module__A_AHSq__PlayPause:hover{background:#0062b3cc}}.DemoPlaybackControls-module__A_AHSq__Time{font-variant-numeric:tabular-nums;white-space:nowrap;flex-shrink:0}.DemoPlaybackControls-module__A_AHSq__Seek[type=range]{flex:1 1 0;min-width:0;max-width:none}.DemoPlaybackControls-module__A_AHSq__Speed{color:#fff;background:#0009;border:1px solid #ffffff4d;border-radius:3px;flex-shrink:0;padding:2px 4px;font-size:12px} diff --git a/docs/_next/static/chunks/9eaea0ae086bad69.js b/docs/_next/static/chunks/9eaea0ae086bad69.js new file mode 100644 index 00000000..d3cb05e5 --- /dev/null +++ b/docs/_next/static/chunks/9eaea0ae086bad69.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,11152,40141,t=>{"use strict";var e=t.i(71645),r={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},o=e.default.createContext&&e.default.createContext(r),n=["attr","size","title"];function c(){return(c=Object.assign.bind()).apply(this,arguments)}function l(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,o)}return r}function a(t){for(var e=1;ee.default.createElement(u,c({attr:a({},t.attr)},r),function t(r){return r&&r.map((r,o)=>e.default.createElement(r.tag,a({key:o},r.attr),t(r.child)))}(t.child))}function u(t){var l=r=>{var o,{attr:l,size:i,title:u}=t,s=function(t,e){if(null==t)return{};var r,o,n=function(t,e){if(null==t)return{};var r={};for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){if(e.indexOf(o)>=0)continue;r[o]=t[o]}return r}(t,e);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(o=0;o=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(t,n),f=i||r.size||"1em";return r.className&&(o=r.className),t.className&&(o=(o?o+" ":"")+t.className),e.default.createElement("svg",c({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},r.attr,l,s,{className:o,style:a(a({color:t.color||r.color},r.style),t.style),height:f,width:f,xmlns:"http://www.w3.org/2000/svg"}),u&&e.default.createElement("title",null,u),t.children)};return void 0!==o?e.default.createElement(o.Consumer,null,t=>l(t)):l(r)}function s(t){return i({tag:"svg",attr:{viewBox:"0 0 288 512"},child:[{tag:"path",attr:{d:"M112 316.94v156.69l22.02 33.02c4.75 7.12 15.22 7.12 19.97 0L176 473.63V316.94c-10.39 1.92-21.06 3.06-32 3.06s-21.61-1.14-32-3.06zM144 0C64.47 0 0 64.47 0 144s64.47 144 144 144 144-64.47 144-144S223.53 0 144 0zm0 76c-37.5 0-68 30.5-68 68 0 6.62-5.38 12-12 12s-12-5.38-12-12c0-50.73 41.28-92 92-92 6.62 0 12 5.38 12 12s-5.38 12-12 12z"},child:[]}]})(t)}function f(t){return i({tag:"svg",attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zM461.64 256l45.64-45.64c6.3-6.3 6.3-16.52 0-22.82l-22.82-22.82c-6.3-6.3-16.52-6.3-22.82 0L416 210.36l-45.64-45.64c-6.3-6.3-16.52-6.3-22.82 0l-22.82 22.82c-6.3 6.3-6.3 16.52 0 22.82L370.36 256l-45.63 45.63c-6.3 6.3-6.3 16.52 0 22.82l22.82 22.82c6.3 6.3 16.52 6.3 22.82 0L416 301.64l45.64 45.64c6.3 6.3 16.52 6.3 22.82 0l22.82-22.82c6.3-6.3 6.3-16.52 0-22.82L461.64 256z"},child:[]}]})(t)}function d(t){return i({tag:"svg",attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M215.03 71.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c15.03 15.03 40.97 4.47 40.97-16.97V88.02c0-21.46-25.96-31.98-40.97-16.97zm233.32-51.08c-11.17-7.33-26.18-4.24-33.51 6.95-7.34 11.17-4.22 26.18 6.95 33.51 66.27 43.49 105.82 116.6 105.82 195.58 0 78.98-39.55 152.09-105.82 195.58-11.17 7.32-14.29 22.34-6.95 33.5 7.04 10.71 21.93 14.56 33.51 6.95C528.27 439.58 576 351.33 576 256S528.27 72.43 448.35 19.97zM480 256c0-63.53-32.06-121.94-85.77-156.24-11.19-7.14-26.03-3.82-33.12 7.46s-3.78 26.21 7.41 33.36C408.27 165.97 432 209.11 432 256s-23.73 90.03-63.48 115.42c-11.19 7.14-14.5 22.07-7.41 33.36 6.51 10.36 21.12 15.14 33.12 7.46C447.94 377.94 480 319.54 480 256zm-141.77-76.87c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.38-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.88s-17.54-61.32-45.78-76.86z"},child:[]}]})(t)}t.s(["GenIcon",()=>i],40141),t.s(["FaMapPin",()=>s,"FaVolumeMute",()=>f,"FaVolumeUp",()=>d],11152)},6090,t=>{t.v({DialogButton:"DialogButton-module__LxvdOa__DialogButton",Secondary:"DialogButton-module__LxvdOa__Secondary DialogButton-module__LxvdOa__DialogButton"})}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/aed6ada67562a5fc.js b/docs/_next/static/chunks/aed6ada67562a5fc.js new file mode 100644 index 00000000..d3de4ba7 --- /dev/null +++ b/docs/_next/static/chunks/aed6ada67562a5fc.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,66789,e=>{"use strict";var t=e.i(43476),i=e.i(71645),r=e.i(71753),a=e.i(90072);e.i(13876);var n=e.i(58647),o=e.i(82816),l=e.i(85557),s=e.i(71505),u=e.i(91907),c=e.i(25947);function m({shapeName:e,playerShapeName:r}){let a=(0,u.useStaticShape)(r),n=(0,u.useStaticShape)(e),o=(0,i.useMemo)(()=>{let t,i,r=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(e),o=(0,l.getPosedNodeTransform)(a.scene,a.animations,"Mount0",[r]);if(!o)return{position:void 0,quaternion:void 0};let s=(0,l.getPosedNodeTransform)(n.scene,n.animations,"Mountpoint");if(s){let e=s.quaternion.clone().invert(),r=s.position.clone().negate().applyQuaternion(e);i=o.quaternion.clone().multiply(e),t=r.clone().applyQuaternion(o.quaternion).add(o.position)}else t=o.position.clone(),i=o.quaternion.clone();return{position:t.applyQuaternion(l._r90),quaternion:l._r90.clone().multiply(i).multiply(l._r90inv)}},[a,n]),s=(0,i.useMemo)(()=>({_class:"weapon",_className:"Weapon",_id:0}),[]);return(0,t.jsx)(c.ShapeInfoProvider,{object:s,shapeName:e,type:"Item",children:(0,t.jsx)("group",{position:o.position,quaternion:o.quaternion,children:(0,t.jsx)(u.ShapeRenderer,{loadingColor:"#4488ff"})})})}function f({entity:e,playback:c}){let m=(0,u.useStaticShape)(e.dataBlock),f=(0,i.useRef)(null),p=(0,i.useRef)((0,n.effectNow)()),h=(0,i.useRef)(Math.random()*Math.PI*2),d=(0,i.useRef)([]),y=(0,i.useMemo)(()=>{if(e.explosionDataBlockId)return c.getDataBlockData(e.explosionDataBlockId)},[e.explosionDataBlockId,c]),g=(0,i.useMemo)(()=>y?function(e){let t=e.sizes,i=e.times;if(!Array.isArray(t)||0===t.length)return{times:[0,1],sizes:[[1,1,1],[1,1,1]]};let r=t.map(e=>[e.x/100,e.y/100,e.z/100]);return{times:Array.isArray(i)?i:r.map((e,t)=>t/Math.max(r.length-1,1)),sizes:r}}(y):void 0,[y]),v=(0,i.useMemo)(()=>{let e=y?.explosionScale;return e?[e.x/100,e.y/100,e.z/100]:[1,1,1]},[y]),M=32*(y?.lifetimeMS??31),A=!1!==e.faceViewer,{scene:_,mixer:S,visNodes:x,iflInfos:q,materials:b}=(0,i.useMemo)(()=>{let t=o.clone(m.scene),i=[];t.traverse(e=>{if(!e.isMesh||!e.material)return;let t=Array.isArray(e.material)?e.material[0]:e.material;if(!t?.userData)return;let r=new Set(t.userData.flag_names??[]),a=t.userData.resource_path;if(r.has("IflMaterial")&&a){let t=e.userData;i.push({mesh:e,iflPath:`textures/${a}.ifl`,sequenceName:t?.ifl_sequence?String(t.ifl_sequence).toLowerCase():void 0,duration:t?.ifl_duration?Number(t.ifl_duration):void 0,cyclic:t?.ifl_sequence?!!t.ifl_cyclic:void 0,toolBegin:t?.ifl_tool_begin!=null?Number(t.ifl_tool_begin):void 0})}}),(0,l.processShapeScene)(t,e.dataBlock);let r=[];for(let e of(t.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let i=t.vis_keyframes,a=t.vis_duration,n=(t.vis_sequence??"").toLowerCase();n&&Array.isArray(i)&&!(i.length<=1)&&a&&!(a<=0)&&"ambient"===n&&r.push({mesh:e,keyframes:i,duration:a,cyclic:!!t.vis_cyclic})}),r))e.mesh.visible=!0,e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.transparent=!0,e.mesh.material.depthWrite=!1);for(let e of i)e.mesh.userData?.vis_sequence||(e.mesh.visible=!0);let n=new Map;for(let e of m.animations)n.set(e.name.toLowerCase(),e);let s=n.get("ambient"),u=null;if(s){let e=(u=new a.AnimationMixer(t)).clipAction(s);e.setLoop(a.LoopOnce,1),e.clampWhenFinished=!0,e.timeScale=(y?.playSpeed??20)/20,e.play()}let c=[];return t.traverse(e=>{e.isMesh&&(Array.isArray(e.material)?c.push(...e.material):e.material&&c.push(e.material))}),t.traverse(e=>{e.frustumCulled=!1}),{scene:t,mixer:u,visNodes:r,iflInfos:i,materials:c}},[m,y]);return(0,i.useEffect)(()=>{for(let e of(d.current=[],q))(0,s.loadIflAtlas)(e.iflPath).then(t=>{let i=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;i&&(i.map=t.texture,i.needsUpdate=!0),d.current.push({atlas:t,info:e})}).catch(()=>{})},[q]),(0,r.useFrame)((e,t)=>{let i=f.current;if(!i)return;let r=n.engineStore.getState().playback,a="playing"===r.status?t*r.rate:0,o=(0,n.effectNow)()-p.current,l=Math.min(o/M,1),u=o/1e3;S&&S.update(a);let c=l>.8?1-(l-.8)/.2:1;for(let{mesh:e,keyframes:t,duration:i,cyclic:r}of x){let a=e.material;if(!a||Array.isArray(a))continue;let n=u/i,o=r?n%1:Math.min(n,1),l=t.length,s=o*l,m=Math.floor(s)%l,f=(m+1)%l,p=s-Math.floor(s);a.opacity=(t[m]+(t[f]-t[m])*p)*c}if(c<1)for(let e of b)"opacity"in e&&(e.transparent=!0,e.opacity*=c);for(let{atlas:e,info:t}of d.current){let i;i=t.sequenceName&&t.duration?(t.cyclic?u/t.duration%1:Math.min(u/t.duration,1))*t.duration+(t.toolBegin??0):u,(0,s.updateAtlasFrame)(e,(0,s.getFrameIndexForTime)(e,i))}if(g){let e=function(e,t){let{times:i,sizes:r}=e;if(0===i.length)return[1,1,1];if(t<=i[0])return r[0];if(t>=i[i.length-1])return r[r.length-1];for(let e=0;e=i[e]&&t<=i[e+1]){let a=(t-i[e])/(i[e+1]-i[e]);return[r[e][0]+(r[e+1][0]-r[e][0])*a,r[e][1]+(r[e+1][1]-r[e][1])*a,r[e][2]+(r[e+1][2]-r[e][2])*a]}return r[r.length-1]}(g,l);i.scale.set(e[0]*v[0],e[1]*v[1],e[2]*v[2])}A&&(i.lookAt(e.camera.position),i.rotateZ(h.current))}),(0,t.jsx)("group",{ref:f,children:(0,t.jsx)("group",{rotation:[0,Math.PI,0],children:(0,t.jsx)("primitive",{object:_})})})}e.s(["ExplosionShape",()=>f,"WeaponModel",()=>m])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/b07469fc6c6cd3bb.js b/docs/_next/static/chunks/b07469fc6c6cd3bb.js new file mode 100644 index 00000000..b170a52d --- /dev/null +++ b/docs/_next/static/chunks/b07469fc6c6cd3bb.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13070,e=>{e.v({Arrow:"KeyboardOverlay-module__HsRBsa__Arrow",Column:"KeyboardOverlay-module__HsRBsa__Column",Key:"KeyboardOverlay-module__HsRBsa__Key",Root:"KeyboardOverlay-module__HsRBsa__Root",Row:"KeyboardOverlay-module__HsRBsa__Row",Spacer:"KeyboardOverlay-module__HsRBsa__Spacer"})},78295,e=>{e.v({Joystick:"TouchControls-module__AkxfgW__Joystick",Left:"TouchControls-module__AkxfgW__Left TouchControls-module__AkxfgW__Joystick",Right:"TouchControls-module__AkxfgW__Right TouchControls-module__AkxfgW__Joystick"})},65883,e=>{e.v({ButtonLabel:"InspectorControls-module__gNRB6W__ButtonLabel",CheckboxField:"InspectorControls-module__gNRB6W__CheckboxField",Controls:"InspectorControls-module__gNRB6W__Controls",Dropdown:"InspectorControls-module__gNRB6W__Dropdown",Field:"InspectorControls-module__gNRB6W__Field",Group:"InspectorControls-module__gNRB6W__Group",IconButton:"InspectorControls-module__gNRB6W__IconButton",LabelledButton:"InspectorControls-module__gNRB6W__LabelledButton",MapInfoButton:"InspectorControls-module__gNRB6W__MapInfoButton InspectorControls-module__gNRB6W__IconButton InspectorControls-module__gNRB6W__LabelledButton",MissionSelectWrapper:"InspectorControls-module__gNRB6W__MissionSelectWrapper",Toggle:"InspectorControls-module__gNRB6W__Toggle InspectorControls-module__gNRB6W__IconButton"})},36679,e=>{e.v({ButtonLabel:"CopyCoordinatesButton-module__BxovtG__ButtonLabel "+e.i(65883).ButtonLabel,ClipboardCheck:"CopyCoordinatesButton-module__BxovtG__ClipboardCheck",MapPin:"CopyCoordinatesButton-module__BxovtG__MapPin",Root:"CopyCoordinatesButton-module__BxovtG__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton,showClipboardCheck:"CopyCoordinatesButton-module__BxovtG__showClipboardCheck"})},28903,e=>{e.v({ButtonLabel:"LoadDemoButton-module__kGZaoW__ButtonLabel "+e.i(65883).ButtonLabel,DemoIcon:"LoadDemoButton-module__kGZaoW__DemoIcon",Root:"LoadDemoButton-module__kGZaoW__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton})},9607,e=>{e.v({LiveIcon:"JoinServerButton-module__DIR70a__LiveIcon",PingLabel:"JoinServerButton-module__DIR70a__PingLabel "+e.i(65883).ButtonLabel,Pulsing:"JoinServerButton-module__DIR70a__Pulsing",Root:"JoinServerButton-module__DIR70a__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton,TextLabel:"JoinServerButton-module__DIR70a__TextLabel "+e.i(65883).ButtonLabel,blink:"JoinServerButton-module__DIR70a__blink"})},75840,e=>{e.v({BarFillEnergy:"PlayerHUD-module__-E1Scq__BarFillEnergy",BarFillHealth:"PlayerHUD-module__-E1Scq__BarFillHealth",BarTrack:"PlayerHUD-module__-E1Scq__BarTrack",Bars:"PlayerHUD-module__-E1Scq__Bars",ChatColor0:"PlayerHUD-module__-E1Scq__ChatColor0",ChatColor1:"PlayerHUD-module__-E1Scq__ChatColor1",ChatColor2:"PlayerHUD-module__-E1Scq__ChatColor2",ChatColor3:"PlayerHUD-module__-E1Scq__ChatColor3",ChatColor4:"PlayerHUD-module__-E1Scq__ChatColor4",ChatColor5:"PlayerHUD-module__-E1Scq__ChatColor5",ChatColor6:"PlayerHUD-module__-E1Scq__ChatColor6",ChatColor7:"PlayerHUD-module__-E1Scq__ChatColor7",ChatColor8:"PlayerHUD-module__-E1Scq__ChatColor8",ChatColor9:"PlayerHUD-module__-E1Scq__ChatColor9",ChatMessage:"PlayerHUD-module__-E1Scq__ChatMessage",ChatWindow:"PlayerHUD-module__-E1Scq__ChatWindow",Compass:"PlayerHUD-module__-E1Scq__Compass",CompassNSEW:"PlayerHUD-module__-E1Scq__CompassNSEW",CompassRing:"PlayerHUD-module__-E1Scq__CompassRing",PackInvCount:"PlayerHUD-module__-E1Scq__PackInvCount",PackInvIcon:"PlayerHUD-module__-E1Scq__PackInvIcon",PackInvInfinity:"PlayerHUD-module__-E1Scq__PackInvInfinity",PackInvItem:"PlayerHUD-module__-E1Scq__PackInvItem",PackInvItemActive:"PlayerHUD-module__-E1Scq__PackInvItemActive",PackInvItemDim:"PlayerHUD-module__-E1Scq__PackInvItemDim",PackInventoryHUD:"PlayerHUD-module__-E1Scq__PackInventoryHUD",PlayerHUD:"PlayerHUD-module__-E1Scq__PlayerHUD",Reticle:"PlayerHUD-module__-E1Scq__Reticle",ReticleDot:"PlayerHUD-module__-E1Scq__ReticleDot",ReticleImage:"PlayerHUD-module__-E1Scq__ReticleImage",TeamCount:"PlayerHUD-module__-E1Scq__TeamCount",TeamNameEnemy:"PlayerHUD-module__-E1Scq__TeamNameEnemy",TeamNameFriendly:"PlayerHUD-module__-E1Scq__TeamNameFriendly",TeamRow:"PlayerHUD-module__-E1Scq__TeamRow",TeamScore:"PlayerHUD-module__-E1Scq__TeamScore",TeamScores:"PlayerHUD-module__-E1Scq__TeamScores",TopRight:"PlayerHUD-module__-E1Scq__TopRight",WeaponHUD:"PlayerHUD-module__-E1Scq__WeaponHUD",WeaponSeparator:"PlayerHUD-module__-E1Scq__WeaponSeparator"})},56614,e=>{e.v({CloseButton:"ServerBrowser-module__kqm3eq__CloseButton "+e.i(6090).Secondary,Dialog:"ServerBrowser-module__kqm3eq__Dialog",Empty:"ServerBrowser-module__kqm3eq__Empty",Footer:"ServerBrowser-module__kqm3eq__Footer",Header:"ServerBrowser-module__kqm3eq__Header",Hint:"ServerBrowser-module__kqm3eq__Hint",JoinButton:"ServerBrowser-module__kqm3eq__JoinButton "+e.i(6090).DialogButton,Overlay:"ServerBrowser-module__kqm3eq__Overlay",PasswordIcon:"ServerBrowser-module__kqm3eq__PasswordIcon",RefreshButton:"ServerBrowser-module__kqm3eq__RefreshButton "+e.i(6090).DialogButton,Selected:"ServerBrowser-module__kqm3eq__Selected",ServerCount:"ServerBrowser-module__kqm3eq__ServerCount",Table:"ServerBrowser-module__kqm3eq__Table",TableWrapper:"ServerBrowser-module__kqm3eq__TableWrapper",Title:"ServerBrowser-module__kqm3eq__Title"})},3011,e=>{e.v({CanvasContainer:"page-module__E0kJGG__CanvasContainer",LoadingIndicator:"page-module__E0kJGG__LoadingIndicator",Progress:"page-module__E0kJGG__Progress",ProgressBar:"page-module__E0kJGG__ProgressBar",ProgressText:"page-module__E0kJGG__ProgressText",Spinner:"page-module__E0kJGG__Spinner",loadingComplete:"page-module__E0kJGG__loadingComplete",spin:"page-module__E0kJGG__spin"})},31713,e=>{"use strict";var t=e.i(43476),a=e.i(932),r=e.i(71645),n=e.i(75056),s=e.i(90072),o=e.i(66027),l=e.i(54970),i=e.i(12979),c=e.i(32424);let u=(0,r.createContext)(null);function d(e){let r,n=(0,a.c)(3),{runtime:s,children:o}=e;return n[0]!==o||n[1]!==s?(r=(0,t.jsx)(u.Provider,{value:s,children:o}),n[0]=o,n[1]=s,n[2]=r):r=n[2],r}var m=e.i(86608),h=e.i(38433),p=e.i(33870),f=e.i(91996);let _=(0,r.createContext)(null).Provider;e.i(13876);var g=e.i(58647),y=e.i(92224),v=e.i(7368),x=e.i(62395),b=e.i(9672);function k(e,t){if(t)return e.state.datablocks.get(t)}let S=(0,c.createScriptLoader)(),C=(0,p.createScriptCache)(),j={findFiles:e=>{let t=(0,l.default)(e,{nocase:!0});return(0,f.getResourceList)().filter(e=>t(e)).map(e=>{let[,t]=(0,f.getSourceAndPath)(e);return t})},isFile:e=>null!=(0,f.getResourceMap)()[(0,f.getResourceKey)(e)]};function w(e){"batch.flushed"===e.type&&g.engineStore.getState().applyRuntimeBatch(e.events,{tick:e.tick})}function N(e){e instanceof Error&&"AbortError"===e.name||console.error("Mission runtime failed to become ready:",e)}let I=(0,r.memo)(function(e){let n,s,l,c,u,p,f,I=(0,a.c)(13),{name:T,missionType:P,onLoadingChange:B}=e,{data:D}=((f=(0,a.c)(2))[0]!==T?(p={queryKey:["parsedMission",T],queryFn:()=>(0,i.loadMission)(T)},f[0]=T,f[1]=p):p=f[1],(0,o.useQuery)(p)),{ready:E,runtime:M,progress:R}=function(e,t,n){let s,o,l,i=(0,a.c)(6);i[0]===Symbol.for("react.memo_cache_sentinel")?(s={ready:!1,runtime:void 0,progress:0},i[0]=s):s=i[0];let[c,u]=(0,r.useState)(s);return i[1]!==e||i[2]!==t||i[3]!==n?(o=()=>{if(!n)return;let a=new AbortController,r=!1,s=null,o=(0,h.createProgressTracker)(),l=()=>{u(e=>({...e,progress:o.progress}))};o.on("update",l);let{runtime:i,ready:c}=(0,m.runServer)({missionName:e,missionType:t,runtimeOptions:{loadScript:S,fileSystem:j,cache:C,signal:a.signal,progress:o,ignoreScripts:v.ignoreScripts}});return c.then(()=>{if(r||a.signal.aborted)return;g.engineStore.getState().setRuntime(i);let e=i.getObjectByName("MissionGroup");if(e){let t=function e(t,a,r){let n=[],s=r;if("SimGroup"===t._className){if(t._name?.toLowerCase()==="teams")s=void 0;else if(void 0===s&&t._name){let e=t._name.match(/^team(\d+)$/i);e&&(s=parseInt(e[1],10))}}let o=function(e,t,a){let r=e._className,n=`mission_${e._id}`,s=(0,x.getPosition)(e),o=(0,x.getScale)(e),l=function(e){let[t,a,r,n]=e.split(" ").map(parseFloat),s=-(n||0)*Math.PI/360,o=Math.sin(s),l=Math.cos(s),i=Math.sqrt((a||0)*(a||0)+(r||0)*(r||0)+(t||0)*(t||0));return i<1e-8?[0,0,0,1]:[(a||0)/i*o,(r||0)/i*o,(t||0)/i*o,l]}(e.rotation??"1 0 0 0"),i=(0,x.getProperty)(e,"dataBlock")??"",c=k(t,i),u=(0,x.getProperty)(e,"missionTypesList"),d={id:n,className:r,runtimeObject:e,missionTypesList:u},m={...d,position:s,rotation:l,scale:o};switch(r){case"TerrainBlock":return{...d,renderType:"TerrainBlock",terrainData:(0,b.terrainFromMis)(e)};case"InteriorInstance":return{...d,renderType:"InteriorInstance",interiorData:(0,b.interiorFromMis)(e)};case"Sky":return{...d,renderType:"Sky",skyData:(0,b.skyFromMis)(e)};case"Sun":return{...d,renderType:"Sun",sunData:(0,b.sunFromMis)(e)};case"WaterBlock":return{...d,renderType:"WaterBlock",waterData:(0,b.waterBlockFromMis)(e)};case"MissionArea":return{...d,renderType:"MissionArea",missionAreaData:(0,b.missionAreaFromMis)(e)};case"StaticShape":case"Item":case"Turret":case"TSStatic":var h=m,p=e,f=c,_=t,g=r,y=a,v=i;let S="TSStatic"===g?(0,x.getProperty)(p,"shapeName"):(0,x.getProperty)(f,"shapeFile"),C={...h,renderType:"Shape",shapeName:S,shapeType:"Turret"===g?"Turret":"Item"===g?"Item":"TSStatic"===g?"TSStatic":"StaticShape",dataBlock:v||void 0,teamId:y};if("Item"===g&&(C.rotate=function(e){if("string"==typeof e){let t=e.toLowerCase();return"0"!==t&&"false"!==t&&""!==t}return!!e}((0,x.getProperty)(p,"rotate")??(0,x.getProperty)(f,"rotate"))),"Turret"===g){let e=(0,x.getProperty)(p,"initialBarrel");if(e){let t=k(_,e);C.barrelShapeName=(0,x.getProperty)(t,"shapeFile")}}return C;case"ForceFieldBare":return function(e,t,a,r){let n,s=(0,x.getProperty)(a,"color"),o=s?[(n=s.split(" ").map(e=>parseFloat(e)))[0]??0,n[1]??0,n[2]??0]:[1,1,1],l=parseFloat((0,x.getProperty)(a,"baseTranslucency"))||1,i=parseInt((0,x.getProperty)(a,"numFrames"),10)||1,c=parseFloat((0,x.getProperty)(a,"framesPerSec"))||1,u=parseFloat((0,x.getProperty)(a,"scrollSpeed"))||0,d=parseFloat((0,x.getProperty)(a,"umapping"))||1,m=parseFloat((0,x.getProperty)(a,"vmapping"))||1,h=[];for(let e=0;e{r=!0,o.off("update",l),a.abort(),s?.(),g.engineStore.getState().clearRuntime(),y.gameEntityStore.getState().clearEntities(),i.destroy()}},l=[e,t,n],i[1]=e,i[2]=t,i[3]=n,i[4]=o,i[5]=l):(o=i[4],l=i[5]),(0,r.useEffect)(o,l),c}(T,P,D),L=!D||!E||!M;I[0]!==P||I[1]!==D?(n={metadata:D,missionType:P},I[0]=P,I[1]=D,I[2]=n):n=I[2];let H=n;return(I[3]!==L||I[4]!==B||I[5]!==R?(s=()=>{B?.(L,R)},l=[L,R,B],I[3]=L,I[4]=B,I[5]=R,I[6]=s,I[7]=l):(s=I[6],l=I[7]),(0,r.useEffect)(s,l),L)?null:(I[8]!==M?(c=(0,t.jsx)(d,{runtime:M}),I[8]=M,I[9]=c):c=I[9],I[10]!==H||I[11]!==c?(u=(0,t.jsx)(_,{value:H,children:c}),I[10]=H,I[11]=c,I[12]=u):u=I[12],u)});var T=e.i(17751),P=e.i(12598),B=e.i(5729),D=e.i(12631),E=e.i(32865),M=e.i(13070);function R(){let e,r,n,s,o,l,i,c,u,d,m,h,p,f,_,g,y,v,x,b,k,S,C,j,w=(0,a.c)(51),N=(0,E.useRecording)(),I=(0,D.useKeyboardControls)(z),T=(0,D.useKeyboardControls)(W),P=(0,D.useKeyboardControls)(U),B=(0,D.useKeyboardControls)(A),R=(0,D.useKeyboardControls)(O),K=(0,D.useKeyboardControls)(q),$=(0,D.useKeyboardControls)(G),J=(0,D.useKeyboardControls)(F),V=(0,D.useKeyboardControls)(H),Y=(0,D.useKeyboardControls)(L);return N&&"live"!==N.source?null:(w[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:M.default.Spacer}),w[0]=e):e=w[0],w[1]!==I?(r=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":I,children:"W"}),w[1]=I,w[2]=r):r=w[2],w[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("div",{className:M.default.Spacer}),w[3]=n):n=w[3],w[4]!==r?(s=(0,t.jsxs)("div",{className:M.default.Row,children:[e,r,n]}),w[4]=r,w[5]=s):s=w[5],w[6]!==P?(o=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":P,children:"A"}),w[6]=P,w[7]=o):o=w[7],w[8]!==T?(l=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":T,children:"S"}),w[8]=T,w[9]=l):l=w[9],w[10]!==B?(i=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":B,children:"D"}),w[10]=B,w[11]=i):i=w[11],w[12]!==o||w[13]!==l||w[14]!==i?(c=(0,t.jsxs)("div",{className:M.default.Row,children:[o,l,i]}),w[12]=o,w[13]=l,w[14]=i,w[15]=c):c=w[15],w[16]!==s||w[17]!==c?(u=(0,t.jsxs)("div",{className:M.default.Column,children:[s,c]}),w[16]=s,w[17]=c,w[18]=u):u=w[18],w[19]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)("span",{className:M.default.Arrow,children:"↑"}),w[19]=d):d=w[19],w[20]!==R?(m=(0,t.jsx)("div",{className:M.default.Row,children:(0,t.jsxs)("div",{className:M.default.Key,"data-pressed":R,children:[d," Space"]})}),w[20]=R,w[21]=m):m=w[21],w[22]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)("span",{className:M.default.Arrow,children:"↓"}),w[22]=h):h=w[22],w[23]!==K?(p=(0,t.jsx)("div",{className:M.default.Row,children:(0,t.jsxs)("div",{className:M.default.Key,"data-pressed":K,children:[h," Shift"]})}),w[23]=K,w[24]=p):p=w[24],w[25]!==m||w[26]!==p?(f=(0,t.jsxs)("div",{className:M.default.Column,children:[m,p]}),w[25]=m,w[26]=p,w[27]=f):f=w[27],w[28]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)("div",{className:M.default.Spacer}),w[28]=_):_=w[28],w[29]!==$?(g=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":$,children:"↑"}),w[29]=$,w[30]=g):g=w[30],w[31]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsx)("div",{className:M.default.Spacer}),w[31]=y):y=w[31],w[32]!==g?(v=(0,t.jsxs)("div",{className:M.default.Row,children:[_,g,y]}),w[32]=g,w[33]=v):v=w[33],w[34]!==V?(x=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":V,children:"←"}),w[34]=V,w[35]=x):x=w[35],w[36]!==J?(b=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":J,children:"↓"}),w[36]=J,w[37]=b):b=w[37],w[38]!==Y?(k=(0,t.jsx)("div",{className:M.default.Key,"data-pressed":Y,children:"→"}),w[38]=Y,w[39]=k):k=w[39],w[40]!==x||w[41]!==b||w[42]!==k?(S=(0,t.jsxs)("div",{className:M.default.Row,children:[x,b,k]}),w[40]=x,w[41]=b,w[42]=k,w[43]=S):S=w[43],w[44]!==v||w[45]!==S?(C=(0,t.jsxs)("div",{className:M.default.Column,children:[v,S]}),w[44]=v,w[45]=S,w[46]=C):C=w[46],w[47]!==f||w[48]!==C||w[49]!==u?(j=(0,t.jsxs)("div",{className:M.default.Root,children:[u,f,C]}),w[47]=f,w[48]=C,w[49]=u,w[50]=j):j=w[50],j)}function L(e){return e.lookRight}function H(e){return e.lookLeft}function F(e){return e.lookDown}function G(e){return e.lookUp}function q(e){return e.down}function O(e){return e.up}function A(e){return e.right}function U(e){return e.left}function W(e){return e.backward}function z(e){return e.forward}var K=e.i(71753),$=e.i(15080),J=e.i(79123),V=e.i(78295);function Y(e){let t=e.querySelector(".back");t&&(t.style.background="rgba(3, 79, 76, 0.6)",t.style.border="1px solid rgba(0, 219, 223, 0.5)",t.style.boxShadow="inset 0 0 10px rgba(0, 0, 0, 0.7)");let a=e.querySelector(".front");a&&(a.style.background="radial-gradient(circle at 50% 50%, rgba(23, 247, 198, 0.9) 0%, rgba(9, 184, 170, 0.95) 100%)",a.style.border="2px solid rgba(255, 255, 255, 0.4)",a.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15), inset 0 -1px 2px rgba(0, 0, 0, 0.3)")}let X=Math.PI/2-.01;function Z({joystickState:a,joystickZone:n,lookJoystickState:s,lookJoystickZone:o}){let{touchMode:l}=(0,J.useControls)();(0,r.useEffect)(()=>{let t=n.current;if(!t)return;let r=null,s=!1;return e.A(84968).then(e=>{s||(r=e.default.create({zone:t,mode:"static",position:{left:"70px",bottom:"70px"},size:120,restOpacity:.9}),Y(t),r.on("move",(e,t)=>{a.current.angle=t.angle.radian,a.current.force=Math.min(1,t.force)}),r.on("end",()=>{a.current.force=0}))}),()=>{s=!0,r?.destroy()}},[a,n,l]),(0,r.useEffect)(()=>{if("dualStick"!==l)return;let t=o.current;if(!t)return;let a=null,r=!1;return e.A(84968).then(e=>{r||(a=e.default.create({zone:t,mode:"static",position:{right:"70px",bottom:"70px"},size:120,restOpacity:.9}),Y(t),a.on("move",(e,t)=>{s.current.angle=t.angle.radian,s.current.force=Math.min(1,t.force)}),a.on("end",()=>{s.current.force=0}))}),()=>{r=!0,a?.destroy()}},[l,s,o]);let i=()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()};return"dualStick"===l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{ref:n,className:V.default.Left,onContextMenu:e=>e.preventDefault(),onTouchStart:i}),(0,t.jsx)("div",{ref:o,className:V.default.Right,onContextMenu:e=>e.preventDefault(),onTouchStart:i})]}):(0,t.jsx)("div",{ref:n,className:V.default.Joystick,onContextMenu:e=>e.preventDefault(),onTouchStart:i})}function Q(e){let t,n,o,l,i,c,u,d,m,h,p=(0,a.c)(25),{joystickState:f,joystickZone:_,lookJoystickState:g}=e,{speedMultiplier:y,touchMode:v}=(0,J.useControls)(),{camera:x,gl:b}=(0,$.useThree)();p[0]===Symbol.for("react.memo_cache_sentinel")?(t=new s.Euler(0,0,0,"YXZ"),p[0]=t):t=p[0];let k=(0,r.useRef)(t),S=(0,r.useRef)(null);p[1]===Symbol.for("react.memo_cache_sentinel")?(n={x:0,y:0},p[1]=n):n=p[1];let C=(0,r.useRef)(n);p[2]===Symbol.for("react.memo_cache_sentinel")?(o=new s.Vector3,p[2]=o):o=p[2];let j=(0,r.useRef)(o);p[3]===Symbol.for("react.memo_cache_sentinel")?(l=new s.Vector3,p[3]=l):l=p[3];let w=(0,r.useRef)(l);p[4]===Symbol.for("react.memo_cache_sentinel")?(i=new s.Vector3,p[4]=i):i=p[4];let N=(0,r.useRef)(i);return p[5]!==x.quaternion?(c=()=>{k.current.setFromQuaternion(x.quaternion,"YXZ")},p[5]=x.quaternion,p[6]=c):c=p[6],p[7]!==x?(u=[x],p[7]=x,p[8]=u):u=p[8],(0,r.useEffect)(c,u),p[9]!==x.quaternion||p[10]!==b.domElement||p[11]!==_||p[12]!==v?(d=()=>{if("moveLookStick"!==v)return;let e=b.domElement,t=e=>{let t=_.current;if(!t)return!1;let a=t.getBoundingClientRect();return e.clientX>=a.left&&e.clientX<=a.right&&e.clientY>=a.top&&e.clientY<=a.bottom},a=e=>{if(null===S.current)for(let a=0;a{if(null!==S.current)for(let t=0;t{for(let t=0;t{e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",r),e.removeEventListener("touchend",n),e.removeEventListener("touchcancel",n),S.current=null}},p[9]=x.quaternion,p[10]=b.domElement,p[11]=_,p[12]=v,p[13]=d):d=p[13],p[14]!==x||p[15]!==b.domElement||p[16]!==_||p[17]!==v?(m=[x,b.domElement,_,v],p[14]=x,p[15]=b.domElement,p[16]=_,p[17]=v,p[18]=m):m=p[18],(0,r.useEffect)(d,m),p[19]!==x||p[20]!==f.current||p[21]!==g||p[22]!==y||p[23]!==v?(h=(e,t)=>{let{force:a,angle:r}=f.current;if("dualStick"===v){let e=g.current;if(e.force>.15){let a=(e.force-.15)/.85,r=Math.cos(e.angle),n=Math.sin(e.angle);k.current.setFromQuaternion(x.quaternion,"YXZ"),k.current.y=k.current.y-r*a*2.5*t,k.current.x=k.current.x+n*a*2.5*t,k.current.x=Math.max(-X,Math.min(X,k.current.x)),x.quaternion.setFromEuler(k.current)}if(a>.08){let e=80*y*((a-.08)/.92),n=Math.cos(r),s=Math.sin(r);x.getWorldDirection(j.current),j.current.normalize(),w.current.crossVectors(x.up,j.current).normalize(),N.current.set(0,0,0).addScaledVector(j.current,s).addScaledVector(w.current,-n),N.current.lengthSq()>0&&(N.current.normalize().multiplyScalar(e*t),x.position.add(N.current))}}else if("moveLookStick"===v&&a>0){let e=80*y*.5;if(x.getWorldDirection(j.current),j.current.normalize(),N.current.copy(j.current).multiplyScalar(e*t),x.position.add(N.current),a>=.15){let e=Math.cos(r),n=Math.sin(r),s=(a-.15)/.85;k.current.setFromQuaternion(x.quaternion,"YXZ"),k.current.y=k.current.y-e*s*1.25*t,k.current.x=k.current.x+n*s*1.25*t,k.current.x=Math.max(-X,Math.min(X,k.current.x)),x.quaternion.setFromEuler(k.current)}}},p[19]=x,p[20]=f.current,p[21]=g,p[22]=y,p[23]=v,p[24]=h):h=p[24],(0,K.useFrame)(h),null}var ee=e.i(11889),et=e.i(56373),ea=e.i(86447),er=e.i(1559),en=e.i(78440),es=e.i(59129),eo=e.i(25998),el=e.i(18364),ei=e.i(70238),ec=e.i(29402),eu=e.i(97442);let ed=new Set(["SkiFree","SkiFree_Daily","SkiFree_Randomizer"]),em={"missions.vl2":"Official","TR2final105-client.vl2":"Team Rabbit 2","z_mappacks/CTF/Classic_maps_v1.vl2":"Classic","z_mappacks/CTF/DynamixFinalPack.vl2":"Official","z_mappacks/CTF/KryMapPack_b3EDIT.vl2":"KryMapPack","z_mappacks/CTF/S5maps.vl2":"S5","z_mappacks/CTF/S8maps.vl2":"S8","z_mappacks/CTF/TWL-MapPack.vl2":"TWL","z_mappacks/CTF/TWL-MapPackEDIT.vl2":"TWL","z_mappacks/CTF/TWL2-MapPack.vl2":"TWL2","z_mappacks/CTF/TWL2-MapPackEDIT.vl2":"TWL2","z_mappacks/TWL_T2arenaOfficialMaps.vl2":"Arena","z_mappacks/xPack2.vl2":"xPack2","z_mappacks/z_DMP2-V0.6.vl2":"DMP2 (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX.vl2":"DMP (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX-ServerOnly.vl2":"DMP (Discord Map Pack)"},eh={"z_mappacks/DM":"DM","z_mappacks/LCTF":"LCTF","z_mappacks/Lak":"LakRabbit"},ep=(0,f.getMissionList)().filter(e=>!ed.has(e)).map(e=>{let t,a=(0,f.getMissionInfo)(e),[r]=(0,f.getSourceAndPath)(a.resourcePath),n=(t=r.match(/^(.*)(\/[^/]+)$/))?t[1]:"",s=em[r]??eh[n]??null;return{resourcePath:a.resourcePath,missionName:e,displayName:a.displayName,sourcePath:r,groupName:s,missionTypes:a.missionTypes}}),ef=new Map(ep.map(e=>[e.missionName,e])),e_=function(e){let t=new Map;for(let a of e){let e=t.get(a.groupName)??[];e.push(a),t.set(a.groupName,e)}return t.forEach((e,a)=>{t.set(a,(0,ec.default)(e,[e=>(e.displayName||e.missionName).toLowerCase()],["asc"]))}),(0,ec.default)(Array.from(t.entries()),[([e])=>"Official"===e?0:null==e?2:1,([e])=>e?e.toLowerCase():""],["asc","asc"])}(ep),eg="u">typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function ey(e){let r,n,s,o,l,i=(0,a.c)(12),{mission:c}=e,u=c.displayName||c.missionName;return i[0]!==u?(r=(0,t.jsx)("span",{className:eu.default.ItemName,children:u}),i[0]=u,i[1]=r):r=i[1],i[2]!==c.missionTypes?(n=c.missionTypes.length>0&&(0,t.jsx)("span",{className:eu.default.ItemTypes,children:c.missionTypes.map(ev)}),i[2]=c.missionTypes,i[3]=n):n=i[3],i[4]!==r||i[5]!==n?(s=(0,t.jsxs)("span",{className:eu.default.ItemHeader,children:[r,n]}),i[4]=r,i[5]=n,i[6]=s):s=i[6],i[7]!==c.missionName?(o=(0,t.jsx)("span",{className:eu.default.ItemMissionName,children:c.missionName}),i[7]=c.missionName,i[8]=o):o=i[8],i[9]!==s||i[10]!==o?(l=(0,t.jsxs)(t.Fragment,{children:[s,o]}),i[9]=s,i[10]=o,i[11]=l):l=i[11],l}function ev(e){return(0,t.jsx)("span",{className:eu.default.ItemType,"data-mission-type":e,children:e},e)}function ex(e){let n,s,o,l,i,c,u,d,m,h,p,_,g,y,v,x,b,k=(0,a.c)(46),{value:S,missionType:C,onChange:j,disabled:w}=e,[N,I]=(0,r.useState)(""),T=(0,r.useRef)(null),P=(0,r.useRef)(C);k[0]===Symbol.for("react.memo_cache_sentinel")?(n=e=>{(0,r.startTransition)(()=>I(e))},k[0]=n):n=k[0];let B=(0,el.useComboboxStore)({resetValueOnHide:!0,selectedValue:S,setSelectedValue:e=>{if(e){let t=P.current,a=(0,f.getMissionInfo)(e).missionTypes;t&&a.includes(t)||(t=a[0]),j({missionName:e,missionType:t}),T.current?.blur()}},setValue:n});k[1]!==B?(s=()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),T.current?.focus(),B.show())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},o=[B],k[1]=B,k[2]=s,k[3]=o):(s=k[2],o=k[3]),(0,r.useEffect)(s,o),k[4]!==S?(l=ef.get(S),k[4]=S,k[5]=l):l=k[5];let D=l;e:{let e,t;if(!N){let e;k[6]===Symbol.for("react.memo_cache_sentinel")?(e={type:"grouped",groups:e_},k[6]=e):e=k[6],i=e;break e}k[7]!==N?(e=(0,ei.matchSorter)(ep,N,{keys:["displayName","missionName","missionTypes","groupName"]}),k[7]=N,k[8]=e):e=k[8];let a=e;k[9]!==a?(t={type:"flat",missions:a},k[9]=a,k[10]=t):t=k[10],i=t}let E=i,M=D?D.displayName||D.missionName:S,R="flat"===E.type?0===E.missions.length:0===E.groups.length,L=e=>(0,t.jsx)(et.ComboboxItem,{value:e.missionName,className:eu.default.Item,focusOnHover:!0,onClick:t=>{if(t.target&&t.target instanceof HTMLElement){let a=t.target.dataset.missionType;a?(P.current=a,e.missionName===S&&j({missionName:e.missionName,missionType:a})):P.current=null}else P.current=null},children:(0,t.jsx)(ey,{mission:e})},e.missionName),H=en.ComboboxProvider;k[11]!==B?(c=()=>{try{document.exitPointerLock()}catch{}B.show()},u=e=>{"Escape"!==e.key||B.getState().open||T.current?.blur()},k[11]=B,k[12]=c,k[13]=u):(c=k[12],u=k[13]),k[14]!==w||k[15]!==M||k[16]!==c||k[17]!==u?(d=(0,t.jsx)(ee.Combobox,{ref:T,autoSelect:!0,disabled:w,placeholder:M,className:eu.default.Input,onFocus:c,onKeyDown:u}),k[14]=w,k[15]=M,k[16]=c,k[17]=u,k[18]=d):d=k[18],k[19]!==M?(m=(0,t.jsx)("span",{className:eu.default.SelectedName,children:M}),k[19]=M,k[20]=m):m=k[20],k[21]!==C?(h=C&&(0,t.jsx)("span",{className:eu.default.ItemType,"data-mission-type":C,children:C}),k[21]=C,k[22]=h):h=k[22],k[23]!==h||k[24]!==m?(p=(0,t.jsxs)("div",{className:eu.default.SelectedValue,children:[m,h]}),k[23]=h,k[24]=m,k[25]=p):p=k[25],k[26]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)("kbd",{className:eu.default.Shortcut,children:eg?"⌘K":"^K"}),k[26]=_):_=k[26],k[27]!==p||k[28]!==d?(g=(0,t.jsxs)("div",{className:eu.default.InputWrapper,children:[d,p,_]}),k[27]=p,k[28]=d,k[29]=g):g=k[29];let F=er.ComboboxPopover,G=eu.default,q=ea.ComboboxList,O=eu.default,A="flat"===E.type?E.missions.map(L):E.groups.map(e=>{let[a,n]=e;return a?(0,t.jsxs)(es.ComboboxGroup,{className:eu.default.Group,children:[(0,t.jsx)(eo.ComboboxGroupLabel,{className:eu.default.GroupLabel,children:a}),n.map(L)]},a):(0,t.jsx)(r.Fragment,{children:n.map(L)},"ungrouped")});return k[30]!==R?(y=R&&(0,t.jsx)("div",{className:eu.default.NoResults,children:"No missions found"}),k[30]=R,k[31]=y):y=k[31],k[32]!==q||k[33]!==O.List||k[34]!==A||k[35]!==y?(v=(0,t.jsxs)(q,{className:O.List,children:[A,y]}),k[32]=q,k[33]=O.List,k[34]=A,k[35]=y,k[36]=v):v=k[36],k[37]!==F||k[38]!==G.Popover||k[39]!==v?(x=(0,t.jsx)(F,{gutter:4,fitViewport:!0,autoFocusOnHide:!1,className:G.Popover,children:v}),k[37]=F,k[38]=G.Popover,k[39]=v,k[40]=x):x=k[40],k[41]!==H||k[42]!==B||k[43]!==g||k[44]!==x?(b=(0,t.jsxs)(H,{store:B,children:[g,x]}),k[41]=H,k[42]=B,k[43]=g,k[44]=x,k[45]=b):b=k[45],b}var eb=e.i(11152),ek=e.i(40141);function eS(e){return(0,ek.GenIcon)({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 0c-41.8 0-77.4 26.7-90.5 64L64 64C28.7 64 0 92.7 0 128L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64l-37.5 0C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM305 273L177 401c-9.4 9.4-24.6 9.4-33.9 0L79 337c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L271 239c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"},child:[]}]})(e)}var eC=e.i(36679);function ej(e){let n,s,o,l,i,c=(0,a.c)(11),{cameraRef:u,missionName:d,missionType:m}=e,{fogEnabled:h}=(0,J.useSettings)(),[p,f]=(0,r.useState)(!1),_=(0,r.useRef)(null);c[0]!==u||c[1]!==h||c[2]!==d||c[3]!==m?(n=async()=>{clearTimeout(_.current);let e=u.current;if(!e)return;let t=function({position:e,quaternion:t}){let a=e=>parseFloat(e.toFixed(3)),r=`${a(e.x)},${a(e.y)},${a(e.z)}`,n=`${a(t.x)},${a(t.y)},${a(t.z)},${a(t.w)}`;return`#c${r}~${n}`}(e),a=new URLSearchParams;a.set("mission",`${d}~${m}`),a.set("fog",h.toString());let r=`${window.location.pathname}?${a}${t}`,n=`${window.location.origin}${r}`;window.history.replaceState(null,"",r);try{await navigator.clipboard.writeText(n),f(!0),_.current=setTimeout(()=>{f(!1)},1100)}catch(e){console.error(e)}},c[0]=u,c[1]=h,c[2]=d,c[3]=m,c[4]=n):n=c[4];let g=n,y=p?"true":"false";return c[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(eb.FaMapPin,{className:eC.default.MapPin}),o=(0,t.jsx)(eS,{className:eC.default.ClipboardCheck}),l=(0,t.jsx)("span",{className:eC.default.ButtonLabel,children:" Copy coordinates URL"}),c[5]=s,c[6]=o,c[7]=l):(s=c[5],o=c[6],l=c[7]),c[8]!==g||c[9]!==y?(i=(0,t.jsxs)("button",{type:"button",className:eC.default.Root,"aria-label":"Copy coordinates URL",title:"Copy coordinates URL",onClick:g,"data-copied":y,id:"copyCoordinatesButton",children:[s,o,l]}),c[8]=g,c[9]=y,c[10]=i):i=c[10],i}function ew(e){return(0,ek.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M21 3H3c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5a2 2 0 0 0-2-2zm0 14H3V5h18v12zm-5-6-7 4V7z"},child:[]}]})(e)}e.i(50593);var eN=e.i(17711),eI=e.i(58281);e.i(70847);var eT=e.i(47566),eP=e.i(25311),eB=e.i(89119),eD=e.i(10244);class eE extends eD.StreamEngine{parser;initialBlock;moveTicks=0;absoluteYaw=0;absolutePitch=0;lastAbsYaw=0;lastAbsPitch=0;exhausted=!1;_teamScoresGen=0;_rosterGen=0;_weaponsHudGen=0;_inventoryHudGen=0;_cachedSnapshot=null;_cachedSnapshotTick=-1;_snap=null;constructor(e){super(),this.parser=e,this.registry=e.getRegistry(),this.ghostTracker=e.getGhostTracker();const t=e.initialBlock;this.initialBlock={dataBlocks:t.dataBlocks,initialGhosts:t.initialGhosts,controlObjectGhostIndex:t.controlObjectGhostIndex,controlObjectData:t.controlObjectData,targetEntries:t.targetEntries,sensorGroupColors:t.sensorGroupColors,taggedStrings:t.taggedStrings,initialEvents:t.initialEvents,demoValues:t.demoValues},this.reset()}getDataBlockData(e){let t=this.initialBlock.dataBlocks.get(e);if(t?.data)return t.data;let a=this.parser.getPacketParser();return a.dataBlockDataMap?.get(e)}_shapeConstructorCache=null;getShapeConstructorSequences(e){if(!this._shapeConstructorCache)for(let[,e]of(this._shapeConstructorCache=new Map,this.initialBlock.dataBlocks)){if("TSShapeConstructor"!==e.className||!e.data)continue;let t=e.data.shape,a=e.data.sequences;t&&a&&this._shapeConstructorCache.set(t.toLowerCase(),a)}return this._shapeConstructorCache.get(e.toLowerCase())}getTimeSec(){return this.moveTicks*(eP.TICK_DURATION_MS/1e3)}getCameraYawPitch(e){let t=!this.isPiloting&&"player"===this.lastControlType,a=t?this.absoluteYaw:this.lastAbsYaw,r=t?this.absolutePitch:this.lastAbsPitch;return t&&(this.lastAbsYaw=a,this.lastAbsPitch=r),{yaw:a,pitch:r}}getControlPlayerHeadPitch(e){return(0,eB.clamp)(this.absolutePitch/eB.MAX_PITCH,-1,1)}onTeamScoresChanged(){this._teamScoresGen++}onRosterChanged(){this._rosterGen++}onWeaponsHudChanged(){this._weaponsHudGen++}onInventoryHudChanged(){this._inventoryHudGen++}reset(){for(let[e,t]of(this.parser.reset(),this.ghostTracker=this.parser.getGhostTracker(),this._cachedSnapshot=null,this._cachedSnapshotTick=-1,this._snap=null,this.resetSharedState(),this.initialBlock.taggedStrings))this.netStrings.set(e,t);for(let e of this.initialBlock.targetEntries)e.name&&this.targetNames.set(e.targetId,(0,eB.stripTaggedStringMarkup)(e.name)),this.targetTeams.set(e.targetId,e.sensorGroup),this.targetRenderFlags.set(e.targetId,e.targetData);for(let e of this.initialBlock.sensorGroupColors){let t=this.sensorGroupColors.get(e.group);t||(t=new Map,this.sensorGroupColors.set(e.group,t)),t.set(e.targetGroup,{r:e.r,g:e.g,b:e.b})}if(this.moveTicks=0,this.absoluteYaw=0,this.absolutePitch=0,this.lastAbsYaw=0,this.lastAbsPitch=0,this.lastControlType=(0,eB.detectControlObjectType)(this.initialBlock.controlObjectData)??"player",this.isPiloting="player"===this.lastControlType&&!!(this.initialBlock.controlObjectData?.pilot||this.initialBlock.controlObjectData?.controlObjectGhost!=null),this.lastCameraMode="camera"===this.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.cameraMode?this.initialBlock.controlObjectData.cameraMode:void 0,this.lastOrbitGhostIndex="camera"===this.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex?this.initialBlock.controlObjectData.orbitObjectGhostIndex:void 0,"camera"===this.lastControlType){let e=this.initialBlock.controlObjectData?.minOrbitDist,t=this.initialBlock.controlObjectData?.maxOrbitDist,a=this.initialBlock.controlObjectData?.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.lastOrbitDistance=Math.max(0,t-e):"number"==typeof a&&Number.isFinite(a)?this.lastOrbitDistance=Math.max(0,a):this.lastOrbitDistance=void 0}else this.lastOrbitDistance=void 0;let e=this.getAbsoluteRotation(this.initialBlock.controlObjectData);for(let t of(e&&(this.absoluteYaw=e.yaw,this.absolutePitch=e.pitch,this.lastAbsYaw=e.yaw,this.lastAbsPitch=e.pitch),this.exhausted=!1,this.latestFov=100,this.latestControl={ghostIndex:this.initialBlock.controlObjectGhostIndex,data:this.initialBlock.controlObjectData,position:(0,eB.isValidPosition)(this.initialBlock.controlObjectData?.position)?this.initialBlock.controlObjectData?.position:void 0},this.controlPlayerGhostId="player"===this.lastControlType&&this.initialBlock.controlObjectGhostIndex>=0?(0,eP.toEntityId)("Player",this.initialBlock.controlObjectGhostIndex):void 0,this.initialBlock.initialGhosts)){if("create"!==t.type||null==t.classId)continue;let e=this.registry.getGhostParser(t.classId)?.name;if(!e)throw Error(`No ghost parser for classId ${t.classId} (ghost index ${t.index})`);let a=(0,eP.toEntityId)(e,t.index),r={id:a,ghostIndex:t.index,className:e,spawnTick:0,type:(0,eP.toEntityType)(e),rotation:[0,0,0,1]};if(this.applyGhostData(r,t.parsedData),t.parsedData){let a=(0,eT.ghostToSceneObject)(e,t.index,t.parsedData);a&&(r.sceneData=a)}this.entities.set(a,r),this.entityIdByGhostIndex.set(t.index,a)}if(0===this.playerSensorGroup&&"player"===this.lastControlType&&this.latestControl.ghostIndex>=0){let e=this.entityIdByGhostIndex.get(this.latestControl.ghostIndex),t=e?this.entities.get(e):void 0;t?.sensorGroup!=null&&t.sensorGroup>0&&(this.playerSensorGroup=t.sensorGroup)}for(let e of this.initialBlock.initialEvents){let t=this.registry.getEventParser(e.classId)?.name;if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.playerSensorGroup=t)}else if("RemoteCommandEvent"===t&&e.parsedData){let t=this.resolveNetString(e.parsedData.funcName),a=e.parsedData.args;"ServerMessage"===t&&this.handleServerMessage(a),this.handleHudRemoteCommand(t,a)}}let t=function(e){let t={weaponsHud:null,backpackHud:null,inventoryHud:null,teamScores:[],playerRoster:new Map,chatMessages:[],gravity:-20};if(!e.length)return t;let a=0,r=()=>{let t=e[a++];return""===t?"":t??""};if(r(),a>=e.length)return t;let n=parseInt(r(),10)||0,s=new Map;for(let e=0;e0&&s.set(o,(s.get(o)??0)+1)}if(a>=e.length||(r(),a>=e.length))return t;{let e=r().split(" "),a=e[0]??"",n="1"===e[1]||"true"===e[1],s=e[2]??"",o="1"===e[4]||"true"===e[4];n&&a&&(t.backpackHud={packIndex:(0,eB.backpackBitmapToIndex)(a),active:o,text:s})}if(a>=e.length)return t;let o=r().split(" "),l=parseInt(o[4],10)||0,i=parseInt(o[5],10)||0,c=parseInt(o[6],10);for(let e=0;e=e.length)return t;let d=r().split(" "),m=parseInt(d[4],10)||0,h=parseInt(d[5],10)||0,p=parseInt(d[6],10);for(let e=0;e0)||e.set(a,n)}e.size>0&&(t.inventoryHud={slots:e,activeSlot:isNaN(p)?-1:p})}if(a>=e.length)return t;let f=r().split(" "),_=f[1]??"",g=parseInt(f[2],10)||0,y=[];for(let e=0;e=8)for(let e=0;e<2;e++){let a=4*e,r=e+1;t.teamScores.push({teamId:r,name:y[a]??"",score:parseInt(y[a+1],10)||0,playerCount:s.get(r)??0})}else if("TR2Game"===_&&g>=4)for(let e=0;e<2;e++){let a=2*e,r=e+1;t.teamScores.push({teamId:r,name:y[a+1]??"",score:parseInt(y[a],10)||0,playerCount:s.get(r)??0})}if(a>=e.length)return t;r();for(let n=0;n<10&&!(a>=e.length);n++){let e=r();e&&t.chatMessages.push(e)}if(ae.text).join("");if(!a.trim())continue;let r=t[0].colorCode;if(t.some(e=>3===e.colorCode||4===e.colorCode)&&a.includes(": ")){let e=a.indexOf(": ");this.chatMessages.push({timeSec:0,sender:a.slice(0,e),text:a.slice(e+2),kind:"chat",colorCode:r,segments:t})}else this.chatMessages.push({timeSec:0,sender:"",text:a,kind:"server",colorCode:r,segments:t})}this.updateCameraAndHud()}getSnapshot(){if(this._cachedSnapshot&&this._cachedSnapshotTick===this.moveTicks)return this._cachedSnapshot;let e=this.buildSnapshot();return this._cachedSnapshot=e,this._cachedSnapshotTick=this.moveTicks,e}getEffectShapes(){let e=new Set,t=t=>{let a=t.dtsFileName;a&&e.add(a);let r=t.subExplosions;if(Array.isArray(r))for(let t of r){if(null==t)continue;let a=this.getDataBlockData(t);a?.dtsFileName&&e.add(a.dtsFileName)}};for(let[,e]of this.initialBlock.dataBlocks){let a=e.data?.explosion;if(null==a)continue;let r=this.getDataBlockData(a);r&&t(r)}return[...e]}stepToTime(e,t=1/0){let a=Math.floor(1e3*(Number.isFinite(e)?Math.max(0,e):0)/eP.TICK_DURATION_MS),r=!1;a({index:e,ammo:t})),activeIndex:this.weaponsHud.activeIndex},l=r&&r.inventoryHudGen===this._inventoryHudGen?r.inventoryHud:{slots:Array.from(this.inventoryHud.slots.entries()).map(([e,t])=>({slot:e,count:t})),activeSlot:this.inventoryHud.activeSlot},i=r&&r.backpackPackIndex===this.backpackHud.packIndex&&r.backpackActive===this.backpackHud.active&&r.backpackText===this.backpackHud.text?r.backpackHud:this.backpackHud.packIndex>=0?{...this.backpackHud}:null;if(r&&r.teamScoresGen===this._teamScoresGen&&r.rosterGen===this._rosterGen)e=r.teamScores;else{e=this.teamScores.map(e=>({...e}));let t=new Map;for(let{teamId:e}of this.playerRoster.values())e>0&&t.set(e,(t.get(e)??0)+1);for(let a of e)a.playerCount=t.get(a.teamId)??0}return this._snap={teamScoresGen:this._teamScoresGen,rosterGen:this._rosterGen,teamScores:e,weaponsHudGen:this._weaponsHudGen,weaponsHud:o,inventoryHudGen:this._inventoryHudGen,inventoryHud:l,backpackPackIndex:this.backpackHud.packIndex,backpackActive:this.backpackHud.active,backpackText:this.backpackHud.text,backpackHud:i},{timeSec:a,exhausted:this.exhausted,camera:this.camera,entities:t,controlPlayerGhostId:this.controlPlayerGhostId,playerSensorGroup:this.playerSensorGroup,status:this.lastStatus,chatMessages:n,audioEvents:s,weaponsHud:o,backpackHud:i,inventoryHud:l,teamScores:e}}isPacketData(e){return!!e&&"object"==typeof e&&"gameState"in e&&"events"in e&&"ghosts"in e}isMoveData(e){return!!e&&"object"==typeof e&&"yaw"in e}isInfoData(e){return!!e&&"object"==typeof e&&"value2"in e&&"number"==typeof e.value2}}async function eM(e){let t=new eI.DemoParser(new Uint8Array(e)),{header:a,initialBlock:r}=await t.load(),{missionName:n,gameType:s}=function(e){let t=null,a=null;for(let r=0;r{if(h){_.current=_.current+1,p(null);return}f.current?.click()},d[0]=h,d[1]=p,d[2]=e):e=d[2];let g=e;d[3]!==p?(n=async e=>{let t=e.target.files?.[0];if(t){e.target.value="";try{let e=await t.arrayBuffer(),a=_.current+1;_.current=a;let r=await eM(e);if(_.current!==a)return;p(r)}catch(e){console.error("Failed to load demo:",e)}}},d[3]=p,d[4]=n):n=d[4];let y=n;d[5]===Symbol.for("react.memo_cache_sentinel")?(s={display:"none"},d[5]=s):s=d[5],d[6]!==y?(o=(0,t.jsx)("input",{ref:f,type:"file",accept:".rec",style:s,onChange:y}),d[6]=y,d[7]=o):o=d[7];let v=h?"Unload demo":"Load demo (.rec)",x=h?"Unload demo":"Load demo (.rec)",b=h?"true":void 0,k=null!=m&&!h;d[8]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(ew,{className:eR.default.DemoIcon}),d[8]=l):l=d[8];let S=h?"Unload demo":"Demo";return d[9]!==S?(i=(0,t.jsx)("span",{className:eR.default.ButtonLabel,children:S}),d[9]=S,d[10]=i):i=d[10],d[11]!==g||d[12]!==i||d[13]!==v||d[14]!==x||d[15]!==b||d[16]!==k?(c=(0,t.jsxs)("button",{type:"button",className:eR.default.Root,"aria-label":v,title:x,onClick:g,"data-active":b,disabled:k,children:[l,i]}),d[11]=g,d[12]=i,d[13]=v,d[14]=x,d[15]=b,d[16]=k,d[17]=c):c=d[17],d[18]!==c||d[19]!==o?(u=(0,t.jsxs)(t.Fragment,{children:[o,c]}),d[18]=c,d[19]=o,d[20]=u):u=d[20],u}function eH(e){return(0,ek.GenIcon)({tag:"svg",attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.251.068a.5.5 0 0 1 .227.58L9.677 6.5H13a.5.5 0 0 1 .364.843l-8 8.5a.5.5 0 0 1-.842-.49L6.323 9.5H3a.5.5 0 0 1-.364-.843l8-8.5a.5.5 0 0 1 .615-.09z"},child:[]}]})(e)}var eF=e.i(12781),eG=e.i(9607);function eq(e){let r,n,s,o,l,i=(0,a.c)(20),{onOpenServerBrowser:c}=e,u=(0,eF.useLiveConnectionOptional)();if(!u)return null;let d="connected"===u.gameStatus,m="connecting"===u.gameStatus||"challenging"===u.gameStatus||"authenticating"===u.gameStatus,h=d?"Disconnect":"Join server",p=d?"Disconnect":"Join server";i[0]!==d||i[1]!==u||i[2]!==c?(r=()=>{d?u.disconnectServer():c()},i[0]=d,i[1]=u,i[2]=c,i[3]=r):r=i[3];let f=d?"true":void 0,_=`${eG.default.LiveIcon} ${d?eG.default.Pulsing:""}`;if(i[4]!==_?(n=(0,t.jsx)(eH,{className:_}),i[4]=_,i[5]=n):n=i[5],i[6]!==m||i[7]!==d?(s=!d&&(0,t.jsx)("span",{className:eG.default.TextLabel,children:m?"Connecting...":"Connect"}),i[6]=m,i[7]=d,i[8]=s):s=i[8],i[9]!==d||i[10]!==u.ping){var g;o=d&&(0,t.jsx)("span",{className:eG.default.PingLabel,children:null!=u.ping?(g=u.ping)>=1e3?g.toLocaleString()+"ms":g+"ms":"Live"}),i[9]=d,i[10]=u.ping,i[11]=o}else o=i[11];return i[12]!==h||i[13]!==p||i[14]!==r||i[15]!==f||i[16]!==n||i[17]!==s||i[18]!==o?(l=(0,t.jsxs)("button",{type:"button",className:eG.default.Root,"aria-label":h,title:p,onClick:r,"data-active":f,children:[n,s,o]}),i[12]=h,i[13]=p,i[14]=r,i[15]=f,i[16]=n,i[17]=s,i[18]=o,i[19]=l):l=i[19],l}function eO(e){return(0,ek.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(e)}function eA(e){return(0,ek.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}var eU=e.i(65883);function eW(e){let n,s,o,l,i,c,u,d,m,h,p,f,_,g,y,v,x,b,k,S,C,j,w,N,I,T,P,B,D,M,R,L,H,F,G,q,O,A,U,W,z=(0,a.c)(95),{missionName:K,missionType:$,onChangeMission:V,onOpenMapInfo:Y,onOpenServerBrowser:X,isTouch:Z,cameraRef:Q}=e,{fogEnabled:ee,setFogEnabled:et,fov:ea,setFov:er,audioEnabled:en,setAudioEnabled:es,animationEnabled:eo,setAnimationEnabled:el}=(0,J.useSettings)(),{speedMultiplier:ei,setSpeedMultiplier:ec,touchMode:eu,setTouchMode:ed}=(0,J.useControls)(),{debugMode:em,setDebugMode:eh}=(0,J.useDebug)(),ep=(0,E.useRecording)(),ef=(0,eF.useLiveConnectionOptional)(),e_=ef?.adapter!=null,eg=null!=ep||e_,ey=eg&&!e_,[ev,eb]=(0,r.useState)(!1),ek=(0,r.useRef)(null),eS=(0,r.useRef)(null),eC=(0,r.useRef)(null);z[0]!==ev?(n=()=>{ev&&ek.current?.focus()},s=[ev],z[0]=ev,z[1]=n,z[2]=s):(n=z[1],s=z[2]),(0,r.useEffect)(n,s),z[3]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{let t=e.relatedTarget;t&&eC.current?.contains(t)||eb(!1)},z[3]=o):o=z[3];let ew=o;z[4]===Symbol.for("react.memo_cache_sentinel")?(l=e=>{"Escape"===e.key&&(eb(!1),eS.current?.focus())},z[4]=l):l=z[4];let eN=l;return z[5]!==eg||z[6]!==K||z[7]!==$||z[8]!==V?(i=(0,t.jsx)("div",{className:eU.default.MissionSelectWrapper,children:(0,t.jsx)(ex,{value:K,missionType:$,onChange:V,disabled:eg})}),z[5]=eg,z[6]=K,z[7]=$,z[8]=V,z[9]=i):i=z[9],z[10]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{eb(ez)},z[10]=c):c=z[10],z[11]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(eA,{}),z[11]=u):u=z[11],z[12]!==ev?(d=(0,t.jsx)("button",{ref:eS,className:eU.default.Toggle,onClick:c,"aria-expanded":ev,"aria-controls":"settingsPanel","aria-label":"Settings",children:u}),z[12]=ev,z[13]=d):d=z[13],z[14]!==Q||z[15]!==K||z[16]!==$?(m=(0,t.jsx)(ej,{missionName:K,missionType:$,cameraRef:Q}),z[14]=Q,z[15]=K,z[16]=$,z[17]=m):m=z[17],z[18]===Symbol.for("react.memo_cache_sentinel")?(h=(0,t.jsx)(eL,{}),z[18]=h):h=z[18],z[19]!==X?(p=X&&(0,t.jsx)(eq,{onOpenServerBrowser:X}),z[19]=X,z[20]=p):p=z[20],z[21]===Symbol.for("react.memo_cache_sentinel")?(f=(0,t.jsx)(eO,{}),_=(0,t.jsx)("span",{className:eU.default.ButtonLabel,children:"Show map info"}),z[21]=f,z[22]=_):(f=z[21],_=z[22]),z[23]!==Y?(g=(0,t.jsxs)("button",{type:"button",className:eU.default.MapInfoButton,"aria-label":"Show map info",onClick:Y,children:[f,_]}),z[23]=Y,z[24]=g):g=z[24],z[25]!==p||z[26]!==g||z[27]!==m?(y=(0,t.jsxs)("div",{className:eU.default.Group,children:[m,h,p,g]}),z[25]=p,z[26]=g,z[27]=m,z[28]=y):y=z[28],z[29]!==et?(v=e=>{et(e.target.checked)},z[29]=et,z[30]=v):v=z[30],z[31]!==ee||z[32]!==v?(x=(0,t.jsx)("input",{id:"fogInput",type:"checkbox",checked:ee,onChange:v}),z[31]=ee,z[32]=v,z[33]=x):x=z[33],z[34]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)("label",{htmlFor:"fogInput",children:"Fog?"}),z[34]=b):b=z[34],z[35]!==x?(k=(0,t.jsxs)("div",{className:eU.default.CheckboxField,children:[x,b]}),z[35]=x,z[36]=k):k=z[36],z[37]!==es?(S=e=>{es(e.target.checked)},z[37]=es,z[38]=S):S=z[38],z[39]!==en||z[40]!==S?(C=(0,t.jsx)("input",{id:"audioInput",type:"checkbox",checked:en,onChange:S}),z[39]=en,z[40]=S,z[41]=C):C=z[41],z[42]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)("label",{htmlFor:"audioInput",children:"Audio?"}),z[42]=j):j=z[42],z[43]!==C?(w=(0,t.jsxs)("div",{className:eU.default.CheckboxField,children:[C,j]}),z[43]=C,z[44]=w):w=z[44],z[45]!==k||z[46]!==w?(N=(0,t.jsxs)("div",{className:eU.default.Group,children:[k,w]}),z[45]=k,z[46]=w,z[47]=N):N=z[47],z[48]!==el?(I=e=>{el(e.target.checked)},z[48]=el,z[49]=I):I=z[49],z[50]!==eo||z[51]!==I?(T=(0,t.jsx)("input",{id:"animationInput",type:"checkbox",checked:eo,onChange:I}),z[50]=eo,z[51]=I,z[52]=T):T=z[52],z[53]===Symbol.for("react.memo_cache_sentinel")?(P=(0,t.jsx)("label",{htmlFor:"animationInput",children:"Animation?"}),z[53]=P):P=z[53],z[54]!==T?(B=(0,t.jsxs)("div",{className:eU.default.CheckboxField,children:[T,P]}),z[54]=T,z[55]=B):B=z[55],z[56]!==eh?(D=e=>{eh(e.target.checked)},z[56]=eh,z[57]=D):D=z[57],z[58]!==em||z[59]!==D?(M=(0,t.jsx)("input",{id:"debugInput",type:"checkbox",checked:em,onChange:D}),z[58]=em,z[59]=D,z[60]=M):M=z[60],z[61]===Symbol.for("react.memo_cache_sentinel")?(R=(0,t.jsx)("label",{htmlFor:"debugInput",children:"Debug?"}),z[61]=R):R=z[61],z[62]!==M?(L=(0,t.jsxs)("div",{className:eU.default.CheckboxField,children:[M,R]}),z[62]=M,z[63]=L):L=z[63],z[64]!==B||z[65]!==L?(H=(0,t.jsxs)("div",{className:eU.default.Group,children:[B,L]}),z[64]=B,z[65]=L,z[66]=H):H=z[66],z[67]!==ea||z[68]!==ey||z[69]!==er?(F=ey?null:(0,t.jsxs)("div",{className:eU.default.Field,children:[(0,t.jsx)("label",{htmlFor:"fovInput",children:"FOV"}),(0,t.jsx)("input",{id:"fovInput",type:"range",min:75,max:120,step:5,value:ea,onChange:e=>er(parseInt(e.target.value))}),(0,t.jsx)("output",{htmlFor:"fovInput",children:ea})]}),z[67]=ea,z[68]=ey,z[69]=er,z[70]=F):F=z[70],z[71]!==ey||z[72]!==ec||z[73]!==ei?(G=ey?null:(0,t.jsxs)("div",{className:eU.default.Field,children:[(0,t.jsx)("label",{htmlFor:"speedInput",children:"Speed"}),(0,t.jsx)("input",{id:"speedInput",type:"range",min:.1,max:5,step:.05,value:ei,onChange:e=>ec(parseFloat(e.target.value))})]}),z[71]=ey,z[72]=ec,z[73]=ei,z[74]=G):G=z[74],z[75]!==F||z[76]!==G?(q=(0,t.jsxs)("div",{className:eU.default.Group,children:[F,G]}),z[75]=F,z[76]=G,z[77]=q):q=z[77],z[78]!==Z||z[79]!==ed||z[80]!==eu?(O=Z&&(0,t.jsx)("div",{className:eU.default.Group,children:(0,t.jsxs)("div",{className:eU.default.Field,children:[(0,t.jsx)("label",{htmlFor:"touchModeInput",children:"Joystick:"})," ",(0,t.jsxs)("select",{id:"touchModeInput",value:eu,onChange:e=>ed(e.target.value),children:[(0,t.jsx)("option",{value:"dualStick",children:"Dual Stick"}),(0,t.jsx)("option",{value:"moveLookStick",children:"Single Stick"})]})]})}),z[78]=Z,z[79]=ed,z[80]=eu,z[81]=O):O=z[81],z[82]!==ev||z[83]!==y||z[84]!==N||z[85]!==H||z[86]!==q||z[87]!==O?(A=(0,t.jsxs)("div",{className:eU.default.Dropdown,ref:ek,id:"settingsPanel",tabIndex:-1,onKeyDown:eN,onBlur:ew,"data-open":ev,children:[y,N,H,q,O]}),z[82]=ev,z[83]=y,z[84]=N,z[85]=H,z[86]=q,z[87]=O,z[88]=A):A=z[88],z[89]!==A||z[90]!==d?(U=(0,t.jsxs)("div",{ref:eC,children:[d,A]}),z[89]=A,z[90]=d,z[91]=U):U=z[91],z[92]!==U||z[93]!==i?(W=(0,t.jsxs)("div",{id:"controls",className:eU.default.Controls,onKeyDown:eJ,onPointerDown:e$,onClick:eK,children:[i,U]}),z[92]=U,z[93]=i,z[94]=W):W=z[94],W}function ez(e){return!e}function eK(e){return e.stopPropagation()}function e$(e){return e.stopPropagation()}function eJ(e){return e.stopPropagation()}let eV=()=>null;var eY=e.i(31067);let eX=r.forwardRef(({envMap:e,resolution:t=256,frames:a=1/0,makeDefault:n,children:o,...l},i)=>{let c=(0,$.useThree)(({set:e})=>e),u=(0,$.useThree)(({camera:e})=>e),d=(0,$.useThree)(({size:e})=>e),m=r.useRef(null);r.useImperativeHandle(i,()=>m.current,[]);let h=r.useRef(null),p=function(e,t,a){let n=(0,$.useThree)(e=>e.size),o=(0,$.useThree)(e=>e.viewport),l="number"==typeof e?e:n.width*o.dpr,i=n.height*o.dpr,c=("number"==typeof e?void 0:e)||{},{samples:u=0,depth:d,...m}=c,h=null!=d?d:c.depthBuffer,p=r.useMemo(()=>{let e=new s.WebGLRenderTarget(l,i,{minFilter:s.LinearFilter,magFilter:s.LinearFilter,type:s.HalfFloatType,...m});return h&&(e.depthTexture=new s.DepthTexture(l,i,s.FloatType)),e.samples=u,e},[]);return r.useLayoutEffect(()=>{p.setSize(l,i),u&&(p.samples=u)},[u,p,l,i]),r.useEffect(()=>()=>p.dispose(),[]),p}(t);r.useLayoutEffect(()=>{l.manual||(m.current.aspect=d.width/d.height)},[d,l]),r.useLayoutEffect(()=>{m.current.updateProjectionMatrix()});let f=0,_=null,g="function"==typeof o;return(0,K.useFrame)(t=>{g&&(a===1/0||f{if(n)return c(()=>({camera:m.current})),()=>c(()=>({camera:u}))},[m,n,c]),r.createElement(r.Fragment,null,r.createElement("perspectiveCamera",(0,eY.default)({ref:m},l),!g&&o),r.createElement("group",{ref:h},g&&o(p.texture)))});function eZ(){let e,r,n=(0,a.c)(3),{fov:s}=(0,J.useSettings)();return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[0,256,0],n[0]=e):e=n[0],n[1]!==s?(r=(0,t.jsx)(eX,{makeDefault:!0,position:e,fov:s}),n[1]=s,n[2]=r):r=n[2],r}var eQ=e.i(51434),e0=e.i(86855),e1=e.i(68294),e2=e.i(87297),e3=e.i(51475),e4=e.i(63318),e5=e.i(38437);function e6(){let e,r=(0,a.c)(3),n=(0,y.useSceneSun)();if(!n){let e;return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("ambientLight",{color:"#888888",intensity:1}),r[0]=e):e=r[0],e}return r[1]!==n?(e=(0,t.jsx)(e8,{sunData:n}),r[1]=n,r[2]=e):e=r[2],e}function e8(e){let n,o,l,i,c,u,d,m,h,p,f=(0,a.c)(29),{sunData:_}=e;f[0]!==_.direction?(n=(0,e4.torqueToThree)(_.direction),f[0]=_.direction,f[1]=n):n=f[1];let[g,y,v]=n,x=Math.sqrt(g*g+y*y+v*v),b=g/x,k=y/x,S=v/x;f[2]!==b||f[3]!==k||f[4]!==S?(o=new s.Vector3(b,k,S),f[2]=b,f[3]=k,f[4]=S,f[5]=o):o=f[5];let C=o,j=-(5e3*C.x),w=-(5e3*C.y),N=-(5e3*C.z);f[6]!==j||f[7]!==w||f[8]!==N?(l=new s.Vector3(j,w,N),f[6]=j,f[7]=w,f[8]=N,f[9]=l):l=f[9];let I=l;f[10]!==_.color.b||f[11]!==_.color.g||f[12]!==_.color.r?(i=new s.Color(_.color.r,_.color.g,_.color.b),f[10]=_.color.b,f[11]=_.color.g,f[12]=_.color.r,f[13]=i):i=f[13];let T=i;f[14]!==_.ambient.b||f[15]!==_.ambient.g||f[16]!==_.ambient.r?(c=new s.Color(_.ambient.r,_.ambient.g,_.ambient.b),f[14]=_.ambient.b,f[15]=_.ambient.g,f[16]=_.ambient.r,f[17]=c):c=f[17];let P=c,B=C.y<0;return f[18]!==B?(u=()=>{(0,e5.updateGlobalSunUniforms)(B)},d=[B],f[18]=B,f[19]=u,f[20]=d):(u=f[19],d=f[20]),(0,r.useEffect)(u,d),f[21]!==T||f[22]!==I?(m=(0,t.jsx)("directionalLight",{position:I,color:T,intensity:1,castShadow:!0,"shadow-mapSize-width":8192,"shadow-mapSize-height":8192,"shadow-camera-left":-4096,"shadow-camera-right":4096,"shadow-camera-top":4096,"shadow-camera-bottom":-4096,"shadow-camera-near":100,"shadow-camera-far":12e3,"shadow-bias":-1e-5,"shadow-normalBias":.4,"shadow-radius":2}),f[21]=T,f[22]=I,f[23]=m):m=f[23],f[24]!==P?(h=(0,t.jsx)("ambientLight",{color:P,intensity:1}),f[24]=P,f[25]=h):h=f[25],f[26]!==m||f[27]!==h?(p=(0,t.jsxs)(t.Fragment,{children:[m,h]}),f[26]=m,f[27]=h,f[28]=p):p=f[28],p}var e7=e.i(75840);let e9=(0,i.textureToUrl)("gui/hud_new_compass"),te=(0,i.textureToUrl)("gui/hud_new_NSEW");function tt(e){let r,n,s=(0,a.c)(3),{yaw:o}=e;if(null==o)return null;let l=180*o/Math.PI;s[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("img",{src:e9,alt:"",className:e7.default.CompassRing}),s[0]=r):r=s[0];let i=`rotate(${-l}deg)`;return s[1]!==i?(n=(0,t.jsxs)("div",{className:e7.default.Compass,children:[r,(0,t.jsx)("img",{src:te,alt:"",className:e7.default.CompassNSEW,style:{transform:i}})]}),s[1]=i,s[2]=n):n=s[2],n}function ta(e){let r,n=(0,a.c)(2),{value:s}=e,o=Math.max(0,Math.min(100,100*s)),l=`${o}%`;return n[0]!==l?(r=(0,t.jsx)("div",{className:e7.default.BarTrack,children:(0,t.jsx)("div",{className:e7.default.BarFillHealth,style:{width:l}})}),n[0]=l,n[1]=r):r=n[1],r}function tr(e){let r,n=(0,a.c)(2),{value:s}=e,o=Math.max(0,Math.min(100,100*s)),l=`${o}%`;return n[0]!==l?(r=(0,t.jsx)("div",{className:e7.default.BarTrack,children:(0,t.jsx)("div",{className:e7.default.BarFillEnergy,style:{width:l}})}),n[0]=l,n[1]=r):r=n[1],r}let tn={weapon_sniper:"gui/hud_ret_sniper",weapon_shocklance:"gui/hud_ret_shocklance",weapon_targeting:"gui/hud_ret_targlaser"};function ts(){let e,r=(0,a.c)(5),n=(0,g.useEngineSelector)(to);if(void 0===n)return null;let s=tn[!n?"":n.replace(/\.dts$/i,"").toLowerCase()];if(s){let e,a;return r[0]!==s?(e=(0,i.textureToUrl)(s),r[0]=s,r[1]=e):e=r[1],r[2]!==e?(a=(0,t.jsx)("div",{className:e7.default.Reticle,children:(0,t.jsx)("img",{src:e,alt:"",className:e7.default.ReticleImage})}),r[2]=e,r[3]=a):a=r[3],a}return r[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:e7.default.Reticle,children:(0,t.jsx)("div",{className:e7.default.ReticleDot})}),r[4]=e):e=r[4],e}function to(e){let t=e.playback.streamSnapshot;if(!t||t.camera?.mode!=="first-person")return;let a=t.controlPlayerGhostId;if(a)return t.entities.find(e=>e.id===a)?.weaponShape}let tl={0:{icon:"gui/hud_blaster",label:"Blaster"},1:{icon:"gui/hud_plasma",label:"Plasma"},2:{icon:"gui/hud_chaingun",label:"Chaingun"},3:{icon:"gui/hud_disc",label:"Spinfusor"},4:{icon:"gui/hud_grenlaunch",label:"GL"},5:{icon:"gui/hud_sniper",label:"Laser Rifle"},6:{icon:"gui/hud_elfgun",label:"ELF Gun"},7:{icon:"gui/hud_new_mortar",label:"Mortar"},8:{icon:"gui/hud_missiles",label:"Missile"},9:{icon:"gui/hud_targetlaser",label:"Targeting"},10:{icon:"gui/hud_shocklance",label:"Shocklance"},11:{icon:"gui/hud_disc",label:"Spinfusor"},12:{icon:"gui/hud_grenlaunch",label:"GL"},13:{icon:"gui/hud_chaingun",label:"Chaingun"},14:{icon:"gui/hud_targetlaser",label:"Targeting"},15:{icon:"gui/hud_targetlaser",label:"Targeting"},16:{icon:"gui/hud_shocklance",label:"Shocklance"},17:{icon:"gui/hud_new_mortar",label:"Mortar"}},ti=new Map(Object.entries(tl).map(([e,t])=>[Number(e),(0,i.textureToUrl)(t.icon)])),tc=new Set([9,14,15]),tu=(0,i.textureToUrl)("gui/hud_infinity");function td(e){let r,n,s,o,l=(0,a.c)(12),{slot:i,isSelected:c}=e,u=tl[i.index];if(!u)return null;let d=i.ammo<0,m=`${e7.default.PackInvItem} ${c?e7.default.PackInvItemActive:e7.default.PackInvItemDim}`;return l[0]!==i.index?(r=ti.get(i.index),l[0]=i.index,l[1]=r):r=l[1],l[2]!==u.label||l[3]!==r?(n=(0,t.jsx)("img",{src:r,alt:u.label,className:e7.default.PackInvIcon}),l[2]=u.label,l[3]=r,l[4]=n):n=l[4],l[5]!==d||l[6]!==i.ammo?(s=d?(0,t.jsx)("img",{src:tu,alt:"\\u221E",className:e7.default.PackInvInfinity}):(0,t.jsx)("span",{className:e7.default.PackInvCount,children:i.ammo}),l[5]=d,l[6]=i.ammo,l[7]=s):s=l[7],l[8]!==m||l[9]!==n||l[10]!==s?(o=(0,t.jsxs)("div",{className:m,children:[n,s]}),l[8]=m,l[9]=n,l[10]=s,l[11]=o):o=l[11],o}function tm(){let e,r,n,s,o,l,i=(0,a.c)(15),c=(0,g.useEngineSelector)(th);if(!c||!c.slots.length)return null;if(i[0]!==c.slots){for(let t of(r=[],e=[],c.slots))tc.has(t.index)?e.push(t):r.push(t);i[0]=c.slots,i[1]=e,i[2]=r}else e=i[1],r=i[2];return i[3]!==r||i[4]!==c?(n=r.map(e=>(0,t.jsx)(td,{slot:e,isSelected:e.index===c.activeIndex},e.index)),i[3]=r,i[4]=c,i[5]=n):n=i[5],i[6]!==e.length?(s=e.length>0&&(0,t.jsx)("div",{className:e7.default.WeaponSeparator}),i[6]=e.length,i[7]=s):s=i[7],i[8]!==e||i[9]!==c?(o=e.map(e=>(0,t.jsx)(td,{slot:e,isSelected:e.index===c.activeIndex},e.index)),i[8]=e,i[9]=c,i[10]=o):o=i[10],i[11]!==n||i[12]!==s||i[13]!==o?(l=(0,t.jsxs)("div",{className:e7.default.WeaponHUD,children:[n,s,o]}),i[11]=n,i[12]=s,i[13]=o,i[14]=l):l=i[14],l}function th(e){return e.playback.streamSnapshot?.weaponsHud}let tp={1:"Storm",2:"Inferno",3:"Starwolf",4:"Diamond Sword",5:"Blood Eagle",6:"Phoenix"};function tf(){let e,r,n,s=(0,a.c)(11),o=(0,g.useEngineSelector)(tg),l=(0,g.useEngineSelector)(t_);if(!o?.length)return null;if(s[0]!==l||s[1]!==o){let a,n;s[4]!==l?(a=(e,t)=>{if(l){if(e.teamId===l)return -1;if(t.teamId===l)return 1}return e.teamId-t.teamId},s[4]=l,s[5]=a):a=s[5];let i=[...o].sort(a);e=e7.default.TeamScores,s[6]!==l?(n=e=>{let a=l>0&&e.teamId===l,r=e.name||(tp[e.teamId]??`Team ${e.teamId}`);return(0,t.jsxs)("div",{className:e7.default.TeamRow,children:[(0,t.jsx)("span",{className:a?e7.default.TeamNameFriendly:e7.default.TeamNameEnemy,children:r}),(0,t.jsx)("span",{className:e7.default.TeamScore,children:e.score}),(0,t.jsxs)("span",{className:e7.default.TeamCount,children:["(",e.playerCount,")"]})]},e.teamId)},s[6]=l,s[7]=n):n=s[7],r=i.map(n),s[0]=l,s[1]=o,s[2]=e,s[3]=r}else e=s[2],r=s[3];return s[8]!==e||s[9]!==r?(n=(0,t.jsx)("div",{className:e,children:r}),s[8]=e,s[9]=r,s[10]=n):n=s[10],n}function t_(e){return e.playback.streamSnapshot?.playerSensorGroup}function tg(e){return e.playback.streamSnapshot?.teamScores}let ty={0:e7.default.ChatColor0,1:e7.default.ChatColor1,2:e7.default.ChatColor2,3:e7.default.ChatColor3,4:e7.default.ChatColor4,5:e7.default.ChatColor5,6:e7.default.ChatColor6,7:e7.default.ChatColor7,8:e7.default.ChatColor8,9:e7.default.ChatColor9};function tv(){let e,r,n,s,o=(0,a.c)(13),l=(0,g.useEngineSelector)(tk),i=(0,g.useEngineSelector)(tb);if(!l||!l.length||null==i)return null;let c=i-7.5;if(o[0]!==c||o[1]!==l||o[2]!==i){n=Symbol.for("react.early_return_sentinel");e:{let a,s;o[6]!==c?(a=e=>e.timeSec>c&&""!==e.text.trim(),o[6]=c,o[7]=a):a=o[7];let u=l.filter(a);if(!u.length){n=null;break e}e=e7.default.ChatWindow,o[8]!==i?(s=(e,a)=>{let r=i-e.timeSec,n=r<=6?1:Math.max(0,1-(r-6)/1.5);return(0,t.jsx)("div",{className:e7.default.ChatMessage,style:{opacity:n},children:e.segments?e.segments.map(tx):(0,t.jsxs)("span",{className:null!=e.colorCode&&ty[e.colorCode]?ty[e.colorCode]:ty[0],children:[e.sender?`${e.sender}: `:"",e.text]})},`${e.timeSec}-${a}`)},o[8]=i,o[9]=s):s=o[9],r=u.map(s)}o[0]=c,o[1]=l,o[2]=i,o[3]=e,o[4]=r,o[5]=n}else e=o[3],r=o[4],n=o[5];return n!==Symbol.for("react.early_return_sentinel")?n:(o[10]!==e||o[11]!==r?(s=(0,t.jsx)("div",{className:e,children:r}),o[10]=e,o[11]=r,o[12]=s):s=o[12],s)}function tx(e,a){return(0,t.jsx)("span",{className:ty[e.colorCode]??ty[0],children:e.text},a)}function tb(e){return e.playback.streamSnapshot?.timeSec}function tk(e){return e.playback.streamSnapshot?.chatMessages}let tS=new Map(Object.entries({0:"gui/hud_new_packammo",1:"gui/hud_new_packcloak",2:"gui/hud_new_packenergy",3:"gui/hud_new_packrepair",4:"gui/hud_new_packsatchel",5:"gui/hud_new_packshield",6:"gui/hud_new_packinventory",7:"gui/hud_new_packmotionsens",8:"gui/hud_new_packradar",9:"gui/hud_new_packturretout",10:"gui/hud_new_packturretin",11:"gui/hud_new_packsensjam",12:"gui/hud_new_packturret",13:"gui/hud_new_packturret",14:"gui/hud_new_packturret",15:"gui/hud_new_packturret",16:"gui/hud_new_packturret",17:"gui/hud_new_packturret",18:"gui/hud_satchel_unarmed",19:"gui/hud_new_packenergy"}).map(([e,t])=>[Number(e),(0,i.textureToUrl)(t)])),tC=new Map(Object.entries({1:"gui/hud_new_packcloak_armed",3:"gui/hud_new_packrepair_armed",4:"gui/hud_satchel_armed",5:"gui/hud_new_packshield_armed",11:"gui/hud_new_packsensjam_armed"}).map(([e,t])=>[Number(e),(0,i.textureToUrl)(t)])),tj={0:{icon:"gui/hud_handgren",label:"Grenade"},1:{icon:"gui/hud_mine",label:"Mine"},2:{icon:"gui/hud_beacon",label:"Beacon"},3:{icon:"gui/hud_medpack",label:"Repair Kit"}},tw=new Map(Object.entries(tj).map(([e,t])=>[Number(e),(0,i.textureToUrl)(t.icon)]));function tN(){let e,r,n,s,o,l,i,c=(0,a.c)(25),u=(0,g.useEngineSelector)(tP),d=(0,g.useEngineSelector)(tT),m=u&&u.packIndex>=0;if(m){let t,a;c[0]!==u.active||c[1]!==u.packIndex?(t=u.active?tC.get(u.packIndex):void 0,c[0]=u.active,c[1]=u.packIndex,c[2]=t):t=c[2];let r=t;c[3]!==r||c[4]!==u.packIndex?(a=r??tS.get(u.packIndex),c[3]=r,c[4]=u.packIndex,c[5]=a):a=c[5],e=a}if(c[6]!==d){if(r=new Map,d)for(let e of d.slots)r.set(e.slot,e.count);c[6]=d,c[7]=r}else r=c[7];if(c[8]!==u||c[9]!==r||c[10]!==m||c[11]!==e){l=Symbol.for("react.early_return_sentinel");e:{let a,i=Object.keys(tj).map(Number).sort(tI);if(!m&&!r.size){l=null;break e}n=e7.default.PackInventoryHUD,c[16]!==u||c[17]!==e?(s=e&&(0,t.jsxs)("div",{className:`${e7.default.PackInvItem} ${u.active?e7.default.PackInvItemActive:""}`,children:[(0,t.jsx)("img",{src:e,alt:"",className:e7.default.PackInvIcon}),(0,t.jsx)("span",{className:e7.default.PackInvCount,children:u.text||" "})]}),c[16]=u,c[17]=e,c[18]=s):s=c[18],c[19]!==r?(a=e=>{let a=tj[e],n=tw.get(e);return a&&n?(0,t.jsxs)("div",{className:e7.default.PackInvItem,children:[(0,t.jsx)("img",{src:n,alt:a.label,className:e7.default.PackInvIcon}),(0,t.jsx)("span",{className:e7.default.PackInvCount,children:r.get(e)??0})]},e):null},c[19]=r,c[20]=a):a=c[20],o=i.map(a)}c[8]=u,c[9]=r,c[10]=m,c[11]=e,c[12]=n,c[13]=s,c[14]=o,c[15]=l}else n=c[12],s=c[13],o=c[14],l=c[15];return l!==Symbol.for("react.early_return_sentinel")?l:(c[21]!==n||c[22]!==s||c[23]!==o?(i=(0,t.jsxs)("div",{className:n,children:[s,o]}),c[21]=n,c[22]=s,c[23]=o,c[24]=i):i=c[24],i)}function tI(e,t){return e-t}function tT(e){return e.playback.streamSnapshot?.inventoryHud}function tP(e){return e.playback.streamSnapshot?.backpackHud}function tB(){let e,r,n,s,o,l,i,c,u,d,m,h=(0,a.c)(19),p=(0,E.useRecording)(),f=(0,g.useEngineSelector)(tD);if(!p)return null;let _=f?.status;if(!_)return null;h[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tv,{}),h[0]=e):e=h[0],h[1]!==_.health?(r=(0,t.jsx)(ta,{value:_.health}),h[1]=_.health,h[2]=r):r=h[2],h[3]!==_.energy?(n=(0,t.jsx)(tr,{value:_.energy}),h[3]=_.energy,h[4]=n):n=h[4],h[5]!==r||h[6]!==n?(s=(0,t.jsxs)("div",{className:e7.default.Bars,children:[r,n]}),h[5]=r,h[6]=n,h[7]=s):s=h[7];let y=f?.camera?.yaw;return h[8]!==y?(o=(0,t.jsx)(tt,{yaw:y}),h[8]=y,h[9]=o):o=h[9],h[10]!==s||h[11]!==o?(l=(0,t.jsxs)("div",{className:e7.default.TopRight,children:[s,o]}),h[10]=s,h[11]=o,h[12]=l):l=h[12],h[13]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(tm,{}),u=(0,t.jsx)(tN,{}),d=(0,t.jsx)(tf,{}),i=(0,t.jsx)(ts,{}),h[13]=i,h[14]=c,h[15]=u,h[16]=d):(i=h[13],c=h[14],u=h[15],d=h[16]),h[17]!==l?(m=(0,t.jsxs)("div",{className:e7.default.PlayerHUD,children:[e,l,c,u,d,i]}),h[17]=l,h[18]=m):m=h[18],m}function tD(e){return e.playback.streamSnapshot}var tE=e.i(56614);function tM({open:e,onClose:a,servers:n,loading:s,onRefresh:o,onJoin:l,wsPing:i}){let[c,u]=(0,r.useState)(null),[d,m]=(0,r.useState)("ping"),[h,p]=(0,r.useState)("asc"),f=(0,r.useRef)(null),_=(0,r.useRef)(o);_.current=o;let g=(0,r.useRef)(!1);(0,r.useEffect)(()=>{if(e){f.current?.focus();try{document.exitPointerLock()}catch{}}else g.current=!1},[e]),(0,r.useEffect)(()=>{e&&0===n.length&&!g.current&&(g.current=!0,_.current())},[e]),(0,r.useEffect)(()=>{if(!e)return;let t=e=>{e.stopPropagation(),"Escape"===e.key&&a()};return window.addEventListener("keydown",t,!0),()=>window.removeEventListener("keydown",t,!0)},[e,a]);let y=(0,r.useCallback)(e=>{d===e?p(e=>"asc"===e?"desc":"asc"):(m(e),p("desc"))},[d]),v=(0,r.useMemo)(()=>[...n].sort((e,t)=>{let a=e[d],r=t[d],n="number"==typeof a&&"number"==typeof r?a-r:String(a).localeCompare(String(r));return"asc"===h?n:-n}),[n,h,d]),x=(0,r.useCallback)(()=>{c&&(l(c),a())},[c,l,a]);return e?(0,t.jsx)("div",{className:tE.default.Overlay,onClick:a,children:(0,t.jsxs)("div",{className:tE.default.Dialog,ref:f,tabIndex:-1,onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)("div",{className:tE.default.Header,children:[(0,t.jsx)("h2",{className:tE.default.Title,children:"Server Browser"}),(0,t.jsxs)("span",{className:tE.default.ServerCount,children:[n.length," server",1!==n.length?"s":""]}),(0,t.jsx)("button",{className:tE.default.RefreshButton,onClick:o,disabled:s,children:s?"Refreshing...":"Refresh"})]}),(0,t.jsx)("div",{className:tE.default.TableWrapper,children:(0,t.jsxs)("table",{className:tE.default.Table,children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{children:[(0,t.jsx)("th",{onClick:()=>y("name"),children:"Server Name"}),(0,t.jsx)("th",{onClick:()=>y("playerCount"),children:"Players"}),(0,t.jsx)("th",{onClick:()=>y("ping"),children:"Ping"}),(0,t.jsx)("th",{onClick:()=>y("mapName"),children:"Map"}),(0,t.jsx)("th",{onClick:()=>y("gameType"),children:"Type"}),(0,t.jsx)("th",{onClick:()=>y("mod"),children:"Mod"})]})}),(0,t.jsxs)("tbody",{children:[v.map(e=>(0,t.jsxs)("tr",{className:c===e.address?tE.default.Selected:void 0,onClick:()=>u(e.address),onDoubleClick:()=>{u(e.address),l(e.address),a()},children:[(0,t.jsxs)("td",{children:[e.passwordRequired&&(0,t.jsx)("span",{className:tE.default.PasswordIcon,children:"🔒"}),e.name]}),(0,t.jsxs)("td",{children:[e.playerCount,"/",e.maxPlayers]}),(0,t.jsx)("td",{children:null!=i?(e.ping+i).toLocaleString():"—"}),(0,t.jsx)("td",{children:e.mapName}),(0,t.jsx)("td",{children:e.gameType}),(0,t.jsx)("td",{children:e.mod})]},e.address)),0===v.length&&!s&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:tE.default.Empty,children:"No servers found"})}),s&&0===v.length&&(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:6,className:tE.default.Empty,children:"Querying master server..."})})]})]})}),(0,t.jsxs)("div",{className:tE.default.Footer,children:[(0,t.jsx)("button",{onClick:x,disabled:!c,className:tE.default.JoinButton,children:"Join"}),(0,t.jsx)("button",{onClick:a,className:tE.default.CloseButton,children:"Cancel"}),(0,t.jsx)("span",{className:tE.default.Hint,children:"Double-click a server to join"})]})]})}):null}var tR=e.i(38847);let tL=(0,r.createContext)({live:!1});function tH(e){let n,s,o=(0,a.c)(5),{children:l}=e,[i]=(0,tR.useQueryState)("features",tR.parseAsString);o[0]!==i?(n=()=>({live:new Set((i??"").split(",").map(tF).filter(Boolean)).has("live")}),o[0]=i,o[1]=n):n=o[1];let[c]=(0,r.useState)(n);return o[2]!==l||o[3]!==c?(s=(0,t.jsx)(tL.Provider,{value:c,children:l}),o[2]=l,o[3]=c,o[4]=s):s=o[4],s}function tF(e){return e.trim().toLowerCase()}var tG=e.i(3011);let tq=(0,r.lazy)(()=>e.A(96239).then(e=>({default:e.DemoPlayback}))),tO=(0,r.lazy)(()=>e.A(93884).then(e=>({default:e.DemoPlaybackControls}))),tA=(0,r.lazy)(()=>e.A(96145).then(e=>({default:e.LiveObserver}))),tU=(0,r.lazy)(()=>e.A(38496).then(e=>({default:e.ChatSoundPlayer}))),tW=(0,r.lazy)(()=>e.A(59197).then(e=>({default:e.MapInfoDialog}))),tz=new T.QueryClient,tK={toneMapping:s.NoToneMapping,outputColorSpace:s.SRGBColorSpace},t$=(0,tR.createParser)({parse(e){let[t,a]=e.split("~"),r=a,n=(0,f.getMissionInfo)(t).missionTypes;return a&&n.includes(a)||(r=n[0]),{missionName:t,missionType:r}},serialize:({missionName:e,missionType:t})=>1===(0,f.getMissionInfo)(e).missionTypes.length?e:`${e}~${t}`,eq:(e,t)=>e.missionName===t.missionName&&e.missionType===t.missionType}).withDefault({missionName:"RiverDance",missionType:"CTF"});function tJ(){let e,o,l,i,c,u,d,m,h,p,_,g,y,v,x,b,k,S,C,j,w,N,I,T,M,L,H,F,G,q,O,A,U,W,z,K,$,V,Y,X,Q,ee,et,ea=(0,a.c)(77),[er,en]=(0,tR.useQueryState)("mission",t$),[es,eo]=(0,tR.useQueryState)("fog",tR.parseAsBoolean);ea[0]!==eo?(e=()=>{eo(null)},ea[0]=eo,ea[1]=e):e=ea[1];let el=e;ea[2]!==el||ea[3]!==en?(o=e=>{window.location.hash="",el(),en(e)},ea[2]=el,ea[3]=en,ea[4]=o):o=ea[4];let ei=o,ec=(X=(0,a.c)(2),Q=(0,r.useRef)(null),X[0]===Symbol.for("react.memo_cache_sentinel")?(V=e=>{let t=window.matchMedia("(pointer: coarse)");return t.addEventListener("change",e),Q.current=t,()=>{t.removeEventListener("change",e)}},X[0]=V):V=X[0],ee=V,X[1]===Symbol.for("react.memo_cache_sentinel")?(Y=()=>Q.current?.matches??null,X[1]=Y):Y=X[1],et=Y,(0,r.useSyncExternalStore)(ee,et,eV)),eu=(0,r.useContext)(tL),ed=(0,eF.useLiveConnection)(),{missionName:em,missionType:eh}=er,[ep,ef]=(0,r.useState)(!1),[e_,eg]=(0,r.useState)(!1),[ey,ev]=(0,r.useState)(0),[ex,eb]=(0,r.useState)(!0),ek=null!=ed.adapter?ed.liveReady?1:"connected"===ed.gameStatus?.8:"authenticating"===ed.gameStatus?.6:"challenging"===ed.gameStatus?.3:"connecting"===ed.gameStatus?.2:.1:null;ea[5]!==ek?(l=()=>{null!=ek&&ev(0)},ea[5]=ek,ea[6]=l):l=ea[6];let eS=null!=ek;ea[7]!==eS?(i=[eS],ea[7]=eS,ea[8]=i):i=ea[8],(0,r.useEffect)(l,i);let eC=ek??ey,ej=eC<1;ea[9]!==ej?(c=()=>{if(ej)eb(!0);else{let e=setTimeout(()=>eb(!1),500);return()=>clearTimeout(e)}},u=[ej],ea[9]=ej,ea[10]=c,ea[11]=u):(c=ea[10],u=ea[11]),(0,r.useEffect)(c,u),ea[12]!==ei?(d=()=>(window.setMissionName=e=>{let t=(0,f.getMissionInfo)(e).missionTypes;ei({missionName:e,missionType:t[0]})},window.getMissionList=f.getMissionList,window.getMissionInfo=f.getMissionInfo,tV),m=[ei],ea[12]=ei,ea[13]=d,ea[14]=m):(d=ea[13],m=ea[14]),(0,r.useEffect)(d,m),ea[15]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{let e=e=>{if("KeyI"!==e.code||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||ef(!0)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},h=[],ea[15]=h,ea[16]=p):(h=ea[15],p=ea[16]),(0,r.useEffect)(p,h),ea[17]===Symbol.for("react.memo_cache_sentinel")?(_=(e,t)=>{ev(void 0===t?0:t)},ea[17]=_):_=ea[17];let ew=_,eN=(0,r.useRef)(null);ea[18]===Symbol.for("react.memo_cache_sentinel")?(g={angle:0,force:0},ea[18]=g):g=ea[18];let eI=(0,r.useRef)(g),eT=(0,r.useRef)(null);ea[19]===Symbol.for("react.memo_cache_sentinel")?(y={angle:0,force:0},ea[19]=y):y=ea[19];let eP=(0,r.useRef)(y),eB=(0,r.useRef)(null);return ea[20]!==ej||ea[21]!==eC||ea[22]!==ex?(v=ex&&(0,t.jsxs)("div",{id:"loadingIndicator",className:tG.default.LoadingIndicator,"data-complete":!ej,children:[(0,t.jsx)("div",{className:tG.default.Spinner}),(0,t.jsx)("div",{className:tG.default.Progress,children:(0,t.jsx)("div",{className:tG.default.ProgressBar,style:{width:`${100*eC}%`}})}),(0,t.jsxs)("div",{className:tG.default.ProgressText,children:[Math.round(100*eC),"%"]})]}),ea[20]=ej,ea[21]=eC,ea[22]=ex,ea[23]=v):v=ea[23],ea[24]===Symbol.for("react.memo_cache_sentinel")?(x={type:s.PCFShadowMap},b=e=>{eN.current=e.camera},ea[24]=x,ea[25]=b):(x=ea[24],b=ea[25]),ea[26]!==em||ea[27]!==eh?(k=(0,t.jsx)(tY,{missionName:em,missionType:eh,onLoadingChange:ew}),ea[26]=em,ea[27]=eh,ea[28]=k):k=ea[28],ea[29]===Symbol.for("react.memo_cache_sentinel")?(S=(0,t.jsx)(e6,{}),ea[29]=S):S=ea[29],ea[30]!==eh?(C=(0,t.jsx)(e2.EntityScene,{missionType:eh}),ea[30]=eh,ea[31]=C):C=ea[31],ea[32]===Symbol.for("react.memo_cache_sentinel")?(j=(0,t.jsx)(eZ,{}),w=(0,t.jsx)(e0.DebugElements,{}),ea[32]=j,ea[33]=w):(j=ea[32],w=ea[33]),ea[34]!==ec?(N=(0,t.jsx)(tX,{isTouch:ec,joystickStateRef:eI,joystickZoneRef:eT,lookJoystickStateRef:eP,lookJoystickZoneRef:eB}),ea[34]=ec,ea[35]=N):N=ea[35],ea[36]!==k||ea[37]!==C||ea[38]!==N?(I=(0,t.jsx)(n.Canvas,{frameloop:"always",gl:tK,shadows:x,onCreated:b,children:(0,t.jsx)(e3.TickProvider,{children:(0,t.jsx)(e1.CamerasProvider,{children:(0,t.jsxs)(eQ.AudioProvider,{children:[k,S,C,j,w,N]})})})}),ea[36]=k,ea[37]=C,ea[38]=N,ea[39]=I):I=ea[39],ea[40]!==v||ea[41]!==I?(T=(0,t.jsxs)("div",{id:"canvasContainer",className:tG.default.CanvasContainer,children:[v,I]}),ea[40]=v,ea[41]=I,ea[42]=T):T=ea[42],ea[43]===Symbol.for("react.memo_cache_sentinel")?(M=(0,t.jsx)(tZ,{}),ea[43]=M):M=ea[43],ea[44]!==ec?(L=ec&&(0,t.jsx)(Z,{joystickState:eI,joystickZone:eT,lookJoystickState:eP,lookJoystickZone:eB}),ea[44]=ec,ea[45]=L):L=ea[45],ea[46]!==ec?(H=!1===ec&&(0,t.jsx)(R,{}),ea[46]=ec,ea[47]=H):H=ea[47],ea[48]===Symbol.for("react.memo_cache_sentinel")?(F=()=>ef(!0),ea[48]=F):F=ea[48],ea[49]!==eu.live?(G=eu.live?()=>eg(!0):void 0,ea[49]=eu.live,ea[50]=G):G=ea[50],ea[51]!==ei||ea[52]!==ec||ea[53]!==em||ea[54]!==eh||ea[55]!==G?(q=(0,t.jsx)(eW,{missionName:em,missionType:eh,onChangeMission:ei,onOpenMapInfo:F,onOpenServerBrowser:G,cameraRef:eN,isTouch:ec}),ea[51]=ei,ea[52]=ec,ea[53]=em,ea[54]=eh,ea[55]=G,ea[56]=q):q=ea[56],ea[57]!==ep||ea[58]!==em||ea[59]!==eh?(O=ep&&(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(tW,{open:ep,onClose:()=>ef(!1),missionName:em,missionType:eh??""})}),ea[57]=ep,ea[58]=em,ea[59]=eh,ea[60]=O):O=ea[60],ea[61]===Symbol.for("react.memo_cache_sentinel")?(A=()=>eg(!1),ea[61]=A):A=ea[61],ea[62]!==e_?(U=(0,t.jsx)(t0,{open:e_,onClose:A}),ea[62]=e_,ea[63]=U):U=ea[63],ea[64]===Symbol.for("react.memo_cache_sentinel")?(W=(0,t.jsx)(tQ,{}),z=(0,t.jsx)(t1,{}),ea[64]=W,ea[65]=z):(W=ea[64],z=ea[65]),ea[66]!==T||ea[67]!==L||ea[68]!==H||ea[69]!==q||ea[70]!==O||ea[71]!==U?(K=(0,t.jsxs)(D.KeyboardControls,{map:B.KEYBOARD_CONTROLS,children:[T,M,L,H,q,O,U,W,z]}),ea[66]=T,ea[67]=L,ea[68]=H,ea[69]=q,ea[70]=O,ea[71]=U,ea[72]=K):K=ea[72],ea[73]!==el||ea[74]!==es||ea[75]!==K?($=(0,t.jsx)(P.QueryClientProvider,{client:tz,children:(0,t.jsx)("main",{children:(0,t.jsx)(E.RecordingProvider,{children:(0,t.jsx)(J.SettingsProvider,{fogEnabledOverride:es,onClearFogEnabledOverride:el,children:K})})})}),ea[73]=el,ea[74]=es,ea[75]=K,ea[76]=$):$=ea[76],$}function tV(){delete window.setMissionName,delete window.getMissionList,delete window.getMissionInfo}function tY(e){let r,n=(0,a.c)(5),{missionName:s,missionType:o,onLoadingChange:l}=e,i=(0,E.useRecording)(),{adapter:c}=(0,eF.useLiveConnection)();if(null!=i||null!=c)return null;let u=`${s}~${o}`;return n[0]!==s||n[1]!==o||n[2]!==l||n[3]!==u?(r=(0,t.jsx)(I,{name:s,missionType:o,onLoadingChange:l},u),n[0]=s,n[1]=o,n[2]=l,n[3]=u,n[4]=r):r=n[4],r}function tX(e){let n,s,o,l,i,c=(0,a.c)(18),{isTouch:u,joystickStateRef:d,joystickZoneRef:m,lookJoystickStateRef:h,lookJoystickZoneRef:p}=e,f=(0,E.useRecording)(),_=null!=(0,eF.useLiveConnection)().adapter,g=null!=f||_,y=!g||_;return c[0]!==f?(n=f&&(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(tq,{})}),c[0]=f,c[1]=n):n=c[1],c[2]!==_?(s=_&&(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(tA,{})}),c[2]=_,c[3]=s):s=c[3],c[4]!==g?(o=g&&(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(tU,{})}),c[4]=g,c[5]=o):o=c[5],c[6]!==u||c[7]!==d||c[8]!==m||c[9]!==h||c[10]!==p||c[11]!==y?(l=y&&null!==u&&(u?(0,t.jsx)(Q,{joystickState:d,joystickZone:m,lookJoystickState:h,lookJoystickZone:p}):(0,t.jsx)(B.ObserverControls,{})),c[6]=u,c[7]=d,c[8]=m,c[9]=h,c[10]=p,c[11]=y,c[12]=l):l=c[12],c[13]!==n||c[14]!==s||c[15]!==o||c[16]!==l?(i=(0,t.jsxs)(t.Fragment,{children:[n,s,o,l]}),c[13]=n,c[14]=s,c[15]=o,c[16]=l,c[17]=i):i=c[17],i}function tZ(){let e,r=(0,a.c)(1),n=(0,E.useRecording)(),s=(0,eF.useLiveConnection)();return n||s.adapter?(r[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(tB,{}),r[0]=e):e=r[0],e):null}function tQ(){let e,n=(0,a.c)(1),s=(0,E.useRecording)(),o=(0,eF.useLiveConnection)();return s&&null==o.adapter?(n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(r.Suspense,{fallback:null,children:(0,t.jsx)(tO,{})}),n[0]=e):e=n[0],e):null}function t0(e){let r,n,s=(0,a.c)(10),{open:o,onClose:l}=e,i=(0,eF.useLiveConnection)();return s[0]!==i?(r=e=>i.joinServer(e),s[0]=i,s[1]=r):r=s[1],s[2]!==i.listServers||s[3]!==i.servers||s[4]!==i.serversLoading||s[5]!==i.wsPing||s[6]!==l||s[7]!==o||s[8]!==r?(n=(0,t.jsx)(tM,{open:o,onClose:l,servers:i.servers,loading:i.serversLoading,onRefresh:i.listServers,onJoin:r,wsPing:i.wsPing}),s[2]=i.listServers,s[3]=i.servers,s[4]=i.serversLoading,s[5]=i.wsPing,s[6]=l,s[7]=o,s[8]=r,s[9]=n):n=s[9],n}function t1(){let e,t,n=(0,a.c)(3),{setRecording:s}=(0,E.usePlaybackActions)();return n[0]!==s?(e=()=>(window.loadDemoRecording=s,t2),t=[s],n[0]=s,n[1]=e,n[2]=t):(e=n[1],t=n[2]),(0,r.useEffect)(e,t),null}function t2(){delete window.loadDemoRecording}function t3(){let e,n=(0,a.c)(1);return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(r.Suspense,{children:(0,t.jsx)(tH,{children:(0,t.jsx)(eF.LiveConnectionProvider,{children:(0,t.jsx)(tJ,{})})})}),n[0]=e):e=n[0],e}e.s(["default",()=>t3],31713)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/bd03a29a57c8ca45.css b/docs/_next/static/chunks/bd03a29a57c8ca45.css new file mode 100644 index 00000000..cc049d83 --- /dev/null +++ b/docs/_next/static/chunks/bd03a29a57c8ca45.css @@ -0,0 +1,5 @@ +.GuiMarkup-module__CLgNnq__GuiMarkup{white-space:pre-wrap;font-size:14px;line-height:1.5}.GuiMarkup-module__CLgNnq__GuiMarkup a{color:inherit;text-decoration:underline}.GuiMarkup-module__CLgNnq__Bullet{margin-left:.5em;margin-right:.5em} +.DialogButton-module__LxvdOa__DialogButton{color:#99fff1;text-shadow:0 -1px 1px #0006;cursor:pointer;background:linear-gradient(#30a497cc,#1f9688cc 33%,#218377cc 67%,#046564cc);border:1px solid #387c74cc;border-top-color:#57b7b9cc;border-radius:4px;padding:4px 18px;font-family:inherit;font-size:14px;font-weight:500;box-shadow:inset 0 0 4px #02808e80}.DialogButton-module__LxvdOa__DialogButton:hover:not(:disabled){color:#b1fff5;border:1px solid #409188e6;border-top-color:#5ac6c2e6;box-shadow:inset 0 0 4px #02808e80,0 0 5px #3effbf80}.DialogButton-module__LxvdOa__DialogButton:active:not(:disabled){transform:translateY(1px)}.DialogButton-module__LxvdOa__DialogButton:disabled{opacity:.4;cursor:not-allowed}.DialogButton-module__LxvdOa__Secondary{box-shadow:none;color:#a2e2cfcc;text-shadow:none;background:0 0;border:1px solid #387c74cc;}.DialogButton-module__LxvdOa__Secondary:hover:not(:disabled){color:#a9ffe5cc;border:1px solid #3f9087e6} +.ServerBrowser-module__kqm3eq__Dialog{color:#b0d5c9;-webkit-user-select:text;user-select:text;-webkit-touch-callout:default;background:#142526cc;border:1px solid #41838b99;border-radius:4px;outline:none;grid-template-rows:auto 1fr auto;grid-template-columns:100%;width:860px;max-width:calc(100dvw - 40px);height:560px;max-height:calc(100dvh - 40px);font-size:14px;line-height:1.5;display:grid;position:relative;overflow:hidden;box-shadow:0 0 50px #0006,inset 0 0 60px #01070d99}.ServerBrowser-module__kqm3eq__Overlay{z-index:10;background:#000000b3;justify-content:center;align-items:center;padding:20px;display:flex;position:fixed;inset:0}.ServerBrowser-module__kqm3eq__Header{border-bottom:1px solid #00bedc40;align-items:center;gap:12px;padding:12px 16px 10px;display:flex}.ServerBrowser-module__kqm3eq__Title{color:#7dffff;text-shadow:0 1px 6px #0006;flex:1;margin:0;font-size:18px;font-weight:500}.ServerBrowser-module__kqm3eq__RefreshButton{padding:3px 14px;font-size:12px;}.ServerBrowser-module__kqm3eq__ServerCount{color:#c9dcd866;font-size:12px}.ServerBrowser-module__kqm3eq__TableWrapper{min-height:0;overflow-y:auto}.ServerBrowser-module__kqm3eq__Table{border-collapse:collapse;width:100%;font-size:13px}.ServerBrowser-module__kqm3eq__Table th{text-align:left;cursor:pointer;-webkit-user-select:none;user-select:none;letter-spacing:.04em;text-transform:uppercase;color:#7dffff99;background:#0a191af2;border-bottom:1px solid #00bedc33;padding:6px 12px;font-size:11px;font-weight:500;position:sticky;top:0}.ServerBrowser-module__kqm3eq__Table th:hover{color:#7dffff}.ServerBrowser-module__kqm3eq__Table th:nth-child(2),.ServerBrowser-module__kqm3eq__Table td:nth-child(2),.ServerBrowser-module__kqm3eq__Table th:nth-child(3),.ServerBrowser-module__kqm3eq__Table td:nth-child(3){text-align:right}.ServerBrowser-module__kqm3eq__Table td{white-space:nowrap;text-overflow:ellipsis;border-bottom:1px solid #ffffff0a;max-width:340px;padding:3px 12px;font-weight:500;overflow:hidden}.ServerBrowser-module__kqm3eq__Table tbody tr{cursor:pointer}.ServerBrowser-module__kqm3eq__Table tbody tr:hover{background:#41838b1f}.ServerBrowser-module__kqm3eq__Selected{color:#1e2828;background:#5dffe1e6!important}.ServerBrowser-module__kqm3eq__PasswordIcon{color:#ffc83c99;margin-right:4px;font-size:11px}.ServerBrowser-module__kqm3eq__Empty{text-align:center;color:#c9dcd84d;font-style:italic;padding:32px 12px!important}.ServerBrowser-module__kqm3eq__Footer{background:#021415b3;border-top:1px solid #00bedc40;flex-shrink:0;align-items:center;gap:16px;padding:10px 12px;display:flex}.ServerBrowser-module__kqm3eq__JoinButton{}.ServerBrowser-module__kqm3eq__CloseButton{}.ServerBrowser-module__kqm3eq__Hint{color:#c9dcd84d;margin-left:auto;font-size:12px}@media (max-width:719px){.ServerBrowser-module__kqm3eq__Dialog{border-radius:0;width:100%;max-width:100dvw;height:100%;max-height:100dvh}.ServerBrowser-module__kqm3eq__Hint{display:none}.ServerBrowser-module__kqm3eq__Table td{max-width:200px}} +.page-module__E0kJGG__CanvasContainer{z-index:0;position:absolute;inset:0}.page-module__E0kJGG__LoadingIndicator{pointer-events:none;z-index:1;opacity:.8;flex-direction:column;align-items:center;gap:16px;display:flex;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.page-module__E0kJGG__LoadingIndicator[data-complete=true]{animation:.3s ease-out forwards page-module__E0kJGG__loadingComplete}.page-module__E0kJGG__Spinner{border:4px solid #fff3;border-top-color:#fff;border-radius:50%;width:48px;height:48px;animation:1s linear infinite page-module__E0kJGG__spin}.page-module__E0kJGG__Progress{background:#fff3;border-radius:2px;width:200px;height:4px;overflow:hidden}.page-module__E0kJGG__ProgressBar{background:#fff;border-radius:2px;height:100%;transition:width .1s ease-out}.page-module__E0kJGG__ProgressText{color:#ffffffb3;font-variant-numeric:tabular-nums;font-size:14px}@keyframes page-module__E0kJGG__spin{to{transform:rotate(360deg)}}@keyframes page-module__E0kJGG__loadingComplete{0%{opacity:1}to{opacity:0}} +.MapInfoDialog-module__m0lXla__Dialog{color:#bccec3;-webkit-user-select:text;user-select:text;-webkit-touch-callout:default;background:#142526cc;border:1px solid #41838b99;border-radius:4px;outline:none;grid-template-rows:1fr auto;grid-template-columns:100%;width:800px;max-width:calc(100dvw - 40px);height:600px;max-height:calc(100dvh - 40px);font-size:14px;line-height:1.5;display:grid;position:relative;overflow:hidden;box-shadow:0 0 50px #0006,inset 0 0 60px #01070d99}.MapInfoDialog-module__m0lXla__Overlay{z-index:10;background:#000000b3;justify-content:center;align-items:center;padding:20px;display:flex;position:fixed;inset:0}.MapInfoDialog-module__m0lXla__Body{grid-template-rows:100%;grid-template-columns:1fr auto;min-height:0;display:grid;overflow:hidden}.MapInfoDialog-module__m0lXla__Left{padding:24px 28px;overflow-y:auto}.MapInfoDialog-module__m0lXla__PreviewImage{border-left:1px solid #00bedc40;height:100%;display:block}.MapInfoDialog-module__m0lXla__PreviewImageFloating{float:right;clear:right;width:auto;max-width:30%;max-height:260px;margin:0 0 16px 20px;display:block}.MapInfoDialog-module__m0lXla__Title{color:#7dffff;text-shadow:0 1px 6px #0006;margin:0;font-size:26px;font-weight:500}.MapInfoDialog-module__m0lXla__MapMeta{flex-wrap:wrap;gap:8px 16px;margin-bottom:4px;font-size:15px;font-weight:400;display:flex}.MapInfoDialog-module__m0lXla__MapPlanet{color:#dbcaa8b3}.MapInfoDialog-module__m0lXla__MapQuote{border-left:2px solid #00bedc59;margin:16px 0;padding:0 0 0 14px;font-style:italic}.MapInfoDialog-module__m0lXla__MapQuote p{white-space:pre-line;margin:0 0 4px}.MapInfoDialog-module__m0lXla__MapQuote cite{color:#ffffff73;font-size:12px;font-style:normal;display:block}.MapInfoDialog-module__m0lXla__MapBlurb{margin:0 0 16px;font-size:13px}.MapInfoDialog-module__m0lXla__Section{margin-top:20px}.MapInfoDialog-module__m0lXla__SectionTitle{color:#7dffff;letter-spacing:.04em;text-transform:uppercase;text-shadow:0 0 16px #00d2f040;margin:0 0 8px;font-size:16px;font-weight:500}.MapInfoDialog-module__m0lXla__MusicTrack{color:#cad0ac80;align-items:center;gap:6px;margin-top:16px;font-size:14px;font-style:italic;display:flex}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true]{color:#f7fdd8b3}.MapInfoDialog-module__m0lXla__MusicButton{cursor:pointer;color:#557663;opacity:.5;background:0 0;border:0;border-radius:20px;flex-shrink:0;place-content:center;width:32px;height:32px;padding:0;font-size:20px;font-style:normal;line-height:1;display:grid}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true] .MapInfoDialog-module__m0lXla__MusicButton{color:#6dffaa;opacity:1}.MapInfoDialog-module__m0lXla__MusicTrack[data-playing=true] .MapInfoDialog-module__m0lXla__MusicButton:hover{opacity:.7}.MapInfoDialog-module__m0lXla__Footer{background:#021415b3;border-top:1px solid #00bedc40;flex-shrink:0;align-items:center;gap:16px;padding:10px 12px;display:flex}.MapInfoDialog-module__m0lXla__CloseButton{}.MapInfoDialog-module__m0lXla__Hint{color:#c9dcd84d;margin-left:auto;font-size:12px}.MapInfoDialog-module__m0lXla__MusicTrackName{text-transform:capitalize}@media (max-width:719px){.MapInfoDialog-module__m0lXla__Body{display:block;overflow:auto}.MapInfoDialog-module__m0lXla__Hint{display:none}.MapInfoDialog-module__m0lXla__Left{width:100%;height:auto;margin:0;padding:16px 20px;overflow:auto}.MapInfoDialog-module__m0lXla__PreviewImage{width:auto;height:auto;margin:16px auto}.MapInfoDialog-module__m0lXla__CloseButton{width:220px;height:36px;margin:0 auto}} diff --git a/docs/_next/static/chunks/c0475cead0a67c33.js b/docs/_next/static/chunks/c0475cead0a67c33.js deleted file mode 100644 index acc05d30..00000000 --- a/docs/_next/static/chunks/c0475cead0a67c33.js +++ /dev/null @@ -1,8 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75056,e=>{"use strict";var t=e.i(40859),r=e.i(71645),n=e.i(8560),i=e.i(90072);e.s(["ACESFilmicToneMapping",()=>i.ACESFilmicToneMapping,"AddEquation",()=>i.AddEquation,"AddOperation",()=>i.AddOperation,"AdditiveAnimationBlendMode",()=>i.AdditiveAnimationBlendMode,"AdditiveBlending",()=>i.AdditiveBlending,"AgXToneMapping",()=>i.AgXToneMapping,"AlphaFormat",()=>i.AlphaFormat,"AlwaysCompare",()=>i.AlwaysCompare,"AlwaysDepth",()=>i.AlwaysDepth,"AlwaysStencilFunc",()=>i.AlwaysStencilFunc,"AmbientLight",()=>i.AmbientLight,"AnimationAction",()=>i.AnimationAction,"AnimationClip",()=>i.AnimationClip,"AnimationLoader",()=>i.AnimationLoader,"AnimationMixer",()=>i.AnimationMixer,"AnimationObjectGroup",()=>i.AnimationObjectGroup,"AnimationUtils",()=>i.AnimationUtils,"ArcCurve",()=>i.ArcCurve,"ArrayCamera",()=>i.ArrayCamera,"ArrowHelper",()=>i.ArrowHelper,"AttachedBindMode",()=>i.AttachedBindMode,"Audio",()=>i.Audio,"AudioAnalyser",()=>i.AudioAnalyser,"AudioContext",()=>i.AudioContext,"AudioListener",()=>i.AudioListener,"AudioLoader",()=>i.AudioLoader,"AxesHelper",()=>i.AxesHelper,"BackSide",()=>i.BackSide,"BasicDepthPacking",()=>i.BasicDepthPacking,"BasicShadowMap",()=>i.BasicShadowMap,"BatchedMesh",()=>i.BatchedMesh,"Bone",()=>i.Bone,"BooleanKeyframeTrack",()=>i.BooleanKeyframeTrack,"Box2",()=>i.Box2,"Box3",()=>i.Box3,"Box3Helper",()=>i.Box3Helper,"BoxGeometry",()=>i.BoxGeometry,"BoxHelper",()=>i.BoxHelper,"BufferAttribute",()=>i.BufferAttribute,"BufferGeometry",()=>i.BufferGeometry,"BufferGeometryLoader",()=>i.BufferGeometryLoader,"ByteType",()=>i.ByteType,"Cache",()=>i.Cache,"Camera",()=>i.Camera,"CameraHelper",()=>i.CameraHelper,"CanvasTexture",()=>i.CanvasTexture,"CapsuleGeometry",()=>i.CapsuleGeometry,"CatmullRomCurve3",()=>i.CatmullRomCurve3,"CineonToneMapping",()=>i.CineonToneMapping,"CircleGeometry",()=>i.CircleGeometry,"ClampToEdgeWrapping",()=>i.ClampToEdgeWrapping,"Clock",()=>i.Clock,"Color",()=>i.Color,"ColorKeyframeTrack",()=>i.ColorKeyframeTrack,"ColorManagement",()=>i.ColorManagement,"CompressedArrayTexture",()=>i.CompressedArrayTexture,"CompressedCubeTexture",()=>i.CompressedCubeTexture,"CompressedTexture",()=>i.CompressedTexture,"CompressedTextureLoader",()=>i.CompressedTextureLoader,"ConeGeometry",()=>i.ConeGeometry,"ConstantAlphaFactor",()=>i.ConstantAlphaFactor,"ConstantColorFactor",()=>i.ConstantColorFactor,"Controls",()=>i.Controls,"CubeCamera",()=>i.CubeCamera,"CubeDepthTexture",()=>i.CubeDepthTexture,"CubeReflectionMapping",()=>i.CubeReflectionMapping,"CubeRefractionMapping",()=>i.CubeRefractionMapping,"CubeTexture",()=>i.CubeTexture,"CubeTextureLoader",()=>i.CubeTextureLoader,"CubeUVReflectionMapping",()=>i.CubeUVReflectionMapping,"CubicBezierCurve",()=>i.CubicBezierCurve,"CubicBezierCurve3",()=>i.CubicBezierCurve3,"CubicInterpolant",()=>i.CubicInterpolant,"CullFaceBack",()=>i.CullFaceBack,"CullFaceFront",()=>i.CullFaceFront,"CullFaceFrontBack",()=>i.CullFaceFrontBack,"CullFaceNone",()=>i.CullFaceNone,"Curve",()=>i.Curve,"CurvePath",()=>i.CurvePath,"CustomBlending",()=>i.CustomBlending,"CustomToneMapping",()=>i.CustomToneMapping,"CylinderGeometry",()=>i.CylinderGeometry,"Cylindrical",()=>i.Cylindrical,"Data3DTexture",()=>i.Data3DTexture,"DataArrayTexture",()=>i.DataArrayTexture,"DataTexture",()=>i.DataTexture,"DataTextureLoader",()=>i.DataTextureLoader,"DataUtils",()=>i.DataUtils,"DecrementStencilOp",()=>i.DecrementStencilOp,"DecrementWrapStencilOp",()=>i.DecrementWrapStencilOp,"DefaultLoadingManager",()=>i.DefaultLoadingManager,"DepthFormat",()=>i.DepthFormat,"DepthStencilFormat",()=>i.DepthStencilFormat,"DepthTexture",()=>i.DepthTexture,"DetachedBindMode",()=>i.DetachedBindMode,"DirectionalLight",()=>i.DirectionalLight,"DirectionalLightHelper",()=>i.DirectionalLightHelper,"DiscreteInterpolant",()=>i.DiscreteInterpolant,"DodecahedronGeometry",()=>i.DodecahedronGeometry,"DoubleSide",()=>i.DoubleSide,"DstAlphaFactor",()=>i.DstAlphaFactor,"DstColorFactor",()=>i.DstColorFactor,"DynamicCopyUsage",()=>i.DynamicCopyUsage,"DynamicDrawUsage",()=>i.DynamicDrawUsage,"DynamicReadUsage",()=>i.DynamicReadUsage,"EdgesGeometry",()=>i.EdgesGeometry,"EllipseCurve",()=>i.EllipseCurve,"EqualCompare",()=>i.EqualCompare,"EqualDepth",()=>i.EqualDepth,"EqualStencilFunc",()=>i.EqualStencilFunc,"EquirectangularReflectionMapping",()=>i.EquirectangularReflectionMapping,"EquirectangularRefractionMapping",()=>i.EquirectangularRefractionMapping,"Euler",()=>i.Euler,"EventDispatcher",()=>i.EventDispatcher,"ExternalTexture",()=>i.ExternalTexture,"ExtrudeGeometry",()=>i.ExtrudeGeometry,"FileLoader",()=>i.FileLoader,"Float16BufferAttribute",()=>i.Float16BufferAttribute,"Float32BufferAttribute",()=>i.Float32BufferAttribute,"FloatType",()=>i.FloatType,"Fog",()=>i.Fog,"FogExp2",()=>i.FogExp2,"FramebufferTexture",()=>i.FramebufferTexture,"FrontSide",()=>i.FrontSide,"Frustum",()=>i.Frustum,"FrustumArray",()=>i.FrustumArray,"GLBufferAttribute",()=>i.GLBufferAttribute,"GLSL1",()=>i.GLSL1,"GLSL3",()=>i.GLSL3,"GreaterCompare",()=>i.GreaterCompare,"GreaterDepth",()=>i.GreaterDepth,"GreaterEqualCompare",()=>i.GreaterEqualCompare,"GreaterEqualDepth",()=>i.GreaterEqualDepth,"GreaterEqualStencilFunc",()=>i.GreaterEqualStencilFunc,"GreaterStencilFunc",()=>i.GreaterStencilFunc,"GridHelper",()=>i.GridHelper,"Group",()=>i.Group,"HalfFloatType",()=>i.HalfFloatType,"HemisphereLight",()=>i.HemisphereLight,"HemisphereLightHelper",()=>i.HemisphereLightHelper,"IcosahedronGeometry",()=>i.IcosahedronGeometry,"ImageBitmapLoader",()=>i.ImageBitmapLoader,"ImageLoader",()=>i.ImageLoader,"ImageUtils",()=>i.ImageUtils,"IncrementStencilOp",()=>i.IncrementStencilOp,"IncrementWrapStencilOp",()=>i.IncrementWrapStencilOp,"InstancedBufferAttribute",()=>i.InstancedBufferAttribute,"InstancedBufferGeometry",()=>i.InstancedBufferGeometry,"InstancedInterleavedBuffer",()=>i.InstancedInterleavedBuffer,"InstancedMesh",()=>i.InstancedMesh,"Int16BufferAttribute",()=>i.Int16BufferAttribute,"Int32BufferAttribute",()=>i.Int32BufferAttribute,"Int8BufferAttribute",()=>i.Int8BufferAttribute,"IntType",()=>i.IntType,"InterleavedBuffer",()=>i.InterleavedBuffer,"InterleavedBufferAttribute",()=>i.InterleavedBufferAttribute,"Interpolant",()=>i.Interpolant,"InterpolateDiscrete",()=>i.InterpolateDiscrete,"InterpolateLinear",()=>i.InterpolateLinear,"InterpolateSmooth",()=>i.InterpolateSmooth,"InterpolationSamplingMode",()=>i.InterpolationSamplingMode,"InterpolationSamplingType",()=>i.InterpolationSamplingType,"InvertStencilOp",()=>i.InvertStencilOp,"KeepStencilOp",()=>i.KeepStencilOp,"KeyframeTrack",()=>i.KeyframeTrack,"LOD",()=>i.LOD,"LatheGeometry",()=>i.LatheGeometry,"Layers",()=>i.Layers,"LessCompare",()=>i.LessCompare,"LessDepth",()=>i.LessDepth,"LessEqualCompare",()=>i.LessEqualCompare,"LessEqualDepth",()=>i.LessEqualDepth,"LessEqualStencilFunc",()=>i.LessEqualStencilFunc,"LessStencilFunc",()=>i.LessStencilFunc,"Light",()=>i.Light,"LightProbe",()=>i.LightProbe,"Line",()=>i.Line,"Line3",()=>i.Line3,"LineBasicMaterial",()=>i.LineBasicMaterial,"LineCurve",()=>i.LineCurve,"LineCurve3",()=>i.LineCurve3,"LineDashedMaterial",()=>i.LineDashedMaterial,"LineLoop",()=>i.LineLoop,"LineSegments",()=>i.LineSegments,"LinearFilter",()=>i.LinearFilter,"LinearInterpolant",()=>i.LinearInterpolant,"LinearMipMapLinearFilter",()=>i.LinearMipMapLinearFilter,"LinearMipMapNearestFilter",()=>i.LinearMipMapNearestFilter,"LinearMipmapLinearFilter",()=>i.LinearMipmapLinearFilter,"LinearMipmapNearestFilter",()=>i.LinearMipmapNearestFilter,"LinearSRGBColorSpace",()=>i.LinearSRGBColorSpace,"LinearToneMapping",()=>i.LinearToneMapping,"LinearTransfer",()=>i.LinearTransfer,"Loader",()=>i.Loader,"LoaderUtils",()=>i.LoaderUtils,"LoadingManager",()=>i.LoadingManager,"LoopOnce",()=>i.LoopOnce,"LoopPingPong",()=>i.LoopPingPong,"LoopRepeat",()=>i.LoopRepeat,"MOUSE",()=>i.MOUSE,"Material",()=>i.Material,"MaterialLoader",()=>i.MaterialLoader,"MathUtils",()=>i.MathUtils,"Matrix2",()=>i.Matrix2,"Matrix3",()=>i.Matrix3,"Matrix4",()=>i.Matrix4,"MaxEquation",()=>i.MaxEquation,"Mesh",()=>i.Mesh,"MeshBasicMaterial",()=>i.MeshBasicMaterial,"MeshDepthMaterial",()=>i.MeshDepthMaterial,"MeshDistanceMaterial",()=>i.MeshDistanceMaterial,"MeshLambertMaterial",()=>i.MeshLambertMaterial,"MeshMatcapMaterial",()=>i.MeshMatcapMaterial,"MeshNormalMaterial",()=>i.MeshNormalMaterial,"MeshPhongMaterial",()=>i.MeshPhongMaterial,"MeshPhysicalMaterial",()=>i.MeshPhysicalMaterial,"MeshStandardMaterial",()=>i.MeshStandardMaterial,"MeshToonMaterial",()=>i.MeshToonMaterial,"MinEquation",()=>i.MinEquation,"MirroredRepeatWrapping",()=>i.MirroredRepeatWrapping,"MixOperation",()=>i.MixOperation,"MultiplyBlending",()=>i.MultiplyBlending,"MultiplyOperation",()=>i.MultiplyOperation,"NearestFilter",()=>i.NearestFilter,"NearestMipMapLinearFilter",()=>i.NearestMipMapLinearFilter,"NearestMipMapNearestFilter",()=>i.NearestMipMapNearestFilter,"NearestMipmapLinearFilter",()=>i.NearestMipmapLinearFilter,"NearestMipmapNearestFilter",()=>i.NearestMipmapNearestFilter,"NeutralToneMapping",()=>i.NeutralToneMapping,"NeverCompare",()=>i.NeverCompare,"NeverDepth",()=>i.NeverDepth,"NeverStencilFunc",()=>i.NeverStencilFunc,"NoBlending",()=>i.NoBlending,"NoColorSpace",()=>i.NoColorSpace,"NoNormalPacking",()=>i.NoNormalPacking,"NoToneMapping",()=>i.NoToneMapping,"NormalAnimationBlendMode",()=>i.NormalAnimationBlendMode,"NormalBlending",()=>i.NormalBlending,"NormalGAPacking",()=>i.NormalGAPacking,"NormalRGPacking",()=>i.NormalRGPacking,"NotEqualCompare",()=>i.NotEqualCompare,"NotEqualDepth",()=>i.NotEqualDepth,"NotEqualStencilFunc",()=>i.NotEqualStencilFunc,"NumberKeyframeTrack",()=>i.NumberKeyframeTrack,"Object3D",()=>i.Object3D,"ObjectLoader",()=>i.ObjectLoader,"ObjectSpaceNormalMap",()=>i.ObjectSpaceNormalMap,"OctahedronGeometry",()=>i.OctahedronGeometry,"OneFactor",()=>i.OneFactor,"OneMinusConstantAlphaFactor",()=>i.OneMinusConstantAlphaFactor,"OneMinusConstantColorFactor",()=>i.OneMinusConstantColorFactor,"OneMinusDstAlphaFactor",()=>i.OneMinusDstAlphaFactor,"OneMinusDstColorFactor",()=>i.OneMinusDstColorFactor,"OneMinusSrcAlphaFactor",()=>i.OneMinusSrcAlphaFactor,"OneMinusSrcColorFactor",()=>i.OneMinusSrcColorFactor,"OrthographicCamera",()=>i.OrthographicCamera,"PCFShadowMap",()=>i.PCFShadowMap,"PCFSoftShadowMap",()=>i.PCFSoftShadowMap,"PMREMGenerator",()=>n.PMREMGenerator,"Path",()=>i.Path,"PerspectiveCamera",()=>i.PerspectiveCamera,"Plane",()=>i.Plane,"PlaneGeometry",()=>i.PlaneGeometry,"PlaneHelper",()=>i.PlaneHelper,"PointLight",()=>i.PointLight,"PointLightHelper",()=>i.PointLightHelper,"Points",()=>i.Points,"PointsMaterial",()=>i.PointsMaterial,"PolarGridHelper",()=>i.PolarGridHelper,"PolyhedronGeometry",()=>i.PolyhedronGeometry,"PositionalAudio",()=>i.PositionalAudio,"PropertyBinding",()=>i.PropertyBinding,"PropertyMixer",()=>i.PropertyMixer,"QuadraticBezierCurve",()=>i.QuadraticBezierCurve,"QuadraticBezierCurve3",()=>i.QuadraticBezierCurve3,"Quaternion",()=>i.Quaternion,"QuaternionKeyframeTrack",()=>i.QuaternionKeyframeTrack,"QuaternionLinearInterpolant",()=>i.QuaternionLinearInterpolant,"R11_EAC_Format",()=>i.R11_EAC_Format,"RED_GREEN_RGTC2_Format",()=>i.RED_GREEN_RGTC2_Format,"RED_RGTC1_Format",()=>i.RED_RGTC1_Format,"REVISION",()=>i.REVISION,"RG11_EAC_Format",()=>i.RG11_EAC_Format,"RGBADepthPacking",()=>i.RGBADepthPacking,"RGBAFormat",()=>i.RGBAFormat,"RGBAIntegerFormat",()=>i.RGBAIntegerFormat,"RGBA_ASTC_10x10_Format",()=>i.RGBA_ASTC_10x10_Format,"RGBA_ASTC_10x5_Format",()=>i.RGBA_ASTC_10x5_Format,"RGBA_ASTC_10x6_Format",()=>i.RGBA_ASTC_10x6_Format,"RGBA_ASTC_10x8_Format",()=>i.RGBA_ASTC_10x8_Format,"RGBA_ASTC_12x10_Format",()=>i.RGBA_ASTC_12x10_Format,"RGBA_ASTC_12x12_Format",()=>i.RGBA_ASTC_12x12_Format,"RGBA_ASTC_4x4_Format",()=>i.RGBA_ASTC_4x4_Format,"RGBA_ASTC_5x4_Format",()=>i.RGBA_ASTC_5x4_Format,"RGBA_ASTC_5x5_Format",()=>i.RGBA_ASTC_5x5_Format,"RGBA_ASTC_6x5_Format",()=>i.RGBA_ASTC_6x5_Format,"RGBA_ASTC_6x6_Format",()=>i.RGBA_ASTC_6x6_Format,"RGBA_ASTC_8x5_Format",()=>i.RGBA_ASTC_8x5_Format,"RGBA_ASTC_8x6_Format",()=>i.RGBA_ASTC_8x6_Format,"RGBA_ASTC_8x8_Format",()=>i.RGBA_ASTC_8x8_Format,"RGBA_BPTC_Format",()=>i.RGBA_BPTC_Format,"RGBA_ETC2_EAC_Format",()=>i.RGBA_ETC2_EAC_Format,"RGBA_PVRTC_2BPPV1_Format",()=>i.RGBA_PVRTC_2BPPV1_Format,"RGBA_PVRTC_4BPPV1_Format",()=>i.RGBA_PVRTC_4BPPV1_Format,"RGBA_S3TC_DXT1_Format",()=>i.RGBA_S3TC_DXT1_Format,"RGBA_S3TC_DXT3_Format",()=>i.RGBA_S3TC_DXT3_Format,"RGBA_S3TC_DXT5_Format",()=>i.RGBA_S3TC_DXT5_Format,"RGBDepthPacking",()=>i.RGBDepthPacking,"RGBFormat",()=>i.RGBFormat,"RGBIntegerFormat",()=>i.RGBIntegerFormat,"RGB_BPTC_SIGNED_Format",()=>i.RGB_BPTC_SIGNED_Format,"RGB_BPTC_UNSIGNED_Format",()=>i.RGB_BPTC_UNSIGNED_Format,"RGB_ETC1_Format",()=>i.RGB_ETC1_Format,"RGB_ETC2_Format",()=>i.RGB_ETC2_Format,"RGB_PVRTC_2BPPV1_Format",()=>i.RGB_PVRTC_2BPPV1_Format,"RGB_PVRTC_4BPPV1_Format",()=>i.RGB_PVRTC_4BPPV1_Format,"RGB_S3TC_DXT1_Format",()=>i.RGB_S3TC_DXT1_Format,"RGDepthPacking",()=>i.RGDepthPacking,"RGFormat",()=>i.RGFormat,"RGIntegerFormat",()=>i.RGIntegerFormat,"RawShaderMaterial",()=>i.RawShaderMaterial,"Ray",()=>i.Ray,"Raycaster",()=>i.Raycaster,"RectAreaLight",()=>i.RectAreaLight,"RedFormat",()=>i.RedFormat,"RedIntegerFormat",()=>i.RedIntegerFormat,"ReinhardToneMapping",()=>i.ReinhardToneMapping,"RenderTarget",()=>i.RenderTarget,"RenderTarget3D",()=>i.RenderTarget3D,"RepeatWrapping",()=>i.RepeatWrapping,"ReplaceStencilOp",()=>i.ReplaceStencilOp,"ReverseSubtractEquation",()=>i.ReverseSubtractEquation,"RingGeometry",()=>i.RingGeometry,"SIGNED_R11_EAC_Format",()=>i.SIGNED_R11_EAC_Format,"SIGNED_RED_GREEN_RGTC2_Format",()=>i.SIGNED_RED_GREEN_RGTC2_Format,"SIGNED_RED_RGTC1_Format",()=>i.SIGNED_RED_RGTC1_Format,"SIGNED_RG11_EAC_Format",()=>i.SIGNED_RG11_EAC_Format,"SRGBColorSpace",()=>i.SRGBColorSpace,"SRGBTransfer",()=>i.SRGBTransfer,"Scene",()=>i.Scene,"ShaderChunk",()=>n.ShaderChunk,"ShaderLib",()=>n.ShaderLib,"ShaderMaterial",()=>i.ShaderMaterial,"ShadowMaterial",()=>i.ShadowMaterial,"Shape",()=>i.Shape,"ShapeGeometry",()=>i.ShapeGeometry,"ShapePath",()=>i.ShapePath,"ShapeUtils",()=>i.ShapeUtils,"ShortType",()=>i.ShortType,"Skeleton",()=>i.Skeleton,"SkeletonHelper",()=>i.SkeletonHelper,"SkinnedMesh",()=>i.SkinnedMesh,"Source",()=>i.Source,"Sphere",()=>i.Sphere,"SphereGeometry",()=>i.SphereGeometry,"Spherical",()=>i.Spherical,"SphericalHarmonics3",()=>i.SphericalHarmonics3,"SplineCurve",()=>i.SplineCurve,"SpotLight",()=>i.SpotLight,"SpotLightHelper",()=>i.SpotLightHelper,"Sprite",()=>i.Sprite,"SpriteMaterial",()=>i.SpriteMaterial,"SrcAlphaFactor",()=>i.SrcAlphaFactor,"SrcAlphaSaturateFactor",()=>i.SrcAlphaSaturateFactor,"SrcColorFactor",()=>i.SrcColorFactor,"StaticCopyUsage",()=>i.StaticCopyUsage,"StaticDrawUsage",()=>i.StaticDrawUsage,"StaticReadUsage",()=>i.StaticReadUsage,"StereoCamera",()=>i.StereoCamera,"StreamCopyUsage",()=>i.StreamCopyUsage,"StreamDrawUsage",()=>i.StreamDrawUsage,"StreamReadUsage",()=>i.StreamReadUsage,"StringKeyframeTrack",()=>i.StringKeyframeTrack,"SubtractEquation",()=>i.SubtractEquation,"SubtractiveBlending",()=>i.SubtractiveBlending,"TOUCH",()=>i.TOUCH,"TangentSpaceNormalMap",()=>i.TangentSpaceNormalMap,"TetrahedronGeometry",()=>i.TetrahedronGeometry,"Texture",()=>i.Texture,"TextureLoader",()=>i.TextureLoader,"TextureUtils",()=>i.TextureUtils,"Timer",()=>i.Timer,"TimestampQuery",()=>i.TimestampQuery,"TorusGeometry",()=>i.TorusGeometry,"TorusKnotGeometry",()=>i.TorusKnotGeometry,"Triangle",()=>i.Triangle,"TriangleFanDrawMode",()=>i.TriangleFanDrawMode,"TriangleStripDrawMode",()=>i.TriangleStripDrawMode,"TrianglesDrawMode",()=>i.TrianglesDrawMode,"TubeGeometry",()=>i.TubeGeometry,"UVMapping",()=>i.UVMapping,"Uint16BufferAttribute",()=>i.Uint16BufferAttribute,"Uint32BufferAttribute",()=>i.Uint32BufferAttribute,"Uint8BufferAttribute",()=>i.Uint8BufferAttribute,"Uint8ClampedBufferAttribute",()=>i.Uint8ClampedBufferAttribute,"Uniform",()=>i.Uniform,"UniformsGroup",()=>i.UniformsGroup,"UniformsLib",()=>n.UniformsLib,"UniformsUtils",()=>i.UniformsUtils,"UnsignedByteType",()=>i.UnsignedByteType,"UnsignedInt101111Type",()=>i.UnsignedInt101111Type,"UnsignedInt248Type",()=>i.UnsignedInt248Type,"UnsignedInt5999Type",()=>i.UnsignedInt5999Type,"UnsignedIntType",()=>i.UnsignedIntType,"UnsignedShort4444Type",()=>i.UnsignedShort4444Type,"UnsignedShort5551Type",()=>i.UnsignedShort5551Type,"UnsignedShortType",()=>i.UnsignedShortType,"VSMShadowMap",()=>i.VSMShadowMap,"Vector2",()=>i.Vector2,"Vector3",()=>i.Vector3,"Vector4",()=>i.Vector4,"VectorKeyframeTrack",()=>i.VectorKeyframeTrack,"VideoFrameTexture",()=>i.VideoFrameTexture,"VideoTexture",()=>i.VideoTexture,"WebGL3DRenderTarget",()=>i.WebGL3DRenderTarget,"WebGLArrayRenderTarget",()=>i.WebGLArrayRenderTarget,"WebGLCoordinateSystem",()=>i.WebGLCoordinateSystem,"WebGLCubeRenderTarget",()=>i.WebGLCubeRenderTarget,"WebGLRenderTarget",()=>i.WebGLRenderTarget,"WebGLRenderer",()=>n.WebGLRenderer,"WebGLUtils",()=>n.WebGLUtils,"WebGPUCoordinateSystem",()=>i.WebGPUCoordinateSystem,"WebXRController",()=>i.WebXRController,"WireframeGeometry",()=>i.WireframeGeometry,"WrapAroundEnding",()=>i.WrapAroundEnding,"ZeroCurvatureEnding",()=>i.ZeroCurvatureEnding,"ZeroFactor",()=>i.ZeroFactor,"ZeroSlopeEnding",()=>i.ZeroSlopeEnding,"ZeroStencilOp",()=>i.ZeroStencilOp,"createCanvasElement",()=>i.createCanvasElement,"error",()=>i.error,"getConsoleFunction",()=>i.getConsoleFunction,"log",()=>i.log,"setConsoleFunction",()=>i.setConsoleFunction,"warn",()=>i.warn,"warnOnce",()=>i.warnOnce],32009);var o=e.i(32009);function a(e,t){let r;return(...n)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...n),t)}}let s=["x","y","top","bottom","left","right","width","height"];var l=e.i(46791),u=e.i(43476);function c({ref:e,children:n,fallback:i,resize:l,style:c,gl:d,events:f=t.f,eventSource:A,eventPrefix:h,shadows:m,linear:p,flat:B,legacy:C,orthographic:g,frameloop:v,dpr:y,performance:b,raycaster:E,camera:M,scene:F,onPointerMissed:S,onCreated:R,...I}){r.useMemo(()=>(0,t.e)(o),[]);let T=(0,t.u)(),[x,G]=function({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){var o,l,u;let c=n||("u"(p.current=!0,()=>void(p.current=!1)));let[B,C,g]=(0,r.useMemo)(()=>{let e=()=>{let e,t;if(!A.current.element)return;let{left:r,top:n,width:o,height:a,bottom:l,right:u,x:c,y:d}=A.current.element.getBoundingClientRect(),h={left:r,top:n,width:o,height:a,bottom:l,right:u,x:c,y:d};A.current.element instanceof HTMLElement&&i&&(h.height=A.current.element.offsetHeight,h.width=A.current.element.offsetWidth),Object.freeze(h),p.current&&(e=A.current.lastBounds,t=h,!s.every(r=>e[r]===t[r]))&&f(A.current.lastBounds=h)};return[e,m?a(e,m):e,h?a(e,h):e]},[f,i,h,m]);function v(){A.current.scrollContainers&&(A.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",g,!0)),A.current.scrollContainers=null),A.current.resizeObserver&&(A.current.resizeObserver.disconnect(),A.current.resizeObserver=null),A.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",A.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",A.current.orientationHandler))}function y(){A.current.element&&(A.current.resizeObserver=new c(g),A.current.resizeObserver.observe(A.current.element),t&&A.current.scrollContainers&&A.current.scrollContainers.forEach(e=>e.addEventListener("scroll",g,{capture:!0,passive:!0})),A.current.orientationHandler=()=>{g()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",A.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",A.current.orientationHandler))}return o=g,l=!!t,(0,r.useEffect)(()=>{if(l)return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)},[o,l]),u=C,(0,r.useEffect)(()=>(window.addEventListener("resize",u),()=>void window.removeEventListener("resize",u)),[u]),(0,r.useEffect)(()=>{v(),y()},[t,g,C]),(0,r.useEffect)(()=>v,[]),[e=>{e&&e!==A.current.element&&(v(),A.current.element=e,A.current.scrollContainers=function e(t){let r=[];if(!t||t===document.body)return r;let{overflow:n,overflowX:i,overflowY:o}=window.getComputedStyle(t);return[n,i,o].some(e=>"auto"===e||"scroll"===e)&&r.push(t),[...r,...e(t.parentElement)]}(e),y())},d,B]}({scroll:!0,debounce:{scroll:50,resize:0},...l}),D=r.useRef(null),w=r.useRef(null);r.useImperativeHandle(e,()=>D.current);let L=(0,t.a)(S),[_,O]=r.useState(!1),[H,P]=r.useState(!1);if(_)throw _;if(H)throw H;let J=r.useRef(null);(0,t.b)(()=>{let e=D.current;G.width>0&&G.height>0&&e&&(J.current||(J.current=(0,t.c)(e)),async function(){await J.current.configure({gl:d,scene:F,events:f,shadows:m,linear:p,flat:B,legacy:C,orthographic:g,frameloop:v,dpr:y,performance:b,raycaster:E,camera:M,size:G,onPointerMissed:(...e)=>null==L.current?void 0:L.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(A?(0,t.i)(A)?A.current:A:w.current),h&&e.setEvents({compute:(e,t)=>{let r=e[h+"X"],n=e[h+"Y"];t.pointer.set(r/t.size.width*2-1,-(2*(n/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==R||R(e)}}),J.current.render((0,u.jsx)(T,{children:(0,u.jsx)(t.E,{set:P,children:(0,u.jsx)(r.Suspense,{fallback:(0,u.jsx)(t.B,{set:O}),children:null!=n?n:null})})}))}())}),r.useEffect(()=>{let e=D.current;if(e)return()=>(0,t.d)(e)},[]);let U=A?"none":"auto";return(0,u.jsx)("div",{ref:w,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:U,...c},...I,children:(0,u.jsx)("div",{ref:x,style:{width:"100%",height:"100%"},children:(0,u.jsx)("canvas",{ref:D,style:{display:"block"},children:i})})})}function d(e){return(0,u.jsx)(l.FiberProvider,{children:(0,u.jsx)(c,{...e})})}e.i(89499),e.s(["Canvas",()=>d],75056)},32424,e=>{"use strict";var t=e.i(12979);function r(){return async e=>{let r;try{r=(0,t.getUrlForPath)(e)}catch(t){return console.warn(`Script not in manifest: ${e} (${t})`),null}try{let t=await fetch(r);if(!t.ok)return console.error(`Script fetch failed: ${e} (${t.status})`),null;return await t.text()}catch(t){return console.error(`Script fetch error: ${e}`),console.error(t),null}}}e.s(["createScriptLoader",()=>r])},91907,8597,78140,82816,25947,51475,71505,71832,e=>{"use strict";let t;e.s(["ShapeRenderer",()=>tc,"applyShapeShaderModifications",()=>tn,"createMaterialFromFlags",()=>ti,"useStaticShape",()=>to],91907);var r=e.i(43476),n=e.i(932),i=e.i(71645),o=i;let a=(0,o.createContext)(null),s={didCatch:!1,error:null};class l extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=s}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(s))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(s))}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:i,error:s}=this.state,l=e;if(i){let e={error:s,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)l=t(e);else if(r)l=(0,o.createElement)(r,e);else if(void 0!==n)l=n;else throw s}return(0,o.createElement)(a.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},l)}}e.s(["ErrorBoundary",()=>l],8597);var u=e.i(31067),c=e.i(90072);function d(e,t){if(t===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==c.TriangleFanDrawMode&&t!==c.TriangleStripDrawMode)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let r=e.getIndex();if(null===r){let t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;etypeof TextDecoder)return new TextDecoder().decode(e);let t="";for(let r=0,n=e.length;r=2.0 are supported."));return}let s=new ei(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}s.setExtensions(o),s.setPlugins(a),s.parse(r,n)}parseAsync(e,t){let r=this;return new Promise(function(n,i){r.parse(e,t,n,i)})}}function B(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class g{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r=0))return null;else throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return t.loadTextureImage(e,i.source,o)}}class w{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],a=n.images[o.source],s=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then(function(i){if(i)return r.loadTextureImage(e,o.source,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class L{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],a=n.images[o.source],s=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then(function(i){if(i)return r.loadTextureImage(e,o.source,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class _{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(!r.extensions||!r.extensions[this.name])return null;{let e=r.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported)if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return n.then(function(t){let r=e.byteOffset||0,n=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,r,n);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*a);return i.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t})})}}}class O{constructor(e){this.name=C.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;for(let e of t.meshes[r.mesh].primitives)if(e.mode!==Q.TRIANGLES&&e.mode!==Q.TRIANGLE_STRIP&&e.mode!==Q.TRIANGLE_FAN&&void 0!==e.mode)return null;let n=r.extensions[this.name].attributes,i=[],o={};for(let e in n)i.push(this.parser.getDependency("accessor",n[e]).then(t=>(o[e]=t,o[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{let t=e.pop(),r=t.isGroup?t.children:[t],n=e[0].count,i=[];for(let e of r){let t=new c.Matrix4,r=new c.Vector3,a=new c.Quaternion,s=new c.Vector3(1,1,1),l=new c.InstancedMesh(e.geometry,e.material,n);for(let e=0;e=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Z={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},z={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete};function $(e,t,r){for(let n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function ee(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function et(e){let t="",r=Object.keys(e).sort();for(let n=0,i=r.length;ntypeof navigator&&void 0!==navigator.userAgent&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=(n=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"u"{let r=this.associations.get(e);for(let[n,o]of(null!=r&&this.associations.set(t,r),e.children.entries()))i(o,t.children[n])};return i(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r=2&&o.setY(t,f[e*s+1]),s>=3&&o.setZ(t,f[e*s+2]),s>=4&&o.setW(t,f[e*s+3]),s>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,r=this.options,n=t.textures[e].source,i=t.images[n],o=this.textureLoader;if(i.uri){let e=r.manager.getHandler(i.uri);null!==e&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,r){let n=this,i=this.json,o=i.textures[e],a=i.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];let l=this.loadImageSource(t,r).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let r=(i.samplers||{})[o.sampler]||{};return t.magFilter=V[r.magFilter]||c.LinearFilter,t.minFilter=V[r.minFilter]||c.LinearMipmapLinearFilter,t.wrapS=q[r.wrapS]||c.RepeatWrapping,t.wrapT=q[r.wrapT]||c.RepeatWrapping,n.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=l,l}loadImageSource(e,t){let r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=r.images[e],o=self.URL||self.webkitURL,a=i.uri||"",s=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then(function(e){s=!0;let t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(e){return new Promise(function(r,i){let o=r;!0===t.isImageBitmapLoader&&(o=function(e){let t=new c.Texture(e);t.needsUpdate=!0,r(t)}),t.load(c.LoaderUtils.resolveURL(e,n.path),o,void 0,i)})}).then(function(e){var t;return!0===s&&o.revokeObjectURL(a),ee(e,i),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){let i=this;return this.getDependency("texture",r.index).then(function(o){if(!o)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((o=o.clone()).channel=r.texCoord),i.extensions[C.KHR_TEXTURE_TRANSFORM]){let e=void 0!==r.extensions?r.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==n&&("number"==typeof n&&(n=3001===n?h:m),"colorSpace"in o?o.colorSpace=n:o.encoding=n===h?3001:3e3),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,r=e.material,n=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new c.PointsMaterial,c.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){let e="LineBasicMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new c.LineBasicMaterial,c.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(n||i||o){let e="ClonedMaterial:"+r.uuid+":";n&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){let t,r=this,n=this.json,i=this.extensions,o=n.materials[e],a={},s=o.extensions||{},l=[];if(s[C.KHR_MATERIALS_UNLIT]){let e=i[C.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(a,o,r))}else{let n=o.pbrMetallicRoughness||{};if(a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],m),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(r.assignTexture(a,"map",n.baseColorTexture,h)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(r.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(r.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=c.DoubleSide);let u=o.alphaMode||"OPAQUE";if("BLEND"===u?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===u&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==c.MeshBasicMaterial&&(l.push(r.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new c.Vector2(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==c.MeshBasicMaterial&&(l.push(r.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==c.MeshBasicMaterial){let e=o.emissiveFactor;a.emissive=new c.Color().setRGB(e[0],e[1],e[2],m)}return void 0!==o.emissiveTexture&&t!==c.MeshBasicMaterial&&l.push(r.assignTexture(a,"emissiveMap",o.emissiveTexture,h)),Promise.all(l).then(function(){let n=new t(a);return o.name&&(n.name=o.name),ee(n,o),r.associations.set(n,{materials:e}),o.extensions&&$(i,n,o),n})}createUniqueName(e){let t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,n=this.primitiveCache,i=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,n=t.weights.length;r1?new c.Group:1===t.length?t[0]:new c.Object3D)!==t[0])for(let e=0,r=t.length;e{let t=new Map;for(let[e,r]of n.associations)(e instanceof c.Material||e instanceof c.Texture)&&t.set(e,r);return e.traverse(e=>{let r=n.associations.get(e);null!=r&&t.set(e,r)}),t})(i),i})}_createAnimationTracks(e,t,r,n,i){let o,a=[],s=e.name?e.name:e.uuid,l=[];switch(Z[i.path]===Z.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(s),Z[i.path]){case Z.weights:o=c.NumberKeyframeTrack;break;case Z.rotation:o=c.QuaternionKeyframeTrack;break;case Z.position:case Z.scale:o=c.VectorKeyframeTrack;break;default:o=1===r.itemSize?c.NumberKeyframeTrack:c.VectorKeyframeTrack}let u=void 0!==n.interpolation?z[n.interpolation]:c.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let e=0,r=l.length;e{let r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(n)},r,n)}decodeDracoFile(e,t,r,n){let i={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){let r;for(let e in t.attributeTypes){let r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}let n=JSON.stringify(t);if(es.has(e)){let t=es.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(i,o).then(n=>(r=n,new Promise((n,o)=>{r._callbacks[i]={resolve:n,reject:o},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return a.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),es.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new ea.BufferGeometry;e.index&&t.setIndex(new ea.BufferAttribute(e.index.array,1));for(let r=0;r{r.load(e,t,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{let r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let n=eu.toString(),i=["/* draco decoder */",r,"\n/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengtht._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{let t=e.draco,r=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{let e=function(e,t,r,n){var i,o,a;let s,l,u,c,d,f,A=n.attributeIDs,h=n.attributeTypes,m=t.GetEncodedGeometryType(r);if(m===e.TRIANGULAR_MESH)d=new e.Mesh,f=t.DecodeBufferToMesh(r,d);else if(m===e.POINT_CLOUD)d=new e.PointCloud,f=t.DecodeBufferToPointCloud(r,d);else throw Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||0===d.ptr)throw Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let r in A){let i,o,a=self[h[r]];if(n.useUniqueIDs)o=A[r],i=t.GetAttributeByUniqueId(d,o);else{if(-1===(o=t.GetAttributeId(d,e[A[r]])))continue;i=t.GetAttribute(d,o)}p.attributes.push(function(e,t,r,n,i,o){let a=o.num_components(),s=r.num_points()*a,l=s*i.BYTES_PER_ELEMENT,u=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(r,o,u,l,c);let d=new i(e.HEAPF32.buffer,c,s).slice();return e._free(c),{name:n,array:d,itemSize:a}}(e,t,d,r,a,i))}return m===e.TRIANGULAR_MESH&&(i=e,o=t,a=d,s=3*a.num_faces(),l=4*s,u=i._malloc(l),o.GetTrianglesUInt32Array(a,l,u),c=new Uint32Array(i.HEAPF32.buffer,u,s).slice(),i._free(u),p.index={array:c,itemSize:1}),e.destroy(d),p}(t,r,a,o),i=e.attributes.map(e=>e.array.buffer);e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(a),t.destroy(r)}})}}}var ec=e.i(99143);let ed=function(e){let t=new Map,r=new Map,n=e.clone();return function e(t,r,n){n(t,r);for(let i=0;i{let A={keys:l,deep:n,inject:s,castShadow:o,receiveShadow:a};if(Array.isArray(t=i.useMemo(()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse(t=>{t.isSkinnedMesh&&(e=!0)}),e)return ed(t)}return t},[t,e])))return i.createElement("group",(0,u.default)({},d,{ref:f}),t.map(e=>i.createElement(ef,(0,u.default)({key:e.uuid,object:e},A))),r);let{children:h,...m}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:n,castShadow:o,receiveShadow:a}){let s={};for(let r of t)s[r]=e[r];return r&&(s.geometry&&"materialsOnly"!==r&&(s.geometry=s.geometry.clone()),s.material&&"geometriesOnly"!==r&&(s.material=s.material.clone())),n&&(s="function"==typeof n?{...s,children:n(e)}:i.isValidElement(n)?{...s,children:n}:{...s,...n}),e instanceof c.Mesh&&(o&&(s.castShadow=!0),a&&(s.receiveShadow=!0)),s}(t,A),p=t.type[0].toLowerCase()+t.type.slice(1);return i.createElement(p,(0,u.default)({},m,d,{ref:f}),t.children.map(e=>"Bone"===e.type?i.createElement("primitive",(0,u.default)({key:e.uuid,object:e},A)):i.createElement(ef,(0,u.default)({key:e.uuid,object:e},A,{isChild:!0}))),r,h)}),eA=null,eh="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function em(e=!0,r=!0,n){return i=>{n&&n(i),e&&(eA||(eA=new el),eA.setDecoderPath("string"==typeof e?e:eh),i.setDRACOLoader(eA)),r&&i.setMeshoptDecoder((()=>{let e;if(t)return t;let r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let i="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(r)&&(i="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");let o=WebAssembly.instantiate(function(e){let t=new Uint8Array(e.length);for(let r=0;r96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let i=0;i{(e=t.instance).exports.__wasm_call_ctors()});function a(t,r,n,i,o,a){let s=e.exports.sbrk,l=n+3&-4,u=s(l*i),c=s(o.length),d=new Uint8Array(e.exports.memory.buffer);d.set(o,c);let f=t(u,n,i,c,o.length);if(0===f&&a&&a(u,l,i),r.set(d.subarray(u,u+n*i)),s(u-s(0)),0!==f)throw Error(`Malformed buffer data: ${f}`)}let s={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},l={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return t={ready:o,supported:!0,decodeVertexBuffer(t,r,n,i,o){a(e.exports.meshopt_decodeVertexBuffer,t,r,n,i,e.exports[s[o]])},decodeIndexBuffer(t,r,n,i){a(e.exports.meshopt_decodeIndexBuffer,t,r,n,i)},decodeIndexSequence(t,r,n,i){a(e.exports.meshopt_decodeIndexSequence,t,r,n,i)},decodeGltfBuffer(t,r,n,i,o,u){a(e.exports[l[o]],t,r,n,i,e.exports[s[u]])}}})())}}let ep=(e,t,r,n)=>(0,ec.useLoader)(p,e,em(t,r,n));ep.preload=(e,t,r,n)=>ec.useLoader.preload(p,e,em(t,r,n)),ep.clear=e=>ec.useLoader.clear(p,e),ep.setDecoderPath=e=>{eh=e},e.s(["useGLTF",()=>ep],78140);var eB=e.i(47071),eC=e.i(71753),eg=e.i(12979);function ev(e){let t=new Map,r=new Map,n=e.clone();return function e(t,r,n){n(t,r);for(let i=0;iev],82816);var ey=e.i(75567),eb=e.i(79123);let eE=/borg|xorg|porg|dorg|plant|tree|bush|fern|vine|grass|leaf|flower|frond|palm|foliage/i;function eM(e){return eE.test(e)}let eF=(0,i.createContext)(null);function eS(){let e=(0,i.useContext)(eF);if(!e)throw Error("useShapeInfo must be used within ShapeInfoProvider");return e}function eR(e){let t,i,o,a=(0,n.c)(10),{children:s,object:l,shapeName:u,type:c}=e;a[0]!==u?(t=eM(u),a[0]=u,a[1]=t):t=a[1];let d=t;a[2]!==d||a[3]!==l||a[4]!==u||a[5]!==c?(i={object:l,shapeName:u,type:c,isOrganic:d},a[2]=d,a[3]=l,a[4]=u,a[5]=c,a[6]=i):i=a[6];let f=i;return a[7]!==s||a[8]!==f?(o=(0,r.jsx)(eF.Provider,{value:f,children:s}),a[7]=s,a[8]=f,a[9]=o):o=a[9],o}e.s(["ShapeInfoProvider",()=>eR,"isOrganicShape",()=>eM,"useShapeInfo",()=>eS],25947),e.i(13876);var eI=e.i(58647),eT=e.i(89887);e.i(47167);var ex=e.i(69230),eG=e.i(69637),eD=e.i(54440);let ew=(0,i.createContext)(null);function eL({children:e}){let t=(0,i.useRef)(void 0),n=(0,i.useRef)(0),o=(0,i.useRef)(0);(0,eC.useFrame)((e,r)=>{for(n.current+=r;n.current>=.03125;)if(n.current-=.03125,o.current++,t.current)for(let e of t.current)e(o.current)});let a=(0,i.useCallback)(e=>(t.current??=new Set,t.current.add(e),()=>{t.current.delete(e)}),[]),s=(0,i.useCallback)(()=>o.current,[]),l=(0,i.useMemo)(()=>({subscribe:a,getTick:s}),[a,s]);return(0,r.jsx)(ew.Provider,{value:l,children:e})}function e_(e){let t=(0,i.useContext)(ew);if(!t)throw Error("useTick must be used within a TickProvider");let r=(0,i.useRef)(e);r.current=e,(0,i.useEffect)(()=>t.subscribe(e=>r.current(e)),[t])}e.s(["TICK_RATE",0,32,"TickProvider",()=>eL,"useTick",()=>e_],51475);let eO=1/30,eH=new Map;function eP(e){let t=e[0].image,r=t.width,n=t.height,i=e.length,o=Math.ceil(Math.sqrt(i)),a=Math.ceil(i/o),s=document.createElement("canvas");s.width=r*o,s.height=n*a;let l=s.getContext("2d");e.forEach((e,t)=>{let i=Math.floor(t/o);l.drawImage(e.image,t%o*r,i*n)});let u=new c.CanvasTexture(s);return u.colorSpace=c.SRGBColorSpace,u.generateMipmaps=!1,u.minFilter=c.NearestFilter,u.magFilter=c.NearestFilter,u.wrapS=c.ClampToEdgeWrapping,u.wrapT=c.ClampToEdgeWrapping,u.repeat.set(1/o,1/a),{texture:u,columns:o,rows:a,frameCount:i,frameOffsetSeconds:[],totalDurationSeconds:0,lastFrame:-1}}function eJ(e,t){let r=0;e.frameOffsetSeconds=t.map(e=>r+=e.frameCount*eO),e.totalDurationSeconds=r}function eU(e,t){if(t===e.lastFrame)return;e.lastFrame=t;let r=t%e.columns,n=e.rows-1-Math.floor(t/e.columns);e.texture.offset.set(r/e.columns,n/e.rows)}function eN(e,t){let r=e.totalDurationSeconds;if(r<=0)return 0;let n=t;n>r&&(n-=r*Math.floor(n/r));for(let t=0;t(0,eg.iflTextureToUrl)(t.name,e)),i=eP(await Promise.all(n.map(ey.loadTextureAsync)));return eJ(i,r),eH.set(e,i),i}function eK(e){var t;let r,i,o,a,s=(0,n.c)(14),{animationEnabled:l}=(0,eb.useSettings)();s[0]!==e?(r={queryKey:["ifl",e],queryFn:()=>(0,eg.loadImageFrameList)(e)},s[0]=e,s[1]=r):r=s[1];let{data:u}=(t=r,(0,eG.useBaseQuery)({...t,enabled:!0,suspense:!0,throwOnError:eD.defaultThrowOnError,placeholderData:void 0},ex.QueryObserver,void 0));if(s[2]!==u||s[3]!==e){let t;s[5]!==e?(t=t=>(0,eg.iflTextureToUrl)(t.name,e),s[5]=e,s[6]=t):t=s[6],i=u.map(t),s[2]=u,s[3]=e,s[4]=i}else i=s[4];let c=i,d=(0,eB.useTexture)(c);s[7]!==u||s[8]!==e||s[9]!==d?((o=eH.get(e))||(o=eP(d),eH.set(e,o)),eJ(o,u),s[7]=u,s[8]=e,s[9]=d,s[10]=o):o=s[10];let f=o;return s[11]!==l||s[12]!==f?(a=e=>{let t=l?eN(f,e/32):0;eU(f,t)},s[11]=l,s[12]=f,s[13]=a):a=s[13],e_(a),f.texture}e.s(["getFrameIndexForTime",()=>eN,"loadIflAtlas",()=>ek,"updateAtlasFrame",()=>eU,"useIflTexture",()=>eK],71505);var ej=e.i(47021),eQ=e.i(48066);e.s(["ANIM_TRANSITION_TIME",()=>eV,"DEFAULT_EYE_HEIGHT",()=>eX,"STREAM_TICK_SEC",()=>eq,"_r90",()=>e$,"_r90inv",()=>e0,"buildStreamDemoEntity",()=>te,"entityTypeColor",()=>tt,"getKeyframeAtTime",()=>e3,"getPosedNodeTransform",()=>e6,"processShapeScene",()=>e5,"replaceWithShapeMaterial",()=>e4,"setQuaternionFromDir",()=>e2,"setupEffectTexture",()=>e9,"torqueHorizontalFovToThreeVerticalFov",()=>e1,"torqueVecToThree",()=>e8],71832);let eX=2.1,eV=.25,eq=.032,eW=new c.Vector3,eY=new c.Vector3,eZ=new c.Matrix4,ez=new c.Vector3(0,1,0),e$=new c.Quaternion().setFromAxisAngle(new c.Vector3(0,1,0),Math.PI/2),e0=e$.clone().invert();function e1(e,t){return 180*(2*Math.atan(Math.tan(Math.max(.01,Math.min(179.99,e))*Math.PI/180/2)/(Number.isFinite(t)&&t>1e-6?t:4/3)))/Math.PI}function e9(e){e.wrapS=c.ClampToEdgeWrapping,e.wrapT=c.ClampToEdgeWrapping,e.minFilter=c.LinearFilter,e.magFilter=c.LinearFilter,e.colorSpace=c.NoColorSpace,e.flipY=!1,e.needsUpdate=!0}function e8(e,t){return t.set(e[1],e[2],e[0])}function e2(e,t){eW.crossVectors(e,ez),1e-8>eW.lengthSq()&&eW.set(-1,0,0),eW.normalize(),eY.crossVectors(eW,e).normalize(),eZ.set(eW.x,e.x,eY.x,0,eW.y,e.y,eY.y,0,eW.z,e.z,eY.z,0,0,0,0,1),t.setFromRotationMatrix(eZ)}function e3(e,t){if(0===e.length)return null;if(t<=e[0].time)return e[0];if(t>=e[e.length-1].time)return e[e.length-1];let r=0,n=e.length-1;for(;n-r>1;){let i=r+n>>1;e[i].time<=t?r=i:n=i}return e[r]}function e6(e,t,r,n){let i=e.clone(!0),o=t.find(e=>"Root"===e.name);if(o){let e=new c.AnimationMixer(i);if(e.clipAction(o).play(),n)for(let r of n){let n=t.find(e=>e.name.toLowerCase()===r.toLowerCase());if(n){let t=e.clipAction(n);t.time=n.duration/2,t.setEffectiveTimeScale(0),t.play()}}e.setTime(0)}i.updateMatrixWorld(!0);let a=null,s=null;return(i.traverse(e=>{a||e.name!==r||(a=new c.Vector3,s=new c.Quaternion,e.getWorldPosition(a),e.getWorldQuaternion(s))}),a&&s)?{position:a,quaternion:s}:null}function e4(e,t){let r=e.userData?.resource_path,n=new Set(e.userData?.flag_names??[]);if(!r){let t=new c.MeshLambertMaterial({color:e.color,side:2,reflectivity:0});return tn(t),{material:t}}if(n.has("IflMaterial")){let i=ti(e,null,n,!1,t),o=Array.isArray(i)?i[1]:i;return{material:o,initialize:(e,t)=>e7(o,r,e,t)}}let i=(0,eg.textureToUrl)(r),o=(0,ey.loadTexture)(i);(0,ey.setupTexture)(o);let a=ti(e,o,n,!1,t);return{material:Array.isArray(a)?a[1]:a}}async function e7(e,t,r,n){let i=`textures/${t}.ifl`,o=await ek(i);e.map=o.texture,e.needsUpdate=!0;let a=!1,s=r.onBeforeRender;return r.onBeforeRender=function(...e){s?.apply(this,e),a||eU(o,eN(o,n()))},()=>{a=!0,r.onBeforeRender=s??(()=>{})}}function e5(e){var t;let r,n=[],i=null;e.traverse(e=>{!i&&e.skeleton&&(i=e.skeleton)});let o=i?(t=i,r=new Set,t.bones.forEach((e,t)=>{e.name.match(/^Hulk/i)&&r.add(t)}),r):new Set;return e.traverse(e=>{if(!e.isMesh)return;if(e.name.match(/^Hulk/i)||e.material?.name==="Unassigned"){e.visible=!1;return}let t=!!e.userData?.vis_sequence;if((e.userData?.vis??1)<.01&&(e.visible=!1),e.geometry){let t=function(e,t){if(0===t.size||!e.attributes.skinIndex)return e;let r=e.attributes.skinIndex,n=e.attributes.skinWeight,i=e.index,o=Array(r.count).fill(!1);for(let e=0;e.01&&t.has(a)){o[e]=!0;break}}if(i){let t=[],r=i.array;for(let e=0;e1){let t=0,r=0,n=0;for(let o of e)t+=i[3*o],r+=i[3*o+1],n+=i[3*o+2];let o=Math.sqrt(t*t+r*r+n*n);for(let a of(o>0&&(t/=o,r/=o,n/=o),e))i[3*a]=t,i[3*a+1]=r,i[3*a+2]=n}r.needsUpdate=!0}(t=t.clone()),e.geometry=t}let r=t?1:e.userData?.vis??1;if(Array.isArray(e.material))e.material=e.material.map(t=>{let i=e4(t,r);return i.initialize&&n.push({mesh:e,initialize:i.initialize}),i.material});else if(e.material){let t=e4(e.material,r);t.initialize&&n.push({mesh:e,initialize:t.initialize}),e.material=t.material}}),n}function te(e,t,r,n,i,o,a,s,l,u,c,d,f){return{id:e,type:t,dataBlock:r,visual:n,direction:i,weaponShape:o,playerName:a,className:s,ghostIndex:l,dataBlockId:u,shapeHint:c,explosionDataBlockId:d,faceViewer:f,keyframes:[{time:0,position:[0,0,0],rotation:[0,0,0,1]}]}}function tt(e){switch(e.toLowerCase()){case"player":return"#00ff88";case"vehicle":return"#ff8800";case"projectile":return"#ff0044";case"deployable":return"#ffcc00";default:return"#8888ff"}}function tr(){return"stopped"!==eI.engineStore.getState().playback.status?(0,eI.demoEffectNow)()/1e3:performance.now()/1e3}function tn(e){e.onBeforeCompile=t=>{(0,ej.injectCustomFog)(t,eQ.globalFogUniforms),e instanceof c.MeshLambertMaterial&&(t.uniforms.shapeDirectionalFactor={value:1},t.uniforms.shapeAmbientFactor={value:1.5},t.fragmentShader=t.fragmentShader.replace("#include ",`#include -uniform float shapeDirectionalFactor; -uniform float shapeAmbientFactor; -`),t.fragmentShader=t.fragmentShader.replace("#include ",`#include - // Apply shape-specific lighting multipliers - reflectedLight.directDiffuse *= shapeDirectionalFactor; - reflectedLight.indirectDiffuse *= shapeAmbientFactor; -`))}}function ti(e,t,r,n,i=1,o=!1){let a=r.has("Translucent"),s=r.has("Additive"),l=r.has("SelfIlluminating"),u=i<1||o;if(l||s){let e=s||a||u,r=new c.MeshBasicMaterial({map:t,side:2,transparent:e,depthWrite:!e,alphaTest:0,fog:!0,...u&&{opacity:i},...s&&{blending:c.AdditiveBlending}});return tn(r),r}if(n||a){let e={map:t,transparent:u,alphaTest:.5*!u,...u&&{opacity:i,depthWrite:!1},reflectivity:0},r=new c.MeshLambertMaterial({...e,side:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),n=new c.MeshLambertMaterial({...e,side:0});return tn(r),tn(n),[r,n]}let d=new c.MeshLambertMaterial({map:t,side:2,reflectivity:0,...u&&{transparent:!0,opacity:i,depthWrite:!1}});return tn(d),d}function to(e){let t,r=(0,n.c)(2);return r[0]!==e?(t=(0,eg.shapeToUrl)(e),r[0]=e,r[1]=t):t=r[1],ep(t)}function ta(e){let t,i,o,a,s=(0,n.c)(9),{color:l,label:u}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,r.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(i=(0,r.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=i):i=s[2],s[3]!==l||s[4]!==u?(o=u?(0,r.jsx)(eT.FloatingLabel,{color:l,children:u}):null,s[3]=l,s[4]=u,s[5]=o):o=s[5],s[6]!==i||s[7]!==o?(a=(0,r.jsxs)("mesh",{children:[t,i,o]}),s[6]=i,s[7]=o,s[8]=a):a=s[8],a}function ts(e){let t,i=(0,n.c)(4),{color:o,label:a}=e,{debugMode:s}=(0,eb.useDebug)();return i[0]!==o||i[1]!==s||i[2]!==a?(t=s?(0,r.jsx)(ta,{color:o,label:a}):null,i[0]=o,i[1]=s,i[2]=a,i[3]=t):t=i[3],t}let tl=new Set(["octahedron.dts"]);function tu(e){let t,i,o,a,s=(0,n.c)(6),{label:l}=e,{debugMode:u}=(0,eb.useDebug)();return u?(s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,r.jsx)("icosahedronGeometry",{args:[1,1]}),i=(0,r.jsx)("meshBasicMaterial",{color:"cyan",wireframe:!0}),s[0]=t,s[1]=i):(t=s[0],i=s[1]),s[2]!==l?(o=l?(0,r.jsx)(eT.FloatingLabel,{color:"cyan",children:l}):null,s[2]=l,s[3]=o):o=s[3],s[4]!==o?(a=(0,r.jsxs)("mesh",{children:[t,i,o]}),s[4]=o,s[5]=a):a=s[5],a):null}function tc(e){let t,o,a,s,u,c=(0,n.c)(17),{loadingColor:d,demoThreads:f,children:A}=e,h=void 0===d?"yellow":d,{object:m,shapeName:p}=eS();if(!p){let e,t=`${m._id}: `;return c[0]!==t?(e=(0,r.jsx)(ts,{color:"orange",label:t}),c[0]=t,c[1]=e):e=c[1],e}if(tl.has(p.toLowerCase())){let e,t=`${m._id}: ${p}`;return c[2]!==t?(e=(0,r.jsx)(tu,{label:t}),c[2]=t,c[3]=e):e=c[3],e}let B=`${m._id}: ${p}`;return c[4]!==B?(t=(0,r.jsx)(ts,{color:"red",label:B}),c[4]=B,c[5]=t):t=c[5],c[6]!==h?(o=(0,r.jsx)(ta,{color:h}),c[6]=h,c[7]=o):o=c[7],c[8]!==f?(a=(0,r.jsx)(tf,{demoThreads:f}),c[8]=f,c[9]=a):a=c[9],c[10]!==A||c[11]!==o||c[12]!==a?(s=(0,r.jsxs)(i.Suspense,{fallback:o,children:[a,A]}),c[10]=A,c[11]=o,c[12]=a,c[13]=s):s=c[13],c[14]!==t||c[15]!==s?(u=(0,r.jsx)(l,{fallback:t,children:s}),c[14]=t,c[15]=s,c[16]=u):u=c[16],u}let td=(0,i.memo)(function({gltf:e,demoThreads:t}){let{object:n,shapeName:o}=eS(),{debugMode:a}=(0,eb.useDebug)(),{animationEnabled:s}=(0,eb.useSettings)(),l=(0,eI.useEngineSelector)(e=>e.runtime.runtime),{clonedScene:u,mixer:d,clipsByName:f,visNodesBySequence:A,iflMeshes:h}=(0,i.useMemo)(()=>{let t=ev(e.scene),r=[];for(let{mesh:e,hasVisSequence:n}of(t.traverse(e=>{if(!e.isMesh||!e.material)return;let t=Array.isArray(e.material)?e.material[0]:e.material;if(!t?.userData)return;let n=new Set(t.userData.flag_names??[]),i=t.userData.resource_path;if(n.has("IflMaterial")&&i){let t=e.userData,n=t?.ifl_sequence?String(t.ifl_sequence).toLowerCase():void 0,o=t?.ifl_duration?Number(t.ifl_duration):void 0,a=t?.ifl_sequence?!!t.ifl_cyclic:void 0,s=t?.ifl_tool_begin!=null?Number(t.ifl_tool_begin):void 0;r.push({mesh:e,iflPath:`textures/${i}.ifl`,hasVisSequence:!!t?.vis_sequence,iflSequence:n,iflDuration:o,iflCyclic:a,iflToolBegin:s})}}),e5(t),r))n||(e.visible=!0);let n=new Map;t.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let r=t.vis_keyframes,i=t.vis_duration,o=(t.vis_sequence??"").toLowerCase();if(!o||!Array.isArray(r)||r.length<=1||!i||i<=0)return;let a=n.get(o);a||(a=[],n.set(o,a)),a.push({mesh:e,keyframes:r,duration:i,cyclic:!!t.vis_cyclic})});let i=new Map;for(let t of e.animations)i.set(t.name.toLowerCase(),t);let o=i.size>0?new c.AnimationMixer(t):null;return{clonedScene:t,mixer:o,clipsByName:i,visNodesBySequence:n,iflMeshes:r}},[e]),m=(0,i.useRef)(new Map),p=(0,i.useRef)(new Map),B=(0,i.useRef)([]),C=(0,i.useRef)(0),g=(0,i.useRef)(s);g.current=s;let v=(0,i.useRef)(null),y=(0,i.useRef)(t);y.current=t;let b=(0,i.useRef)(null),E=(0,i.useRef)(null),M=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{for(let e of(B.current=[],p.current.clear(),h))ek(e.iflPath).then(t=>{let r=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;r&&(r.map=t.texture,r.needsUpdate=!0),B.current.push({atlas:t,sequenceName:e.iflSequence,sequenceDuration:e.iflDuration,cyclic:e.iflCyclic,toolBegin:e.iflToolBegin}),p.current.set(e.mesh,t)}).catch(()=>{})},[h]),(0,i.useEffect)(()=>{let e=m.current;function t(e){if(e.mesh.visible=!0,e.mesh.material?.isMeshStandardMaterial){let t=e4(e.mesh.material,e.mesh.userData?.vis??0);e.mesh.material=t.material}e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.transparent=!0,e.mesh.material.depthWrite=!1);let t=p.current.get(e.mesh);t&&e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.map=t.texture,e.mesh.material.needsUpdate=!0)}function r(r,n){let o=n.toLowerCase();i(r);let a=f.get(o),s=A.get(o),l={sequence:o,startTime:tr()};if(a&&d){let e=d.clipAction(a);"deploy"===o?(e.setLoop(c.LoopOnce,1),e.clampWhenFinished=!0):e.setLoop(c.LoopRepeat,1/0),e.reset().play(),l.action=e,!g.current&&"deploy"===o&&(e.time=a.duration,d.update(0),v.current&&queueMicrotask(()=>v.current?.(r)))}if(s){for(let e of s)t(e);l.visNodes=s}e.set(r,l)}function i(t){let r=e.get(t);if(r){if(r.action&&r.action.stop(),r.visNodes)for(let e of r.visNodes)e.mesh.visible=!1,e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.opacity=e.keyframes[0]);e.delete(t)}}if(b.current=r,E.current=i,null!=y.current)return()=>{for(let t of(b.current=null,E.current=null,[...e.keys()]))i(t)};let o=f.has("deploy"),a=!!(l&&o&&n.datablock);function s(e){if(!l)return;let t=n.datablock;if(!t)return;let r=l.getObjectByName(String(t));r&&l.$.call(r,"onEndSequence",n,e)}function u(){for(let r of["ambient","power"]){let n=A.get(r);if(n){let i=tr();for(let e of n)t(e);let o=+("power"!==r);e.set(o,{sequence:r,visNodes:n,startTime:i})}let i=f.get(r);if(i&&d){let t=d.clipAction(i);t.setLoop(c.LoopRepeat,1/0),t.reset().play();let n=+("power"!==r),o=e.get(n);o?o.action=t:e.set(n,{sequence:r,action:t,startTime:tr()})}}}v.current=a?s:()=>u();let h=[],B=d?t=>{for(let[r,n]of e)if(n.action===t.action){a?s(r):u();break}}:null;return B&&d&&d.addEventListener("finished",B),l&&(h.push(l.$.onMethodCalled("ShapeBase","playThread",(e,t,i)=>{e._id===n._id&&r(Number(t),String(i))})),h.push(l.$.onMethodCalled("ShapeBase","stopThread",(e,t)=>{e._id===n._id&&i(Number(t))})),h.push(l.$.onMethodCalled("ShapeBase","pauseThread",(t,r)=>{if(t._id!==n._id)return;let i=e.get(Number(r));i?.action&&(i.action.paused=!0)}))),a?l.$.call(n,"deploy"):o?r(3,"deploy"):u(),()=>{for(let t of(B&&d&&d.removeEventListener("finished",B),h.forEach(e=>e()),v.current=null,b.current=null,E.current=null,[...e.keys()]))i(t)}},[d,f,A,n,l]);let F=(0,i.useMemo)(()=>{let t=e.scene.userData?.dts_sequence_names;if("string"==typeof t)try{return JSON.parse(t).map(e=>e.toLowerCase())}catch{}return e.animations.map(e=>e.name.toLowerCase())},[e]);return(0,eC.useFrame)((e,t)=>{let r=m.current,n=null!=y.current,i=eI.engineStore.getState().playback,o=n?"playing"===i.status?t*i.rate:0:t,a=y.current,l=M.current;if(a!==l){let e=b.current,t=E.current;if(e&&t){M.current=a;let n=[];if(a)for(let e of a)n[e.index]=e;let i=[];if(l)for(let e of l)i[e.index]=e;let o=Math.max(n.length,i.length);for(let a=0;a0)for(let e of(C.current+=o,u)){if(!s){eU(e.atlas,0);continue}if(e.sequenceName&&e.sequenceDuration){let t=0;for(let[,n]of r)if(n.sequence===e.sequenceName){let r=tr()-n.startTime,i=e.sequenceDuration;t=(e.cyclic?r/i%1:Math.min(r/i,1))*i+(e.toolBegin??0);break}eU(e.atlas,eN(e.atlas,t))}else eU(e.atlas,eN(e.atlas,C.current))}}),(0,r.jsxs)("group",{rotation:[0,Math.PI/2,0],children:[(0,r.jsx)("primitive",{object:u}),a?(0,r.jsxs)(eT.FloatingLabel,{children:[n._id,": ",o]}):null]})});function tf(e){let t,i=(0,n.c)(3),{demoThreads:o}=e,{shapeName:a}=eS(),s=to(a);return i[0]!==o||i[1]!==s?(t=(0,r.jsx)(td,{gltf:s,demoThreads:o}),i[0]=o,i[1]=s,i[2]=t):t=i[2],t}},7368,e=>{"use strict";e.s(["ignoreScripts",0,["scripts/admin.cs","scripts/ai.cs","scripts/aiBotProfiles.cs","scripts/aiBountyGame.cs","scripts/aiChat.cs","scripts/aiCnH.cs","scripts/aiCTF.cs","scripts/aiDeathMatch.cs","scripts/aiDebug.cs","scripts/aiDefaultTasks.cs","scripts/aiDnD.cs","scripts/aiHumanTasks.cs","scripts/aiHunters.cs","scripts/aiInventory.cs","scripts/aiObjectiveBuilder.cs","scripts/aiObjectives.cs","scripts/aiRabbit.cs","scripts/aiSiege.cs","scripts/aiTDM.cs","scripts/aiTeamHunters.cs","scripts/deathMessages.cs","scripts/graphBuild.cs","scripts/navGraph.cs","scripts/serverTasks.cs","scripts/spdialog.cs"]])},17751,85413,e=>{"use strict";var t=e.i(19273),r=e.i(86491),n=e.i(40143),i=e.i(15823),o=class extends i.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,n,i){let o=n.queryKey,a=n.queryHash??(0,t.hashQueryKeyByOptions)(o,n),s=this.get(a);return s||(s=new r.Query({client:e,queryKey:o,queryHash:a,options:e.defaultQueryOptions(n),state:i,defaultOptions:e.getQueryDefaults(o)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchQuery)(r,e))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(r=>(0,t.matchQuery)(e,r)):r}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},a=e.i(88587),s=e.i(36553),l=class extends a.Removable{#t;#r;#n;#i;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#r=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#r.includes(e)||(this.#r.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#r=this.#r.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#r.length||("pending"===this.state.status?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#o({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=(0,s.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#o({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#o({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let n="pending"===this.state.status,i=!this.#i.canStart();try{if(n)t();else{this.#o({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#o({type:"pending",context:t,variables:e,isPaused:i})}let o=await this.#i.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,r),await this.options.onSuccess?.(o,e,this.state.context,r),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(o,null,e,this.state.context,r),this.#o({type:"success",data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#o({type:"error",error:t}),t}finally{this.#n.runNext(this)}}#o(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),n.notifyManager.batch(()=>{this.#r.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}},u=i,c=class extends u.Subscribable{constructor(e={}){super(),this.config=e,this.#a=new Set,this.#s=new Map,this.#l=0}#a;#s;#l;build(e,t,r){let n=new l({client:e,mutationCache:this,mutationId:++this.#l,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#a.add(e);let t=d(e);if("string"==typeof t){let r=this.#s.get(t);r?r.push(e):this.#s.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#a.delete(e)){let t=d(e);if("string"==typeof t){let r=this.#s.get(t);if(r)if(r.length>1){let t=r.indexOf(e);-1!==t&&r.splice(t,1)}else r[0]===e&&this.#s.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=d(e);if("string"!=typeof t)return!0;{let r=this.#s.get(t),n=r?.find(e=>"pending"===e.state.status);return!n||n===e}}runNext(e){let t=d(e);if("string"!=typeof t)return Promise.resolve();{let r=this.#s.get(t)?.find(t=>t!==e&&t.state.isPaused);return r?.continue()??Promise.resolve()}}clear(){n.notifyManager.batch(()=>{this.#a.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#a.clear(),this.#s.clear()})}getAll(){return Array.from(this.#a)}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchMutation)(r,e))}findAll(e={}){return this.getAll().filter(r=>(0,t.matchMutation)(e,r))}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return n.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(t.noop))))}};function d(e){return e.options.scope?.id}var f=e.i(75555),A=e.i(14448);function h(e){return{onFetch:(r,n)=>{let i=r.options,o=r.fetchOptions?.meta?.fetchMore?.direction,a=r.state.data?.pages||[],s=r.state.data?.pageParams||[],l={pages:[],pageParams:[]},u=0,c=async()=>{let n=!1,c=(0,t.ensureQueryFn)(r.options,r.fetchOptions),d=async(e,i,o)=>{let a;if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);let s=(a={client:r.client,queryKey:r.queryKey,pageParam:i,direction:o?"backward":"forward",meta:r.options.meta},(0,t.addConsumeAwareSignal)(a,()=>r.signal,()=>n=!0),a),l=await c(s),{maxPages:u}=r.options,d=o?t.addToStart:t.addToEnd;return{pages:d(e.pages,l,u),pageParams:d(e.pageParams,i,u)}};if(o&&a.length){let e="backward"===o,t={pages:a,pageParams:s},r=(e?function(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}:m)(i,t);l=await d(t,r,e)}else{let t=e??a.length;do{let e=0===u?s[0]??i.initialPageParam:m(i,l);if(u>0&&null==e)break;l=await d(l,e),u++}while(ur.options.persister?.(c,{client:r.client,queryKey:r.queryKey,meta:r.options.meta,signal:r.signal},n):r.fetchFn=c}}}function m(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}var p=class{#u;#n;#c;#d;#f;#A;#h;#m;constructor(e={}){this.#u=e.queryCache||new o,this.#n=e.mutationCache||new c,this.#c=e.defaultOptions||{},this.#d=new Map,this.#f=new Map,this.#A=0}mount(){this.#A++,1===this.#A&&(this.#h=f.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onFocus())}),this.#m=A.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onOnline())}))}unmount(){this.#A--,0===this.#A&&(this.#h?.(),this.#h=void 0,this.#m?.(),this.#m=void 0)}isFetching(e){return this.#u.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#n.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state.data}ensureQueryData(e){let r=this.defaultQueryOptions(e),n=this.#u.build(this,r),i=n.state.data;return void 0===i?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(i))}getQueriesData(e){return this.#u.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,r,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#u.get(i.queryHash),a=o?.state.data,s=(0,t.functionalUpdate)(r,a);if(void 0!==s)return this.#u.build(this,i).setData(s,{...n,manual:!0})}setQueriesData(e,t,r){return n.notifyManager.batch(()=>this.#u.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state}removeQueries(e){let t=this.#u;n.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let r=this.#u;return n.notifyManager.batch(()=>(r.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,r={}){let i={revert:!0,...r};return Promise.all(n.notifyManager.batch(()=>this.#u.findAll(e).map(e=>e.cancel(i)))).then(t.noop).catch(t.noop)}invalidateQueries(e,t={}){return n.notifyManager.batch(()=>(this.#u.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,r={}){let i={...r,cancelRefetch:r.cancelRefetch??!0};return Promise.all(n.notifyManager.batch(()=>this.#u.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let r=e.fetch(void 0,i);return i.throwOnError||(r=r.catch(t.noop)),"paused"===e.state.fetchStatus?Promise.resolve():r}))).then(t.noop)}fetchQuery(e){let r=this.defaultQueryOptions(e);void 0===r.retry&&(r.retry=!1);let n=this.#u.build(this,r);return n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(t.noop).catch(t.noop)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(t.noop).catch(t.noop)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return A.onlineManager.isOnline()?this.#n.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#u}getMutationCache(){return this.#n}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,r){this.#d.set((0,t.hashKey)(e),{queryKey:e,defaultOptions:r})}getQueryDefaults(e){let r=[...this.#d.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,r){this.#f.set((0,t.hashKey)(e),{mutationKey:e,defaultOptions:r})}getMutationDefaults(e){let r=[...this.#f.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let r={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return r.queryHash||(r.queryHash=(0,t.hashQueryKeyByOptions)(r.queryKey,r)),void 0===r.refetchOnReconnect&&(r.refetchOnReconnect="always"!==r.networkMode),void 0===r.throwOnError&&(r.throwOnError=!!r.suspense),!r.networkMode&&r.persister&&(r.networkMode="offlineFirst"),r.queryFn===t.skipToken&&(r.enabled=!1),r}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#u.clear(),this.#n.clear()}};e.s(["QueryClient",()=>p],17751);var B=Object.defineProperty;class C{constructor(){((e,t,r)=>{let n;return(n="symbol"!=typeof t?t+"":t)in e?B(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let r=this._listeners[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let r=t.slice(0);for(let t=0,n=r.length;tC],85413)},38360,(e,t,r)=>{var n={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},i=Object.keys(n).join("|"),o=RegExp(i,"g"),a=RegExp(i,"");function s(e){return n[e]}var l=function(e){return e.replace(o,s)};t.exports=l,t.exports.has=function(e){return!!e.match(a)},t.exports.remove=l},11889,56373,86447,1559,18364,78440,59129,25998,70238,e=>{"use strict";e.i(47167);var t,r="u">typeof window&&!!(null==(t=window.document)?void 0:t.createElement);function n(e){return e?"self"in e?e.document:e.ownerDocument||document:document}function i(e){return e?"self"in e?e.self:n(e).defaultView||window:self}function o(e,t=!1){var r;let{activeElement:i}=n(e);if(!(null==i?void 0:i.nodeName))return null;if(s(i)&&(null==(r=i.contentDocument)?void 0:r.body))return o(i.contentDocument.body,t);if(t){let e=i.getAttribute("aria-activedescendant");if(e){let t=n(i).getElementById(e);if(t)return t}}return i}function a(e,t){return e===t||e.contains(t)}function s(e){return"IFRAME"===e.tagName}function l(e){let t=e.tagName.toLowerCase();return"button"===t||"input"===t&&!!e.type&&-1!==u.indexOf(e.type)}var u=["button","color","file","image","reset","submit"];function c(e){return"function"==typeof e.checkVisibility?e.checkVisibility():e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0}function d(e){try{let t=e instanceof HTMLInputElement&&null!==e.selectionStart,r="TEXTAREA"===e.tagName;return t||r||!1}catch(e){return!1}}function f(e){return e.isContentEditable||d(e)}function A(e){let t=0,r=0;if(d(e))t=e.selectionStart||0,r=e.selectionEnd||0;else if(e.isContentEditable){let i=n(e).getSelection();if((null==i?void 0:i.rangeCount)&&i.anchorNode&&a(e,i.anchorNode)&&i.focusNode&&a(e,i.focusNode)){let n=i.getRangeAt(0),o=n.cloneRange();o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),t=o.toString().length,o.setEnd(n.endContainer,n.endOffset),r=o.toString().length}}return{start:t,end:r}}function h(e,t){let r=null==e?void 0:e.getAttribute("role");return r&&-1!==["dialog","menu","listbox","tree","grid"].indexOf(r)?r:t}function m(e){if(!e)return null;let t=e=>"auto"===e||"scroll"===e;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:r}=getComputedStyle(e);if(t(r))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:r}=getComputedStyle(e);if(t(r))return e}return m(e.parentElement)||document.scrollingElement||document.body}function p(e,...t){/text|search|password|tel|url/i.test(e.type)&&e.setSelectionRange(...t)}function B(e,t){return t&&e.item(t)||null}var C=Symbol("FOCUS_SILENTLY");function g(e,t,r){if(!t||t===r)return!1;let n=e.item(t.id);return!!n&&(!r||n.element!==r)}function v(){}function y(e,t){return"function"==typeof Object.hasOwn?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function b(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}function E(e){return e}function M(e,t){if(!e){if("string"!=typeof t)throw Error("Invariant failed");throw Error(t)}}function F(e,...t){let r="function"==typeof e?e(...t):e;return null!=r&&!r}function S(e){return e.disabled||!0===e["aria-disabled"]||"true"===e["aria-disabled"]}function R(e){let t={};for(let r in e)void 0!==e[r]&&(t[r]=e[r]);return t}function I(...e){for(let t of e)if(void 0!==t)return t}var T=e.i(71645);function x(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function G(){return r&&!!navigator.maxTouchPoints}function D(){return!!r&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}function w(){return r&&D()&&/apple/i.test(navigator.vendor)}function L(e){return!!(e.currentTarget&&!a(e.currentTarget,e.target))}function _(e){return e.target===e.currentTarget}function O(e,t){let r=new FocusEvent("blur",t),n=e.dispatchEvent(r),i={...t,bubbles:!0};return e.dispatchEvent(new FocusEvent("focusout",i)),n}function H(e,t){let r=new MouseEvent("click",t);return e.dispatchEvent(r)}function P(e,t){let r=t||e.currentTarget,n=e.relatedTarget;return!n||!a(r,n)}function J(e,t,r,n){let i=(e=>{if(n){let t=setTimeout(e,n);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,o,!0),r()}),o=()=>{i(),r()};return e.addEventListener(t,o,{once:!0,capture:!0}),i}function U(e,t,r,n=window){let i=[];try{for(let o of(n.document.addEventListener(e,t,r),Array.from(n.frames)))i.push(U(e,t,r,o))}catch(e){}return()=>{try{n.document.removeEventListener(e,t,r)}catch(e){}for(let e of i)e()}}var N={...T},k=N.useId;N.useDeferredValue;var K=N.useInsertionEffect,j=r?T.useLayoutEffect:T.useEffect;function Q(e){let t=(0,T.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return K?K(()=>{t.current=e}):t.current=e,(0,T.useCallback)((...e)=>{var r;return null==(r=t.current)?void 0:r.call(t,...e)},[])}function X(...e){return(0,T.useMemo)(()=>{if(e.some(Boolean))return t=>{for(let r of e)x(r,t)}},e)}function V(e){if(k){let t=k();return e||t}let[t,r]=(0,T.useState)(e);return j(()=>{if(e||t)return;let n=Math.random().toString(36).slice(2,8);r(`id-${n}`)},[e,t]),e||t}function q(e,t){let r=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(r.current)return e();r.current=!0},t),(0,T.useEffect)(()=>()=>{r.current=!1},[])}function W(){return(0,T.useReducer)(()=>[],[])}function Y(e){return Q("function"==typeof e?e:()=>e)}function Z(e,t,r=[]){let n=(0,T.useCallback)(r=>(e.wrapElement&&(r=e.wrapElement(r)),t(r)),[...r,e.wrapElement]);return{...e,wrapElement:n}}function z(e=!1,t){let[r,n]=(0,T.useState)(null);return{portalRef:X(n,t),portalNode:r,domReady:!e||r}}var $=!1,ee=!1,et=0,er=0;function en(e){let t,r;t=e.movementX||e.screenX-et,r=e.movementY||e.screenY-er,et=e.screenX,er=e.screenY,(t||r||0)&&(ee=!0)}function ei(){ee=!1}var eo=e.i(43476);function ea(e){let t=T.forwardRef((t,r)=>e({...t,ref:r}));return t.displayName=e.displayName||e.name,t}function es(e,t){return T.memo(e,t)}function el(e,t){let r,{wrapElement:n,render:i,...o}=t,a=X(t.ref,i&&(0,T.isValidElement)(i)&&("ref"in i.props||"ref"in i)?({...i.props}).ref||i.ref:null);if(T.isValidElement(i)){let e={...i.props,ref:a};r=T.cloneElement(i,function(e,t){let r={...e};for(let n in t){if(!y(t,n))continue;if("className"===n){let n="className";r[n]=e[n]?`${e[n]} ${t[n]}`:t[n];continue}if("style"===n){let n="style";r[n]=e[n]?{...e[n],...t[n]}:t[n];continue}let i=t[n];if("function"==typeof i&&n.startsWith("on")){let t=e[n];if("function"==typeof t){r[n]=(...e)=>{i(...e),t(...e)};continue}}r[n]=i}return r}(o,e))}else r=i?i(o):(0,eo.jsx)(e,{...o});return n?n(r):r}function eu(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function ec(e=[],t=[]){let r=T.createContext(void 0),n=T.createContext(void 0),i=()=>T.useContext(r),o=t=>e.reduceRight((e,r)=>(0,eo.jsx)(r,{...t,children:e}),(0,eo.jsx)(r.Provider,{...t}));return{context:r,scopedContext:n,useContext:i,useScopedContext:(e=!1)=>{let t=T.useContext(n),r=i();return e?t:t||r},useProviderContext:()=>{let e=T.useContext(n),t=i();if(!e||e!==t)return t},ContextProvider:o,ScopedContextProvider:e=>(0,eo.jsx)(o,{...e,children:t.reduceRight((t,r)=>(0,eo.jsx)(r,{...e,children:t}),(0,eo.jsx)(n.Provider,{...e}))})}}var ed=ec(),ef=ed.useContext;ed.useScopedContext,ed.useProviderContext;var eA=ec([ed.ContextProvider],[ed.ScopedContextProvider]),eh=eA.useContext;eA.useScopedContext;var em=eA.useProviderContext,ep=eA.ContextProvider,eB=eA.ScopedContextProvider,eC=(0,T.createContext)(void 0),eg=(0,T.createContext)(void 0),ev=(0,T.createContext)(!0),ey="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function eb(e){return!(!e.matches(ey)||!c(e)||e.closest("[inert]"))}function eE(e){if(!eb(e)||0>Number.parseInt(e.getAttribute("tabindex")||"0",10))return!1;if(!("form"in e)||!e.form||e.checked||"radio"!==e.type)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!("length"in t))return!0;let r=o(e);return!r||r===e||!("form"in r)||r.form!==e.form||r.name!==e.name}function eM(e,t){let r=Array.from(e.querySelectorAll(ey));t&&r.unshift(e);let n=r.filter(eb);return n.forEach((e,t)=>{var r;if(!s(e))return;let i=null==(r=e.contentDocument)?void 0:r.body;i&&n.splice(t,1,...eM(i))}),n}function eF(e,t,r){let n=Array.from(e.querySelectorAll(ey)),i=n.filter(eE);return(t&&eE(e)&&i.unshift(e),i.forEach((e,t)=>{var n;if(!s(e))return;let o=null==(n=e.contentDocument)?void 0:n.body;if(!o)return;let a=eF(o,!1,r);i.splice(t,1,...a)}),!i.length&&r)?n:i}function eS(e,t){var r;let n,i,a,s;return r=document.body,n=o(r),a=(i=eM(r,!1)).indexOf(n),(s=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?s[0]:null)||null}function eR(e,t){var r;let n,i,a,s;return r=document.body,n=o(r),a=(i=eM(r,!1).reverse()).indexOf(n),(s=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?s[0]:null)||null}function eI(e){let t=o(e);if(!t)return!1;if(t===e)return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&r===e.id}function eT(e){let t=o(e);if(!t)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&"id"in e&&(r===e.id||!!e.querySelector(`#${CSS.escape(r)}`))}function ex(e){!eT(e)&&eb(e)&&e.focus()}var eG=w(),eD=["text","search","url","tel","email","password","number","date","month","week","time","datetime","datetime-local"],ew=Symbol("safariFocusAncestor");function eL(e){return"input"===e.tagName.toLowerCase()&&!!e.type&&("radio"===e.type||"checkbox"===e.type)}function e_(e,t){return Q(r=>{null==e||e(r),!r.defaultPrevented&&t&&(r.stopPropagation(),r.preventDefault())})}var eO=!1,eH=!0;function eP(e){let t=e.target;t&&"hasAttribute"in t&&!t.hasAttribute("data-focus-visible")&&(eH=!1)}function eJ(e){e.metaKey||e.ctrlKey||e.altKey||(eH=!0)}var eU=eu(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:r,onFocusVisible:n,...i}){var o,a,s,u,c;let d=(0,T.useRef)(null);(0,T.useEffect)(()=>{!e||eO||(U("mousedown",eP,!0),U("keydown",eJ,!0),eO=!0)},[e]),eG&&(0,T.useEffect)(()=>{if(!e)return;let t=d.current;if(!t||!eL(t))return;let r="labels"in t?t.labels:null;if(!r)return;let n=()=>queueMicrotask(()=>t.focus());for(let e of r)e.addEventListener("mouseup",n);return()=>{for(let e of r)e.removeEventListener("mouseup",n)}},[e]);let f=e&&S(i),A=!!f&&!t,[h,m]=(0,T.useState)(!1);(0,T.useEffect)(()=>{e&&A&&h&&m(!1)},[e,A,h]),(0,T.useEffect)(()=>{if(!e||!h)return;let t=d.current;if(!t||"u"{eb(t)||m(!1)});return r.observe(t),()=>r.disconnect()},[e,h]);let p=e_(i.onKeyPressCapture,f),B=e_(i.onMouseDownCapture,f),C=e_(i.onClickCapture,f),g=i.onMouseDown,v=Q(t=>{if(null==g||g(t),t.defaultPrevented||!e)return;let r=t.currentTarget;if(!eG||L(t)||!l(r)&&!eL(r))return;let n=!1,i=()=>{n=!0};r.addEventListener("focusin",i,{capture:!0,once:!0});let o=function(e){for(;e&&!eb(e);)e=e.closest(ey);return e||null}(r.parentElement);o&&(o[ew]=!0),J(r,"mouseup",()=>{r.removeEventListener("focusin",i,!0),o&&(o[ew]=!1),n||ex(r)})}),y=(t,r)=>{if(r&&(t.currentTarget=r),!e)return;let i=t.currentTarget;i&&eI(i)&&(null==n||n(t),t.defaultPrevented||(i.dataset.focusVisible="true",m(!0)))},b=i.onKeyDownCapture,E=Q(t=>{if(null==b||b(t),t.defaultPrevented||!e||h||t.metaKey||t.altKey||t.ctrlKey||!_(t))return;let r=t.currentTarget;J(r,"focusout",()=>y(t,r))}),M=i.onFocusCapture,F=Q(t=>{if(null==M||M(t),t.defaultPrevented||!e)return;if(!_(t))return void m(!1);let r=t.currentTarget;eH||function(e){let{tagName:t,readOnly:r,type:n}=e;return"TEXTAREA"===t&&!r||"SELECT"===t&&!r||("INPUT"!==t||r?!!e.isContentEditable||"combobox"===e.getAttribute("role")&&!!e.dataset.name:eD.includes(n))}(t.target)?J(t.target,"focusout",()=>y(t,r)):m(!1)}),I=i.onBlur,x=Q(t=>{null==I||I(t),!e||P(t)&&(t.currentTarget.removeAttribute("data-focus-visible"),m(!1))}),G=(0,T.useContext)(ev),D=Q(t=>{e&&r&&t&&G&&queueMicrotask(()=>{eI(t)||eb(t)&&t.focus()})}),w=function(e,t){let r=e=>{if("string"==typeof e)return e},[n,i]=(0,T.useState)(()=>r(void 0));return j(()=>{let t=e&&"current"in e?e.current:e;i((null==t?void 0:t.tagName.toLowerCase())||r(void 0))},[e,void 0]),n}(d),O=e&&(!w||"button"===w||"summary"===w||"input"===w||"select"===w||"textarea"===w||"a"===w),H=e&&(!w||"button"===w||"input"===w||"select"===w||"textarea"===w),N=i.style,k=(0,T.useMemo)(()=>A?{pointerEvents:"none",...N}:N,[A,N]);return i={"data-focus-visible":e&&h||void 0,"data-autofocus":r||void 0,"aria-disabled":f||void 0,...i,ref:X(d,D,i.ref),style:k,tabIndex:(o=e,a=A,s=O,u=H,c=i.tabIndex,o?a?s&&!u?-1:void 0:s?c:c||0:c),disabled:!!H&&!!A||void 0,contentEditable:f?void 0:i.contentEditable,onKeyPressCapture:p,onClickCapture:C,onMouseDownCapture:B,onMouseDown:v,onKeyDownCapture:E,onFocusCapture:F,onBlur:x},R(i)});function eN(e){let t=[];for(let r of e)t.push(...r);return t}function ek(e){return e.slice().reverse()}function eK(e,t,r){return Q(n=>{var i;let o,a;if(null==t||t(n),n.defaultPrevented||n.isPropagationStopped()||!_(n)||"Shift"===n.key||"Control"===n.key||"Alt"===n.key||"Meta"===n.key||(!(o=n.target)||d(o))&&1===n.key.length&&!n.ctrlKey&&!n.metaKey)return;let s=e.getState(),l=null==(i=B(e,s.activeId))?void 0:i.element;if(!l)return;let{view:u,...c}=n;l!==(null==r?void 0:r.current)&&l.focus(),a=new KeyboardEvent(n.type,c),l.dispatchEvent(a)||n.preventDefault(),n.currentTarget.contains(l)&&n.stopPropagation()})}ea(function(e){return el("div",eU(e))});var ej=eu(function({store:e,composite:t=!0,focusOnMove:r=t,moveOnKeyPress:n=!0,...i}){let a=em();M(e=e||a,!1);let s=(0,T.useRef)(null),l=(0,T.useRef)(null),u=function(e){let[t,r]=(0,T.useState)(!1),n=(0,T.useCallback)(()=>r(!0),[]),i=e.useState(t=>B(e,t.activeId));return(0,T.useEffect)(()=>{let e=null==i?void 0:i.element;!t||e&&(r(!1),e.focus({preventScroll:!0}))},[i,t]),n}(e),c=e.useState("moves"),[,f]=function(e){let[t,r]=(0,T.useState)(null);return j(()=>{if(null==t||!e)return;let r=null;return e(e=>(r=e,t)),()=>{e(r)}},[t,e]),[t,r]}(t?e.setBaseElement:null);(0,T.useEffect)(()=>{var n;if(!e||!c||!t||!r)return;let{activeId:i}=e.getState(),o=null==(n=B(e,i))?void 0:n.element;o&&("scrollIntoView"in o?(o.focus({preventScroll:!0}),o.scrollIntoView({block:"nearest",inline:"nearest",...void 0})):o.focus())},[e,c,t,r]),j(()=>{if(!e||!c||!t)return;let{baseElement:r,activeId:n}=e.getState();if(null!==n||!r)return;let i=l.current;l.current=null,i&&O(i,{relatedTarget:r}),eI(r)||r.focus()},[e,c,t]);let A=e.useState("activeId"),h=e.useState("virtualFocus");j(()=>{var r;if(!e||!t||!h)return;let n=l.current;if(l.current=null,!n)return;let i=(null==(r=B(e,A))?void 0:r.element)||o(n);i!==n&&O(n,{relatedTarget:i})},[e,A,h,t]);let m=eK(e,i.onKeyDownCapture,l),p=eK(e,i.onKeyUpCapture,l),v=i.onFocusCapture,y=Q(t=>{var r;let n;if(null==v||v(t),t.defaultPrevented||!e)return;let{virtualFocus:i}=e.getState();if(!i)return;let o=t.relatedTarget,a=(n=(r=t.currentTarget)[C],delete r[C],n);_(t)&&a&&(t.stopPropagation(),l.current=o)}),b=i.onFocus,E=Q(r=>{if(null==b||b(r),r.defaultPrevented||!t||!e)return;let{relatedTarget:n}=r,{virtualFocus:i}=e.getState();i?_(r)&&!g(e,n)&&queueMicrotask(u):_(r)&&e.setActiveId(null)}),F=i.onBlurCapture,S=Q(t=>{var r;if(null==F||F(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:i}=e.getState();if(!n)return;let o=null==(r=B(e,i))?void 0:r.element,a=t.relatedTarget,s=g(e,a),u=l.current;l.current=null,_(t)&&s?(a===o?u&&u!==a&&O(u,t):o?O(o,t):u&&O(u,t),t.stopPropagation()):!g(e,t.target)&&o&&O(o,t)}),R=i.onKeyDown,I=Y(n),x=Q(t=>{var r;if(null==R||R(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!_(t))return;let{orientation:n,renderedItems:i,activeId:o}=e.getState(),a=B(e,o);if(null==(r=null==a?void 0:a.element)?void 0:r.isConnected)return;let s="horizontal"!==n,l="vertical"!==n,u=i.some(e=>!!e.rowId);if(("ArrowLeft"===t.key||"ArrowRight"===t.key||"Home"===t.key||"End"===t.key)&&d(t.currentTarget))return;let c={ArrowUp:(u||s)&&(()=>{if(u){let e=eN(ek(function(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}(i))).find(e=>!e.disabled);return null==e?void 0:e.id}return null==e?void 0:e.last()}),ArrowRight:(u||l)&&e.first,ArrowDown:(u||s)&&e.first,ArrowLeft:(u||l)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(c){let r=c();if(void 0!==r){if(!I(t))return;t.preventDefault(),e.move(r)}}});return i=Z(i,t=>(0,eo.jsx)(ep,{value:e,children:t}),[e]),i={"aria-activedescendant":e.useState(r=>{var n;if(e&&t&&r.virtualFocus)return null==(n=B(e,r.activeId))?void 0:n.id}),...i,ref:X(s,f,i.ref),onKeyDownCapture:m,onKeyUpCapture:p,onFocusCapture:y,onFocus:E,onBlurCapture:S,onKeyDown:x},i=eU({focusable:e.useState(e=>t&&(e.virtualFocus||null===e.activeId)),...i})});ea(function(e){return el("div",ej(e))});var eQ=ec();eQ.useContext,eQ.useScopedContext;var eX=eQ.useProviderContext,eV=ec([eQ.ContextProvider],[eQ.ScopedContextProvider]);eV.useContext,eV.useScopedContext;var eq=eV.useProviderContext,eW=eV.ContextProvider,eY=eV.ScopedContextProvider,eZ=(0,T.createContext)(void 0),ez=(0,T.createContext)(void 0),e$=ec([eW],[eY]);e$.useContext,e$.useScopedContext;var e0=e$.useProviderContext,e1=e$.ContextProvider,e9=e$.ScopedContextProvider,e8=eu(function({store:e,...t}){let r=e0();return e=e||r,t={...t,ref:X(null==e?void 0:e.setAnchorElement,t.ref)}});ea(function(e){return el("div",e8(e))});var e2=(0,T.createContext)(void 0),e3=ec([e1,ep],[e9,eB]),e6=e3.useContext,e4=e3.useScopedContext,e7=e3.useProviderContext,e5=e3.ContextProvider,te=e3.ScopedContextProvider,tt=(0,T.createContext)(void 0),tr=(0,T.createContext)(!1);function tn(e,t){let r=e.__unstableInternals;return M(r,"Invalid store"),r[t]}function ti(e,...t){let r=e,n=r,i=Symbol(),o=v,a=new Set,s=new Set,l=new Set,u=new Set,c=new Set,d=new WeakMap,f=new WeakMap,A=(e,t,r=u)=>(r.add(t),f.set(t,e),()=>{var e;null==(e=d.get(t))||e(),d.delete(t),f.delete(t),r.delete(t)}),h=(e,o,a=!1)=>{var l,A;if(!y(r,e))return;let h=(A=r[e],"function"==typeof o?o("function"==typeof A?A():A):o);if(h===r[e])return;if(!a)for(let r of t)null==(l=null==r?void 0:r.setState)||l.call(r,e,h);let m=r;r={...r,[e]:h};let p=Symbol();i=p,s.add(e);let B=(t,n,i)=>{var o;let a=f.get(t);(!a||a.some(t=>i?i.has(t):t===e))&&(null==(o=d.get(t))||o(),d.set(t,t(r,n)))};for(let e of u)B(e,m);queueMicrotask(()=>{if(i!==p)return;let e=r;for(let e of c)B(e,n,s);n=e,s.clear()})},m={getState:()=>r,setState:h,__unstableInternals:{setup:e=>(l.add(e),()=>l.delete(e)),init:()=>{let e=a.size,n=Symbol();a.add(n);let i=()=>{a.delete(n),a.size||o()};if(e)return i;let s=Object.keys(r).map(e=>b(...t.map(t=>{var r;let n=null==(r=null==t?void 0:t.getState)?void 0:r.call(t);if(n&&y(n,e))return tl(t,[e],t=>{h(e,t[e],!0)})}))),u=[];for(let e of l)u.push(e());return o=b(...s,...u,...t.map(ta)),i},subscribe:(e,t)=>A(e,t),sync:(e,t)=>(d.set(t,t(r,r)),A(e,t)),batch:(e,t)=>(d.set(t,t(r,n)),A(e,t,c)),pick:e=>ti(function(e,t){let r={};for(let n of t)y(e,n)&&(r[n]=e[n]);return r}(r,e),m),omit:e=>ti(function(e,t){let r={...e};for(let e of t)y(r,e)&&delete r[e];return r}(r,e),m)}};return m}function to(e,...t){if(e)return tn(e,"setup")(...t)}function ta(e,...t){if(e)return tn(e,"init")(...t)}function ts(e,...t){if(e)return tn(e,"subscribe")(...t)}function tl(e,...t){if(e)return tn(e,"sync")(...t)}function tu(e,...t){if(e)return tn(e,"batch")(...t)}function tc(e,...t){if(e)return tn(e,"omit")(...t)}function td(...e){var t;let r={};for(let n of e){let e=null==(t=null==n?void 0:n.getState)?void 0:t.call(n);e&&Object.assign(r,e)}let n=ti(r,...e);return Object.assign({},...e,n)}function tf(e,t){}function tA(e,t,r){if(!r)return!1;let n=e.find(e=>!e.disabled&&e.value);return(null==n?void 0:n.value)===t}function th(e,t){return!!t&&null!=e&&(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase()))}var tm=eu(function({store:e,focusable:t=!0,autoSelect:r=!1,getAutoSelectId:n,setValueOnChange:i,showMinLength:o=0,showOnChange:a,showOnMouseDown:s,showOnClick:l=s,showOnKeyDown:u,showOnKeyPress:c=u,blurActiveItemOnClick:d,setValueOnClick:f=!0,moveOnKeyPress:B=!0,autoComplete:C="list",...g}){var y;let b,E=e7();M(e=e||E,!1);let S=(0,T.useRef)(null),[R,I]=W(),x=(0,T.useRef)(!1),G=(0,T.useRef)(!1),D=e.useState(e=>e.virtualFocus&&r),w="inline"===C||"both"===C,[L,_]=(0,T.useState)(w);y=[w],b=(0,T.useRef)(!1),j(()=>{if(b.current)return(()=>{w&&_(!0)})();b.current=!0},y),j(()=>()=>{b.current=!1},[]);let O=e.useState("value"),H=(0,T.useRef)(void 0);(0,T.useEffect)(()=>tl(e,["selectedValue","activeId"],(e,t)=>{H.current=t.selectedValue}),[]);let U=e.useState(e=>{var t;if(w&&L){if(e.activeValue&&Array.isArray(e.selectedValue)&&(e.selectedValue.includes(e.activeValue)||(null==(t=H.current)?void 0:t.includes(e.activeValue))))return;return e.activeValue}}),N=e.useState("renderedItems"),k=e.useState("open"),K=e.useState("contentElement"),Z=(0,T.useMemo)(()=>{if(!w||!L)return O;if(tA(N,U,D)){if(th(O,U)){let e=(null==U?void 0:U.slice(O.length))||"";return O+e}return O}return U||O},[w,L,N,U,D,O]);(0,T.useEffect)(()=>{let e=S.current;if(!e)return;let t=()=>_(!0);return e.addEventListener("combobox-item-move",t),()=>{e.removeEventListener("combobox-item-move",t)}},[]),(0,T.useEffect)(()=>{if(!w||!L||!U||!tA(N,U,D)||!th(O,U))return;let e=v;return queueMicrotask(()=>{let t=S.current;if(!t)return;let{start:r,end:n}=A(t),i=O.length,o=U.length;p(t,i,o),e=()=>{if(!eI(t))return;let{start:e,end:a}=A(t);e!==i||a===o&&p(t,r,n)}}),()=>e()},[R,w,L,U,N,D,O]);let z=(0,T.useRef)(null),$=Q(n),ee=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!k||!K)return;let t=m(K);if(!t)return;z.current=t;let r=()=>{x.current=!1},n=()=>{if(!e||!x.current)return;let{activeId:t}=e.getState();null===t||t!==ee.current&&(x.current=!1)},i={passive:!0,capture:!0};return t.addEventListener("wheel",r,i),t.addEventListener("touchmove",r,i),t.addEventListener("scroll",n,i),()=>{t.removeEventListener("wheel",r,!0),t.removeEventListener("touchmove",r,!0),t.removeEventListener("scroll",n,!0)}},[k,K,e]),j(()=>{!O||G.current||(x.current=!0)},[O]),j(()=>{"always"!==D&&k||(x.current=k)},[D,k]);let et=e.useState("resetValueOnSelect");q(()=>{var t,r;let n=x.current;if(!e||!k||!n&&!et)return;let{baseElement:i,contentElement:o,activeId:a}=e.getState();if(!i||eI(i)){if(null==o?void 0:o.hasAttribute("data-placing")){let e=new MutationObserver(I);return e.observe(o,{attributeFilter:["data-placing"]}),()=>e.disconnect()}if(D&&n){let r,n=$(N),i=void 0!==n?n:null!=(t=null==(r=N.find(e=>{var t;return!e.disabled&&(null==(t=e.element)?void 0:t.getAttribute("role"))!=="tab"}))?void 0:r.id)?t:e.first();ee.current=i,e.move(null!=i?i:null)}else{let t=null==(r=e.item(a||e.first()))?void 0:r.element;t&&"scrollIntoView"in t&&t.scrollIntoView({block:"nearest",inline:"nearest"})}}},[e,k,R,O,D,et,$,N]),(0,T.useEffect)(()=>{if(!w)return;let t=S.current;if(!t)return;let r=[t,K].filter(e=>!!e),n=t=>{r.every(e=>P(t,e))&&(null==e||e.setValue(Z))};for(let e of r)e.addEventListener("focusout",n);return()=>{for(let e of r)e.removeEventListener("focusout",n)}},[w,K,e,Z]);let er=e=>e.currentTarget.value.length>=o,en=g.onChange,ei=Y(null!=a?a:er),eo=Y(null!=i?i:!e.tag),ea=Q(t=>{if(null==en||en(t),t.defaultPrevented||!e)return;let r=t.currentTarget,{value:n,selectionStart:i,selectionEnd:o}=r,a=t.nativeEvent;if(x.current=!0,"input"===a.type&&(a.isComposing&&(x.current=!1,G.current=!0),w)){let e="insertText"===a.inputType||"insertCompositionText"===a.inputType,t=i===n.length;_(e&&t)}if(eo(t)){let t=n===e.getState().value;e.setValue(n),queueMicrotask(()=>{p(r,i,o)}),w&&D&&t&&I()}ei(t)&&e.show(),D&&x.current||e.setActiveId(null)}),es=g.onCompositionEnd,el=Q(e=>{x.current=!0,G.current=!1,null==es||es(e),e.defaultPrevented||D&&I()}),eu=g.onMouseDown,ec=Y(null!=d?d:()=>!!(null==e?void 0:e.getState().includesBaseElement)),ed=Y(f),ef=Y(null!=l?l:er),eA=Q(t=>{null==eu||eu(t),t.defaultPrevented||t.button||t.ctrlKey||e&&(ec(t)&&e.setActiveId(null),ed(t)&&e.setValue(Z),ef(t)&&J(t.currentTarget,"mouseup",e.show))}),eh=g.onKeyDown,em=Y(null!=c?c:er),ep=Q(t=>{if(null==eh||eh(t),t.repeat||(x.current=!1),t.defaultPrevented||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||!e)return;let{open:r}=e.getState();!r&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&em(t)&&(t.preventDefault(),e.show())}),eB=g.onBlur,eC=Q(e=>{if(x.current=!1,null==eB||eB(e),e.defaultPrevented)return}),eg=V(g.id),ev=e.useState(e=>null===e.activeId);return g={id:eg,role:"combobox","aria-autocomplete":"inline"===C||"list"===C||"both"===C||"none"===C?C:void 0,"aria-haspopup":h(K,"listbox"),"aria-expanded":k,"aria-controls":null==K?void 0:K.id,"data-active-item":ev||void 0,value:Z,...g,ref:X(S,g.ref),onChange:ea,onCompositionEnd:el,onMouseDown:eA,onKeyDown:ep,onBlur:eC},g=ej({store:e,focusable:t,...g,moveOnKeyPress:e=>!F(B,e)&&(w&&_(!0),!0)}),{autoComplete:"off",...g=e8({store:e,...g})}}),tp=ea(function(e){return el("input",tm(e))});function tB(e){let t=e.relatedTarget;return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE?t:null}e.s(["Combobox",()=>tp],11889);var tC=Symbol("composite-hover"),tg=eu(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:r=!!t,...n}){let i=eh();M(e=e||i,!1);let o=((0,T.useEffect)(()=>{$||(U("mousemove",en,!0),U("mousedown",ei,!0),U("mouseup",ei,!0),U("keydown",ei,!0),U("scroll",ei,!0),$=!0)},[]),Q(()=>ee)),s=n.onMouseMove,l=Y(t),u=Q(t=>{if((null==s||s(t),!t.defaultPrevented&&o())&&l(t)){if(!eT(t.currentTarget)){let t=null==e?void 0:e.getState().baseElement;t&&!eI(t)&&t.focus()}null==e||e.setActiveId(t.currentTarget.id)}}),c=n.onMouseLeave,d=Y(r),f=Q(t=>{var r;let n;null==c||c(t),!t.defaultPrevented&&o()&&((n=tB(t))&&a(t.currentTarget,n)||function(e){let t=tB(e);if(!t)return!1;do{if(y(t,tC)&&t[tC])return!0;t=t.parentElement}while(t)return!1}(t)||!l(t)||d(t)&&(null==e||e.setActiveId(null),null==(r=null==e?void 0:e.getState().baseElement)||r.focus()))}),A=(0,T.useCallback)(e=>{e&&(e[tC]=!0)},[]);return R(n={...n,ref:X(A,n.ref),onMouseMove:u,onMouseLeave:f})});es(ea(function(e){return el("div",tg(e))}));var tv=eu(function({store:e,shouldRegisterItem:t=!0,getItem:r=E,element:n,...i}){let o=ef();e=e||o;let a=V(i.id),s=(0,T.useRef)(n);return(0,T.useEffect)(()=>{let n=s.current;if(!a||!n||!t)return;let i=r({id:a,element:n});return null==e?void 0:e.renderItem(i)},[a,t,r,e]),R(i={...i,ref:X(s,i.ref)})});function ty(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return"Enter"===e.key?l(t)||"SUMMARY"===t.tagName||"A"===t.tagName:" "===e.key&&(l(t)||"SUMMARY"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName)}ea(function(e){return el("div",tv(e))});var tb=Symbol("command"),tE=eu(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let i,o,a=(0,T.useRef)(null),[s,u]=(0,T.useState)(!1);(0,T.useEffect)(()=>{a.current&&u(l(a.current))},[]);let[c,f]=(0,T.useState)(!1),A=(0,T.useRef)(!1),h=S(n),[m,p]=(i=n.onLoadedMetadataCapture,o=(0,T.useMemo)(()=>Object.assign(()=>{},{...i,[tb]:!0}),[i,tb,!0]),[null==i?void 0:i[tb],{onLoadedMetadataCapture:o}]),B=n.onKeyDown,C=Q(n=>{null==B||B(n);let i=n.currentTarget;if(n.defaultPrevented||m||h||!_(n)||d(i)||i.isContentEditable)return;let o=e&&"Enter"===n.key,a=t&&" "===n.key,s="Enter"===n.key&&!e,l=" "===n.key&&!t;if(s||l)return void n.preventDefault();if(o||a){let e=ty(n);if(o){if(!e){n.preventDefault();let{view:e,...t}=n,o=()=>H(i,t);r&&/firefox\//i.test(navigator.userAgent)?J(i,"keyup",o):queueMicrotask(o)}}else a&&(A.current=!0,e||(n.preventDefault(),f(!0)))}}),g=n.onKeyUp,v=Q(e=>{if(null==g||g(e),e.defaultPrevented||m||h||e.metaKey)return;let r=t&&" "===e.key;if(A.current&&r&&(A.current=!1,!ty(e))){e.preventDefault(),f(!1);let t=e.currentTarget,{view:r,...n}=e;queueMicrotask(()=>H(t,n))}});return eU(n={"data-active":c||void 0,type:s?"button":void 0,...p,...n,ref:X(a,n.ref),onKeyDown:C,onKeyUp:v})});ea(function(e){return el("button",tE(e))});var{useSyncExternalStore:tM}=e.i(2239).default,tF=()=>()=>{};function tS(e,t=E){let r=T.useCallback(t=>e?ts(e,null,t):tF(),[e]),n=()=>{let r="string"==typeof t?t:null,n="function"==typeof t?t:null,i=null==e?void 0:e.getState();return n?n(i):i&&r&&y(i,r)?i[r]:void 0};return tM(r,n,n)}function tR(e,t){let r=T.useRef({}),n=T.useCallback(t=>e?ts(e,null,t):tF(),[e]),i=()=>{let n=null==e?void 0:e.getState(),i=!1,o=r.current;for(let e in t){let r=t[e];if("function"==typeof r){let t=r(n);t!==o[e]&&(o[e]=t,i=!0)}if("string"==typeof r){if(!n||!y(n,r))continue;let t=n[r];t!==o[e]&&(o[e]=t,i=!0)}}return i&&(r.current={...o}),r.current};return tM(n,i,i)}function tI(e,t,r,n){var i;let o,a=y(t,r)?t[r]:void 0,s=(i={value:a,setValue:n?t[n]:void 0},o=(0,T.useRef)(i),j(()=>{o.current=i}),o);j(()=>tl(e,[r],(e,t)=>{let{value:n,setValue:i}=s.current;i&&e[r]!==t[r]&&e[r]!==n&&i(e[r])}),[e,r]),j(()=>{if(void 0!==a)return e.setState(r,a),tu(e,[r],()=>{void 0!==a&&e.setState(r,a)})})}function tT(e,t){let[r,n]=T.useState(()=>e(t));j(()=>ta(r),[r]);let i=T.useCallback(e=>tS(r,e),[r]);return[T.useMemo(()=>({...r,useState:i}),[r,i]),Q(()=>{n(r=>e({...t,...r.getState()}))})]}function tx(e,t,r,n=!1){var i;let o,a;if(!t||!r)return;let{renderedItems:s}=t.getState(),l=m(e);if(!l)return;let u=function(e,t=!1){let r=e.clientHeight,{top:n}=e.getBoundingClientRect(),i=1.5*Math.max(.875*r,r-40),o=t?r-i+n:i+n;return"HTML"===e.tagName?o+e.scrollTop:o}(l,n);for(let e=0;e=0){void 0!==a&&at||(e&&(null==B?void 0:B.baseElement)&&B.baseElement===e.baseElement?B.id:void 0),baseElement:e=>(null==e?void 0:e.baseElement)||void 0,isActiveItem:e=>!!e&&e.activeId===m,ariaSetSize:e=>null!=s?s:e&&(null==B?void 0:B.ariaSetSize)&&B.baseElement===e.baseElement?B.ariaSetSize:void 0,ariaPosInSet(e){if(null!=u)return u;if(!e||!(null==B?void 0:B.ariaPosInSet)||B.baseElement!==e.baseElement)return;let t=e.renderedItems.filter(e=>e.rowId===y);return B.ariaPosInSet+t.findIndex(e=>e.id===m)},isTabbable(t){if(!(null==t?void 0:t.renderedItems.length))return!0;if(t.virtualFocus)return!1;if(o)return!0;if(null===t.activeId)return!1;let r=null==e?void 0:e.item(t.activeId);return null!=r&&!!r.disabled||null==r||!r.element||t.activeId===m}}),x=(0,T.useCallback)(e=>{var t;let r={...e,id:m||e.id,rowId:y,disabled:!!v,children:null==(t=e.element)?void 0:t.textContent};return a?a(r):r},[m,y,v,a]),G=c.onFocus,D=(0,T.useRef)(!1),O=Q(t=>{var r,i;if(null==G||G(t),t.defaultPrevented||L(t)||!m||!e||(r=e,!_(t)&&g(r,t.target)))return;let{virtualFocus:o,baseElement:a}=e.getState();e.setActiveId(m),f(t.currentTarget)&&function(e,t=!1){if(d(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let r=n(e).getSelection();null==r||r.selectAllChildren(e),t&&(null==r||r.collapseToEnd())}}(t.currentTarget),!o||!_(t)||!f(i=t.currentTarget)&&("INPUT"!==i.tagName||l(i))&&(null==a?void 0:a.isConnected)&&((w()&&t.currentTarget.hasAttribute("data-autofocus")&&t.currentTarget.scrollIntoView({block:"nearest",inline:"nearest"}),D.current=!0,t.relatedTarget===a||g(e,t.relatedTarget))?(a[C]=!0,a.focus({preventScroll:!0})):a.focus())}),H=c.onBlurCapture,P=Q(t=>{if(null==H||H(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState();(null==r?void 0:r.virtualFocus)&&D.current&&(D.current=!1,t.preventDefault(),t.stopPropagation())}),J=c.onKeyDown,U=Y(r),N=Y(i),k=Q(t=>{if(null==J||J(t),t.defaultPrevented||!_(t)||!e)return;let{currentTarget:r}=t,i=e.getState(),o=e.item(m),a=!!(null==o?void 0:o.rowId),s="horizontal"!==i.orientation,l="vertical"!==i.orientation,u=()=>!(!a&&!l&&i.baseElement&&d(i.baseElement)),c={ArrowUp:(a||s)&&e.up,ArrowRight:(a||l)&&e.next,ArrowDown:(a||s)&&e.down,ArrowLeft:(a||l)&&e.previous,Home:()=>{if(u())return!a||t.ctrlKey?null==e?void 0:e.first():null==e?void 0:e.previous(-1)},End:()=>{if(u())return!a||t.ctrlKey?null==e?void 0:e.last():null==e?void 0:e.next(-1)},PageUp:()=>tx(r,e,null==e?void 0:e.up,!0),PageDown:()=>tx(r,e,null==e?void 0:e.down)}[t.key];if(c){if(f(r)){let e=A(r),i=l&&"ArrowLeft"===t.key,o=l&&"ArrowRight"===t.key,a=s&&"ArrowUp"===t.key,u=s&&"ArrowDown"===t.key;if(o||u){let{length:t}=function(e){if(d(e))return e.value;if(e.isContentEditable){let t=n(e).createRange();return t.selectNodeContents(e),t.toString()}return""}(r);if(e.end!==t)return}else if((i||a)&&0!==e.start)return}let i=c();if(U(t)||void 0!==i){if(!N(t))return;t.preventDefault(),e.move(i)}}}),K=(0,T.useMemo)(()=>({id:m,baseElement:b}),[m,b]);return c={id:m,"data-active-item":E||void 0,...c=Z(c,e=>(0,eo.jsx)(eC.Provider,{value:K,children:e}),[K]),ref:X(p,c.ref),tabIndex:I?c.tabIndex:-1,onFocus:O,onBlurCapture:P,onKeyDown:k},c=tE(c),R({...c=tv({store:e,...c,getItem:x,shouldRegisterItem:!!m&&c.shouldRegisterItem}),"aria-setsize":M,"aria-posinset":F})});es(ea(function(e){return el("button",tG(e))}));var tD=eu(function({store:e,value:t,hideOnClick:r,setValueOnClick:n,selectValueOnClick:i=!0,resetValueOnSelect:o,focusOnHover:a=!1,moveOnKeyPress:s=!0,getItem:l,...u}){var c,f;let A=e4();M(e=e||A,!1);let{resetValueOnSelectState:h,multiSelectable:m,selected:p}=tR(e,{resetValueOnSelectState:"resetValueOnSelect",multiSelectable:e=>Array.isArray(e.selectedValue),selected:e=>(function(e,t){if(null!=t)return null!=e&&(Array.isArray(e)?e.includes(t):e===t)})(e.selectedValue,t)}),B=(0,T.useCallback)(e=>{let r={...e,value:t};return l?l(r):r},[t,l]);n=null!=n?n:!m,r=null!=r?r:null!=t&&!m;let C=u.onClick,g=Y(n),v=Y(i),y=Y(null!=(c=null!=o?o:h)?c:m),b=Y(r),E=Q(r=>{null==C||C(r),r.defaultPrevented||function(e){let t=e.currentTarget;if(!t)return!1;let r=t.tagName.toLowerCase();return!!e.altKey&&("a"===r||"button"===r&&"submit"===t.type||"input"===r&&"submit"===t.type)}(r)||!function(e){let t=e.currentTarget;if(!t)return!1;let r=D();if(r&&!e.metaKey||!r&&!e.ctrlKey)return!1;let n=t.tagName.toLowerCase();return"a"===n||"button"===n&&"submit"===t.type||"input"===n&&"submit"===t.type}(r)&&(null!=t&&(v(r)&&(y(r)&&(null==e||e.resetValue()),null==e||e.setSelectedValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t)),g(r)&&(null==e||e.setValue(t))),b(r)&&(null==e||e.hide()))}),F=u.onKeyDown,S=Q(t=>{if(null==F||F(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState().baseElement;!r||eI(r)||(1===t.key.length||"Backspace"===t.key||"Delete"===t.key)&&(queueMicrotask(()=>r.focus()),d(r)&&(null==e||e.setValue(r.value)))});m&&null!=p&&(u={"aria-selected":p,...u}),u=Z(u,e=>(0,eo.jsx)(tt.Provider,{value:t,children:(0,eo.jsx)(tr.Provider,{value:null!=p&&p,children:e})}),[t,p]),u={role:null!=(f=({menu:"menuitem",listbox:"option",tree:"treeitem"})[(0,T.useContext)(e2)])?f:"option",children:t,...u,onClick:E,onKeyDown:S};let R=Y(s);return u=tG({store:e,...u,getItem:B,moveOnKeyPress:t=>{if(!R(t))return!1;let r=new Event("combobox-item-move"),n=null==e?void 0:e.getState().baseElement;return null==n||n.dispatchEvent(r),!0}}),u=tg({store:e,focusOnHover:a,...u})}),tw=es(ea(function(e){return el("div",tD(e))}));e.s(["ComboboxItem",()=>tw],56373);var tL=e.i(74080);function t_(e,t){let r=setTimeout(t,e);return()=>clearTimeout(r)}function tO(...e){return e.join(", ").split(", ").reduce((e,t)=>{let r=t.endsWith("ms")?1:1e3,n=Number.parseFloat(t||"0s")*r;return n>e?n:e},0)}function tH(e,t,r){return!r&&!1!==t&&(!e||!!t)}var tP=eu(function({store:e,alwaysVisible:t,...r}){let n=eX();M(e=e||n,!1);let i=(0,T.useRef)(null),o=V(r.id),[a,s]=(0,T.useState)(null),l=e.useState("open"),u=e.useState("mounted"),c=e.useState("animated"),d=e.useState("contentElement"),f=tS(e.disclosure,"contentElement");j(()=>{i.current&&(null==e||e.setContentElement(i.current))},[e]),j(()=>{let t;return null==e||e.setState("animated",e=>(t=e,!0)),()=>{void 0!==t&&(null==e||e.setState("animated",t))}},[e]),j(()=>{if(c){var e;let t;return(null==d?void 0:d.isConnected)?(e=()=>{s(l?"enter":u?"leave":null)},t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)}),()=>cancelAnimationFrame(t)):void s(null)}},[c,d,l,u]),j(()=>{if(!e||!c||!a||!d)return;let t=()=>null==e?void 0:e.setState("animating",!1),r=()=>(0,tL.flushSync)(t);if("leave"===a&&l||"enter"===a&&!l)return;if("number"==typeof c)return t_(c,r);let{transitionDuration:n,animationDuration:i,transitionDelay:o,animationDelay:s}=getComputedStyle(d),{transitionDuration:u="0",animationDuration:A="0",transitionDelay:h="0",animationDelay:m="0"}=f?getComputedStyle(f):{},p=tO(o,s,h,m)+tO(n,i,u,A);if(!p){"enter"===a&&e.setState("animated",!1),t();return}return t_(Math.max(p-1e3/60,0),r)},[e,c,d,f,l,a]);let A=tH(u,(r=Z(r,t=>(0,eo.jsx)(eY,{value:e,children:t}),[e])).hidden,t),h=r.style,m=(0,T.useMemo)(()=>A?{...h,display:"none"}:h,[A,h]);return R(r={id:o,"data-open":l||void 0,"data-enter":"enter"===a||void 0,"data-leave":"leave"===a||void 0,hidden:A,...r,ref:X(o?e.setContentElement:null,i,r.ref),style:m})}),tJ=ea(function(e){return el("div",tP(e))});ea(function({unmountOnHide:e,...t}){let r=eX();return!1===tS(t.store||r,t=>!e||(null==t?void 0:t.mounted))?null:(0,eo.jsx)(tJ,{...t})});var tU=eu(function({store:e,alwaysVisible:t,...r}){let n=e4(!0),i=e6(),o=!!(e=e||i)&&e===n;M(e,!1);let a=(0,T.useRef)(null),s=V(r.id),l=e.useState("mounted"),u=tH(l,r.hidden,t),c=u?{...r.style,display:"none"}:r.style,d=e.useState(e=>Array.isArray(e.selectedValue)),f=function(e,t,r){let n=function(e){let[t]=(0,T.useState)(e);return t}(r),[i,o]=(0,T.useState)(n);return(0,T.useEffect)(()=>{let r=e&&"current"in e?e.current:e;if(!r)return;let i=()=>{let e=r.getAttribute(t);o(null==e?n:e)},a=new MutationObserver(i);return a.observe(r,{attributeFilter:[t]}),i(),()=>a.disconnect()},[e,t,n]),i}(a,"role",r.role),A="listbox"===f||"tree"===f||"grid"===f,[h,m]=(0,T.useState)(!1),p=e.useState("contentElement");j(()=>{if(!l)return;let e=a.current;if(!e||p!==e)return;let t=()=>{m(!!e.querySelector("[role='listbox']"))},r=new MutationObserver(t);return r.observe(e,{subtree:!0,childList:!0,attributeFilter:["role"]}),t(),()=>r.disconnect()},[l,p]),h||(r={role:"listbox","aria-multiselectable":A&&d||void 0,...r}),r=Z(r,t=>(0,eo.jsx)(te,{value:e,children:(0,eo.jsx)(e2.Provider,{value:f,children:t})}),[e,f]);let B=!s||n&&o?null:e.setContentElement;return R(r={id:s,hidden:u,...r,ref:X(B,a,r.ref),style:c})}),tN=ea(function(e){return el("div",tU(e))});e.s(["ComboboxList",()=>tN,"useComboboxList",()=>tU],86447);var tk=(0,T.createContext)(null),tK=eu(function(e){return{...e,style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px",...e.style}}});ea(function(e){return el("span",tK(e))});var tj=eu(function(e){return tK(e={"data-focus-trap":"",tabIndex:0,"aria-hidden":!0,...e,style:{position:"fixed",top:0,left:0,...e.style}})}),tQ=ea(function(e){return el("span",tj(e))});function tX(e){queueMicrotask(()=>{null==e||e.focus()})}var tV=eu(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:r,portalRef:i,portal:o=!0,...a}){let s=(0,T.useRef)(null),l=X(s,a.ref),u=(0,T.useContext)(tk),[c,d]=(0,T.useState)(null),[f,A]=(0,T.useState)(null),h=(0,T.useRef)(null),m=(0,T.useRef)(null),p=(0,T.useRef)(null),B=(0,T.useRef)(null);return j(()=>{let e=s.current;if(!e||!o)return void d(null);let t=r?"function"==typeof r?r(e):r:n(e).createElement("div");if(!t)return void d(null);let a=t.isConnected;if(a||(u||n(e).body).appendChild(t),t.id||(t.id=e.id?`portal/${e.id}`:function(e="id"){return`${e?`${e}-`:""}${Math.random().toString(36).slice(2,8)}`}()),d(t),x(i,t),!a)return()=>{t.remove(),x(i,null)}},[o,r,u,i]),j(()=>{if(!o||!e||!t)return;let r=n(t).createElement("span");return r.style.position="fixed",t.insertAdjacentElement("afterend",r),A(r),()=>{r.remove(),A(null)}},[o,e,t]),(0,T.useEffect)(()=>{if(!c||!e)return;let t=0,r=e=>{if(!P(e))return;let r="focusin"===e.type;if(cancelAnimationFrame(t),r){let e=c.querySelectorAll("[data-tabindex]"),t=e=>{let t=e.getAttribute("data-tabindex");e.removeAttribute("data-tabindex"),t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")};for(let r of(c.hasAttribute("data-tabindex")&&t(c),e))t(r);return}t=requestAnimationFrame(()=>{for(let e of eF(c,!0))!function(e){var t;let r=null!=(t=e.getAttribute("tabindex"))?t:"";e.setAttribute("data-tabindex",r),e.setAttribute("tabindex","-1")}(e)})};return c.addEventListener("focusin",r,!0),c.addEventListener("focusout",r,!0),()=>{cancelAnimationFrame(t),c.removeEventListener("focusin",r,!0),c.removeEventListener("focusout",r,!0)}},[c,e]),a={...a=Z(a,t=>{if(t=(0,eo.jsx)(tk.Provider,{value:c||u,children:t}),!o)return t;if(!c)return(0,eo.jsx)("span",{ref:l,id:a.id,style:{position:"fixed"},hidden:!0});t=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tQ,{ref:m,"data-focus-trap":a.id,className:"__focus-trap-inner-before",onFocus:e=>{P(e,c)?tX(eS()):tX(h.current)}}),t,e&&c&&(0,eo.jsx)(tQ,{ref:p,"data-focus-trap":a.id,className:"__focus-trap-inner-after",onFocus:e=>{P(e,c)?tX(eR()):tX(B.current)}})]}),c&&(t=(0,tL.createPortal)(t,c));let r=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tQ,{ref:h,"data-focus-trap":a.id,className:"__focus-trap-outer-before",onFocus:e=>{e.relatedTarget!==B.current&&P(e,c)?tX(m.current):tX(eR())}}),e&&(0,eo.jsx)("span",{"aria-owns":null==c?void 0:c.id,style:{position:"fixed"}}),e&&c&&(0,eo.jsx)(tQ,{ref:B,"data-focus-trap":a.id,className:"__focus-trap-outer-after",onFocus:e=>{if(P(e,c))tX(p.current);else{let e=eS();if(e===m.current)return void requestAnimationFrame(()=>{var e;return null==(e=eS())?void 0:e.focus()});tX(e)}}})]});return f&&e&&(r=(0,tL.createPortal)(r,f)),(0,eo.jsxs)(eo.Fragment,{children:[r,t]})},[c,u,o,a.id,e,f]),ref:l}});ea(function(e){return el("div",tV(e))});var tq=(0,T.createContext)(0);function tW({level:e,children:t}){let r=(0,T.useContext)(tq),n=Math.max(Math.min(e||r+1,6),1);return(0,eo.jsx)(tq.Provider,{value:n,children:t})}var tY=eu(function({autoFocusOnShow:e=!0,...t}){return Z(t,t=>(0,eo.jsx)(ev.Provider,{value:e,children:t}),[e])});ea(function(e){return el("div",tY(e))});var tZ=new WeakMap;function tz(e,t,r){tZ.has(e)||tZ.set(e,new Map);let n=tZ.get(e),i=n.get(t);if(!i)return n.set(t,r()),()=>{var e;null==(e=n.get(t))||e(),n.delete(t)};let o=r(),a=()=>{o(),i(),n.delete(t)};return n.set(t,a),()=>{n.get(t)===a&&(o(),n.set(t,i))}}function t$(e,t,r){return tz(e,t,()=>{let n=e.getAttribute(t);return e.setAttribute(t,r),()=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)}})}function t0(e,t,r){return tz(e,t,()=>{let n=t in e,i=e[t];return e[t]=r,()=>{n?e[t]=i:delete e[t]}})}function t1(e,t){return e?tz(e,"style",()=>{let r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}):()=>{}}var t9=["SCRIPT","STYLE"];function t8(e){return`__ariakit-dialog-snapshot-${e}`}function t2(e,t,r,i){for(let o of t){if(!(null==o?void 0:o.isConnected))continue;let s=t.some(e=>!!e&&e!==o&&e.contains(o)),l=n(o),u=o;for(;o.parentElement&&o!==l.body;){if(null==i||i(o.parentElement,u),!s)for(let i of o.parentElement.children)(function(e,t,r){return!t9.includes(t.tagName)&&!!function(e,t){let r=n(t),i=t8(e);if(!r.body[i])return!0;for(;;){if(t===r.body)return!1;if(t[i])return!0;if(!t.parentElement)return!1;t=t.parentElement}}(e,t)&&!r.some(e=>e&&a(t,e))})(e,i,t)&&r(i,u);o=o.parentElement}}}function t3(e,...t){if(!e)return!1;let r=e.getAttribute("data-backdrop");return null!=r&&(""===r||"true"===r||!t.length||t.some(e=>r===e))}function t6(e="",t=!1){return`__ariakit-dialog-${t?"ancestor":"outside"}${e?`-${e}`:""}`}function t4(e,t=""){return b(t0(e,t6("",!0),!0),t0(e,t6(t,!0),!0))}function t7(e,t){if(e[t6(t,!0)])return!0;let r=t6(t);for(;;){if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}}function t5(e,t){let r=[],n=t.map(e=>null==e?void 0:e.id);return t2(e,t,t=>{t3(t,...n)||r.unshift(function(e,t=""){return b(t0(e,t6(),!0),t0(e,t6(t),!0))}(t,e))},(t,n)=>{n.hasAttribute("data-dialog")&&n.id!==e||r.unshift(t4(t,e))}),()=>{for(let e of r)e()}}function re({store:e,type:t,listener:r,capture:i,domReady:o}){let s=Q(r),l=tS(e,"open"),u=(0,T.useRef)(!1);j(()=>{if(!l||!o)return;let{contentElement:t}=e.getState();if(!t)return;let r=()=>{u.current=!0};return t.addEventListener("focusin",r,!0),()=>t.removeEventListener("focusin",r,!0)},[e,l,o]),(0,T.useEffect)(()=>{if(l)return U(t,t=>{let{contentElement:r,disclosureElement:i}=e.getState(),o=t.target;!r||!o||!(!("HTML"===o.tagName||a(n(o).body,o))||a(r,o)||function(e,t){if(!e)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");if(r){let t=n(e).getElementById(r);if(t)return a(e,t)}return!1}(i,o)||o.hasAttribute("data-focus-trap")||function(e,t){if(!("clientY"in e))return!1;let r=t.getBoundingClientRect();return 0!==r.width&&0!==r.height&&r.top<=e.clientY&&e.clientY<=r.top+r.height&&r.left<=e.clientX&&e.clientX<=r.left+r.width}(t,r))&&(!u.current||t7(o,r.id))&&(o&&o[ew]||s(t))},i)},[l,i])}function rt(e,t){return"function"==typeof e?e(t):!!e}var rr=(0,T.createContext)({});function rn(){return"inert"in HTMLElement.prototype}function ri(e,t){if(!("style"in e))return v;if(rn())return t0(e,"inert",!0);let r=eF(e,!0).map(e=>{if(null==t?void 0:t.some(t=>t&&a(t,e)))return v;let r=tz(e,"focus",()=>(e.focus=v,()=>{delete e.focus}));return b(t$(e,"tabindex","-1"),r)});return b(...r,t$(e,"aria-hidden","true"),t1(e,{pointerEvents:"none",userSelect:"none",cursor:"default"}))}function ro(e={}){let t=td(e.store,tc(e.disclosure,["contentElement","disclosureElement"]));tf(e,t);let r=null==t?void 0:t.getState(),n=I(e.open,null==r?void 0:r.open,e.defaultOpen,!1),i=I(e.animated,null==r?void 0:r.animated,!1),o=ti({open:n,animated:i,animating:!!i&&n,mounted:n,contentElement:I(null==r?void 0:r.contentElement,null),disclosureElement:I(null==r?void 0:r.disclosureElement,null)},t);return to(o,()=>tl(o,["animated","animating"],e=>{e.animated||o.setState("animating",!1)})),to(o,()=>ts(o,["open"],()=>{o.getState().animated&&o.setState("animating",!0)})),to(o,()=>tl(o,["open","animating"],e=>{o.setState("mounted",e.open||e.animating)})),{...o,disclosure:e.disclosure,setOpen:e=>o.setState("open",e),show:()=>o.setState("open",!0),hide:()=>o.setState("open",!1),toggle:()=>o.setState("open",e=>!e),stopAnimation:()=>o.setState("animating",!1),setContentElement:e=>o.setState("contentElement",e),setDisclosureElement:e=>o.setState("disclosureElement",e)}}function ra(e,t,r){return q(t,[r.store,r.disclosure]),tI(e,r,"open","setOpen"),tI(e,r,"mounted","setMounted"),tI(e,r,"animated"),Object.assign(e,{disclosure:r.disclosure})}eu(function(e){return e});var rs=ea(function(e){return el("div",e)});function rl({store:e,backdrop:t,alwaysVisible:r,hidden:n}){let i=(0,T.useRef)(null),o=function(e={}){let[t,r]=tT(ro,e);return ra(t,r,e)}({disclosure:e}),a=tS(e,"contentElement");(0,T.useEffect)(()=>{let e=i.current;!e||a&&(e.style.zIndex=getComputedStyle(a).zIndex)},[a]),j(()=>{let e=null==a?void 0:a.id;if(!e)return;let t=i.current;if(t)return t4(t,e)},[a]);let s=tP({ref:i,store:o,role:"presentation","data-backdrop":(null==a?void 0:a.id)||"",alwaysVisible:r,hidden:null!=n?n:void 0,style:{position:"fixed",top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,T.isValidElement)(t))return(0,eo.jsx)(rs,{...s,render:t});let l="boolean"!=typeof t?t:"div";return(0,eo.jsx)(rs,{...s,render:(0,eo.jsx)(l,{})})}function ru(e={}){return ro(e)}Object.assign(rs,["a","button","details","dialog","div","form","h1","h2","h3","h4","h5","h6","header","img","input","label","li","nav","ol","p","section","select","span","summary","textarea","ul","svg"].reduce((e,t)=>(e[t]=ea(function(e){return el(t,e)}),e),{}));var rc=w();function rd(e,t=!1){if(!e)return null;let r="current"in e?e.current:e;return r?t?eb(r)?r:null:r:null}var rf=eu(function({store:e,open:t,onClose:s,focusable:u=!0,modal:d=!0,portal:f=!!d,backdrop:A=!!d,hideOnEscape:h=!0,hideOnInteractOutside:m=!0,getPersistentElements:p,preventBodyScroll:B=!!d,autoFocusOnShow:C=!0,autoFocusOnHide:g=!0,initialFocus:v,finalFocus:y,unmountOnHide:E,unstable_treeSnapshotKey:M,...F}){var S;let R,I,x,w=eq(),L=(0,T.useRef)(null),_=function(e={}){let[t,r]=tT(ru,e);return ra(t,r,e)}({store:e||w,open:t,setOpen(e){if(e)return;let t=L.current;if(!t)return;let r=new Event("close",{bubbles:!1,cancelable:!0});s&&t.addEventListener("close",s,{once:!0}),t.dispatchEvent(r),r.defaultPrevented&&_.setOpen(!0)}}),{portalRef:O,domReady:H}=z(f,F.portalRef),P=F.preserveTabOrder,N=tS(_,e=>P&&!d&&e.mounted),k=V(F.id),K=tS(_,"open"),q=tS(_,"mounted"),$=tS(_,"contentElement"),ee=tH(q,F.hidden,F.alwaysVisible);R=function({attribute:e,contentId:t,contentElement:r,enabled:i}){let[o,a]=W(),s=(0,T.useCallback)(()=>{if(!i||!r)return!1;let{body:o}=n(r),a=o.getAttribute(e);return!a||a===t},[o,i,r,e,t]);return(0,T.useEffect)(()=>{if(!i||!t||!r)return;let{body:o}=n(r);if(s())return o.setAttribute(e,t),()=>o.removeAttribute(e);let l=new MutationObserver(()=>(0,tL.flushSync)(a));return l.observe(o,{attributeFilter:[e]}),()=>l.disconnect()},[o,i,t,r,s,e]),s}({attribute:"data-dialog-prevent-body-scroll",contentElement:$,contentId:k,enabled:B&&!ee}),(0,T.useEffect)(()=>{var e,t;if(!R()||!$)return;let o=n($),a=i($),{documentElement:s,body:l}=o,u=s.style.getPropertyValue("--scrollbar-width"),c=u?Number.parseInt(u,10):a.innerWidth-s.clientWidth,d=Math.round(s.getBoundingClientRect().left)+s.scrollLeft?"paddingLeft":"paddingRight",f=D()&&!(r&&navigator.platform.startsWith("Mac")&&!G());return b((e="--scrollbar-width",t=`${c}px`,s?tz(s,e,()=>{let r=s.style.getPropertyValue(e);return s.style.setProperty(e,t),()=>{r?s.style.setProperty(e,r):s.style.removeProperty(e)}}):()=>{}),f?(()=>{var e,t;let{scrollX:r,scrollY:n,visualViewport:i}=a,o=null!=(e=null==i?void 0:i.offsetLeft)?e:0,s=null!=(t=null==i?void 0:i.offsetTop)?t:0,u=t1(l,{position:"fixed",overflow:"hidden",top:`${-(n-Math.floor(s))}px`,left:`${-(r-Math.floor(o))}px`,right:"0",[d]:`${c}px`});return()=>{u(),a.scrollTo({left:r,top:n,behavior:"instant"})}})():t1(l,{overflow:"hidden",[d]:`${c}px`}))},[R,$]),S=tS(_,"open"),I=(0,T.useRef)(null),(0,T.useEffect)(()=>{if(!S){I.current=null;return}return U("mousedown",e=>{I.current=e.target},!0)},[S]),re({...x={store:_,domReady:H,capture:!0},type:"click",listener:e=>{let{contentElement:t}=_.getState(),r=I.current;r&&c(r)&&t7(r,null==t?void 0:t.id)&&rt(m,e)&&_.hide()}}),re({...x,type:"focusin",listener:e=>{let{contentElement:t}=_.getState();!t||e.target===n(t)||rt(m,e)&&_.hide()}}),re({...x,type:"contextmenu",listener:e=>{rt(m,e)&&_.hide()}});let{wrapElement:et,nestedDialogs:er}=function(e){let t=(0,T.useContext)(rr),[r,n]=(0,T.useState)([]),i=(0,T.useCallback)(e=>{var r;return n(t=>[...t,e]),b(null==(r=t.add)?void 0:r.call(t,e),()=>{n(t=>t.filter(t=>t!==e))})},[t]);j(()=>tl(e,["open","contentElement"],r=>{var n;if(r.open&&r.contentElement)return null==(n=t.add)?void 0:n.call(t,e)}),[e,t]);let o=(0,T.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,T.useCallback)(e=>(0,eo.jsx)(rr.Provider,{value:o,children:e}),[o]),nestedDialogs:r}}(_);F=Z(F,et,[et]),j(()=>{if(!K)return;let e=L.current,t=o(e,!0);!t||"BODY"===t.tagName||e&&a(e,t)||_.setDisclosureElement(t)},[_,K]),rc&&(0,T.useEffect)(()=>{if(!q)return;let{disclosureElement:e}=_.getState();if(!e||!l(e))return;let t=()=>{let t=!1,r=()=>{t=!0};e.addEventListener("focusin",r,{capture:!0,once:!0}),J(e,"mouseup",()=>{e.removeEventListener("focusin",r,!0),t||ex(e)})};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},[_,q]),(0,T.useEffect)(()=>{if(!q||!H)return;let e=L.current;if(!e)return;let t=i(e),r=t.visualViewport||t,n=()=>{var r,n;let i=null!=(n=null==(r=t.visualViewport)?void 0:r.height)?n:t.innerHeight;e.style.setProperty("--dialog-viewport-height",`${i}px`)};return n(),r.addEventListener("resize",n),()=>{r.removeEventListener("resize",n)}},[q,H]),(0,T.useEffect)(()=>{if(!d||!q||!H)return;let e=L.current;if(e&&!e.querySelector("[data-dialog-dismiss]")){var t;let r;return t=_.hide,(r=n(e).createElement("button")).type="button",r.tabIndex=-1,r.textContent="Dismiss popup",Object.assign(r.style,{border:"0px",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0px",position:"absolute",whiteSpace:"nowrap",width:"1px"}),r.addEventListener("click",t),e.prepend(r),()=>{r.removeEventListener("click",t),r.remove()}}},[_,d,q,H]),j(()=>{if(!rn()||K||!q||!H)return;let e=L.current;if(e)return ri(e)},[K,q,H]);let en=K&&H;j(()=>{if(k&&en)return function(e,t){let{body:r}=n(t[0]),i=[];return t2(e,t,t=>{i.push(t0(t,t8(e),!0))}),b(t0(r,t8(e),!0),()=>{for(let e of i)e()})}(k,[L.current])},[k,en,M]);let ei=Q(p);j(()=>{if(!k||!en)return;let{disclosureElement:e}=_.getState(),t=[L.current,...ei()||[],...er.map(e=>e.getState().contentElement)];if(d){let e,r;return b(t5(k,t),(e=[],r=t.map(e=>null==e?void 0:e.id),t2(k,t,n=>{t3(n,...r)||!function(e,...t){if(!e)return!1;let r=e.getAttribute("data-focus-trap");return null!=r&&(!t.length||""!==r&&t.some(e=>r===e))}(n,...r)&&e.unshift(ri(n,t))},r=>{!r.hasAttribute("role")||t.some(e=>e&&a(e,r))||e.unshift(t$(r,"role","none"))}),()=>{for(let t of e)t()}))}return t5(k,[e,...t])},[k,_,en,ei,er,d,M]);let ea=!!C,es=Y(C),[el,eu]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!K||!ea||!H||!(null==$?void 0:$.isConnected))return;let e=rd(v,!0)||$.querySelector("[data-autofocus=true],[autofocus]")||function(e,t,r){let[n]=eF(e,t,r);return n||null}($,!0,f&&N)||$,t=eb(e);es(t?e:null)&&(eu(!0),queueMicrotask(()=>{e.focus(),!rc||t&&e.scrollIntoView({block:"nearest",inline:"nearest"})}))},[K,ea,H,$,v,f,N,es]);let ec=!!g,ed=Y(g),[ef,eA]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(K)return eA(!0),()=>eA(!1)},[K]);let eh=(0,T.useCallback)((e,t=!0)=>{let r,{disclosureElement:i}=_.getState();if(!(!(r=o())||e&&a(e,r))&&eb(r))return;let s=rd(y)||i;if(null==s?void 0:s.id){let e=n(s),t=`[aria-activedescendant="${s.id}"]`,r=e.querySelector(t);r&&(s=r)}if(s&&!eb(s)){let e=s.closest("[data-dialog]");if(null==e?void 0:e.id){let t=n(e),r=`[aria-controls~="${e.id}"]`,i=t.querySelector(r);i&&(s=i)}}let l=s&&eb(s);!l&&t?requestAnimationFrame(()=>eh(e,!1)):!ed(l?s:null)||l&&(null==s||s.focus({preventScroll:!0}))},[_,y,ed]),em=(0,T.useRef)(!1);j(()=>{if(K||!ef||!ec)return;let e=L.current;em.current=!0,eh(e)},[K,ef,H,ec,eh]),(0,T.useEffect)(()=>{if(!ef||!ec)return;let e=L.current;return()=>{if(em.current){em.current=!1;return}eh(e)}},[ef,ec,eh]);let ep=Y(h);(0,T.useEffect)(()=>{if(H&&q)return U("keydown",e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=L.current;if(!t||t7(t))return;let r=e.target;if(!r)return;let{disclosureElement:n}=_.getState();!("BODY"===r.tagName||a(t,r)||!n||a(n,r))||ep(e)&&_.hide()},!0)},[_,H,q,ep]);let eB=(F=Z(F,e=>(0,eo.jsx)(tW,{level:d?1:void 0,children:e}),[d])).hidden,eC=F.alwaysVisible;F=Z(F,e=>A?(0,eo.jsxs)(eo.Fragment,{children:[(0,eo.jsx)(rl,{store:_,backdrop:A,hidden:eB,alwaysVisible:eC}),e]}):e,[_,A,eB,eC]);let[eg,ev]=(0,T.useState)(),[ey,eE]=(0,T.useState)();return F=tY({...F={id:k,"data-dialog":"",role:"dialog",tabIndex:u?-1:void 0,"aria-labelledby":eg,"aria-describedby":ey,...F=Z(F,e=>(0,eo.jsx)(eY,{value:_,children:(0,eo.jsx)(eZ.Provider,{value:ev,children:(0,eo.jsx)(ez.Provider,{value:eE,children:e})})}),[_]),ref:X(L,F.ref)},autoFocusOnShow:el}),F=tV({portal:f,...F=eU({...F=tP({store:_,...F}),focusable:u}),portalRef:O,preserveTabOrder:N})});function rA(e,t=eq){return ea(function(r){let n=t();return tS(r.store||n,e=>!r.unmountOnHide||(null==e?void 0:e.mounted)||!!r.open)?(0,eo.jsx)(e,{...r}):null})}rA(ea(function(e){return el("div",rf(e))}),eq);let rh=Math.min,rm=Math.max,rp=Math.round,rB=Math.floor,rC=e=>({x:e,y:e}),rg={left:"right",right:"left",bottom:"top",top:"bottom"},rv={start:"end",end:"start"};function ry(e,t){return"function"==typeof e?e(t):e}function rb(e){return e.split("-")[0]}function rE(e){return e.split("-")[1]}function rM(e){return"x"===e?"y":"x"}function rF(e){return"y"===e?"height":"width"}let rS=new Set(["top","bottom"]);function rR(e){return rS.has(rb(e))?"y":"x"}function rI(e){return e.replace(/start|end/g,e=>rv[e])}let rT=["left","right"],rx=["right","left"],rG=["top","bottom"],rD=["bottom","top"];function rw(e){return e.replace(/left|right|bottom|top/g,e=>rg[e])}function rL(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function r_(e){let{x:t,y:r,width:n,height:i}=e;return{width:n,height:i,top:r,left:t,right:t+n,bottom:r+i,x:t,y:r}}function rO(e,t,r){let n,{reference:i,floating:o}=e,a=rR(t),s=rM(rR(t)),l=rF(s),u=rb(t),c="y"===a,d=i.x+i.width/2-o.width/2,f=i.y+i.height/2-o.height/2,A=i[l]/2-o[l]/2;switch(u){case"top":n={x:d,y:i.y-o.height};break;case"bottom":n={x:d,y:i.y+i.height};break;case"right":n={x:i.x+i.width,y:f};break;case"left":n={x:i.x-o.width,y:f};break;default:n={x:i.x,y:i.y}}switch(rE(t)){case"start":n[s]-=A*(r&&c?-1:1);break;case"end":n[s]+=A*(r&&c?-1:1)}return n}async function rH(e,t){var r;void 0===t&&(t={});let{x:n,y:i,platform:o,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:A=0}=ry(t,e),h=rL(A),m=s[f?"floating"===d?"reference":"floating":d],p=r_(await o.getClippingRect({element:null==(r=await (null==o.isElement?void 0:o.isElement(m)))||r?m:m.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),B="floating"===d?{x:n,y:i,width:a.floating.width,height:a.floating.height}:a.reference,C=await (null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),g=await (null==o.isElement?void 0:o.isElement(C))&&await (null==o.getScale?void 0:o.getScale(C))||{x:1,y:1},v=r_(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:B,offsetParent:C,strategy:l}):B);return{top:(p.top-v.top+h.top)/g.y,bottom:(v.bottom-p.bottom+h.bottom)/g.y,left:(p.left-v.left+h.left)/g.x,right:(v.right-p.right+h.right)/g.x}}let rP=async(e,t,r)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:a}=r,s=o.filter(Boolean),l=await (null==a.isRTL?void 0:a.isRTL(t)),u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:d}=rO(u,n,l),f=n,A={},h=0;for(let r=0;rtypeof window}function rk(e){return rQ(e)?(e.nodeName||"").toLowerCase():"#document"}function rK(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function rj(e){var t;return null==(t=(rQ(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function rQ(e){return!!rN()&&(e instanceof Node||e instanceof rK(e).Node)}function rX(e){return!!rN()&&(e instanceof Element||e instanceof rK(e).Element)}function rV(e){return!!rN()&&(e instanceof HTMLElement||e instanceof rK(e).HTMLElement)}function rq(e){return!(!rN()||"u"{try{return e.matches(t)}catch(e){return!1}})}let r0=["transform","translate","scale","rotate","perspective"],r1=["transform","translate","scale","rotate","perspective","filter"],r9=["paint","layout","strict","content"];function r8(e){let t=r2(),r=rX(e)?r4(e):e;return r0.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||r1.some(e=>(r.willChange||"").includes(e))||r9.some(e=>(r.contain||"").includes(e))}function r2(){return!("u"rX(e)&&"body"!==rk(e)),i=null,o="fixed"===r4(e).position,a=o?r5(e):e;for(;rX(a)&&!r6(a);){let t=r4(a),r=r8(a);r||"fixed"!==t.position||(i=null),(o?!r&&!i:!r&&"static"===t.position&&!!i&&nc.has(i.position)||rY(a)&&!r&&function e(t,r){let n=r5(t);return!(n===r||!rX(n)||r6(n))&&("fixed"===r4(n).position||e(n,r))}(e,a))?n=n.filter(e=>e!==a):i=t,a=r5(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=o[0],s=o.reduce((e,r)=>{let n=nd(t,r,i);return e.top=rm(n.top,e.top),e.right=rh(n.right,e.right),e.bottom=rh(n.bottom,e.bottom),e.left=rm(n.left,e.left),e},nd(t,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:nh,getElementRects:nm,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:r}=nr(e);return{width:t,height:r}},getScale:ni,isElement:rX,isRTL:function(e){return"rtl"===r4(e).direction}};function nB(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nC(e=0,t=0,r=0,n=0){if("function"==typeof DOMRect)return new DOMRect(e,t,r,n);let i={x:e,y:t,width:r,height:n,top:t,right:e+r,bottom:t+n,left:e};return{...i,toJSON:()=>i}}function ng(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function nv(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}var ny=eu(function({store:e,modal:t=!1,portal:r=!!t,preserveTabOrder:n=!0,autoFocusOnShow:i=!0,wrapperProps:o,fixed:a=!1,flip:s=!0,shift:l=0,slide:u=!0,overlap:c=!1,sameWidth:d=!1,fitViewport:f=!1,gutter:A,arrowPadding:h=4,overflowPadding:m=8,getAnchorRect:p,updatePosition:B,...C}){let g=e0();M(e=e||g,!1);let v=e.useState("arrowElement"),y=e.useState("anchorElement"),b=e.useState("disclosureElement"),E=e.useState("popoverElement"),F=e.useState("contentElement"),S=e.useState("placement"),R=e.useState("mounted"),I=e.useState("rendered"),x=(0,T.useRef)(null),[G,D]=(0,T.useState)(!1),{portalRef:w,domReady:L}=z(r,C.portalRef),_=Q(p),O=Q(B),H=!!B;j(()=>{if(!(null==E?void 0:E.isConnected))return;E.style.setProperty("--popover-overflow-padding",`${m}px`);let t={contextElement:y||void 0,getBoundingClientRect:()=>{let e=null==_?void 0:_(y);return e||!y?function(e){if(!e)return nC();let{x:t,y:r,width:n,height:i}=e;return nC(t,r,n,i)}(e):y.getBoundingClientRect()}},r=async()=>{var r,n,i,o,p;let B,C,g;if(!R)return;v||(x.current=x.current||document.createElement("div"));let y=v||x.current,b=[(r={gutter:A,shift:l},void 0===(n=({placement:e})=>{var t;let n=((null==y?void 0:y.clientHeight)||0)/2,i="number"==typeof r.gutter?r.gutter+n:null!=(t=r.gutter)?t:n;return{crossAxis:e.split("-")[1]?void 0:r.shift,mainAxis:i,alignmentAxis:r.shift}})&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:a,middlewareData:s}=e,l=await rU(e,n);return a===(null==(t=s.offset)?void 0:t.placement)&&null!=(r=s.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:a}}}}),function(e){var t;if(!1===e.flip)return;let r="string"==typeof e.flip?e.flip.split(" "):void 0;return M(!r||r.every(ng),!1),{name:"flip",options:t={padding:e.overflowPadding,fallbackPlacements:r},async fn(e){var r,n,i,o,a,s,l,u;let c,d,f,{placement:A,middlewareData:h,rects:m,initialPlacement:p,platform:B,elements:C}=e,{mainAxis:g=!0,crossAxis:v=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:M=!0,...F}=ry(t,e);if(null!=(r=h.arrow)&&r.alignmentOffset)return{};let S=rb(A),R=rR(p),I=rb(p)===p,T=await (null==B.isRTL?void 0:B.isRTL(C.floating)),x=y||(I||!M?[rw(p)]:(c=rw(p),[rI(p),c,rI(c)])),G="none"!==E;!y&&G&&x.push(...(d=rE(p),f=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?rx:rT;return t?rT:rx;case"left":case"right":return t?rG:rD;default:return[]}}(rb(p),"start"===E,T),d&&(f=f.map(e=>e+"-"+d),M&&(f=f.concat(f.map(rI)))),f));let D=[p,...x],w=await B.detectOverflow(e,F),L=[],_=(null==(n=h.flip)?void 0:n.overflows)||[];if(g&&L.push(w[S]),v){let e,t,r,n,i=(s=A,l=m,void 0===(u=T)&&(u=!1),e=rE(s),r=rF(t=rM(rR(s))),n="x"===t?e===(u?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[r]>l.floating[r]&&(n=rw(n)),[n,rw(n)]);L.push(w[i[0]],w[i[1]])}if(_=[..._,{placement:A,overflows:L}],!L.every(e=>e<=0)){let e=((null==(i=h.flip)?void 0:i.index)||0)+1,t=D[e];if(t&&("alignment"!==v||R===rR(t)||_.every(e=>rR(e.placement)!==R||e.overflows[0]>0)))return{data:{index:e,overflows:_},reset:{placement:t}};let r=null==(o=_.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:o.placement;if(!r)switch(b){case"bestFit":{let e=null==(a=_.filter(e=>{if(G){let t=rR(e.placement);return t===R||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:a[0];e&&(r=e);break}case"initialPlacement":r=p}if(A!==r)return{reset:{placement:r}}}return{}}}}({flip:s,overflowPadding:m}),function(e){if(e.slide||e.overlap){var t,r;return{name:"shift",options:r={mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:(void 0===t&&(t={}),{options:t,fn(e){let{x:r,y:n,placement:i,rects:o,middlewareData:a}=e,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=ry(t,e),c={x:r,y:n},d=rR(i),f=rM(d),A=c[f],h=c[d],m=ry(s,e),p="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){let e="y"===f?"height":"width",t=o.reference[f]-o.floating[e]+p.mainAxis,r=o.reference[f]+o.reference[e]-p.mainAxis;Ar&&(A=r)}if(u){var B,C;let e="y"===f?"width":"height",t=rJ.has(rb(i)),r=o.reference[d]-o.floating[e]+(t&&(null==(B=a.offset)?void 0:B[d])||0)+(t?0:p.crossAxis),n=o.reference[d]+o.reference[e]+(t?0:(null==(C=a.offset)?void 0:C[d])||0)-(t?p.crossAxis:0);hn&&(h=n)}return{[f]:A,[d]:h}}})},async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:a=!0,crossAxis:s=!1,limiter:l={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...u}=ry(r,e),c={x:t,y:n},d=await o.detectOverflow(e,u),f=rR(rb(i)),A=rM(f),h=c[A],m=c[f];if(a){let e="y"===A?"top":"left",t="y"===A?"bottom":"right",r=h+d[e],n=h-d[t];h=rm(r,rh(h,n))}if(s){let e="y"===f?"top":"left",t="y"===f?"bottom":"right",r=m+d[e],n=m-d[t];m=rm(r,rh(m,n))}let p=l.fn({...e,[A]:h,[f]:m});return{...p,data:{x:p.x-t,y:p.y-n,enabled:{[A]:a,[f]:s}}}}}}}({slide:u,shift:l,overlap:c,overflowPadding:m}),function(e,t){if(e){let r;return{name:"arrow",options:r={element:e,padding:t.arrowPadding},async fn(e){let{x:t,y:n,placement:i,rects:o,platform:a,elements:s,middlewareData:l}=e,{element:u,padding:c=0}=ry(r,e)||{};if(null==u)return{};let d=rL(c),f={x:t,y:n},A=rM(rR(i)),h=rF(A),m=await a.getDimensions(u),p="y"===A,B=p?"clientHeight":"clientWidth",C=o.reference[h]+o.reference[A]-f[A]-o.floating[h],g=f[A]-o.reference[A],v=await (null==a.getOffsetParent?void 0:a.getOffsetParent(u)),y=v?v[B]:0;y&&await (null==a.isElement?void 0:a.isElement(v))||(y=s.floating[B]||o.floating[h]);let b=y/2-m[h]/2-1,E=rh(d[p?"top":"left"],b),M=rh(d[p?"bottom":"right"],b),F=y-m[h]-M,S=y/2-m[h]/2+(C/2-g/2),R=rm(E,rh(S,F)),I=!l.arrow&&null!=rE(i)&&S!==R&&o.reference[h]/2-(S{},...d}=ry(o,e),f=await l.detectOverflow(e,d),A=rb(a),h=rE(a),m="y"===rR(a),{width:p,height:B}=s.floating;"top"===A||"bottom"===A?(n=A,i=h===(await (null==l.isRTL?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(i=A,n="end"===h?"top":"bottom");let C=B-f.top-f.bottom,g=p-f.left-f.right,v=rh(B-f[n],C),y=rh(p-f[i],g),b=!e.middlewareData.shift,E=v,M=y;if(null!=(t=e.middlewareData.shift)&&t.enabled.x&&(M=g),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(E=C),b&&!h){let e=rm(f.left,0),t=rm(f.right,0),r=rm(f.top,0),n=rm(f.bottom,0);m?M=p-2*(0!==e||0!==t?e+t:rm(f.left,f.right)):E=B-2*(0!==r||0!==n?r+n:rm(f.top,f.bottom))}await c({...e,availableWidth:M,availableHeight:E});let F=await l.getDimensions(u.floating);return p!==F.width||B!==F.height?{reset:{rects:!0}}:{}}}],F=await (p={placement:S,strategy:a?"fixed":"absolute",middleware:b},B=new Map,g={...(C={platform:np,...p}).platform,_c:B},rP(t,E,{...C,platform:g}));null==e||e.setState("currentPlacement",F.placement),D(!0);let I=nv(F.x),T=nv(F.y);if(Object.assign(E.style,{top:"0",left:"0",transform:`translate3d(${I}px,${T}px,0)`}),y&&F.middlewareData.arrow){let{x:e,y:t}=F.middlewareData.arrow,r=F.placement.split("-")[0],n=y.clientWidth/2,i=y.clientHeight/2,o=null!=e?e+n:-n,a=null!=t?t+i:-i;E.style.setProperty("--popover-transform-origin",{top:`${o}px calc(100% + ${i}px)`,bottom:`${o}px ${-i}px`,left:`calc(100% + ${n}px) ${a}px`,right:`${-n}px ${a}px`}[r]),Object.assign(y.style,{left:null!=e?`${e}px`:"",top:null!=t?`${t}px`:"",[r]:"100%"})}},n=function(e,t,r,n){let i;void 0===n&&(n={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:u=!1}=n,c=nn(e),d=o||a?[...c?ne(c):[],...ne(t)]:[];d.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),a&&e.addEventListener("resize",r)});let f=c&&l?function(e,t){let r,n=null,i=rj(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return!function a(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),o();let u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:A}=u;if(s||t(),!f||!A)return;let h={rootMargin:-rB(d)+"px "+-rB(i.clientWidth-(c+f))+"px "+-rB(i.clientHeight-(d+A))+"px "+-rB(c)+"px",threshold:rm(0,rh(1,l))||1},m=!0;function p(t){let n=t[0].intersectionRatio;if(n!==l){if(!m)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||nB(u,e.getBoundingClientRect())||a(),m=!1}try{n=new IntersectionObserver(p,{...h,root:i.ownerDocument})}catch(e){n=new IntersectionObserver(p,h)}n.observe(e)}(!0),o}(c,r):null,A=-1,h=null;s&&(h=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(A),A=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),r()}),c&&!u&&h.observe(c),h.observe(t));let m=u?ns(e):null;return u&&function t(){let n=ns(e);m&&!nB(m,n)&&r(),m=n,i=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{o&&e.removeEventListener("scroll",r),a&&e.removeEventListener("resize",r)}),null==f||f(),null==(e=h)||e.disconnect(),h=null,u&&cancelAnimationFrame(i)}}(t,E,async()=>{H?(await O({updatePosition:r}),D(!0)):await r()},{elementResize:"function"==typeof ResizeObserver});return()=>{D(!1),n()}},[e,I,E,v,y,E,S,R,L,a,s,l,u,c,d,f,A,h,m,_,H,O]),j(()=>{if(!R||!L||!(null==E?void 0:E.isConnected)||!(null==F?void 0:F.isConnected))return;let e=()=>{E.style.zIndex=getComputedStyle(F).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[R,L,E,F]);let P=a?"fixed":"absolute";return C=Z(C,t=>(0,eo.jsx)("div",{...o,style:{position:P,top:0,left:0,width:"max-content",...null==o?void 0:o.style},ref:null==e?void 0:e.setPopoverElement,children:t}),[e,P,o]),C={"data-placing":!G||void 0,...C=Z(C,t=>(0,eo.jsx)(e9,{value:e,children:t}),[e]),style:{position:"relative",...C.style}},C=rf({store:e,modal:t,portal:r,preserveTabOrder:n,preserveTabOrderAnchor:b||y,autoFocusOnShow:G&&i,...C,portalRef:w})});rA(ea(function(e){return el("div",ny(e))}),e0);var nb=eu(function({store:e,modal:t,tabIndex:r,alwaysVisible:i,autoFocusOnHide:o=!0,hideOnInteractOutside:a=!0,...s}){let l=e7();M(e=e||l,!1);let u=e.useState("baseElement"),c=(0,T.useRef)(!1),d=tS(e.tag,e=>null==e?void 0:e.renderedItems.length);return s=tU({store:e,alwaysVisible:i,...s}),s=ny({store:e,modal:t,alwaysVisible:i,backdrop:!1,autoFocusOnShow:!1,finalFocus:u,preserveTabOrderAnchor:null,unstable_treeSnapshotKey:d,...s,getPersistentElements(){var r;let i=(null==(r=s.getPersistentElements)?void 0:r.call(s))||[];if(!t||!e)return i;let{contentElement:o,baseElement:a}=e.getState();if(!a)return i;let l=n(a),u=[];if((null==o?void 0:o.id)&&u.push(`[aria-controls~="${o.id}"]`),(null==a?void 0:a.id)&&u.push(`[aria-controls~="${a.id}"]`),!u.length)return[...i,a];let c=u.join(",");return[...i,...l.querySelectorAll(c)]},autoFocusOnHide:e=>!F(o,e)&&(!c.current||(c.current=!1,!1)),hideOnInteractOutside(t){var r,n;let i=null==e?void 0:e.getState(),o=null==(r=null==i?void 0:i.contentElement)?void 0:r.id,s=null==(n=null==i?void 0:i.baseElement)?void 0:n.id;if(function(e,...t){if(!e)return!1;if("id"in e){let r=t.filter(Boolean).map(e=>`[aria-controls~="${e}"]`).join(", ");return!!r&&e.matches(r)}return!1}(t.target,o,s))return!1;let l="function"==typeof a?a(t):a;return l&&(c.current="click"===t.type),l}})}),nE=rA(ea(function(e){return el("div",nb(e))}),e7);e.s(["ComboboxPopover",()=>nE],1559),(0,T.createContext)(null),(0,T.createContext)(null);var nM=ec([ep],[eB]),nF=nM.useContext;nM.useScopedContext,nM.useProviderContext,nM.ContextProvider,nM.ScopedContextProvider;var nS={id:null};function nR(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function nI(e,t){return e.filter(e=>e.rowId===t)}function nT(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}function nx(e){let t=0;for(let{length:r}of e)r>t&&(t=r);return t}var nG=w()&&G();function nD({tag:e,...t}={}){let r=td(t.store,function(e,...t){if(e)return tn(e,"pick")(...t)}(e,["value","rtl"]));tf(t,r);let i=null==e?void 0:e.getState(),o=null==r?void 0:r.getState(),a=I(t.activeId,null==o?void 0:o.activeId,t.defaultActiveId,null),s=function(e={}){var t;let r=null==(t=e.store)?void 0:t.getState(),i=function(e={}){var t,r;tf(e,e.store);let i=null==(t=e.store)?void 0:t.getState(),o=I(e.items,null==i?void 0:i.items,e.defaultItems,[]),a=new Map(o.map(e=>[e.id,e])),s={items:o,renderedItems:I(null==i?void 0:i.renderedItems,[])},l=null==(r=e.store)?void 0:r.__unstablePrivateStore,u=ti({items:o,renderedItems:s.renderedItems},l),c=ti(s,e.store),d=e=>{var t;let r,n,i=(t=e=>e.element,r=e.map((e,t)=>[t,e]),n=!1,(r.sort(([e,r],[i,o])=>{var a;let s=t(r),l=t(o);return s!==l&&s&&l?(a=s,l.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)?(e>i&&(n=!0),-1):(et):e);u.setState("renderedItems",i),c.setState("renderedItems",i)};to(c,()=>ta(u)),to(u,()=>tu(u,["items"],e=>{c.setState("items",e.items)})),to(u,()=>tu(u,["renderedItems"],e=>{let t=!0,r=requestAnimationFrame(()=>{let{renderedItems:t}=c.getState();e.renderedItems!==t&&d(e.renderedItems)});if("function"!=typeof IntersectionObserver)return()=>cancelAnimationFrame(r);let i=new IntersectionObserver(()=>{if(t){t=!1;return}cancelAnimationFrame(r),r=requestAnimationFrame(()=>d(e.renderedItems))},{root:function(e){var t;let r=e.find(e=>!!e.element),i=[...e].reverse().find(e=>!!e.element),o=null==(t=null==r?void 0:r.element)?void 0:t.parentElement;for(;o&&(null==i?void 0:i.element);){let e=o;if(i&&e.contains(i.element))return o;o=o.parentElement}return n(o).body}(e.renderedItems)});for(let t of e.renderedItems)t.element&&i.observe(t.element);return()=>{cancelAnimationFrame(r),i.disconnect()}}));let f=(e,t,r=!1)=>{let n;return t(t=>{let r=t.findIndex(({id:t})=>t===e.id),i=t.slice();if(-1!==r){let o={...n=t[r],...e};i[r]=o,a.set(e.id,o)}else i.push(e),a.set(e.id,e);return i}),()=>{t(t=>{if(!n)return r&&a.delete(e.id),t.filter(({id:t})=>t!==e.id);let i=t.findIndex(({id:t})=>t===e.id);if(-1===i)return t;let o=t.slice();return o[i]=n,a.set(e.id,n),o})}},A=e=>f(e,e=>u.setState("items",e),!0);return{...c,registerItem:A,renderItem:e=>b(A(e),f(e,e=>u.setState("renderedItems",e))),item:e=>{if(!e)return null;let t=a.get(e);if(!t){let{items:r}=u.getState();(t=r.find(t=>t.id===e))&&a.set(e,t)}return t||null},__unstablePrivateStore:u}}(e),o=I(e.activeId,null==r?void 0:r.activeId,e.defaultActiveId),a=ti({...i.getState(),id:I(e.id,null==r?void 0:r.id,`id-${Math.random().toString(36).slice(2,8)}`),activeId:o,baseElement:I(null==r?void 0:r.baseElement,null),includesBaseElement:I(e.includesBaseElement,null==r?void 0:r.includesBaseElement,null===o),moves:I(null==r?void 0:r.moves,0),orientation:I(e.orientation,null==r?void 0:r.orientation,"both"),rtl:I(e.rtl,null==r?void 0:r.rtl,!1),virtualFocus:I(e.virtualFocus,null==r?void 0:r.virtualFocus,!1),focusLoop:I(e.focusLoop,null==r?void 0:r.focusLoop,!1),focusWrap:I(e.focusWrap,null==r?void 0:r.focusWrap,!1),focusShift:I(e.focusShift,null==r?void 0:r.focusShift,!1)},i,e.store);to(a,()=>tl(a,["renderedItems","activeId"],e=>{a.setState("activeId",t=>{var r;return void 0!==t?t:null==(r=nR(e.renderedItems))?void 0:r.id})}));let s=(e="next",t={})=>{var r,n;let i=a.getState(),{skip:o=0,activeId:s=i.activeId,focusShift:l=i.focusShift,focusLoop:u=i.focusLoop,focusWrap:c=i.focusWrap,includesBaseElement:d=i.includesBaseElement,renderedItems:f=i.renderedItems,rtl:A=i.rtl}=t,h="up"===e||"down"===e,m="next"===e||"down"===e,p=h?eN(function(e,t,r){let n=nx(e);for(let i of e)for(let e=0;ee.id===s);if(!B)return null==(n=nR(p))?void 0:n.id;let C=p.some(e=>e.rowId),g=p.indexOf(B),v=p.slice(g+1),y=nI(v,B.rowId);if(o){let e=y.filter(e=>s?!e.disabled&&e.id!==s:!e.disabled),t=e.slice(o)[0]||e[e.length-1];return null==t?void 0:t.id}let b=u&&(h?"horizontal"!==u:"vertical"!==u),E=C&&c&&(h?"horizontal"!==c:"vertical"!==c),M=m?(!C||h)&&b&&d:!!h&&d;if(b){let e=nR(function(e,t,r=!1){let n=e.findIndex(e=>e.id===t);return[...e.slice(n+1),...r?[nS]:[],...e.slice(0,n)]}(E&&!M?p:nI(p,B.rowId),s,M),s);return null==e?void 0:e.id}if(E){let e=nR(M?y:v,s);return M?(null==e?void 0:e.id)||null:null==e?void 0:e.id}let F=nR(y,s);return!F&&M?null:null==F?void 0:F.id};return{...i,...a,setBaseElement:e=>a.setState("baseElement",e),setActiveId:e=>a.setState("activeId",e),move:e=>{void 0!==e&&(a.setState("activeId",e),a.setState("moves",e=>e+1))},first:()=>{var e;return null==(e=nR(a.getState().renderedItems))?void 0:e.id},last:()=>{var e;return null==(e=nR(ek(a.getState().renderedItems)))?void 0:e.id},next:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("next",e)),previous:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("previous",e)),down:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("down",e)),up:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("up",e))}}({...t,activeId:a,includesBaseElement:I(t.includesBaseElement,null==o?void 0:o.includesBaseElement,!0),orientation:I(t.orientation,null==o?void 0:o.orientation,"vertical"),focusLoop:I(t.focusLoop,null==o?void 0:o.focusLoop,!0),focusWrap:I(t.focusWrap,null==o?void 0:o.focusWrap,!0),virtualFocus:I(t.virtualFocus,null==o?void 0:o.virtualFocus,!0)}),l=function({popover:e,...t}={}){let r=td(t.store,tc(e,["arrowElement","anchorElement","contentElement","popoverElement","disclosureElement"]));tf(t,r);let n=null==r?void 0:r.getState(),i=ru({...t,store:r}),o=I(t.placement,null==n?void 0:n.placement,"bottom"),a=ti({...i.getState(),placement:o,currentPlacement:o,anchorElement:I(null==n?void 0:n.anchorElement,null),popoverElement:I(null==n?void 0:n.popoverElement,null),arrowElement:I(null==n?void 0:n.arrowElement,null),rendered:Symbol("rendered")},i,r);return{...i,...a,setAnchorElement:e=>a.setState("anchorElement",e),setPopoverElement:e=>a.setState("popoverElement",e),setArrowElement:e=>a.setState("arrowElement",e),render:()=>a.setState("rendered",Symbol("rendered"))}}({...t,placement:I(t.placement,null==o?void 0:o.placement,"bottom-start")}),u=I(t.value,null==o?void 0:o.value,t.defaultValue,""),c=I(t.selectedValue,null==o?void 0:o.selectedValue,null==i?void 0:i.values,t.defaultSelectedValue,""),d=Array.isArray(c),f={...s.getState(),...l.getState(),value:u,selectedValue:c,resetValueOnSelect:I(t.resetValueOnSelect,null==o?void 0:o.resetValueOnSelect,d),resetValueOnHide:I(t.resetValueOnHide,null==o?void 0:o.resetValueOnHide,d&&!e),activeValue:null==o?void 0:o.activeValue},A=ti(f,s,l,r);return nG&&to(A,()=>tl(A,["virtualFocus"],()=>{A.setState("virtualFocus",!1)})),to(A,()=>{if(e)return b(tl(A,["selectedValue"],t=>{Array.isArray(t.selectedValue)&&e.setValues(t.selectedValue)}),tl(e,["values"],e=>{A.setState("selectedValue",e.values)}))}),to(A,()=>tl(A,["resetValueOnHide","mounted"],e=>{!e.resetValueOnHide||e.mounted||A.setState("value",u)})),to(A,()=>tl(A,["open"],e=>{e.open||(A.setState("activeId",a),A.setState("moves",0))})),to(A,()=>tl(A,["moves","activeId"],(e,t)=>{e.moves===t.moves&&A.setState("activeValue",void 0)})),to(A,()=>tu(A,["moves","renderedItems"],(e,t)=>{if(e.moves===t.moves)return;let{activeId:r}=A.getState(),n=s.item(r);A.setState("activeValue",null==n?void 0:n.value)})),{...l,...s,...A,tag:e,setValue:e=>A.setState("value",e),resetValue:()=>A.setState("value",f.value),setSelectedValue:e=>A.setState("selectedValue",e)}}function nw(e={}){var t,r,n,i,o,a,s,l;let u;t=e,u=nF();let[c,d]=tT(nD,e={id:V((r=t={...t,tag:void 0!==t.tag?t.tag:u}).id),...r});return q(d,[(n=e).tag]),tI(c,n,"value","setValue"),tI(c,n,"selectedValue","setSelectedValue"),tI(c,n,"resetValueOnHide"),tI(c,n,"resetValueOnSelect"),Object.assign((a=c,q(s=d,[(l=n).popover]),tI(a,l,"placement"),i=ra(a,s,l),o=i,q(d,[n.store]),tI(o,n,"items","setItems"),tI(i=o,n,"activeId","setActiveId"),tI(i,n,"includesBaseElement"),tI(i,n,"virtualFocus"),tI(i,n,"orientation"),tI(i,n,"rtl"),tI(i,n,"focusLoop"),tI(i,n,"focusWrap"),tI(i,n,"focusShift"),i),{tag:n.tag})}function nL(e={}){let t=nw(e);return(0,eo.jsx)(e5,{value:t,children:e.children})}e.s(["useComboboxStore",()=>nw],18364),e.s(["ComboboxProvider",()=>nL],78440);var n_=(0,T.createContext)(void 0),nO=eu(function(e){let[t,r]=(0,T.useState)();return R(e={role:"group","aria-labelledby":t,...e=Z(e,e=>(0,eo.jsx)(n_.Provider,{value:r,children:e}),[])})});ea(function(e){return el("div",nO(e))});var nH=eu(function({store:e,...t}){return nO(t)});ea(function(e){return el("div",nH(e))});var nP=eu(function({store:e,...t}){let r=e4();return M(e=e||r,!1),"grid"===h(e.useState("contentElement"))&&(t={role:"rowgroup",...t}),t=nH({store:e,...t})}),nJ=ea(function(e){return el("div",nP(e))});e.s(["ComboboxGroup",()=>nJ],59129);var nU=eu(function(e){let t=(0,T.useContext)(n_),r=V(e.id);return j(()=>(null==t||t(r),()=>null==t?void 0:t(void 0)),[t,r]),R(e={id:r,"aria-hidden":!0,...e})});ea(function(e){return el("div",nU(e))});var nN=eu(function({store:e,...t}){return nU(t)});ea(function(e){return el("div",nN(e))});var nk=eu(function(e){return nN(e)}),nK=ea(function(e){return el("div",nk(e))});e.s(["ComboboxGroupLabel",()=>nK],25998);var nj=e.i(38360);let nQ={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},nX=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function nV(e,t,r={}){let{keys:n,threshold:i=nQ.MATCHES,baseSort:o=nX,sorter:a=e=>e.sort((e,t)=>(function(e,t,r){let{rank:n,keyIndex:i}=e,{rank:o,keyIndex:a}=t;return n!==o?n>o?-1:1:i===a?r(e,t):i{let s=nq(i,u,c),l=t,{minRanking:d,maxRanking:f,threshold:A}=o;return s=nQ.MATCHES?s=d:s>f&&(s=f),s>e&&(e=s,r=a,n=A,l=i),{rankedValue:l,rank:e,keyIndex:r,keyThreshold:n}},{rankedValue:s,rank:nQ.NO_MATCH,keyIndex:-1,keyThreshold:c.threshold}):{rankedValue:s,rank:nq(s,u,c),keyIndex:-1,keyThreshold:c.threshold}),{rank:f,keyThreshold:A=i}=d;return f>=A&&e.push({...d,item:o,index:a}),e},[])).map(({item:e})=>e)}function nq(e,t,r){if(e=nW(e,r),(t=nW(t,r)).length>e.length)return nQ.NO_MATCH;if(e===t)return nQ.CASE_SENSITIVE_EQUAL;let n=function*(e,t){let r=-1;for(;(r=e.indexOf(t,r+1))>-1;)yield r;return -1}(e=e.toLowerCase(),t=t.toLowerCase()),i=n.next(),o=i.value;if(e.length===t.length&&0===o)return nQ.EQUAL;if(0===o)return nQ.STARTS_WITH;let a=i;for(;!a.done;){if(a.value>0&&" "===e[a.value-1])return nQ.WORD_STARTS_WITH;a=n.next()}return o>0?nQ.CONTAINS:1===t.length?nQ.NO_MATCH:(function(e){let t="",r=" ";for(let n=0;n-1))return nQ.NO_MATCH;return r=o-s,n=i/t.length,nQ.MATCHES+1/r*n}(e,t)}function nW(e,{keepDiacritics:t}){return e=`${e}`,t||(e=(0,nj.default)(e)),e}nV.rankings=nQ;let nY={maxRanking:1/0,minRanking:-1/0};e.s(["matchSorter",()=>nV],70238)},29402,(e,t,r)=>{var n,i,o,a,s="__lodash_hash_undefined__",l=1/0,u="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",A="[object Error]",h="[object Function]",m="[object Map]",p="[object Number]",B="[object Object]",C="[object Promise]",g="[object RegExp]",v="[object Set]",y="[object String]",b="[object Symbol]",E="[object WeakMap]",M="[object ArrayBuffer]",F="[object DataView]",S=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,R=/^\w*$/,I=/^\./,T=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,x=/\\(\\)?/g,G=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,w={};w["[object Float32Array]"]=w["[object Float64Array]"]=w["[object Int8Array]"]=w["[object Int16Array]"]=w["[object Int32Array]"]=w["[object Uint8Array]"]=w["[object Uint8ClampedArray]"]=w["[object Uint16Array]"]=w["[object Uint32Array]"]=!0,w[u]=w[c]=w[M]=w[d]=w[F]=w[f]=w[A]=w[h]=w[m]=w[p]=w[B]=w[g]=w[v]=w[y]=w[E]=!1;var L=e.g&&e.g.Object===Object&&e.g,_="object"==typeof self&&self&&self.Object===Object&&self,O=L||_||Function("return this")(),H=r&&!r.nodeType&&r,P=H&&t&&!t.nodeType&&t,J=P&&P.exports===H&&L.process,U=function(){try{return J&&J.binding("util")}catch(e){}}(),N=U&&U.isTypedArray;function k(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},eb.prototype.set=function(e,t){var r=this.__data__,n=eS(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},eE.prototype.clear=function(){this.__data__={hash:new ey,map:new(el||eb),string:new ey}},eE.prototype.delete=function(e){return eL(this,e).delete(e)},eE.prototype.get=function(e){return eL(this,e).get(e)},eE.prototype.has=function(e){return eL(this,e).has(e)},eE.prototype.set=function(e,t){return eL(this,e).set(e,t),this},eM.prototype.add=eM.prototype.push=function(e){return this.__data__.set(e,s),this},eM.prototype.has=function(e){return this.__data__.has(e)},eF.prototype.clear=function(){this.__data__=new eb},eF.prototype.delete=function(e){return this.__data__.delete(e)},eF.prototype.get=function(e){return this.__data__.get(e)},eF.prototype.has=function(e){return this.__data__.has(e)},eF.prototype.set=function(e,t){var r=this.__data__;if(r instanceof eb){var n=r.__data__;if(!el||n.length<199)return n.push([e,t]),this;r=this.__data__=new eE(n)}return r.set(e,t),this};var eR=(n=function(e,t){return e&&eI(e,t,e0)},function(e,t){if(null==e)return e;if(!eV(e))return n(e,t);for(var r=e.length,i=-1,o=Object(e);++is))return!1;var u=o.get(e);if(u&&o.get(t))return u==t;var c=-1,d=!0,f=1&i?new eM:void 0;for(o.set(e,t),o.set(t,e);++c-1&&e%1==0&&e-1&&e%1==0&&e<=0x1fffffffffffff}function eY(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eZ(e){return!!e&&"object"==typeof e}function ez(e){return"symbol"==typeof e||eZ(e)&&ee.call(e)==b}var e$=N?K(N):function(e){return eZ(e)&&eW(e.length)&&!!w[ee.call(e)]};function e0(e){return eV(e)?function(e,t){var r=eX(e)||eQ(e)?function(e,t){for(var r=-1,n=Array(e);++rt||o&&a&&l&&!s&&!u||n&&a&&l||!r&&l||!i)return 1;if(!n&&!o&&!u&&e=s)return l;return l*("desc"==r[n]?-1:1)}}return e.index-t.index}(e,t,r)});l--;)s[l]=s[l].value;return s}(e,t,r))}},97442,e=>{e.v({Group:"MissionSelect-module__N_AIjG__Group",GroupLabel:"MissionSelect-module__N_AIjG__GroupLabel",Input:"MissionSelect-module__N_AIjG__Input",InputWrapper:"MissionSelect-module__N_AIjG__InputWrapper",Item:"MissionSelect-module__N_AIjG__Item",ItemHeader:"MissionSelect-module__N_AIjG__ItemHeader",ItemMissionName:"MissionSelect-module__N_AIjG__ItemMissionName",ItemName:"MissionSelect-module__N_AIjG__ItemName",ItemType:"MissionSelect-module__N_AIjG__ItemType",ItemTypes:"MissionSelect-module__N_AIjG__ItemTypes",List:"MissionSelect-module__N_AIjG__List",NoResults:"MissionSelect-module__N_AIjG__NoResults",Popover:"MissionSelect-module__N_AIjG__Popover",SelectedName:"MissionSelect-module__N_AIjG__SelectedName",SelectedValue:"MissionSelect-module__N_AIjG__SelectedValue",Shortcut:"MissionSelect-module__N_AIjG__Shortcut"})},81405,(e,t,r)=>{var n;e.e,(n=function(){function e(e){return i.appendChild(e.dom),e}function t(e){for(var t=0;ta+1e3&&(l.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:i,setMode:t}}).Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),s=80*a,l=48*a,u=3*a,c=2*a,d=3*a,f=15*a,A=74*a,h=30*a,m=document.createElement("canvas");m.width=s,m.height=l,m.style.cssText="width:80px;height:48px";var p=m.getContext("2d");return p.font="bold "+9*a+"px Helvetica,Arial,sans-serif",p.textBaseline="top",p.fillStyle=r,p.fillRect(0,0,s,l),p.fillStyle=t,p.fillText(e,u,c),p.fillRect(d,f,A,h),p.fillStyle=r,p.globalAlpha=.9,p.fillRect(d,f,A,h),{dom:m,update:function(l,B){n=Math.min(n,l),i=Math.max(i,l),p.fillStyle=r,p.globalAlpha=1,p.fillRect(0,0,s,f),p.fillStyle=t,p.fillText(o(l)+" "+e+" ("+o(n)+"-"+o(i)+")",u,c),p.drawImage(m,d+a,f,A-a,h,d,f,A-a,h),p.fillRect(d+A-a,f,a,h),p.fillStyle=r,p.globalAlpha=.9,p.fillRect(d+A-a,f,a,o((1-l/B)*h))}}},t.exports=n},55141,e=>{e.v({AxisLabel:"DebugElements-module__Cmeo9W__AxisLabel",StatsPanel:"DebugElements-module__Cmeo9W__StatsPanel"})},86855,e=>{"use strict";var t=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(40859),i=i,o=i,a=e.i(81405);function s(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}function l({showPanel:e=0,className:t,parent:r}){let l=function(e,t=[],r){let[i,o]=n.useState();return n.useLayoutEffect(()=>{let t=e();return o(t),s(void 0,t),()=>s(void 0,null)},t),i}(()=>new a.default,[]);return n.useEffect(()=>{if(l){let n=r&&r.current||document.body;l.showPanel(e),null==n||n.appendChild(l.dom);let a=(null!=t?t:"").split(" ").filter(e=>e);a.length&&l.dom.classList.add(...a);let s=(0,i.j)(()=>l.begin()),u=(0,o.k)(()=>l.end());return()=>{a.length&&l.dom.classList.remove(...a),null==n||n.removeChild(l.dom),s(),u()}}},[r,l,t,e]),null}var u=e.i(60099),c=e.i(79123),d=e.i(55141);function f(){let e,i,o=(0,r.c)(3),{debugMode:a}=(0,c.useDebug)(),s=(0,n.useRef)(null);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=s.current;e&&e.setColors("rgb(153, 255, 0)","rgb(0, 153, 255)","rgb(255, 153, 0)")},o[0]=e):e=o[0],(0,n.useEffect)(e),o[1]!==a?(i=a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l,{className:d.default.StatsPanel}),(0,t.jsx)("axesHelper",{ref:s,args:[70],renderOrder:999,children:(0,t.jsx)("lineBasicMaterial",{depthTest:!1,depthWrite:!1,fog:!1,vertexColors:!0})}),(0,t.jsx)(u.Html,{position:[80,0,0],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"y",children:"Y"})}),(0,t.jsx)(u.Html,{position:[0,80,0],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"z",children:"Z"})}),(0,t.jsx)(u.Html,{position:[0,0,80],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"x",children:"X"})})]}):null,o[1]=a,o[2]=i):i=o[2],i}e.s(["DebugElements",()=>f],86855)},38847,e=>{"use strict";var t=e.i(80902),r=e.i(22289),n=e.i(71645);function i(e,t,n){try{return e(t)}catch(e){return(0,r.l)("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":""),t,e,n),null}}function o(e){function t(t){if(void 0===t)return null;let r="";if(Array.isArray(t)){if(void 0===t[0])return null;r=t[0]}return"string"==typeof t&&(r=t),i(e.parse,r)}return{type:"single",eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide:r=>t(r)??e}},withOptions(e){return{...this,...e}}}}o({parse:e=>e,serialize:String}),o({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),o({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),o({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(1&t.length?"0":"")+t}}),o({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});let a=o({parse:e=>"true"===e.toLowerCase(),serialize:String});function s(e,t){return e.valueOf()===t.valueOf()}o({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:s}),o({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:s}),o({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:s});let l=(0,t.r)(),u={};function c(e,r,n,o,a,s){let l=!1,u=Object.entries(e).reduce((e,[u,c])=>{var d;let f=r?.[u]??u,A=o[f],h="multi"===c.type?[]:null,m=void 0===A?("multi"===c.type?n?.getAll(f):n?.get(f))??h:A;return a&&s&&((d=a[f]??h)===m||null!==d&&null!==m&&"string"!=typeof d&&"string"!=typeof m&&d.length===m.length&&d.every((e,t)=>e===m[t]))?e[u]=s[u]??null:(l=!0,e[u]=((0,t.i)(m)?null:i(c.parse,m,f))??null,a&&(a[f]=m)),e},{});if(!l){let t=Object.keys(e),r=Object.keys(s??{});l=t.length!==r.length||t.some(e=>!r.includes(e))}return{state:u,hasChanged:l}}function d(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,e[r]??t[r]??null]))}function f(e,i={}){let{parse:o,type:a,serialize:s,eq:A,defaultValue:h,...m}=i,[{[e]:p},B]=function(e,i={}){let o=(0,n.useId)(),a=(0,r.i)(),s=(0,r.a)(),{history:f="replace",scroll:A=a?.scroll??!1,shallow:h=a?.shallow??!0,throttleMs:m=t.s.timeMs,limitUrlUpdates:p=a?.limitUrlUpdates,clearOnDefault:B=a?.clearOnDefault??!0,startTransition:C,urlKeys:g=u}=i,v=Object.keys(e).join(","),y=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(e=>[e,g[e]??e])),[v,JSON.stringify(g)]),b=(0,r.r)(Object.values(y)),E=b.searchParams,M=(0,n.useRef)({}),F=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(t=>[t,e[t].defaultValue??null])),[Object.values(e).map(({defaultValue:e})=>e).join(",")]),S=t.t.useQueuedQueries(Object.values(y)),[R,I]=(0,n.useState)(()=>c(e,g,E??new URLSearchParams,S).state),T=(0,n.useRef)(R);if((0,r.c)("[nuq+ %s `%s`] render - state: %O, iSP: %s",o,v,R,E),Object.keys(M.current).join("&")!==Object.values(y).join("&")){let{state:t,hasChanged:n}=c(e,g,E,S,M.current,T.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,v,{state:t,initialSearchParams:E,queuedQueries:S,queryRef:M.current,stateRef:T.current}),T.current=t,I(t)),M.current=Object.fromEntries(Object.entries(y).map(([t,r])=>[r,e[t]?.type==="multi"?E?.getAll(r):E?.get(r)??null]))}(0,n.useEffect)(()=>{let{state:t,hasChanged:n}=c(e,g,E,S,M.current,T.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,v,{state:t,initialSearchParams:E,queuedQueries:S,queryRef:M.current,stateRef:T.current}),T.current=t,I(t))},[Object.values(y).map(e=>`${e}=${E?.getAll(e)}`).join("&"),JSON.stringify(S)]),(0,n.useEffect)(()=>{let t=Object.keys(e).reduce((t,n)=>(t[n]=({state:t,query:i})=>{I(a=>{let{defaultValue:s}=e[n],l=y[n],u=t??s??null;return Object.is(a[n]??s??null,u)?((0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",o,v,l,t,s,T.current),a):(T.current={...T.current,[n]:u},M.current[l]=i,(0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",o,v,l,t,s,T.current),T.current)})},t),{});for(let n of Object.keys(e)){let e=y[n];(0,r.c)("[nuq+ %s `%s`] Subscribing to sync for `%s`",o,e,v),l.on(e,t[n])}return()=>{for(let n of Object.keys(e)){let e=y[n];(0,r.c)("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",o,e,v),l.off(e,t[n])}}},[v,y]);let x=(0,n.useCallback)((n,i={})=>{let a,u=Object.fromEntries(Object.keys(e).map(e=>[e,null])),c="function"==typeof n?n(d(T.current,F))??u:n??u;(0,r.c)("[nuq+ %s `%s`] setState: %O",o,v,c);let g=0,E=!1,M=[];for(let[n,o]of Object.entries(c)){let u=e[n],c=y[n];if(!u||void 0===o)continue;(i.clearOnDefault??u.clearOnDefault??B)&&null!==o&&void 0!==u.defaultValue&&(u.eq??((e,t)=>e===t))(o,u.defaultValue)&&(o=null);let d=null===o?null:(u.serialize??String)(o);l.emit(c,{state:o,query:d});let v={key:c,query:d,options:{history:i.history??u.history??f,shallow:i.shallow??u.shallow??h,scroll:i.scroll??u.scroll??A,startTransition:i.startTransition??u.startTransition??C}};if(i?.limitUrlUpdates?.method==="debounce"||p?.method==="debounce"||u.limitUrlUpdates?.method==="debounce"){!0===v.options.shallow&&console.warn((0,r.s)(422));let e=i?.limitUrlUpdates?.timeMs??p?.timeMs??u.limitUrlUpdates?.timeMs??t.s.timeMs,n=t.t.push(v,e,b,s);gt(e),E?t.n.flush(b,s):t.n.getPendingPromise(b));return a??S},[v,f,h,A,m,p?.method,p?.timeMs,C,y,b.updateUrl,b.getSearchParamsSnapshot,b.rateLimitFactor,s,F]);return[(0,n.useMemo)(()=>d(R,F),[R,F]),x]}({[e]:{parse:o??(e=>e),type:a,serialize:s,eq:A,defaultValue:h}},m);return[p,(0,n.useCallback)((t,r={})=>B(r=>({[e]:"function"==typeof t?t(r[e]):t}),r),[e,B])]}e.s(["createParser",()=>o,"parseAsBoolean",()=>a,"useQueryState",()=>f],38847)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/ca289845e0f08110.js b/docs/_next/static/chunks/ca289845e0f08110.js new file mode 100644 index 00000000..24b4d621 --- /dev/null +++ b/docs/_next/static/chunks/ca289845e0f08110.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,78462,e=>{e.v({PlayPause:"DemoPlaybackControls-module__A_AHSq__PlayPause",Root:"DemoPlaybackControls-module__A_AHSq__Root",Seek:"DemoPlaybackControls-module__A_AHSq__Seek",Speed:"DemoPlaybackControls-module__A_AHSq__Speed",Time:"DemoPlaybackControls-module__A_AHSq__Time"})},94737,e=>{"use strict";var t=e.i(43476),a=e.i(932),o=e.i(71645),n=e.i(32865),l=e.i(78462);let r=[.25,.5,1,2,4];function s(e){let t=Math.floor(e/60),a=Math.floor(e%60);return`${t}:${a.toString().padStart(2,"0")}`}function i(){let e,i,_,p,P,f,g,y,S,b,A,C,k=(0,a.c)(33),T=(0,n.useRecording)(),h=(0,n.useIsPlaying)(),v=(0,n.useCurrentTime)(),N=(0,n.useDuration)(),D=(0,n.useSpeed)(),{play:w,pause:x,seek:E,setSpeed:j}=(0,n.usePlaybackActions)();k[0]!==h||k[1]!==x||k[2]!==w||k[3]!==T?(e=()=>{if(!T)return;let e=e=>{if("Space"!==e.code)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||"BUTTON"===t.tagName||t.isContentEditable||(e.preventDefault(),h?x():w())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},i=[T,h,w,x],k[0]=h,k[1]=x,k[2]=w,k[3]=T,k[4]=e,k[5]=i):(e=k[4],i=k[5]),(0,o.useEffect)(e,i),k[6]!==E?(_=e=>{E(parseFloat(e.target.value))},k[6]=E,k[7]=_):_=k[7];let R=_;k[8]!==j?(p=e=>{j(parseFloat(e.target.value))},k[8]=j,k[9]=p):p=k[9];let q=p;if(!T||!Number.isFinite(T.duration))return null;let H=h?x:w,U=h?"Pause":"Play",$=h?"❚❚":"▶";k[10]!==H||k[11]!==U||k[12]!==$?(P=(0,t.jsx)("button",{className:l.default.PlayPause,onClick:H,"aria-label":U,children:$}),k[10]=H,k[11]=U,k[12]=$,k[13]=P):P=k[13],k[14]!==v?(f=s(v),k[14]=v,k[15]=f):f=k[15],k[16]!==N?(g=s(N),k[16]=N,k[17]=g):g=k[17];let B=`${f} / ${g}`;return k[18]!==B?(y=(0,t.jsx)("span",{className:l.default.Time,children:B}),k[18]=B,k[19]=y):y=k[19],k[20]!==v||k[21]!==N||k[22]!==R?(S=(0,t.jsx)("input",{className:l.default.Seek,type:"range",min:0,max:N,step:.01,value:v,onChange:R}),k[20]=v,k[21]=N,k[22]=R,k[23]=S):S=k[23],k[24]===Symbol.for("react.memo_cache_sentinel")?(b=r.map(u),k[24]=b):b=k[24],k[25]!==q||k[26]!==D?(A=(0,t.jsx)("select",{className:l.default.Speed,value:D,onChange:q,children:b}),k[25]=q,k[26]=D,k[27]=A):A=k[27],k[28]!==y||k[29]!==S||k[30]!==A||k[31]!==P?(C=(0,t.jsxs)("div",{className:l.default.Root,onKeyDown:m,onPointerDown:d,onClick:c,children:[P,y,S,A]}),k[28]=y,k[29]=S,k[30]=A,k[31]=P,k[32]=C):C=k[32],C}function u(e){return(0,t.jsxs)("option",{value:e,children:[e,"x"]},e)}function c(e){return e.stopPropagation()}function d(e){return e.stopPropagation()}function m(e){return e.stopPropagation()}e.s(["DemoPlaybackControls",()=>i])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/d96f10e4606ed566.js b/docs/_next/static/chunks/d96f10e4606ed566.js deleted file mode 100644 index 76a9dd5b..00000000 --- a/docs/_next/static/chunks/d96f10e4606ed566.js +++ /dev/null @@ -1,609 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,13070,e=>{e.v({Arrow:"KeyboardOverlay-module__HsRBsa__Arrow",Column:"KeyboardOverlay-module__HsRBsa__Column",Key:"KeyboardOverlay-module__HsRBsa__Key",Root:"KeyboardOverlay-module__HsRBsa__Root",Row:"KeyboardOverlay-module__HsRBsa__Row",Spacer:"KeyboardOverlay-module__HsRBsa__Spacer"})},78295,e=>{e.v({Joystick:"TouchControls-module__AkxfgW__Joystick",Left:"TouchControls-module__AkxfgW__Left TouchControls-module__AkxfgW__Joystick",Right:"TouchControls-module__AkxfgW__Right TouchControls-module__AkxfgW__Joystick"})},65883,e=>{e.v({ButtonLabel:"InspectorControls-module__gNRB6W__ButtonLabel",CheckboxField:"InspectorControls-module__gNRB6W__CheckboxField",Controls:"InspectorControls-module__gNRB6W__Controls",Dropdown:"InspectorControls-module__gNRB6W__Dropdown",Field:"InspectorControls-module__gNRB6W__Field",Group:"InspectorControls-module__gNRB6W__Group",IconButton:"InspectorControls-module__gNRB6W__IconButton",LabelledButton:"InspectorControls-module__gNRB6W__LabelledButton",MapInfoButton:"InspectorControls-module__gNRB6W__MapInfoButton InspectorControls-module__gNRB6W__IconButton InspectorControls-module__gNRB6W__LabelledButton",MissionSelectWrapper:"InspectorControls-module__gNRB6W__MissionSelectWrapper",Toggle:"InspectorControls-module__gNRB6W__Toggle InspectorControls-module__gNRB6W__IconButton"})},36679,e=>{e.v({ButtonLabel:"CopyCoordinatesButton-module__BxovtG__ButtonLabel "+e.i(65883).ButtonLabel,ClipboardCheck:"CopyCoordinatesButton-module__BxovtG__ClipboardCheck",MapPin:"CopyCoordinatesButton-module__BxovtG__MapPin",Root:"CopyCoordinatesButton-module__BxovtG__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton,showClipboardCheck:"CopyCoordinatesButton-module__BxovtG__showClipboardCheck"})},76775,(e,t,a)=>{function r(e,t,a,r){return Math.round(e/a)+" "+r+(t>=1.5*a?"s":"")}t.exports=function(e,t){t=t||{};var a,n,i,o,s=typeof e;if("string"===s&&e.length>0){var l=e;if(!((l=String(l)).length>100)){var c=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(l);if(c){var d=parseFloat(c[1]);switch((c[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*d;case"weeks":case"week":case"w":return 6048e5*d;case"days":case"day":case"d":return 864e5*d;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*d;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*d;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*d;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:break}}}return}if("number"===s&&isFinite(e)){return t.long?(n=Math.abs(a=e))>=864e5?r(a,n,864e5,"day"):n>=36e5?r(a,n,36e5,"hour"):n>=6e4?r(a,n,6e4,"minute"):n>=1e3?r(a,n,1e3,"second"):a+" ms":(o=Math.abs(i=e))>=864e5?Math.round(i/864e5)+"d":o>=36e5?Math.round(i/36e5)+"h":o>=6e4?Math.round(i/6e4)+"m":o>=1e3?Math.round(i/1e3)+"s":i+"ms"}throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7003,(e,t,a)=>{t.exports=function(t){function a(e){let t,n,i,o=null;function s(...e){if(!s.enabled)return;let r=Number(new Date);s.diff=r-(t||r),s.prev=t,s.curr=r,t=r,e[0]=a.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let n=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return"%";n++;let i=a.formatters[r];if("function"==typeof i){let a=e[n];t=i.call(s,a),e.splice(n,1),n--}return t}),a.formatArgs.call(s,e),(s.log||a.log).apply(s,e)}return s.namespace=e,s.useColors=a.useColors(),s.color=a.selectColor(e),s.extend=r,s.destroy=a.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(n!==a.namespaces&&(n=a.namespaces,i=a.enabled(e)),i),set:e=>{o=e}}),"function"==typeof a.init&&a.init(s),s}function r(e,t){let r=a(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function n(e,t){let a=0,r=0,n=-1,i=0;for(;a"-"+e)].join(",");return a.enable(""),e},a.enable=function(e){for(let t of(a.save(e),a.namespaces=e,a.names=[],a.skips=[],("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean)))"-"===t[0]?a.skips.push(t.slice(1)):a.names.push(t)},a.enabled=function(e){for(let t of a.skips)if(n(e,t))return!1;for(let t of a.names)if(n(e,t))return!0;return!1},a.humanize=e.r(76775),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(t).forEach(e=>{a[e]=t[e]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(e){let t=0;for(let a=0;a{let r;var n=e.i(47167);a.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(n=r))}),e.splice(n,0,a)},a.save=function(e){try{e?a.storage.setItem("debug",e):a.storage.removeItem("debug")}catch(e){}},a.load=function(){let e;try{e=a.storage.getItem("debug")||a.storage.getItem("DEBUG")}catch(e){}return!e&&void 0!==n.default&&"env"in n.default&&(e=n.default.env.DEBUG),e},a.useColors=function(){let e;return"u">typeof window&&!!window.process&&("renderer"===window.process.type||!!window.process.__nwjs)||!("u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("u">typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"u">typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"u">typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"u">typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch(e){}}(),r=!1,a.destroy=()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))},a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),t.exports=e.r(7003)(a);let{formatters:i}=t.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},28903,e=>{e.v({ButtonLabel:"LoadDemoButton-module__kGZaoW__ButtonLabel "+e.i(65883).ButtonLabel,DemoIcon:"LoadDemoButton-module__kGZaoW__DemoIcon",Root:"LoadDemoButton-module__kGZaoW__Root "+e.i(65883).IconButton+" "+e.i(65883).LabelledButton})},29418,e=>{e.v({Bottom:"PlayerNameplate-module__zYDm0a__Bottom PlayerNameplate-module__zYDm0a__Root",HealthBar:"PlayerNameplate-module__zYDm0a__HealthBar",HealthFill:"PlayerNameplate-module__zYDm0a__HealthFill",IffArrow:"PlayerNameplate-module__zYDm0a__IffArrow",Name:"PlayerNameplate-module__zYDm0a__Name",Root:"PlayerNameplate-module__zYDm0a__Root",Top:"PlayerNameplate-module__zYDm0a__Top PlayerNameplate-module__zYDm0a__Root"})},78779,e=>{e.v({Distance:"FlagMarker-module__INpLba__Distance",Icon:"FlagMarker-module__INpLba__Icon",Root:"FlagMarker-module__INpLba__Root"})},21629,e=>{e.v({PlayPause:"DemoControls-module__PjV4fq__PlayPause",Root:"DemoControls-module__PjV4fq__Root",Seek:"DemoControls-module__PjV4fq__Seek",Speed:"DemoControls-module__PjV4fq__Speed",Time:"DemoControls-module__PjV4fq__Time"})},75840,e=>{e.v({BarFillEnergy:"PlayerHUD-module__-E1Scq__BarFillEnergy",BarFillHealth:"PlayerHUD-module__-E1Scq__BarFillHealth",BarTrack:"PlayerHUD-module__-E1Scq__BarTrack",Bars:"PlayerHUD-module__-E1Scq__Bars",ChatColor0:"PlayerHUD-module__-E1Scq__ChatColor0",ChatColor1:"PlayerHUD-module__-E1Scq__ChatColor1",ChatColor2:"PlayerHUD-module__-E1Scq__ChatColor2",ChatColor3:"PlayerHUD-module__-E1Scq__ChatColor3",ChatColor4:"PlayerHUD-module__-E1Scq__ChatColor4",ChatColor5:"PlayerHUD-module__-E1Scq__ChatColor5",ChatColor6:"PlayerHUD-module__-E1Scq__ChatColor6",ChatColor7:"PlayerHUD-module__-E1Scq__ChatColor7",ChatColor8:"PlayerHUD-module__-E1Scq__ChatColor8",ChatColor9:"PlayerHUD-module__-E1Scq__ChatColor9",ChatMessage:"PlayerHUD-module__-E1Scq__ChatMessage",ChatWindow:"PlayerHUD-module__-E1Scq__ChatWindow",Compass:"PlayerHUD-module__-E1Scq__Compass",CompassNSEW:"PlayerHUD-module__-E1Scq__CompassNSEW",CompassRing:"PlayerHUD-module__-E1Scq__CompassRing",PackInvCount:"PlayerHUD-module__-E1Scq__PackInvCount",PackInvIcon:"PlayerHUD-module__-E1Scq__PackInvIcon",PackInvInfinity:"PlayerHUD-module__-E1Scq__PackInvInfinity",PackInvItem:"PlayerHUD-module__-E1Scq__PackInvItem",PackInvItemActive:"PlayerHUD-module__-E1Scq__PackInvItemActive",PackInvItemDim:"PlayerHUD-module__-E1Scq__PackInvItemDim",PackInventoryHUD:"PlayerHUD-module__-E1Scq__PackInventoryHUD",PlayerHUD:"PlayerHUD-module__-E1Scq__PlayerHUD",Reticle:"PlayerHUD-module__-E1Scq__Reticle",ReticleDot:"PlayerHUD-module__-E1Scq__ReticleDot",ReticleImage:"PlayerHUD-module__-E1Scq__ReticleImage",TeamCount:"PlayerHUD-module__-E1Scq__TeamCount",TeamNameEnemy:"PlayerHUD-module__-E1Scq__TeamNameEnemy",TeamNameFriendly:"PlayerHUD-module__-E1Scq__TeamNameFriendly",TeamRow:"PlayerHUD-module__-E1Scq__TeamRow",TeamScore:"PlayerHUD-module__-E1Scq__TeamScore",TeamScores:"PlayerHUD-module__-E1Scq__TeamScores",TopRight:"PlayerHUD-module__-E1Scq__TopRight",WeaponHUD:"PlayerHUD-module__-E1Scq__WeaponHUD",WeaponSeparator:"PlayerHUD-module__-E1Scq__WeaponSeparator"})},3011,e=>{e.v({CanvasContainer:"page-module__E0kJGG__CanvasContainer",LoadingIndicator:"page-module__E0kJGG__LoadingIndicator",Progress:"page-module__E0kJGG__Progress",ProgressBar:"page-module__E0kJGG__ProgressBar",ProgressText:"page-module__E0kJGG__ProgressText",Spinner:"page-module__E0kJGG__Spinner",loadingComplete:"page-module__E0kJGG__loadingComplete",spin:"page-module__E0kJGG__spin"})},31713,e=>{"use strict";var t,a=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(75056),o=e.i(90072),s=e.i(66027),l=e.i(54970),c=e.i(12979),d=e.i(32424),u=e.i(71753),h=e.i(15080),m=e.i(62395),f=e.i(75567),g=e.i(47071);let p={value:!0},y=` -vec3 terrainLinearToSRGB(vec3 linear) { - vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055; - vec3 lower = linear * 12.92; - return mix(lower, higher, step(vec3(0.0031308), linear)); -} - -vec3 terrainSRGBToLinear(vec3 srgb) { - vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4)); - vec3 lower = srgb / 12.92; - return mix(lower, higher, step(vec3(0.04045), srgb)); -} - -// Debug grid overlay using screen-space derivatives for sharp, anti-aliased lines -// Returns 1.0 on grid lines, 0.0 elsewhere -float terrainDebugGrid(vec2 uv, float gridSize, float lineWidth) { - vec2 scaledUV = uv * gridSize; - vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); - float line = min(grid.x, grid.y); - return 1.0 - min(line / lineWidth, 1.0); -} -`;var v=e.i(79123),F=e.i(47021),b=e.i(48066);let S={0:32,1:32,2:32,3:32,4:32,5:32};function x({displacementMap:e,visibilityMask:t,textureNames:r,alphaTextures:i,detailTextureName:s,lightmap:l}){let{debugMode:d}=(0,v.useDebug)(),u=(0,g.useTexture)(r.map(e=>(0,c.terrainTextureToUrl)(e)),e=>{e.forEach(e=>(0,f.setupTexture)(e))}),h=s?(0,c.textureToUrl)(s):null,m=(0,g.useTexture)(h??c.FALLBACK_TEXTURE_URL,e=>{(0,f.setupTexture)(e)}),x=(0,n.useCallback)(e=>{!function({shader:e,baseTextures:t,alphaTextures:a,visibilityMask:r,tiling:n,detailTexture:i=null,lightmap:o=null}){e.uniforms.sunLightPointsDown=p;let s=t.length;if(t.forEach((t,a)=>{e.uniforms[`albedo${a}`]={value:t}}),a.forEach((t,a)=>{e.uniforms[`mask${a}`]={value:t}}),r&&(e.uniforms.visibilityMask={value:r}),t.forEach((t,a)=>{e.uniforms[`tiling${a}`]={value:n[a]??32}}),o&&(e.uniforms.terrainLightmap={value:o}),i&&(e.uniforms.detailTexture={value:i},e.uniforms.detailTiling={value:64},e.uniforms.detailFadeDistance={value:150},e.vertexShader=e.vertexShader.replace("#include ",`#include -varying vec3 vTerrainWorldPos;`),e.vertexShader=e.vertexShader.replace("#include ",`#include -vTerrainWorldPos = (modelMatrix * vec4(transformed, 1.0)).xyz;`)),e.fragmentShader=` -uniform sampler2D albedo0; -uniform sampler2D albedo1; -uniform sampler2D albedo2; -uniform sampler2D albedo3; -uniform sampler2D albedo4; -uniform sampler2D albedo5; -uniform sampler2D mask0; -uniform sampler2D mask1; -uniform sampler2D mask2; -uniform sampler2D mask3; -uniform sampler2D mask4; -uniform sampler2D mask5; -uniform float tiling0; -uniform float tiling1; -uniform float tiling2; -uniform float tiling3; -uniform float tiling4; -uniform float tiling5; -${r?"uniform sampler2D visibilityMask;":""} -${o?"uniform sampler2D terrainLightmap;":""} -uniform bool sunLightPointsDown; -${i?`uniform sampler2D detailTexture; -uniform float detailTiling; -uniform float detailFadeDistance; -varying vec3 vTerrainWorldPos;`:""} - -${y} - -// Global variable to store shadow factor from RE_Direct for use in output calculation -float terrainShadowFactor = 1.0; -`+e.fragmentShader,r){let t="#include ";e.fragmentShader=e.fragmentShader.replace(t,`${t} - // Early discard for invisible areas (before fog/lighting) - float visibility = texture2D(visibilityMask, vMapUv).r; - if (visibility < 0.5) { - discard; - } - `)}e.fragmentShader=e.fragmentShader.replace("#include ",` - // Sample base albedo layers (sRGB textures auto-decoded to linear by Three.js) - vec2 baseUv = vMapUv; - vec3 c0 = texture2D(albedo0, baseUv * vec2(tiling0)).rgb; - ${s>1?"vec3 c1 = texture2D(albedo1, baseUv * vec2(tiling1)).rgb;":""} - ${s>2?"vec3 c2 = texture2D(albedo2, baseUv * vec2(tiling2)).rgb;":""} - ${s>3?"vec3 c3 = texture2D(albedo3, baseUv * vec2(tiling3)).rgb;":""} - ${s>4?"vec3 c4 = texture2D(albedo4, baseUv * vec2(tiling4)).rgb;":""} - ${s>5?"vec3 c5 = texture2D(albedo5, baseUv * vec2(tiling5)).rgb;":""} - - // Sample alpha masks for all layers (use R channel) - // Add +0.5 texel offset: Torque samples alpha at grid corners (integer indices), - // but GPU linear filtering samples at texel centers. This offset aligns them. - vec2 alphaUv = baseUv + vec2(0.5 / 256.0); - float a0 = texture2D(mask0, alphaUv).r; - ${s>1?"float a1 = texture2D(mask1, alphaUv).r;":""} - ${s>2?"float a2 = texture2D(mask2, alphaUv).r;":""} - ${s>3?"float a3 = texture2D(mask3, alphaUv).r;":""} - ${s>4?"float a4 = texture2D(mask4, alphaUv).r;":""} - ${s>5?"float a5 = texture2D(mask5, alphaUv).r;":""} - - // Torque-style additive weighted blending (blender.cc): - // result = tex0 * alpha0 + tex1 * alpha1 + tex2 * alpha2 + ... - // Each layer's alpha map defines its contribution weight. - vec3 blended = c0 * a0; - ${s>1?"blended += c1 * a1;":""} - ${s>2?"blended += c2 * a2;":""} - ${s>3?"blended += c3 * a3;":""} - ${s>4?"blended += c4 * a4;":""} - ${s>5?"blended += c5 * a5;":""} - - // Assign to diffuseColor before lighting - vec3 textureColor = blended; - - ${i?`// Detail texture blending (Torque-style multiplicative blend) - // Sample detail texture at high frequency tiling - vec3 detailColor = texture2D(detailTexture, baseUv * detailTiling).rgb; - - // Calculate distance-based fade factor using world positions - // Torque: distFactor = (zeroDetailDistance - distance) / zeroDetailDistance - float distToCamera = distance(vTerrainWorldPos, cameraPosition); - float detailFade = clamp(1.0 - distToCamera / detailFadeDistance, 0.0, 1.0); - - // Torque blending: dst * lerp(1.0, detailTexel, fadeFactor) - // Detail textures are authored with bright values (~0.8 mean), not 0.5 gray - // Direct multiplication adds subtle darkening for surface detail - textureColor *= mix(vec3(1.0), detailColor, detailFade);`:""} - - // Store blended texture in diffuseColor (still in linear space here) - // We'll convert to sRGB in the output calculation - diffuseColor.rgb = textureColor; -`),o&&(e.fragmentShader=e.fragmentShader.replace("#include ",`#include - -// Override RE_Direct to extract shadow factor for Torque-style gamma-space lighting -#undef RE_Direct -void RE_Direct_TerrainShadow( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { - // Torque lighting (terrLighting.cc): if light points up, terrain gets only ambient - // This prevents shadow acne from light hitting terrain backfaces - if (!sunLightPointsDown) { - terrainShadowFactor = 0.0; - return; - } - // directLight.color = sunColor * shadowFactor (shadow already applied by Three.js) - // Extract shadow factor by comparing to original sun color - #if ( NUM_DIR_LIGHTS > 0 ) - vec3 originalSunColor = directionalLights[0].color; - float sunMax = max(max(originalSunColor.r, originalSunColor.g), originalSunColor.b); - float shadowedMax = max(max(directLight.color.r, directLight.color.g), directLight.color.b); - terrainShadowFactor = clamp(shadowedMax / max(sunMax, 0.001), 0.0, 1.0); - #endif - // Don't add to reflectedLight - we'll compute lighting in gamma space at output -} -#define RE_Direct RE_Direct_TerrainShadow - -`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include -// Clear indirect diffuse - we'll compute ambient in gamma space -#if defined( RE_IndirectDiffuse ) - irradiance = vec3(0.0); -#endif -`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include - // Clear Three.js lighting - we compute everything in gamma space - reflectedLight.directDiffuse = vec3(0.0); - reflectedLight.indirectDiffuse = vec3(0.0); -`)),e.fragmentShader=e.fragmentShader.replace("#include ",`// Torque-style terrain lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space -{ - // Get texture in sRGB space (undo Three.js linear decode) - vec3 textureSRGB = terrainLinearToSRGB(diffuseColor.rgb); - - ${o?` - // Sample terrain lightmap for smooth NdotL - vec2 lightmapUv = vMapUv + vec2(0.5 / 512.0); - float lightmapNdotL = texture2D(terrainLightmap, lightmapUv).r; - - // Get sun and ambient colors from Three.js lights (these ARE sRGB values from mission file) - // Three.js interprets them as linear, but the numerical values are preserved - #if ( NUM_DIR_LIGHTS > 0 ) - vec3 sunColorSRGB = directionalLights[0].color; - #else - vec3 sunColorSRGB = vec3(0.7); - #endif - vec3 ambientColorSRGB = ambientLightColor; - - // Torque formula (terrLighting.cc:471-483): - // lighting = ambient + NdotL * shadowFactor * sunColor - // Clamp lighting to [0,1] before multiplying by texture - vec3 lightingSRGB = clamp(ambientColorSRGB + lightmapNdotL * terrainShadowFactor * sunColorSRGB, 0.0, 1.0); - `:` - // No lightmap - use simple ambient lighting - vec3 lightingSRGB = ambientLightColor; - `} - - // Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space - vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0); - - // Convert back to linear for Three.js output pipeline - outgoingLight = terrainSRGBToLinear(resultSRGB) + totalEmissiveRadiance; -} -#include `),e.fragmentShader=e.fragmentShader.replace("#include ",`#if DEBUG_MODE - // Debug mode: overlay green grid matching terrain grid squares (256x256) - float gridIntensity = terrainDebugGrid(vMapUv, 256.0, 1.5); - vec3 gridColor = vec3(0.0, 0.8, 0.4); // Green - gl_FragColor.rgb = mix(gl_FragColor.rgb, gridColor, gridIntensity * 0.1); -#endif - -#include `)}({shader:e,baseTextures:u,alphaTextures:i,visibilityMask:t,tiling:S,detailTexture:h?m:null,lightmap:l}),(0,F.injectCustomFog)(e,b.globalFogUniforms)},[u,i,t,m,h,l]),k=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=k.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!d,e.needsUpdate=!0)},[d]);let w=`${h?"detail":"nodetail"}-${l?"lightmap":"nolightmap"}`;return(0,a.jsx)("meshLambertMaterial",{ref:k,map:e,depthWrite:!0,side:o.FrontSide,defines:{DEBUG_MODE:+!!d},onBeforeCompile:x},w)}function k(e){let t,i,o=(0,r.c)(8),{displacementMap:s,visibilityMask:l,textureNames:c,alphaTextures:d,detailTextureName:u,lightmap:h}=e;return o[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("meshLambertMaterial",{color:"rgb(0, 109, 56)",wireframe:!0}),o[0]=t):t=o[0],o[1]!==d||o[2]!==u||o[3]!==s||o[4]!==h||o[5]!==c||o[6]!==l?(i=(0,a.jsx)(n.Suspense,{fallback:t,children:(0,a.jsx)(x,{displacementMap:s,visibilityMask:l,textureNames:c,alphaTextures:d,detailTextureName:u,lightmap:h})}),o[1]=d,o[2]=u,o[3]=s,o[4]=h,o[5]=c,o[6]=l,o[7]=i):i=o[7],i}let w=(0,n.memo)(function(e){let t,n,i,o=(0,r.c)(15),{tileX:s,tileZ:l,blockSize:c,basePosition:d,textureNames:u,geometry:h,displacementMap:m,visibilityMask:f,alphaTextures:g,detailTextureName:p,lightmap:y,visible:v}=e,F=void 0===v||v,b=c/2,S=d.x+s*c+b,x=d.z+l*c+b;o[0]!==S||o[1]!==x?(t=[S,0,x],o[0]=S,o[1]=x,o[2]=t):t=o[2];let w=t;return o[3]!==g||o[4]!==p||o[5]!==m||o[6]!==y||o[7]!==u||o[8]!==f?(n=(0,a.jsx)(k,{displacementMap:m,visibilityMask:f,textureNames:u,alphaTextures:g,detailTextureName:p,lightmap:y}),o[3]=g,o[4]=p,o[5]=m,o[6]=y,o[7]=u,o[8]=f,o[9]=n):n=o[9],o[10]!==h||o[11]!==w||o[12]!==n||o[13]!==F?(i=(0,a.jsx)("mesh",{position:w,geometry:h,castShadow:!0,receiveShadow:!0,visible:F,children:n}),o[10]=h,o[11]=w,o[12]=n,o[13]=F,o[14]=i):i=o[14],i});e.i(13876);var I=e.i(58647);function C(e){return(0,I.useRuntimeObjectByName)(e)}let _=null;function P(e){let t=new Uint8Array(65536);for(let a of(t.fill(255),e)){let e=255&a,r=a>>8&255,n=a>>16,i=256*r;for(let a=0;a0?n:(t[0]!==a?(e=(0,m.getFloat)(a,"visibleDistance")??600,t[0]=a,t[1]=e):e=t[1],e)}(),X=(0,h.useThree)(M),Z=-(128*W);V[6]!==Z?(d={x:Z,z:Z},V[6]=Z,V[7]=d):d=V[7];let J=d;if(V[8]!==q){let e=(0,m.getProperty)(q,"emptySquares");f=e?e.split(" ").map(T):[],V[8]=q,V[9]=f}else f=V[9];let Q=f,{data:ee}=((O=(0,r.c)(2))[0]!==H?(z={queryKey:["terrain",H],queryFn:()=>(0,c.loadTerrain)(H)},O[0]=H,O[1]=z):z=O[1],(0,s.useQuery)(z));e:{let e;if(!ee){g=null;break e}let t=256*W;V[10]!==t||V[11]!==W||V[12]!==ee.heightMap?(!function(e,t,a){let r=e.attributes.position,n=e.attributes.uv,i=e.attributes.normal,o=r.array,s=n.array,l=i.array,c=r.count,d=(e,a)=>(e=Math.max(0,Math.min(255,e)),t[256*(a=Math.max(0,Math.min(255,a)))+e]/65535*2048),u=(e,a)=>{let r=Math.floor(e=Math.max(0,Math.min(255,e))),n=Math.floor(a=Math.max(0,Math.min(255,a))),i=Math.min(r+1,255),o=Math.min(n+1,255),s=e-r,l=a-n;return(t[256*n+r]/65535*2048*(1-s)+t[256*n+i]/65535*2048*s)*(1-l)+(t[256*o+r]/65535*2048*(1-s)+t[256*o+i]/65535*2048*s)*l};for(let e=0;e0?(f/=y,g/=y,p/=y):(f=0,g=1,p=0),l[3*e]=f,l[3*e+1]=g,l[3*e+2]=p}r.needsUpdate=!0,i.needsUpdate=!0}(e=function(e,t){let a=new o.BufferGeometry,r=new Float32Array(198147),n=new Float32Array(198147),i=new Float32Array(132098),s=new Uint32Array(393216),l=0,c=e/256;for(let t=0;t<=256;t++)for(let a=0;a<=256;a++){let o=257*t+a;r[3*o]=a*c-e/2,r[3*o+1]=e/2-t*c,r[3*o+2]=0,n[3*o]=0,n[3*o+1]=0,n[3*o+2]=1,i[2*o]=a/256,i[2*o+1]=1-t/256}for(let e=0;e<256;e++)for(let t=0;t<256;t++){let a=257*e+t,r=a+1,n=(e+1)*257+t,i=n+1;((t^e)&1)==0?(s[l++]=a,s[l++]=n,s[l++]=i,s[l++]=a,s[l++]=i,s[l++]=r):(s[l++]=a,s[l++]=n,s[l++]=r,s[l++]=r,s[l++]=n,s[l++]=i)}return a.setIndex(new o.BufferAttribute(s,1)),a.setAttribute("position",new o.Float32BufferAttribute(r,3)),a.setAttribute("normal",new o.Float32BufferAttribute(n,3)),a.setAttribute("uv",new o.Float32BufferAttribute(i,2)),a.rotateX(-Math.PI/2),a.rotateY(-Math.PI/2),a}(t,0),ee.heightMap,W),V[10]=t,V[11]=W,V[12]=ee.heightMap,V[13]=e):e=V[13],g=e}let et=g;V[14]!==W||V[15]!==ee?(p=()=>{if(ee){var e;return e=ee.heightMap,_=(t,a)=>{let r=Math.max(0,Math.min(255,a/W+128)),n=Math.max(0,Math.min(255,t/W+128)),i=Math.floor(r),o=Math.floor(n),s=Math.min(i+1,255),l=Math.min(o+1,255),c=r-i,d=n-o;return((e[256*o+i]*(1-c)+e[256*o+s]*c)*(1-d)+(e[256*l+i]*(1-c)+e[256*l+s]*c)*d)/65535*2048},E}},y=[ee,W],V[14]=W,V[15]=ee,V[16]=p,V[17]=y):(p=V[16],y=V[17]),(0,n.useEffect)(p,y);let ea=C("Sun");t:{let e,t;if(!ea){let e;V[18]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector3(.57735,-.57735,.57735),V[18]=e):e=V[18],v=e;break t}V[19]!==ea?(e=((0,m.getProperty)(ea,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(B),V[19]=ea,V[20]=e):e=V[20];let[a,r,n]=e,i=Math.sqrt(a*a+n*n+r*r),s=a/i,l=n/i,c=r/i;V[21]!==s||V[22]!==l||V[23]!==c?(t=new o.Vector3(s,l,c),V[21]=s,V[22]=l,V[23]=c,V[24]=t):t=V[24],v=t}let er=v;a:{let e;if(!ee){F=null;break a}V[25]!==W||V[26]!==er||V[27]!==ee.heightMap?(e=function(e,t,a){let r=(t,a)=>{let r=Math.max(0,Math.min(255,t)),n=Math.max(0,Math.min(255,a)),i=Math.floor(r),o=Math.floor(n),s=Math.min(i+1,255),l=Math.min(o+1,255),c=r-i,d=n-o;return((e[256*o+i]/65535*(1-c)+e[256*o+s]/65535*c)*(1-d)+(e[256*l+i]/65535*(1-c)+e[256*l+s]/65535*c)*d)*2048},n=new o.Vector3(-t.x,-t.y,-t.z).normalize(),i=new Uint8Array(262144);for(let e=0;e<512;e++)for(let t=0;t<512;t++){let o=t/2+.25,s=e/2+.25,l=r(o,s),c=r(o-.5,s),d=r(o+.5,s),u=r(o,s-.5),h=-((r(o,s+.5)-u)/1),m=-((d-c)/1),f=Math.sqrt(h*h+a*a+m*m),g=Math.max(0,h/f*n.x+a/f*n.y+m/f*n.z),p=1;g>0&&(p=function(e,t,a,r,n,i){let o=r.z/n,s=r.x/n,l=r.y,c=Math.sqrt(o*o+s*s);if(c<1e-4)return 1;let d=.5/c,u=o*d,h=s*d,m=l*d,f=e,g=t,p=a+.1;for(let e=0;e<768&&(f+=u,g+=h,p+=m,!(f<0)&&!(f>=256)&&!(g<0)&&!(g>=256)&&!(p>2048));e++)if(pArray(ed).fill(null),V[38]=ed,V[39]=D):D=V[39];let[eh,em]=(0,n.useState)(D);V[40]===Symbol.for("react.memo_cache_sentinel")?(N={xStart:0,xEnd:0,zStart:0,zEnd:0},V[40]=N):N=V[40];let ef=(0,n.useRef)(N);return(V[41]!==J.x||V[42]!==J.z||V[43]!==Y||V[44]!==X.position.x||V[45]!==X.position.z||V[46]!==ed||V[47]!==K?(A=()=>{let e=X.position.x-J.x,t=X.position.z-J.z,a=Math.floor((e-K)/Y),r=Math.ceil((e+K)/Y),n=Math.floor((t-K)/Y),i=Math.ceil((t+K)/Y),o=ef.current;if(a===o.xStart&&r===o.xEnd&&n===o.zStart&&i===o.zEnd)return;o.xStart=a,o.xEnd=r,o.zStart=n,o.zEnd=i;let s=[];for(let e=a;e{let t=eh[e];return(0,a.jsx)(w,{tileX:t?.tileX??0,tileZ:t?.tileZ??0,blockSize:Y,basePosition:J,textureNames:ee.textureNames,geometry:et,displacementMap:ei,visibilityMask:es,alphaTextures:el,detailTextureName:$,lightmap:en,visible:null!==t},e)}),V[59]=J,V[60]=Y,V[61]=$,V[62]=eu,V[63]=el,V[64]=ei,V[65]=et,V[66]=ee.textureNames,V[67]=en,V[68]=eh,V[69]=U):U=V[69],V[70]!==G||V[71]!==U?(L=(0,a.jsxs)(a.Fragment,{children:[G,U]}),V[70]=G,V[71]=U,V[72]=L):L=V[72],L):null});function M(e){return e.camera}function T(e){return parseInt(e,10)}function E(){_=null}function B(e){return parseFloat(e)}function j(e){return(0,f.setupMask)(e)}function R(e,t){return t}let N=(0,n.createContext)(null);function A(){return(0,n.useContext)(N)}function G(e){return(0,a.jsx)(eM,{objectId:e},e)}var U=e.i(8597),L=e.i(78140),z=e.i(89887);let O=` -vec3 interiorLinearToSRGB(vec3 linear) { - vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055; - vec3 lower = linear * 12.92; - return mix(lower, higher, step(vec3(0.0031308), linear)); -} - -vec3 interiorSRGBToLinear(vec3 srgb) { - vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4)); - vec3 lower = srgb / 12.92; - return mix(lower, higher, step(vec3(0.04045), srgb)); -} - -// Debug grid overlay function using screen-space derivatives for sharp, anti-aliased lines -// Returns 1.0 on grid lines, 0.0 elsewhere -float debugGrid(vec2 uv, float gridSize, float lineWidth) { - vec2 scaledUV = uv * gridSize; - vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); - float line = min(grid.x, grid.y); - return 1.0 - min(line / lineWidth, 1.0); -} -`;function V({materialName:e,material:t,lightMap:r}){let i=(0,v.useDebug)(),s=i?.debugMode??!1,l=(0,c.textureToUrl)(e),d=(0,g.useTexture)(l,e=>(0,f.setupTexture)(e)),u=new Set(t?.userData?.flag_names??[]).has("SelfIlluminating"),h=new Set(t?.userData?.surface_flag_names??[]).has("SurfaceOutsideVisible"),m=(0,n.useCallback)(e=>{let t;(0,F.injectCustomFog)(e,b.globalFogUniforms),t=h??!1,e.uniforms.useSceneLighting={value:t},e.uniforms.interiorDebugColor={value:t?new o.Vector3(0,.4,1):new o.Vector3(1,.2,0)},e.fragmentShader=e.fragmentShader.replace("#include ",`#include -${O} -uniform bool useSceneLighting; -uniform vec3 interiorDebugColor; -`),e.fragmentShader=e.fragmentShader.replace("#include ",`// Lightmap handled in custom output calculation -#ifdef USE_LIGHTMAP - vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); -#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`// Torque-style lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space -// Get texture in sRGB space (undo Three.js linear decode) -vec3 textureSRGB = interiorLinearToSRGB(diffuseColor.rgb); - -// Compute lighting in sRGB space -vec3 lightingSRGB = vec3(0.0); - -if (useSceneLighting) { - // Three.js computed: reflectedLight = lighting \xd7 texture_linear / PI - // Extract pure lighting: lighting = reflectedLight \xd7 PI / texture_linear - vec3 totalLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; - vec3 safeTexLinear = max(diffuseColor.rgb, vec3(0.001)); - vec3 extractedLighting = totalLight * PI / safeTexLinear; - // NOTE: extractedLighting is ALREADY sRGB values because mission sun/ambient colors - // are sRGB values (Torque used them directly in gamma space). Three.js treats them - // as linear but the numerical values are the same. DO NOT convert to sRGB here! - // IMPORTANT: Torque clamps scene lighting to [0,1] BEFORE adding to lightmap - // (sceneLighting.cc line 1785: tmp.clamp()) - lightingSRGB = clamp(extractedLighting, 0.0, 1.0); -} - -// Add lightmap contribution (for BOTH outside and inside surfaces) -// In Torque, scene lighting is ADDED to lightmaps for outside surfaces at mission load -// (stored in .ml files). Inside surfaces only have base lightmap. Both need lightmap here. -#ifdef USE_LIGHTMAP - // Lightmap is stored as linear in Three.js (decoded from sRGB texture), convert back - lightingSRGB += interiorLinearToSRGB(lightMapTexel.rgb); -#endif -// Torque clamps the sum to [0,1] per channel (sceneLighting.cc lines 1817-1827) -lightingSRGB = clamp(lightingSRGB, 0.0, 1.0); - -// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space -vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0); - -// Convert back to linear for Three.js output pipeline -vec3 resultLinear = interiorSRGBToLinear(resultSRGB); - -// Reassign outgoingLight before opaque_fragment consumes it -outgoingLight = resultLinear + totalEmissiveRadiance; - -#include `),e.fragmentShader=e.fragmentShader.replace("#include ",`// Debug mode: overlay colored grid on top of normal rendering -// Blue grid = SurfaceOutsideVisible (receives scene ambient light) -// Red grid = inside surface (no scene ambient light) -#if DEBUG_MODE && defined(USE_MAP) - // gridSize=4 creates 4x4 grid per UV tile, lineWidth=1.5 is ~1.5 pixels wide - float gridIntensity = debugGrid(vMapUv, 4.0, 1.5); - gl_FragColor.rgb = mix(gl_FragColor.rgb, interiorDebugColor, gridIntensity * 0.1); -#endif - -#include `)},[h]),p=(0,n.useRef)(null),y=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=p.current??y.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!s,e.needsUpdate=!0)},[s]);let S={DEBUG_MODE:+!!s},x=`${h}`;return u?(0,a.jsx)("meshBasicMaterial",{ref:p,map:d,toneMapped:!1,defines:S,onBeforeCompile:m},x):(0,a.jsx)("meshLambertMaterial",{ref:y,map:d,lightMap:r,toneMapped:!1,defines:S,onBeforeCompile:m},x)}function q(e){if(!e)return null;let t=e.emissiveMap;return t&&(t.colorSpace=o.SRGBColorSpace),t??null}function H(e){let t,i,o,s=(0,r.c)(13),{node:l}=e;e:{let e,a;if(!l.material){let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],s[0]=e):e=s[0],t=e;break e}if(Array.isArray(l.material)){let e;s[1]!==l.material?(e=l.material.map(W),s[1]=l.material,s[2]=e):e=s[2],t=e;break e}s[3]!==l.material?(e=q(l.material),s[3]=l.material,s[4]=e):e=s[4],s[5]!==e?(a=[e],s[5]=e,s[6]=a):a=s[6],t=a}let c=t;return s[7]!==c||s[8]!==l.material?(i=l.material?(0,a.jsx)(n.Suspense,{fallback:(0,a.jsx)("meshStandardMaterial",{color:"yellow",wireframe:!0}),children:Array.isArray(l.material)?l.material.map((e,t)=>(0,a.jsx)(V,{materialName:e.userData.resource_path,material:e,lightMap:c[t]},t)):(0,a.jsx)(V,{materialName:l.material.userData.resource_path,material:l.material,lightMap:c[0]})}):null,s[7]=c,s[8]=l.material,s[9]=i):i=s[9],s[10]!==l.geometry||s[11]!==i?(o=(0,a.jsx)("mesh",{geometry:l.geometry,castShadow:!0,receiveShadow:!0,children:i}),s[10]=l.geometry,s[11]=i,s[12]=o):o=s[12],o}function W(e){return q(e)}let $=(0,n.memo)(function(e){let t,n,i,o,s,l,d,u=(0,r.c)(10),{object:h,interiorFile:m}=e,{nodes:f}=((l=(0,r.c)(2))[0]!==m?(s=(0,c.interiorToUrl)(m),l[0]=m,l[1]=s):s=l[1],d=s,(0,L.useGLTF)(d)),g=(0,v.useDebug)(),p=g?.debugMode??!1;return u[0]===Symbol.for("react.memo_cache_sentinel")?(t=[0,-Math.PI/2,0],u[0]=t):t=u[0],u[1]!==f?(n=Object.entries(f).filter(Z).map(J),u[1]=f,u[2]=n):n=u[2],u[3]!==p||u[4]!==m||u[5]!==h?(i=p?(0,a.jsxs)(z.FloatingLabel,{children:[h._id,": ",m]}):null,u[3]=p,u[4]=m,u[5]=h,u[6]=i):i=u[6],u[7]!==n||u[8]!==i?(o=(0,a.jsxs)("group",{rotation:t,children:[n,i]}),u[7]=n,u[8]=i,u[9]=o):o=u[9],o});function Y(e){let t,n,i,o,s=(0,r.c)(9),{color:l,label:c}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(n=(0,a.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=n):n=s[2],s[3]!==l||s[4]!==c?(i=c?(0,a.jsx)(z.FloatingLabel,{color:l,children:c}):null,s[3]=l,s[4]=c,s[5]=i):i=s[5],s[6]!==n||s[7]!==i?(o=(0,a.jsxs)("mesh",{children:[t,n,i]}),s[6]=n,s[7]=i,s[8]=o):o=s[8],o}function K(e){let t,n=(0,r.c)(3),{label:i}=e,o=(0,v.useDebug)(),s=o?.debugMode??!1;return n[0]!==s||n[1]!==i?(t=s?(0,a.jsx)(Y,{color:"red",label:i}):null,n[0]=s,n[1]=i,n[2]=t):t=n[2],t}let X=(0,n.memo)(function(e){let t,i,o,s,l,c,d,u,h,f=(0,r.c)(22),{object:g}=e;f[0]!==g?(t=(0,m.getProperty)(g,"interiorFile"),f[0]=g,f[1]=t):t=f[1];let p=t;f[2]!==g?(i=(0,m.getPosition)(g),f[2]=g,f[3]=i):i=f[3];let y=i;f[4]!==g?(o=(0,m.getScale)(g),f[4]=g,f[5]=o):o=f[5];let v=o;f[6]!==g?(s=(0,m.getRotation)(g),f[6]=g,f[7]=s):s=f[7];let F=s,b=`${g._id}: ${p}`;return f[8]!==b?(l=(0,a.jsx)(K,{label:b}),f[8]=b,f[9]=l):l=f[9],f[10]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(Y,{color:"orange"}),f[10]=c):c=f[10],f[11]!==p||f[12]!==g?(d=(0,a.jsx)(n.Suspense,{fallback:c,children:(0,a.jsx)($,{object:g,interiorFile:p})}),f[11]=p,f[12]=g,f[13]=d):d=f[13],f[14]!==l||f[15]!==d?(u=(0,a.jsx)(U.ErrorBoundary,{fallback:l,children:d}),f[14]=l,f[15]=d,f[16]=u):u=f[16],f[17]!==y||f[18]!==F||f[19]!==v||f[20]!==u?(h=(0,a.jsx)("group",{position:y,quaternion:F,scale:v,children:u}),f[17]=y,f[18]=F,f[19]=v,f[20]=u,f[21]=h):h=f[21],h});function Z(e){let[,t]=e;return t.isMesh}function J(e){let[t,r]=e;return(0,a.jsx)(H,{node:r},t)}var Q=e.i(99143);function ee(e,{path:t}){let[a]=(0,Q.useLoader)(o.CubeTextureLoader,[e],e=>e.setPath(t));return a}ee.preload=(e,{path:t})=>Q.useLoader.preload(o.CubeTextureLoader,[e],e=>e.setPath(t));let et=()=>{};function ea(e){return e.wrapS=o.RepeatWrapping,e.wrapT=o.RepeatWrapping,e.minFilter=o.LinearFilter,e.magFilter=o.LinearFilter,e.colorSpace=o.NoColorSpace,e.needsUpdate=!0,e}let er=` - attribute float alpha; - - uniform vec2 uvOffset; - - varying vec2 vUv; - varying float vAlpha; - - void main() { - // Apply UV offset for scrolling - vUv = uv + uvOffset; - vAlpha = alpha; - - vec4 pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0); - // Set depth to far plane so clouds are always visible and behind other geometry - gl_Position = pos.xyww; - } -`,en=` - uniform sampler2D cloudTexture; - uniform float debugMode; - uniform int layerIndex; - - varying vec2 vUv; - varying float vAlpha; - - // Debug grid using screen-space derivatives for sharp, anti-aliased lines - float debugGrid(vec2 uv, float gridSize, float lineWidth) { - vec2 scaledUV = uv * gridSize; - vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); - float line = min(grid.x, grid.y); - return 1.0 - min(line / lineWidth, 1.0); - } - - void main() { - vec4 texColor = texture2D(cloudTexture, vUv); - - // Tribes 2 uses GL_MODULATE: final = texture \xd7 vertex color - // Vertex color is white with varying alpha, so: - // Final RGB = Texture RGB \xd7 1.0 = Texture RGB - // Final Alpha = Texture Alpha \xd7 Vertex Alpha - float finalAlpha = texColor.a * vAlpha; - vec3 color = texColor.rgb; - - // Debug mode: overlay R/G/B grid for layers 0/1/2 - if (debugMode > 0.5) { - float gridIntensity = debugGrid(vUv, 4.0, 1.5); - vec3 gridColor; - if (layerIndex == 0) { - gridColor = vec3(1.0, 0.0, 0.0); // Red - } else if (layerIndex == 1) { - gridColor = vec3(0.0, 1.0, 0.0); // Green - } else { - gridColor = vec3(0.0, 0.0, 1.0); // Blue - } - color = mix(color, gridColor, gridIntensity * 0.5); - } - - // Output clouds with texture color and combined alpha - gl_FragColor = vec4(color, finalAlpha); - } -`;function ei({textureUrl:e,radius:t,heightPercent:r,speed:i,windDirection:s,layerIndex:l}){let{debugMode:c}=(0,v.useDebug)(),{animationEnabled:d}=(0,v.useSettings)(),h=(0,n.useRef)(null),m=(0,g.useTexture)(e,ea),f=(0,n.useMemo)(()=>{let e=r-.05;return function(e,t,a,r){var n;let i,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S,x,k=new o.BufferGeometry,w=new Float32Array(75),I=new Float32Array(50),C=[.05,.05,.05,.05,.05,.05,a,a,a,.05,.05,a,t,a,.05,.05,a,a,a,.05,.05,.05,.05,.05,.05],_=2*e/4;for(let t=0;t<5;t++)for(let a=0;a<5;a++){let r=5*t+a,n=-e+a*_,i=e-t*_,o=e*C[r];w[3*r]=n,w[3*r+1]=o,w[3*r+2]=i,I[2*r]=a,I[2*r+1]=t}n=w,i=e=>({x:n[3*e],y:n[3*e+1],z:n[3*e+2]}),s=(e,t,a,r)=>{n[3*e]=t,n[3*e+1]=a,n[3*e+2]=r},l=i(1),c=i(3),d=i(5),u=i(6),h=i(8),m=i(9),f=i(15),g=i(16),p=i(18),y=i(19),v=i(21),F=i(23),b=d.x+(l.x-d.x)*.5,S=d.y+(l.y-d.y)*.5,x=d.z+(l.z-d.z)*.5,s(0,u.x+(b-u.x)*2,u.y+(S-u.y)*2,u.z+(x-u.z)*2),b=m.x+(c.x-m.x)*.5,S=m.y+(c.y-m.y)*.5,x=m.z+(c.z-m.z)*.5,s(4,h.x+(b-h.x)*2,h.y+(S-h.y)*2,h.z+(x-h.z)*2),b=v.x+(f.x-v.x)*.5,S=v.y+(f.y-v.y)*.5,x=v.z+(f.z-v.z)*.5,s(20,g.x+(b-g.x)*2,g.y+(S-g.y)*2,g.z+(x-g.z)*2),b=F.x+(y.x-F.x)*.5,S=F.y+(y.y-F.y)*.5,x=F.z+(y.z-F.z)*.5,s(24,p.x+(b-p.x)*2,p.y+(S-p.y)*2,p.z+(x-p.z)*2);let P=function(e,t){let a=new Float32Array(25);for(let r=0;r<25;r++){let n=e[3*r],i=e[3*r+2],o=1.3-Math.sqrt(n*n+i*i)/t;o<.4?o=0:o>.8&&(o=1),a[r]=o}return a}(w,e),D=[];for(let e=0;e<4;e++)for(let t=0;t<4;t++){let a=5*e+t,r=a+1,n=a+5,i=n+1;D.push(a,n,i),D.push(a,i,r)}return k.setIndex(D),k.setAttribute("position",new o.Float32BufferAttribute(w,3)),k.setAttribute("uv",new o.Float32BufferAttribute(I,2)),k.setAttribute("alpha",new o.Float32BufferAttribute(P,1)),k.computeBoundingSphere(),k}(t,r,e,0)},[t,r]);(0,n.useEffect)(()=>()=>{f.dispose()},[f]);let p=(0,n.useMemo)(()=>new o.ShaderMaterial({uniforms:{cloudTexture:{value:m},uvOffset:{value:new o.Vector2(0,0)},debugMode:{value:+!!c},layerIndex:{value:l}},vertexShader:er,fragmentShader:en,transparent:!0,depthWrite:!1,side:o.DoubleSide}),[m,c,l]);return(0,n.useEffect)(()=>()=>{p.dispose()},[p]),(0,u.useFrame)(d?(e,t)=>{let a=1e3*t/32;h.current??=new o.Vector2(0,0),h.current.x+=s.x*i*a,h.current.y+=s.y*i*a,h.current.x-=Math.floor(h.current.x),h.current.y-=Math.floor(h.current.y),p.uniforms.uvOffset.value.copy(h.current)}:et),(0,a.jsx)("mesh",{geometry:f,frustumCulled:!1,renderOrder:10,children:(0,a.jsx)("primitive",{object:p,attach:"material"})})}function eo(e){var t;let i,l,d,h,f,g,p,y,v,F,b,S,x,k,w,I,C,_,P,D=(0,r.c)(37),{object:M}=e;D[0]!==M?(i=(0,m.getProperty)(M,"materialList"),D[0]=M,D[1]=i):i=D[1];let{data:T}=(t=i,(_=(0,r.c)(7))[0]!==t?(w=["detailMapList",t],I=()=>(0,c.loadDetailMapList)(t),_[0]=t,_[1]=w,_[2]=I):(w=_[1],I=_[2]),P=!!t,_[3]!==w||_[4]!==I||_[5]!==P?(C={queryKey:w,queryFn:I,enabled:P},_[3]=w,_[4]=I,_[5]=P,_[6]=C):C=_[6],(0,s.useQuery)(C));D[2]!==M?(l=(0,m.getFloat)(M,"visibleDistance")??500,D[2]=M,D[3]=l):l=D[3];let E=.95*l;D[4]!==M?(d=(0,m.getFloat)(M,"cloudSpeed1")??1e-4,D[4]=M,D[5]=d):d=D[5],D[6]!==M?(h=(0,m.getFloat)(M,"cloudSpeed2")??2e-4,D[6]=M,D[7]=h):h=D[7],D[8]!==M?(f=(0,m.getFloat)(M,"cloudSpeed3")??3e-4,D[8]=M,D[9]=f):f=D[9],D[10]!==d||D[11]!==h||D[12]!==f?(g=[d,h,f],D[10]=d,D[11]=h,D[12]=f,D[13]=g):g=D[13];let B=g;D[14]!==M?(p=(0,m.getFloat)(M,"cloudHeightPer1")??.35,D[14]=M,D[15]=p):p=D[15],D[16]!==M?(y=(0,m.getFloat)(M,"cloudHeightPer2")??.25,D[16]=M,D[17]=y):y=D[17],D[18]!==M?(v=(0,m.getFloat)(M,"cloudHeightPer3")??.2,D[18]=M,D[19]=v):v=D[19],D[20]!==p||D[21]!==y||D[22]!==v?(F=[p,y,v],D[20]=p,D[21]=y,D[22]=v,D[23]=F):F=D[23];let j=F;if(D[24]!==M){e:{let e,t=(0,m.getProperty)(M,"windVelocity");if(t){let[e,a]=t.split(" ").map(es);if(0!==e||0!==a){b=new o.Vector2(a,-e).normalize();break e}}D[26]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector2(1,0),D[26]=e):e=D[26],b=e}D[24]=M,D[25]=b}else b=D[25];let R=b;t:{let e;if(!T){let e;D[27]===Symbol.for("react.memo_cache_sentinel")?(e=[],D[27]=e):e=D[27],S=e;break t}if(D[28]!==j||D[29]!==B||D[30]!==T){e=[];for(let t=0;t<3;t++){let a=T[7+t];a&&e.push({texture:a,height:j[t],speed:B[t]})}D[28]=j,D[29]=B,D[30]=T,D[31]=e}else e=D[31];S=e}let N=S,A=(0,n.useRef)(null);return(D[32]===Symbol.for("react.memo_cache_sentinel")?(x=e=>{let{camera:t}=e;A.current&&A.current.position.copy(t.position)},D[32]=x):x=D[32],(0,u.useFrame)(x),N&&0!==N.length)?(D[33]!==N||D[34]!==E||D[35]!==R?(k=(0,a.jsx)("group",{ref:A,children:N.map((e,t)=>{let r=(0,c.textureToUrl)(e.texture);return(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(ei,{textureUrl:r,radius:E,heightPercent:e.height,speed:e.speed,windDirection:R,layerIndex:t})},t)})}),D[33]=N,D[34]=E,D[35]=R,D[36]=k):k=D[36],k):null}function es(e){return parseFloat(e)}let el=!1;function ec(e){if(!e)return;let[t,a,r]=e.split(" ").map(e=>parseFloat(e));return[new o.Color().setRGB(t,a,r),new o.Color().setRGB(t,a,r).convertSRGBToLinear()]}function ed({skyBoxFiles:e,fogColor:t,fogState:r}){let{camera:i}=(0,h.useThree)(),s=ee(e,{path:""}),l=!!t,c=(0,n.useMemo)(()=>i.projectionMatrixInverse,[i]),d=(0,n.useMemo)(()=>r?(0,b.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),u=(0,n.useRef)({skybox:{value:s},fogColor:{value:t??new o.Color(0,0,0)},enableFog:{value:l},inverseProjectionMatrix:{value:c},cameraMatrixWorld:{value:i.matrixWorld},cameraHeight:b.globalFogUniforms.cameraHeight,fogVolumeData:{value:d},horizonFogHeight:{value:.18}}),m=(0,n.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]);return(0,n.useEffect)(()=>{u.current.skybox.value=s,u.current.fogColor.value=t??new o.Color(0,0,0),u.current.enableFog.value=l,u.current.fogVolumeData.value=d,u.current.horizonFogHeight.value=m},[s,t,l,d,m]),(0,a.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,a.jsxs)("bufferGeometry",{children:[(0,a.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,a.jsx)("shaderMaterial",{uniforms:u.current,vertexShader:` - varying vec2 vUv; - - void main() { - vUv = uv; - gl_Position = vec4(position.xy, 0.9999, 1.0); - } - `,fragmentShader:` - uniform samplerCube skybox; - uniform vec3 fogColor; - uniform bool enableFog; - uniform mat4 inverseProjectionMatrix; - uniform mat4 cameraMatrixWorld; - uniform float cameraHeight; - uniform float fogVolumeData[12]; - uniform float horizonFogHeight; - - varying vec2 vUv; - - // Convert linear to sRGB for display - // shaderMaterial does NOT get automatic linear->sRGB output conversion - // Use proper sRGB transfer function (not simplified gamma 2.2) to match Three.js - vec3 linearToSRGB(vec3 linear) { - vec3 low = linear * 12.92; - vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055; - return mix(low, high, step(vec3(0.0031308), linear)); - } - - void main() { - vec2 ndc = vUv * 2.0 - 1.0; - vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0); - viewPos.xyz /= viewPos.w; - vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz); - direction = vec3(direction.z, direction.y, -direction.x); - // Sample skybox - Three.js CubeTexture with SRGBColorSpace auto-converts to linear - vec4 skyColor = textureCube(skybox, direction); - vec3 finalColor; - - if (enableFog) { - vec3 effectiveFogColor = fogColor; - - // Calculate how much fog volume the ray passes through - // For skybox at "infinite" distance, the relevant height is how much - // of the volume is above/below camera depending on view direction - float volumeFogInfluence = 0.0; - - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - if (volVisDist <= 0.0) continue; - - // Check if camera is inside this volume - if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { - // Camera is inside the fog volume - // Looking horizontally or up at shallow angles means ray travels - // through more fog before exiting the volume - float heightAboveCamera = volMaxH - cameraHeight; - float heightBelowCamera = cameraHeight - volMinH; - float volumeHeight = volMaxH - volMinH; - - // For horizontal rays (direction.y ≈ 0), maximum fog influence - // For rays going up steeply, less fog (exits volume quickly) - // For rays going down, more fog (travels through volume below) - float rayInfluence; - if (direction.y >= 0.0) { - // Looking up: influence based on how steep we're looking - // Shallow angles = long path through fog = high influence - rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y); - } else { - // Looking down: always high fog (into the volume) - rayInfluence = 1.0; - } - - // Scale by percentage and volume depth factor - volumeFogInfluence += rayInfluence * volPct; - } - } - - // Base fog factor from view direction (for haze at horizon) - // In Torque, the fog "bans" (bands) are rendered as geometry from - // height 0 (HORIZON) to height 60 (OFFSET_HEIGHT) on the skybox. - // The skybox corner is at mSkyBoxPt.x = mRadius / sqrt(3). - // - // horizonFogHeight is the direction.y value where the fog band ends: - // horizonFogHeight = 60 / sqrt(skyBoxPt.x^2 + 60^2) - // - // For Firestorm (visDist=600): mRadius=570, skyBoxPt.x=329, horizonFogHeight≈0.18 - // - // Torque renders the fog bands as geometry with linear vertex alpha - // interpolation. We use a squared curve (t^2) to create a gentler - // falloff at the top of the gradient, matching Tribes 2's appearance. - float baseFogFactor; - if (direction.y <= 0.0) { - // Looking at or below horizon: full fog - baseFogFactor = 1.0; - } else if (direction.y >= horizonFogHeight) { - // Above fog band: no fog - baseFogFactor = 0.0; - } else { - // Within fog band: squared curve for gentler falloff at top - float t = direction.y / horizonFogHeight; - baseFogFactor = (1.0 - t) * (1.0 - t); - } - - // Combine base fog with volume fog influence - // When inside a volume, increase fog intensity - float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5); - - finalColor = mix(skyColor.rgb, effectiveFogColor, finalFogFactor); - } else { - finalColor = skyColor.rgb; - } - // Convert linear result to sRGB for display - gl_FragColor = vec4(linearToSRGB(finalColor), 1.0); - } - `,depthWrite:!1,depthTest:!1})]})}function eu(e){let t,n,i,o,l=(0,r.c)(6),{materialList:d,fogColor:u,fogState:h}=e,{data:m}=((o=(0,r.c)(2))[0]!==d?(i={queryKey:["detailMapList",d],queryFn:()=>(0,c.loadDetailMapList)(d)},o[0]=d,o[1]=i):i=o[1],(0,s.useQuery)(i));l[0]!==m?(t=m?[(0,c.textureToUrl)(m[1]),(0,c.textureToUrl)(m[3]),(0,c.textureToUrl)(m[4]),(0,c.textureToUrl)(m[5]),(0,c.textureToUrl)(m[0]),(0,c.textureToUrl)(m[2])]:null,l[0]=m,l[1]=t):t=l[1];let f=t;return f?(l[2]!==u||l[3]!==h||l[4]!==f?(n=(0,a.jsx)(ed,{skyBoxFiles:f,fogColor:u,fogState:h}),l[2]=u,l[3]=h,l[4]=f,l[5]=n):n=l[5],n):null}function eh({skyColor:e,fogColor:t,fogState:r}){let{camera:i}=(0,h.useThree)(),s=!!t,l=(0,n.useMemo)(()=>i.projectionMatrixInverse,[i]),c=(0,n.useMemo)(()=>r?(0,b.packFogVolumeData)(r.fogVolumes):new Float32Array(12),[r]),d=(0,n.useMemo)(()=>{if(!r)return .18;let e=.95*r.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[r]),u=(0,n.useRef)({skyColor:{value:e},fogColor:{value:t??new o.Color(0,0,0)},enableFog:{value:s},inverseProjectionMatrix:{value:l},cameraMatrixWorld:{value:i.matrixWorld},cameraHeight:b.globalFogUniforms.cameraHeight,fogVolumeData:{value:c},horizonFogHeight:{value:d}});return(0,n.useEffect)(()=>{u.current.skyColor.value=e,u.current.fogColor.value=t??new o.Color(0,0,0),u.current.enableFog.value=s,u.current.fogVolumeData.value=c,u.current.horizonFogHeight.value=d},[e,t,s,c,d]),(0,a.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,a.jsxs)("bufferGeometry",{children:[(0,a.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,a.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,a.jsx)("shaderMaterial",{uniforms:u.current,vertexShader:` - varying vec2 vUv; - - void main() { - vUv = uv; - gl_Position = vec4(position.xy, 0.9999, 1.0); - } - `,fragmentShader:` - uniform vec3 skyColor; - uniform vec3 fogColor; - uniform bool enableFog; - uniform mat4 inverseProjectionMatrix; - uniform mat4 cameraMatrixWorld; - uniform float cameraHeight; - uniform float fogVolumeData[12]; - uniform float horizonFogHeight; - - varying vec2 vUv; - - // Convert linear to sRGB for display - vec3 linearToSRGB(vec3 linear) { - vec3 low = linear * 12.92; - vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055; - return mix(low, high, step(vec3(0.0031308), linear)); - } - - void main() { - vec2 ndc = vUv * 2.0 - 1.0; - vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0); - viewPos.xyz /= viewPos.w; - vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz); - direction = vec3(direction.z, direction.y, -direction.x); - - vec3 finalColor; - - if (enableFog) { - // Calculate volume fog influence (same logic as SkyBoxTexture) - float volumeFogInfluence = 0.0; - - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = fogVolumeData[offset + 0]; - float volMinH = fogVolumeData[offset + 1]; - float volMaxH = fogVolumeData[offset + 2]; - float volPct = fogVolumeData[offset + 3]; - - if (volVisDist <= 0.0) continue; - - if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { - float rayInfluence; - if (direction.y >= 0.0) { - rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y); - } else { - rayInfluence = 1.0; - } - volumeFogInfluence += rayInfluence * volPct; - } - } - - // Base fog factor from view direction - float baseFogFactor; - if (direction.y <= 0.0) { - baseFogFactor = 1.0; - } else if (direction.y >= horizonFogHeight) { - baseFogFactor = 0.0; - } else { - float t = direction.y / horizonFogHeight; - baseFogFactor = (1.0 - t) * (1.0 - t); - } - - // Combine base fog with volume fog influence - float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5); - - finalColor = mix(skyColor, fogColor, finalFogFactor); - } else { - finalColor = skyColor; - } - - gl_FragColor = vec4(linearToSRGB(finalColor), 1.0); - } - `,depthWrite:!1,depthTest:!1})]})}function em(e,t){let{fogDistance:a,visibleDistance:r}=e;return[a,r]}function ef({fogState:e,enabled:t}){let{scene:a,camera:r}=(0,h.useThree)(),i=(0,n.useRef)(null),s=(0,n.useMemo)(()=>(0,b.packFogVolumeData)(e.fogVolumes),[e.fogVolumes]);return(0,n.useEffect)(()=>{el||((0,F.installCustomFogShader)(),el=!0)},[]),(0,n.useEffect)(()=>{(0,b.resetGlobalFogUniforms)();let[t,n]=em(e,r.position.y),l=new o.Fog(e.fogColor,t,n);return a.fog=l,i.current=l,(0,b.updateGlobalFogUniforms)(r.position.y,s),()=>{a.fog=null,i.current=null,(0,b.resetGlobalFogUniforms)()}},[a,r,e,s]),(0,n.useEffect)(()=>{let a=i.current;if(a)if(t){let[t,n]=em(e,r.position.y);a.near=t,a.far=n}else a.near=1e10,a.far=1e10},[t,e,r.position.y]),(0,u.useFrame)(()=>{let a=i.current;if(!a)return;let n=r.position.y;if((0,b.updateGlobalFogUniforms)(n,s,t),t){let[t,r]=em(e,n);a.near=t,a.far=r,a.color.copy(e.fogColor)}}),null}function eg(e){return parseFloat(e)}function ep(e){return parseFloat(e)}function ey(e){return parseFloat(e)}var ev=e.i(91907),eF=e.i(25947),eb=e.i(6112);let eS={1:"Storm",2:"Inferno"},ex=(0,n.createContext)(null);function ek(){let e=(0,n.useContext)(ex);if(!e)throw Error("useCameras must be used within CamerasProvider");return e}function ew({children:e}){let{camera:t}=(0,h.useThree)(),[r,i]=(0,n.useState)(-1),[s,l]=(0,n.useState)({}),[c,d]=(0,n.useState)(()=>({initialized:!1,position:null,quarternion:null})),u=(0,n.useCallback)(e=>{l(t=>({...t,[e.id]:e}))},[]),m=(0,n.useCallback)(e=>{l(t=>{let{[e.id]:a,...r}=t;return r})},[]),f=Object.keys(s).length,g=(0,n.useCallback)(e=>{if(e>=0&&e{g(f?(r+1)%f:-1)},[f,r,g]);(0,n.useEffect)(()=>{let e=()=>{let e=window.location.hash;if(e.startsWith("#c")){let[t,a]=e.slice(2).split("~"),r=t.split(",").map(e=>parseFloat(e)),n=a.split(",").map(e=>parseFloat(e));d({initialized:!0,position:new o.Vector3(...r),quarternion:new o.Quaternion(...n)})}else d({initialized:!0,position:null,quarternion:null})};return window.addEventListener("hashchange",e),e(),()=>{window.removeEventListener("hashchange",e)}},[]),(0,n.useEffect)(()=>{c.initialized&&c.position&&(t.position.copy(c.position),c.quarternion&&t.quaternion.copy(c.quarternion))},[t,c]),(0,n.useEffect)(()=>{c.initialized&&!c.position&&f>0&&-1===r&&g(0)},[f,g,r,c]);let y=(0,n.useMemo)(()=>({registerCamera:u,unregisterCamera:m,nextCamera:p,setCameraIndex:g,cameraCount:f}),[u,m,p,g,f]);return 0===f&&-1!==r&&i(-1),(0,a.jsx)(ex.Provider,{value:y,children:e})}let eI=(0,n.createContext)(null),eC=eI.Provider,e_=(0,n.lazy)(()=>e.A(61921).then(e=>({default:e.AudioEmitter}))),eP={AudioEmitter:function(e){let t,n=(0,r.c)(3),{audioEnabled:i}=(0,v.useSettings)();return n[0]!==i||n[1]!==e?(t=i?(0,a.jsx)(e_,{...e}):null,n[0]=i,n[1]=e,n[2]=t):t=n[2],t},Camera:function(e){let t,a,i,s,l,c=(0,r.c)(14),{object:d}=e,{registerCamera:u,unregisterCamera:h}=ek(),f=(0,n.useId)();c[0]!==d?(t=(0,m.getProperty)(d,"dataBlock"),c[0]=d,c[1]=t):t=c[1];let g=t;c[2]!==d?(a=(0,m.getPosition)(d),c[2]=d,c[3]=a):a=c[3];let p=a;c[4]!==d?(i=(0,m.getRotation)(d),c[4]=d,c[5]=i):i=c[5];let y=i;return c[6]!==g||c[7]!==f||c[8]!==p||c[9]!==y||c[10]!==u||c[11]!==h?(s=()=>{if("Observer"===g){let e={id:f,position:new o.Vector3(...p),rotation:y};return u(e),()=>{h(e)}}},l=[f,g,u,h,p,y],c[6]=g,c[7]=f,c[8]=p,c[9]=y,c[10]=u,c[11]=h,c[12]=s,c[13]=l):(s=c[12],l=c[13]),(0,n.useEffect)(s,l),null},ForceFieldBare:(0,n.lazy)(()=>e.A(25147).then(e=>({default:e.ForceFieldBare}))),InteriorInstance:X,Item:function(e){let t,i,o,s,l,c,d,h,f,g,p,y,F=(0,r.c)(32),{object:b}=e,S=A();F[0]!==b?(t=(0,m.getProperty)(b,"dataBlock")??"",F[0]=b,F[1]=t):t=F[1];let x=t,k=(0,eb.useDatablock)(x);F[2]!==k||F[3]!==b?(i=function(e){if("string"==typeof e){let t=e.toLowerCase();return"0"!==t&&"false"!==t&&""!==t}return!!e}((0,m.getProperty)(b,"rotate")??(0,m.getProperty)(k,"rotate")),F[2]=k,F[3]=b,F[4]=i):i=F[4];let w=i;F[5]!==b?(o=(0,m.getPosition)(b),F[5]=b,F[6]=o):o=F[6];let I=o;F[7]!==b?(s=(0,m.getScale)(b),F[7]=b,F[8]=s):s=F[8];let C=s;F[9]!==b?(l=(0,m.getRotation)(b),F[9]=b,F[10]=l):l=F[10];let _=l,{animationEnabled:P}=(0,v.useSettings)(),D=(0,n.useRef)(null);F[11]!==P||F[12]!==w?(c=()=>{if(!D.current||!w||!P)return;let e=performance.now()/1e3;D.current.rotation.y=e/3*Math.PI*2},F[11]=P,F[12]=w,F[13]=c):c=F[13],(0,u.useFrame)(c),F[14]!==k?(d=(0,m.getProperty)(k,"shapeFile"),F[14]=k,F[15]=d):d=F[15];let M=d;M||console.error(` missing shape for datablock: ${x}`);let T=x?.toLowerCase()==="flag",E=S?.team??null,B=E&&E>0?eS[E]:null,j=T&&B?`${B} Flag`:null;return F[16]!==_||F[17]!==w?(h=!w&&{quaternion:_},F[16]=_,F[17]=w,F[18]=h):h=F[18],F[19]!==j?(f=j?(0,a.jsx)(z.FloatingLabel,{opacity:.6,children:j}):null,F[19]=j,F[20]=f):f=F[20],F[21]!==f?(g=(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"pink",children:f}),F[21]=f,F[22]=g):g=F[22],F[23]!==I||F[24]!==C||F[25]!==g||F[26]!==h?(p=(0,a.jsx)("group",{ref:D,position:I,...h,scale:C,children:g}),F[23]=I,F[24]=C,F[25]=g,F[26]=h,F[27]=p):p=F[27],F[28]!==b||F[29]!==M||F[30]!==p?(y=(0,a.jsx)(eF.ShapeInfoProvider,{type:"Item",object:b,shapeName:M,children:p}),F[28]=b,F[29]=M,F[30]=p,F[31]=y):y=F[31],y},SimGroup:function(e){let t,n,i,o,s=(0,r.c)(17),{object:l}=e,c=(0,I.useRuntimeObjectById)(l._id)??l,d=A();s[0]!==c._children?(t=c._children??[],s[0]=c._children,s[1]=t):t=s[1];let u=(0,I.useRuntimeChildIds)(c._id,t),h=null,m=!1;if(d&&d.hasTeams){if(m=!0,null!=d.team)h=d.team;else if(c._name){let e;if(s[2]!==c._name){let t;s[4]===Symbol.for("react.memo_cache_sentinel")?(t=/^team(\d+)$/i,s[4]=t):t=s[4],e=c._name.match(t),s[2]=c._name,s[3]=e}else e=s[3];let t=e;t&&(h=parseInt(t[1],10))}}else if(c._name){let e;s[5]!==c._name?(e=c._name.toLowerCase(),s[5]=c._name,s[6]=e):e=s[6],m="teams"===e}s[7]!==m||s[8]!==c||s[9]!==d||s[10]!==h?(n={object:c,parent:d,hasTeams:m,team:h},s[7]=m,s[8]=c,s[9]=d,s[10]=h,s[11]=n):n=s[11];let f=n;return s[12]!==u?(i=u.map(G),s[12]=u,s[13]=i):i=s[13],s[14]!==f||s[15]!==i?(o=(0,a.jsx)(N.Provider,{value:f,children:i}),s[14]=f,s[15]=i,s[16]=o):o=s[16],o},Sky:function({object:e}){let{fogEnabled:t,highQualityFog:r}=(0,v.useSettings)(),i=(0,m.getProperty)(e,"materialList"),s=(0,n.useMemo)(()=>ec((0,m.getProperty)(e,"SkySolidColor")),[e]),l=(0,m.getInt)(e,"useSkyTextures")??1,c=(0,n.useMemo)(()=>(function(e,t=!0){let a=(0,m.getFloat)(e,"fogDistance")??0,r=(0,m.getFloat)(e,"visibleDistance")??1e3,n=(0,m.getFloat)(e,"high_fogDistance"),i=(0,m.getFloat)(e,"high_visibleDistance"),s=t&&null!=n&&n>0?n:a,l=t&&null!=i&&i>0?i:r,c=function(e){if(!e)return new o.Color(.5,.5,.5);let[t,a,r]=e.split(" ").map(e=>parseFloat(e));return new o.Color().setRGB(t,a,r).convertSRGBToLinear()}((0,m.getProperty)(e,"fogColor")),d=[];for(let t=1;t<=3;t++){let a=function(e,t=1){if(!e)return null;let a=e.split(" ").map(e=>parseFloat(e));if(a.length<3)return null;let[r,n,i]=a;return r<=0||i<=n?null:{visibleDistance:r,minHeight:n,maxHeight:i,percentage:Math.max(0,Math.min(1,t))}}((0,m.getProperty)(e,`fogVolume${t}`),1);a&&d.push(a)}let u=d.reduce((e,t)=>Math.max(e,t.maxHeight),0);return{fogDistance:s,visibleDistance:l,fogColor:c,fogVolumes:d,fogLine:u,enabled:l>s}})(e,r),[e,r]),d=(0,n.useMemo)(()=>ec((0,m.getProperty)(e,"fogColor")),[e]),u=s||d,f=c.enabled&&t,g=c.fogColor,{scene:p,gl:y}=(0,h.useThree)();(0,n.useEffect)(()=>{if(f){let e=g.clone();p.background=e,y.setClearColor(e)}else if(u){let e=u[0].clone();p.background=e,y.setClearColor(e)}else p.background=null;return()=>{p.background=null}},[p,y,f,g,u]);let F=s?.[1];return(0,a.jsxs)(a.Fragment,{children:[i&&l?(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(eu,{materialList:i,fogColor:f?g:void 0,fogState:f?c:void 0},i)}):F?(0,a.jsx)(eh,{skyColor:F,fogColor:f?g:void 0,fogState:f?c:void 0}):null,(0,a.jsx)(n.Suspense,{children:(0,a.jsx)(eo,{object:e})}),c.enabled?(0,a.jsx)(ef,{fogState:c,enabled:t}):null]})},StaticShape:function(e){let t,n,i,o,s,l,c,d,u=(0,r.c)(19),{object:h}=e;u[0]!==h?(t=(0,m.getProperty)(h,"dataBlock")??"",u[0]=h,u[1]=t):t=u[1];let f=t,g=(0,eb.useDatablock)(f);u[2]!==h?(n=(0,m.getPosition)(h),u[2]=h,u[3]=n):n=u[3];let p=n;u[4]!==h?(i=(0,m.getRotation)(h),u[4]=h,u[5]=i):i=u[5];let y=i;u[6]!==h?(o=(0,m.getScale)(h),u[6]=h,u[7]=o):o=u[7];let v=o;u[8]!==g?(s=(0,m.getProperty)(g,"shapeFile"),u[8]=g,u[9]=s):s=u[9];let F=s;return F||console.error(` missing shape for datablock: ${f}`),u[10]===Symbol.for("react.memo_cache_sentinel")?(l=(0,a.jsx)(ev.ShapeRenderer,{}),u[10]=l):l=u[10],u[11]!==p||u[12]!==y||u[13]!==v?(c=(0,a.jsx)("group",{position:p,quaternion:y,scale:v,children:l}),u[11]=p,u[12]=y,u[13]=v,u[14]=c):c=u[14],u[15]!==h||u[16]!==F||u[17]!==c?(d=(0,a.jsx)(eF.ShapeInfoProvider,{type:"StaticShape",object:h,shapeName:F,children:c}),u[15]=h,u[16]=F,u[17]=c,u[18]=d):d=u[18],d},Sun:function(e){let t,i,s,l,c,d,u,h,f,g,y=(0,r.c)(25),{object:v}=e;y[0]!==v?(t=((0,m.getProperty)(v,"direction")??"0.57735 0.57735 -0.57735").split(" ").map(ey),y[0]=v,y[1]=t):t=y[1];let[F,b,S]=t,x=Math.sqrt(F*F+S*S+b*b),k=F/x,w=S/x,I=b/x;y[2]!==k||y[3]!==w||y[4]!==I?(i=new o.Vector3(k,w,I),y[2]=k,y[3]=w,y[4]=I,y[5]=i):i=y[5];let C=i,_=-(5e3*C.x),P=-(5e3*C.y),D=-(5e3*C.z);y[6]!==_||y[7]!==P||y[8]!==D?(s=new o.Vector3(_,P,D),y[6]=_,y[7]=P,y[8]=D,y[9]=s):s=y[9];let M=s;if(y[10]!==v){let[e,t,a]=((0,m.getProperty)(v,"color")??"0.7 0.7 0.7 1").split(" ").map(ep);l=new o.Color(e,t,a),y[10]=v,y[11]=l}else l=y[11];let T=l;if(y[12]!==v){let[e,t,a]=((0,m.getProperty)(v,"ambient")??"0.5 0.5 0.5 1").split(" ").map(eg);c=new o.Color(e,t,a),y[12]=v,y[13]=c}else c=y[13];let E=c,B=C.y<0;return y[14]!==B?(d=()=>{p.value=B},u=[B],y[14]=B,y[15]=d,y[16]=u):(d=y[15],u=y[16]),(0,n.useEffect)(d,u),y[17]!==T||y[18]!==M?(h=(0,a.jsx)("directionalLight",{position:M,color:T,intensity:1,castShadow:!0,"shadow-mapSize-width":8192,"shadow-mapSize-height":8192,"shadow-camera-left":-4096,"shadow-camera-right":4096,"shadow-camera-top":4096,"shadow-camera-bottom":-4096,"shadow-camera-near":100,"shadow-camera-far":12e3,"shadow-bias":-1e-5,"shadow-normalBias":.4,"shadow-radius":2}),y[17]=T,y[18]=M,y[19]=h):h=y[19],y[20]!==E?(f=(0,a.jsx)("ambientLight",{color:E,intensity:1}),y[20]=E,y[21]=f):f=y[21],y[22]!==h||y[23]!==f?(g=(0,a.jsxs)(a.Fragment,{children:[h,f]}),y[22]=h,y[23]=f,y[24]=g):g=y[24],g},TerrainBlock:D,TSStatic:function(e){let t,n,i,o,s,l,c,d=(0,r.c)(17),{object:u}=e;d[0]!==u?(t=(0,m.getProperty)(u,"shapeName"),d[0]=u,d[1]=t):t=d[1];let h=t;d[2]!==u?(n=(0,m.getPosition)(u),d[2]=u,d[3]=n):n=d[3];let f=n;d[4]!==u?(i=(0,m.getRotation)(u),d[4]=u,d[5]=i):i=d[5];let g=i;d[6]!==u?(o=(0,m.getScale)(u),d[6]=u,d[7]=o):o=d[7];let p=o;return h||console.error(" missing shapeName for object",u),d[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(ev.ShapeRenderer,{}),d[8]=s):s=d[8],d[9]!==f||d[10]!==g||d[11]!==p?(l=(0,a.jsx)("group",{position:f,quaternion:g,scale:p,children:s}),d[9]=f,d[10]=g,d[11]=p,d[12]=l):l=d[12],d[13]!==u||d[14]!==h||d[15]!==l?(c=(0,a.jsx)(eF.ShapeInfoProvider,{type:"TSStatic",object:u,shapeName:h,children:l}),d[13]=u,d[14]=h,d[15]=l,d[16]=c):c=d[16],c},Turret:function(e){let t,n,i,o,s,l,c,d,u,h,f,g=(0,r.c)(27),{object:p}=e;g[0]!==p?(t=(0,m.getProperty)(p,"dataBlock")??"",g[0]=p,g[1]=t):t=g[1];let y=t;g[2]!==p?(n=(0,m.getProperty)(p,"initialBarrel"),g[2]=p,g[3]=n):n=g[3];let v=n,F=(0,eb.useDatablock)(y),b=(0,eb.useDatablock)(v);g[4]!==p?(i=(0,m.getPosition)(p),g[4]=p,g[5]=i):i=g[5];let S=i;g[6]!==p?(o=(0,m.getRotation)(p),g[6]=p,g[7]=o):o=g[7];let x=o;g[8]!==p?(s=(0,m.getScale)(p),g[8]=p,g[9]=s):s=g[9];let k=s;g[10]!==F?(l=(0,m.getProperty)(F,"shapeFile"),g[10]=F,g[11]=l):l=g[11];let w=l;g[12]!==b?(c=(0,m.getProperty)(b,"shapeFile"),g[12]=b,g[13]=c):c=g[13];let I=c;return w||console.error(` missing shape for datablock: ${y}`),v&&!I&&console.error(` missing shape for barrel datablock: ${v}`),g[14]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(ev.ShapeRenderer,{}),g[14]=d):d=g[14],g[15]!==I||g[16]!==p?(u=I?(0,a.jsx)(eF.ShapeInfoProvider,{type:"Turret",object:p,shapeName:I,children:(0,a.jsx)("group",{position:[0,1.5,0],children:(0,a.jsx)(ev.ShapeRenderer,{})})}):null,g[15]=I,g[16]=p,g[17]=u):u=g[17],g[18]!==S||g[19]!==x||g[20]!==k||g[21]!==u?(h=(0,a.jsxs)("group",{position:S,quaternion:x,scale:k,children:[d,u]}),g[18]=S,g[19]=x,g[20]=k,g[21]=u,g[22]=h):h=g[22],g[23]!==p||g[24]!==w||g[25]!==h?(f=(0,a.jsx)(eF.ShapeInfoProvider,{type:"Turret",object:p,shapeName:w,children:h}),g[23]=p,g[24]=w,g[25]=h,g[26]=f):f=g[26],f},WaterBlock:(0,n.lazy)(()=>e.A(18599).then(e=>({default:e.WaterBlock}))),WayPoint:function(e){let t,n,i,o=(0,r.c)(7),{object:s}=e;o[0]!==s?(t=(0,m.getPosition)(s),o[0]=s,o[1]=t):t=o[1];let l=t;o[2]!==s?(n=(0,m.getProperty)(s,"name"),o[2]=s,o[3]=n):n=o[3];let c=n;return o[4]!==c||o[5]!==l?(i=c?(0,a.jsx)(z.FloatingLabel,{position:l,opacity:.6,children:c}):null,o[4]=c,o[5]=l,o[6]=i):i=o[6],i}},eD=new Set(["ForceFieldBare","Item","StaticShape","Turret"]);function eM(e){let t,i,o,s=(0,r.c)(13),{object:l,objectId:c}=e,d=(0,I.useRuntimeObjectById)(c??l?._id)??l,{missionType:u}=(0,n.useContext)(eI),h=(0,I.useEngineSelector)(eT);e:{let e,a;if(!d){t=!1;break e}s[0]!==d?(e=new Set(((0,m.getProperty)(d,"missionTypesList")??"").toLowerCase().split(/\s+/).filter(Boolean)),s[0]=d,s[1]=e):e=s[1];let r=e;s[2]!==u||s[3]!==r?(a=!r.size||r.has(u.toLowerCase()),s[2]=u,s[3]=r,s[4]=a):a=s[4],t=a}let f=t;if(!d)return null;let g=eP[d._className];s[5]!==h||s[6]!==d._className?(i=h&&eD.has(d._className),s[5]=h,s[6]=d._className,s[7]=i):i=s[7];let p=i;return s[8]!==g||s[9]!==p||s[10]!==d||s[11]!==f?(o=f&&g?(0,a.jsx)(n.Suspense,{children:!p&&(0,a.jsx)(g,{object:d})}):null,s[8]=g,s[9]=p,s[10]=d,s[11]=f,s[12]=o):o=s[12],o}function eT(e){return null!=e.playback.recording}var eE=e.i(51475);let eB=(0,n.createContext)(null);function ej(e){let t,n,i=(0,r.c)(5),{runtime:o,children:s}=e;return i[0]!==s?(t=(0,a.jsx)(eE.TickProvider,{children:s}),i[0]=s,i[1]=t):t=i[1],i[2]!==o||i[3]!==t?(n=(0,a.jsx)(eB.Provider,{value:o,children:t}),i[2]=o,i[3]=t,i[4]=n):n=i[4],n}var eR=e.i(86608),eN=e.i(38433),eA=e.i(33870),eG=e.i(91996),eU=e.i(7368);let eL=(0,d.createScriptLoader)(),ez=(0,eA.createScriptCache)(),eO={findFiles:e=>{let t=(0,l.default)(e,{nocase:!0});return(0,eG.getResourceList)().filter(e=>t(e)).map(e=>{let[,t]=(0,eG.getSourceAndPath)(e);return t})},isFile:e=>null!=(0,eG.getResourceMap)()[(0,eG.getResourceKey)(e)]};function eV(e){"batch.flushed"===e.type&&I.engineStore.getState().applyRuntimeBatch(e.events,{tick:e.tick})}function eq(e){e instanceof Error&&"AbortError"===e.name||console.error("Mission runtime failed to become ready:",e)}let eH=(0,n.memo)(function(e){let t,i,o,l,d,u,h,m,f=(0,r.c)(17),{name:g,missionType:p,onLoadingChange:y}=e,{data:v}=((m=(0,r.c)(2))[0]!==g?(h={queryKey:["parsedMission",g],queryFn:()=>(0,c.loadMission)(g)},m[0]=g,m[1]=h):h=m[1],(0,s.useQuery)(h)),{missionGroup:F,runtime:b,progress:S}=function(e,t,a){let i,o,s,l=(0,r.c)(6);l[0]===Symbol.for("react.memo_cache_sentinel")?(i={missionGroup:void 0,runtime:void 0,progress:0},l[0]=i):i=l[0];let[c,d]=(0,n.useState)(i);return l[1]!==e||l[2]!==t||l[3]!==a?(o=()=>{if(!a)return;let r=new AbortController,n=!1,i=null,o=(0,eN.createProgressTracker)(),s=()=>{d(e=>({...e,progress:o.progress}))};o.on("update",s);let{runtime:l,ready:c}=(0,eR.runServer)({missionName:e,missionType:t,runtimeOptions:{loadScript:eL,fileSystem:eO,cache:ez,signal:r.signal,progress:o,ignoreScripts:eU.ignoreScripts}});return c.then(()=>{n||r.signal.aborted||(I.engineStore.getState().setRuntime(l),d({missionGroup:l.getObjectByName("MissionGroup"),runtime:l,progress:1}))}).catch(eq),i=l.subscribeRuntimeEvents(eV),I.engineStore.getState().setRuntime(l),()=>{n=!0,o.off("update",s),r.abort(),i?.(),I.engineStore.getState().clearRuntime(),l.destroy()}},s=[e,t,a],l[1]=e,l[2]=t,l[3]=a,l[4]=o,l[5]=s):(o=l[4],s=l[5]),(0,n.useEffect)(o,s),c}(g,p,v),x=!v||!F||!b;f[0]!==F||f[1]!==p||f[2]!==v?(t={metadata:v,missionType:p,missionGroup:F},f[0]=F,f[1]=p,f[2]=v,f[3]=t):t=f[3];let k=t;return(f[4]!==x||f[5]!==y||f[6]!==S?(i=()=>{y?.(x,S)},o=[x,S,y],f[4]=x,f[5]=y,f[6]=S,f[7]=i,f[8]=o):(i=f[7],o=f[8]),(0,n.useEffect)(i,o),x)?null:(f[9]!==F?(l=(0,a.jsx)(eM,{object:F}),f[9]=F,f[10]=l):l=f[10],f[11]!==b||f[12]!==l?(d=(0,a.jsx)(ej,{runtime:b,children:l}),f[11]=b,f[12]=l,f[13]=d):d=f[13],f[14]!==k||f[15]!==d?(u=(0,a.jsx)(eC,{value:k,children:d}),f[14]=k,f[15]=d,f[16]=u):u=f[16],u)});var eW=e.i(17751),e$=e.i(12598),eY=e.i(8155);let eK=e=>{let t=(0,eY.createStore)(e),a=e=>(function(e,t=e=>e){let a=n.default.useSyncExternalStore(e.subscribe,n.default.useCallback(()=>t(e.getState()),[e,t]),n.default.useCallback(()=>t(e.getInitialState()),[e,t]));return n.default.useDebugValue(a),a})(t,e);return Object.assign(a,t),a};var eX=e.i(79473);let eZ=n.createContext(null);function eJ({map:e,children:t,onChange:a,domElement:r}){let i=e.map(e=>e.name+e.keys).join("-"),o=n.useMemo(()=>{let t;return(t=(0,eX.subscribeWithSelector)(()=>e.reduce((e,t)=>({...e,[t.name]:!1}),{})))?eK(t):eK},[i]),s=n.useMemo(()=>[o.subscribe,o.getState,o],[i]),l=o.setState;return n.useEffect(()=>{let t=e.map(({name:e,keys:t,up:r})=>({keys:t,up:r,fn:t=>{l({[e]:t}),a&&a(e,t,s[1]())}})).reduce((e,{keys:t,fn:a,up:r=!0})=>(t.forEach(t=>e[t]={fn:a,pressed:!1,up:r}),e),{}),n=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,pressed:i,up:o}=r;r.pressed=!0,(o||!i)&&n(!0)},i=({key:e,code:a})=>{let r=t[e]||t[a];if(!r)return;let{fn:n,up:i}=r;r.pressed=!1,i&&n(!1)},o=r||window;return o.addEventListener("keydown",n,{passive:!0}),o.addEventListener("keyup",i,{passive:!0}),()=>{o.removeEventListener("keydown",n),o.removeEventListener("keyup",i)}},[r,i]),n.createElement(eZ.Provider,{value:s,children:t})}function eQ(e){let[t,a,r]=n.useContext(eZ);return e?r(e):[t,a]}var e0=e.i(85413),e1=Object.defineProperty,e2=(e,t,a)=>{let r;return(r="symbol"!=typeof t?t+"":t)in e?e1(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a,a};let e3=new o.Euler(0,0,0,"YXZ"),e5=new o.Vector3,e4={type:"change"},e6={type:"lock"},e8={type:"unlock"},e7=Math.PI/2;class e9 extends e0.EventDispatcher{constructor(e,t){super(),e2(this,"camera"),e2(this,"domElement"),e2(this,"isLocked"),e2(this,"minPolarAngle"),e2(this,"maxPolarAngle"),e2(this,"pointerSpeed"),e2(this,"onMouseMove",e=>{this.domElement&&!1!==this.isLocked&&(e3.setFromQuaternion(this.camera.quaternion),e3.y-=.002*e.movementX*this.pointerSpeed,e3.x-=.002*e.movementY*this.pointerSpeed,e3.x=Math.max(e7-this.maxPolarAngle,Math.min(e7-this.minPolarAngle,e3.x)),this.camera.quaternion.setFromEuler(e3),this.dispatchEvent(e4))}),e2(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(e6),this.isLocked=!0):(this.dispatchEvent(e8),this.isLocked=!1))}),e2(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),e2(this,"connect",e=>{this.domElement=e||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),e2(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),e2(this,"dispose",()=>{this.disconnect()}),e2(this,"getObject",()=>this.camera),e2(this,"direction",new o.Vector3(0,0,-1)),e2(this,"getDirection",e=>e.copy(this.direction).applyQuaternion(this.camera.quaternion)),e2(this,"moveForward",e=>{e5.setFromMatrixColumn(this.camera.matrix,0),e5.crossVectors(this.camera.up,e5),this.camera.position.addScaledVector(e5,e)}),e2(this,"moveRight",e=>{e5.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(e5,e)}),e2(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),e2(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}(t={}).forward="forward",t.backward="backward",t.left="left",t.right="right",t.up="up",t.down="down",t.lookUp="lookUp",t.lookDown="lookDown",t.lookLeft="lookLeft",t.lookRight="lookRight",t.camera1="camera1",t.camera2="camera2",t.camera3="camera3",t.camera4="camera4",t.camera5="camera5",t.camera6="camera6",t.camera7="camera7",t.camera8="camera8",t.camera9="camera9";let te=Math.PI/2-.01;function tt(){let e,t,a,i,s,l,c,d,m,f,g,p,y,F=(0,r.c)(26),{speedMultiplier:b,setSpeedMultiplier:S}=(0,v.useControls)(),[x,k]=eQ(),{camera:w,gl:I}=(0,h.useThree)(),{nextCamera:C,setCameraIndex:_,cameraCount:P}=ek(),D=(0,n.useRef)(null);F[0]===Symbol.for("react.memo_cache_sentinel")?(e=new o.Vector3,F[0]=e):e=F[0];let M=(0,n.useRef)(e);F[1]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Vector3,F[1]=t):t=F[1];let T=(0,n.useRef)(t);F[2]===Symbol.for("react.memo_cache_sentinel")?(a=new o.Vector3,F[2]=a):a=F[2];let E=(0,n.useRef)(a);F[3]===Symbol.for("react.memo_cache_sentinel")?(i=new o.Euler(0,0,0,"YXZ"),F[3]=i):i=F[3];let B=(0,n.useRef)(i);return F[4]!==w||F[5]!==I.domElement?(s=()=>{let e=new e9(w,I.domElement);return D.current=e,()=>{e.dispose()}},l=[w,I.domElement],F[4]=w,F[5]=I.domElement,F[6]=s,F[7]=l):(s=F[6],l=F[7]),(0,n.useEffect)(s,l),F[8]!==w||F[9]!==I.domElement||F[10]!==C?(c=()=>{let e=I.domElement,t=new o.Euler(0,0,0,"YXZ"),a=!1,r=!1,n=0,i=0,s=t=>{D.current?.isLocked||t.target===e&&(a=!0,r=!1,n=t.clientX,i=t.clientY)},l=e=>{!a||!r&&3>Math.abs(e.clientX-n)&&3>Math.abs(e.clientY-i)||(r=!0,t.setFromQuaternion(w.quaternion,"YXZ"),t.y=t.y-.003*e.movementX,t.x=t.x-.003*e.movementY,t.x=Math.max(-te,Math.min(te,t.x)),w.quaternion.setFromEuler(t))},c=()=>{a=!1},d=t=>{let a=D.current;!a||a.isLocked?C():t.target!==e||r||a.lock()};return e.addEventListener("mousedown",s),document.addEventListener("mousemove",l),document.addEventListener("mouseup",c),document.addEventListener("click",d),()=>{e.removeEventListener("mousedown",s),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c),document.removeEventListener("click",d)}},d=[w,I.domElement,C],F[8]=w,F[9]=I.domElement,F[10]=C,F[11]=c,F[12]=d):(c=F[11],d=F[12]),(0,n.useEffect)(c,d),F[13]!==P||F[14]!==_||F[15]!==x?(m=()=>{let e=["camera1","camera2","camera3","camera4","camera5","camera6","camera7","camera8","camera9"];return x(t=>{for(let a=0;a{let e=e=>{e.preventDefault();let t=e.deltaY>0?-1:1,a=Math.max(.05,Math.min(.5,Math.abs(.01*e.deltaY)))*t;S(e=>Math.max(.1,Math.min(5,Math.round((e+a)*20)/20)))},t=I.domElement;return t.addEventListener("wheel",e,{passive:!1}),()=>{t.removeEventListener("wheel",e)}},p=[I.domElement,S],F[18]=I.domElement,F[19]=S,F[20]=g,F[21]=p):(g=F[20],p=F[21]),(0,n.useEffect)(g,p),F[22]!==w||F[23]!==k||F[24]!==b?(y=(e,t)=>{let{forward:a,backward:r,left:n,right:i,up:o,down:s,lookUp:l,lookDown:c,lookLeft:d,lookRight:u}=k();if((l||c||d||u)&&(B.current.setFromQuaternion(w.quaternion,"YXZ"),d&&(B.current.y=B.current.y+ +t),u&&(B.current.y=B.current.y-t),l&&(B.current.x=B.current.x+ +t),c&&(B.current.x=B.current.x-t),B.current.x=Math.max(-te,Math.min(te,B.current.x)),w.quaternion.setFromEuler(B.current)),!a&&!r&&!n&&!i&&!o&&!s)return;let h=80*b;w.getWorldDirection(M.current),M.current.normalize(),T.current.crossVectors(w.up,M.current).normalize(),E.current.set(0,0,0),a&&E.current.add(M.current),r&&E.current.sub(M.current),n&&E.current.add(T.current),i&&E.current.sub(T.current),o&&(E.current.y=E.current.y+1),s&&(E.current.y=E.current.y-1),E.current.lengthSq()>0&&(E.current.normalize().multiplyScalar(h*t),w.position.add(E.current))},F[22]=w,F[23]=k,F[24]=b,F[25]=y):y=F[25],(0,u.useFrame)(y),null}let ta=[{name:"forward",keys:["KeyW"]},{name:"backward",keys:["KeyS"]},{name:"left",keys:["KeyA"]},{name:"right",keys:["KeyD"]},{name:"up",keys:["Space"]},{name:"down",keys:["ShiftLeft","ShiftRight"]},{name:"lookUp",keys:["ArrowUp"]},{name:"lookDown",keys:["ArrowDown"]},{name:"lookLeft",keys:["ArrowLeft"]},{name:"lookRight",keys:["ArrowRight"]},{name:"camera1",keys:["Digit1"]},{name:"camera2",keys:["Digit2"]},{name:"camera3",keys:["Digit3"]},{name:"camera4",keys:["Digit4"]},{name:"camera5",keys:["Digit5"]},{name:"camera6",keys:["Digit6"]},{name:"camera7",keys:["Digit7"]},{name:"camera8",keys:["Digit8"]},{name:"camera9",keys:["Digit9"]}];function tr(){let e,t,i=(0,r.c)(2);return i[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],i[0]=e):e=i[0],(0,n.useEffect)(tn,e),i[1]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(tt,{}),i[1]=t):t=i[1],t}function tn(){return window.addEventListener("keydown",ti,{capture:!0}),window.addEventListener("keyup",ti,{capture:!0}),()=>{window.removeEventListener("keydown",ti,{capture:!0}),window.removeEventListener("keyup",ti,{capture:!0})}}function ti(e){(e.metaKey||e.ctrlKey)&&"k"===e.key||e.metaKey&&e.stopImmediatePropagation()}function to(e){let t,n=(0,r.c)(2),{children:i}=e;return n[0]!==i?(t=(0,a.jsx)(a.Fragment,{children:i}),n[0]=i,n[1]=t):t=n[1],t}function ts(){return(0,I.useEngineSelector)(tl)}function tl(e){return e.playback.recording}function tc(e){return"playing"===e.playback.status}function td(e){return e.playback.timeMs/1e3}function tu(e){return e.playback.durationMs/1e3}function th(e){return e.playback.rate}function tm(){let e,t,a,n,i,o,s=(0,r.c)(17),l=ts(),c=(0,I.useEngineSelector)(ty),d=(0,I.useEngineSelector)(tp),u=(0,I.useEngineSelector)(tg),h=(0,I.useEngineSelector)(tf);s[0]!==c?(e=e=>{c(e)},s[0]=c,s[1]=e):e=s[1];let m=e;s[2]!==l||s[3]!==d?(t=()=>{l&&d("playing")},s[2]=l,s[3]=d,s[4]=t):t=s[4];let f=t;s[5]!==d?(a=()=>{d("paused")},s[5]=d,s[6]=a):a=s[6];let g=a;s[7]!==u?(n=e=>{u(1e3*e)},s[7]=u,s[8]=n):n=s[8];let p=n;s[9]!==h?(i=e=>{h(e)},s[9]=h,s[10]=i):i=s[10];let y=i;return s[11]!==g||s[12]!==f||s[13]!==p||s[14]!==m||s[15]!==y?(o={setRecording:m,play:f,pause:g,seek:p,setSpeed:y},s[11]=g,s[12]=f,s[13]=p,s[14]=m,s[15]=y,s[16]=o):o=s[16],o}function tf(e){return e.setPlaybackRate}function tg(e){return e.setPlaybackTime}function tp(e){return e.setPlaybackStatus}function ty(e){return e.setDemoRecording}var tv=e.i(13070);function tF(){let e,t,n,i,o,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S,x,k,w,I,C=(0,r.c)(51),_=ts(),P=eQ(tD),D=eQ(tP),M=eQ(t_),T=eQ(tC),E=eQ(tI),B=eQ(tw),j=eQ(tk),R=eQ(tx),N=eQ(tS),A=eQ(tb);return _?null:(C[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("div",{className:tv.default.Spacer}),C[0]=e):e=C[0],C[1]!==P?(t=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":P,children:"W"}),C[1]=P,C[2]=t):t=C[2],C[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,a.jsx)("div",{className:tv.default.Spacer}),C[3]=n):n=C[3],C[4]!==t?(i=(0,a.jsxs)("div",{className:tv.default.Row,children:[e,t,n]}),C[4]=t,C[5]=i):i=C[5],C[6]!==M?(o=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":M,children:"A"}),C[6]=M,C[7]=o):o=C[7],C[8]!==D?(s=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":D,children:"S"}),C[8]=D,C[9]=s):s=C[9],C[10]!==T?(l=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":T,children:"D"}),C[10]=T,C[11]=l):l=C[11],C[12]!==o||C[13]!==s||C[14]!==l?(c=(0,a.jsxs)("div",{className:tv.default.Row,children:[o,s,l]}),C[12]=o,C[13]=s,C[14]=l,C[15]=c):c=C[15],C[16]!==i||C[17]!==c?(d=(0,a.jsxs)("div",{className:tv.default.Column,children:[i,c]}),C[16]=i,C[17]=c,C[18]=d):d=C[18],C[19]===Symbol.for("react.memo_cache_sentinel")?(u=(0,a.jsx)("span",{className:tv.default.Arrow,children:"↑"}),C[19]=u):u=C[19],C[20]!==E?(h=(0,a.jsx)("div",{className:tv.default.Row,children:(0,a.jsxs)("div",{className:tv.default.Key,"data-pressed":E,children:[u," Space"]})}),C[20]=E,C[21]=h):h=C[21],C[22]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)("span",{className:tv.default.Arrow,children:"↓"}),C[22]=m):m=C[22],C[23]!==B?(f=(0,a.jsx)("div",{className:tv.default.Row,children:(0,a.jsxs)("div",{className:tv.default.Key,"data-pressed":B,children:[m," Shift"]})}),C[23]=B,C[24]=f):f=C[24],C[25]!==h||C[26]!==f?(g=(0,a.jsxs)("div",{className:tv.default.Column,children:[h,f]}),C[25]=h,C[26]=f,C[27]=g):g=C[27],C[28]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("div",{className:tv.default.Spacer}),C[28]=p):p=C[28],C[29]!==j?(y=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":j,children:"↑"}),C[29]=j,C[30]=y):y=C[30],C[31]===Symbol.for("react.memo_cache_sentinel")?(v=(0,a.jsx)("div",{className:tv.default.Spacer}),C[31]=v):v=C[31],C[32]!==y?(F=(0,a.jsxs)("div",{className:tv.default.Row,children:[p,y,v]}),C[32]=y,C[33]=F):F=C[33],C[34]!==N?(b=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":N,children:"←"}),C[34]=N,C[35]=b):b=C[35],C[36]!==R?(S=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":R,children:"↓"}),C[36]=R,C[37]=S):S=C[37],C[38]!==A?(x=(0,a.jsx)("div",{className:tv.default.Key,"data-pressed":A,children:"→"}),C[38]=A,C[39]=x):x=C[39],C[40]!==b||C[41]!==S||C[42]!==x?(k=(0,a.jsxs)("div",{className:tv.default.Row,children:[b,S,x]}),C[40]=b,C[41]=S,C[42]=x,C[43]=k):k=C[43],C[44]!==F||C[45]!==k?(w=(0,a.jsxs)("div",{className:tv.default.Column,children:[F,k]}),C[44]=F,C[45]=k,C[46]=w):w=C[46],C[47]!==g||C[48]!==w||C[49]!==d?(I=(0,a.jsxs)("div",{className:tv.default.Root,children:[d,g,w]}),C[47]=g,C[48]=w,C[49]=d,C[50]=I):I=C[50],I)}function tb(e){return e.lookRight}function tS(e){return e.lookLeft}function tx(e){return e.lookDown}function tk(e){return e.lookUp}function tw(e){return e.down}function tI(e){return e.up}function tC(e){return e.right}function t_(e){return e.left}function tP(e){return e.backward}function tD(e){return e.forward}var tM=e.i(78295);function tT(e){let t=e.querySelector(".back");t&&(t.style.background="rgba(3, 79, 76, 0.6)",t.style.border="1px solid rgba(0, 219, 223, 0.5)",t.style.boxShadow="inset 0 0 10px rgba(0, 0, 0, 0.7)");let a=e.querySelector(".front");a&&(a.style.background="radial-gradient(circle at 50% 50%, rgba(23, 247, 198, 0.9) 0%, rgba(9, 184, 170, 0.95) 100%)",a.style.border="2px solid rgba(255, 255, 255, 0.4)",a.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 1px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15), inset 0 -1px 2px rgba(0, 0, 0, 0.3)")}let tE=Math.PI/2-.01;function tB({joystickState:t,joystickZone:r,lookJoystickState:i,lookJoystickZone:o}){let{touchMode:s}=(0,v.useControls)();(0,n.useEffect)(()=>{let a=r.current;if(!a)return;let n=null,i=!1;return e.A(84968).then(e=>{i||(n=e.default.create({zone:a,mode:"static",position:{left:"70px",bottom:"70px"},size:120,restOpacity:.9}),tT(a),n.on("move",(e,a)=>{t.current.angle=a.angle.radian,t.current.force=Math.min(1,a.force)}),n.on("end",()=>{t.current.force=0}))}),()=>{i=!0,n?.destroy()}},[t,r,s]),(0,n.useEffect)(()=>{if("dualStick"!==s)return;let t=o.current;if(!t)return;let a=null,r=!1;return e.A(84968).then(e=>{r||(a=e.default.create({zone:t,mode:"static",position:{right:"70px",bottom:"70px"},size:120,restOpacity:.9}),tT(t),a.on("move",(e,t)=>{i.current.angle=t.angle.radian,i.current.force=Math.min(1,t.force)}),a.on("end",()=>{i.current.force=0}))}),()=>{r=!0,a?.destroy()}},[s,i,o]);let l=()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur()};return"dualStick"===s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{ref:r,className:tM.default.Left,onContextMenu:e=>e.preventDefault(),onTouchStart:l}),(0,a.jsx)("div",{ref:o,className:tM.default.Right,onContextMenu:e=>e.preventDefault(),onTouchStart:l})]}):(0,a.jsx)("div",{ref:r,className:tM.default.Joystick,onContextMenu:e=>e.preventDefault(),onTouchStart:l})}function tj(e){let t,a,i,s,l,c,d,m,f,g,p=(0,r.c)(25),{joystickState:y,joystickZone:F,lookJoystickState:b}=e,{speedMultiplier:S,touchMode:x}=(0,v.useControls)(),{camera:k,gl:w}=(0,h.useThree)();p[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Euler(0,0,0,"YXZ"),p[0]=t):t=p[0];let I=(0,n.useRef)(t),C=(0,n.useRef)(null);p[1]===Symbol.for("react.memo_cache_sentinel")?(a={x:0,y:0},p[1]=a):a=p[1];let _=(0,n.useRef)(a);p[2]===Symbol.for("react.memo_cache_sentinel")?(i=new o.Vector3,p[2]=i):i=p[2];let P=(0,n.useRef)(i);p[3]===Symbol.for("react.memo_cache_sentinel")?(s=new o.Vector3,p[3]=s):s=p[3];let D=(0,n.useRef)(s);p[4]===Symbol.for("react.memo_cache_sentinel")?(l=new o.Vector3,p[4]=l):l=p[4];let M=(0,n.useRef)(l);return p[5]!==k.quaternion?(c=()=>{I.current.setFromQuaternion(k.quaternion,"YXZ")},p[5]=k.quaternion,p[6]=c):c=p[6],p[7]!==k?(d=[k],p[7]=k,p[8]=d):d=p[8],(0,n.useEffect)(c,d),p[9]!==k.quaternion||p[10]!==w.domElement||p[11]!==F||p[12]!==x?(m=()=>{if("moveLookStick"!==x)return;let e=w.domElement,t=e=>{let t=F.current;if(!t)return!1;let a=t.getBoundingClientRect();return e.clientX>=a.left&&e.clientX<=a.right&&e.clientY>=a.top&&e.clientY<=a.bottom},a=e=>{if(null===C.current)for(let a=0;a{if(null!==C.current)for(let t=0;t{for(let t=0;t{e.removeEventListener("touchstart",a),e.removeEventListener("touchmove",r),e.removeEventListener("touchend",n),e.removeEventListener("touchcancel",n),C.current=null}},p[9]=k.quaternion,p[10]=w.domElement,p[11]=F,p[12]=x,p[13]=m):m=p[13],p[14]!==k||p[15]!==w.domElement||p[16]!==F||p[17]!==x?(f=[k,w.domElement,F,x],p[14]=k,p[15]=w.domElement,p[16]=F,p[17]=x,p[18]=f):f=p[18],(0,n.useEffect)(m,f),p[19]!==k||p[20]!==y.current||p[21]!==b||p[22]!==S||p[23]!==x?(g=(e,t)=>{let{force:a,angle:r}=y.current;if("dualStick"===x){let e=b.current;if(e.force>.15){let a=(e.force-.15)/.85,r=Math.cos(e.angle),n=Math.sin(e.angle);I.current.setFromQuaternion(k.quaternion,"YXZ"),I.current.y=I.current.y-r*a*2.5*t,I.current.x=I.current.x+n*a*2.5*t,I.current.x=Math.max(-tE,Math.min(tE,I.current.x)),k.quaternion.setFromEuler(I.current)}if(a>.08){let e=80*S*((a-.08)/.92),n=Math.cos(r),i=Math.sin(r);k.getWorldDirection(P.current),P.current.normalize(),D.current.crossVectors(k.up,P.current).normalize(),M.current.set(0,0,0).addScaledVector(P.current,i).addScaledVector(D.current,-n),M.current.lengthSq()>0&&(M.current.normalize().multiplyScalar(e*t),k.position.add(M.current))}}else if("moveLookStick"===x&&a>0){let e=80*S*.5;if(k.getWorldDirection(P.current),P.current.normalize(),M.current.copy(P.current).multiplyScalar(e*t),k.position.add(M.current),a>=.15){let e=Math.cos(r),n=Math.sin(r),i=(a-.15)/.85;I.current.setFromQuaternion(k.quaternion,"YXZ"),I.current.y=I.current.y-e*i*1.25*t,I.current.x=I.current.x+n*i*1.25*t,I.current.x=Math.max(-tE,Math.min(tE,I.current.x)),k.quaternion.setFromEuler(I.current)}}},p[19]=k,p[20]=y.current,p[21]=b,p[22]=S,p[23]=x,p[24]=g):g=p[24],(0,u.useFrame)(g),null}var tR=e.i(11889),tN=e.i(56373),tA=e.i(86447),tG=e.i(1559),tU=e.i(78440),tL=e.i(59129),tz=e.i(25998),tO=e.i(18364),tV=e.i(70238),tq=e.i(29402),tH=e.i(97442);let tW=new Set(["SkiFree","SkiFree_Daily","SkiFree_Randomizer"]),t$={"missions.vl2":"Official","TR2final105-client.vl2":"Team Rabbit 2","z_mappacks/CTF/Classic_maps_v1.vl2":"Classic","z_mappacks/CTF/DynamixFinalPack.vl2":"Official","z_mappacks/CTF/KryMapPack_b3EDIT.vl2":"KryMapPack","z_mappacks/CTF/S5maps.vl2":"S5","z_mappacks/CTF/S8maps.vl2":"S8","z_mappacks/CTF/TWL-MapPack.vl2":"TWL","z_mappacks/CTF/TWL-MapPackEDIT.vl2":"TWL","z_mappacks/CTF/TWL2-MapPack.vl2":"TWL2","z_mappacks/CTF/TWL2-MapPackEDIT.vl2":"TWL2","z_mappacks/TWL_T2arenaOfficialMaps.vl2":"Arena","z_mappacks/xPack2.vl2":"xPack2","z_mappacks/z_DMP2-V0.6.vl2":"DMP2 (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX.vl2":"DMP (Discord Map Pack)","z_mappacks/zDMP-4.7.3DX-ServerOnly.vl2":"DMP (Discord Map Pack)"},tY={"z_mappacks/DM":"DM","z_mappacks/LCTF":"LCTF","z_mappacks/Lak":"LakRabbit"},tK=(0,eG.getMissionList)().filter(e=>!tW.has(e)).map(e=>{let t,a=(0,eG.getMissionInfo)(e),[r]=(0,eG.getSourceAndPath)(a.resourcePath),n=(t=r.match(/^(.*)(\/[^/]+)$/))?t[1]:"",i=t$[r]??tY[n]??null;return{resourcePath:a.resourcePath,missionName:e,displayName:a.displayName,sourcePath:r,groupName:i,missionTypes:a.missionTypes}}),tX=new Map(tK.map(e=>[e.missionName,e])),tZ=function(e){let t=new Map;for(let a of e){let e=t.get(a.groupName)??[];e.push(a),t.set(a.groupName,e)}return t.forEach((e,a)=>{t.set(a,(0,tq.default)(e,[e=>(e.displayName||e.missionName).toLowerCase()],["asc"]))}),(0,tq.default)(Array.from(t.entries()),[([e])=>"Official"===e?0:null==e?2:1,([e])=>e?e.toLowerCase():""],["asc","asc"])}(tK),tJ="u">typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.platform);function tQ(e){let t,n,i,o,s,l=(0,r.c)(12),{mission:c}=e,d=c.displayName||c.missionName;return l[0]!==d?(t=(0,a.jsx)("span",{className:tH.default.ItemName,children:d}),l[0]=d,l[1]=t):t=l[1],l[2]!==c.missionTypes?(n=c.missionTypes.length>0&&(0,a.jsx)("span",{className:tH.default.ItemTypes,children:c.missionTypes.map(t0)}),l[2]=c.missionTypes,l[3]=n):n=l[3],l[4]!==t||l[5]!==n?(i=(0,a.jsxs)("span",{className:tH.default.ItemHeader,children:[t,n]}),l[4]=t,l[5]=n,l[6]=i):i=l[6],l[7]!==c.missionName?(o=(0,a.jsx)("span",{className:tH.default.ItemMissionName,children:c.missionName}),l[7]=c.missionName,l[8]=o):o=l[8],l[9]!==i||l[10]!==o?(s=(0,a.jsxs)(a.Fragment,{children:[i,o]}),l[9]=i,l[10]=o,l[11]=s):s=l[11],s}function t0(e){return(0,a.jsx)("span",{className:tH.default.ItemType,"data-mission-type":e,children:e},e)}function t1(e){let t,i,o,s,l,c,d,u,h,m,f,g,p,y,v,F,b,S=(0,r.c)(46),{value:x,missionType:k,onChange:w,disabled:I}=e,[C,_]=(0,n.useState)(""),P=(0,n.useRef)(null),D=(0,n.useRef)(k);S[0]===Symbol.for("react.memo_cache_sentinel")?(t=e=>{(0,n.startTransition)(()=>_(e))},S[0]=t):t=S[0];let M=(0,tO.useComboboxStore)({resetValueOnHide:!0,selectedValue:x,setSelectedValue:e=>{if(e){let t=D.current,a=(0,eG.getMissionInfo)(e).missionTypes;t&&a.includes(t)||(t=a[0]),w({missionName:e,missionType:t}),P.current?.blur()}},setValue:t});S[1]!==M?(i=()=>{let e=e=>{"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),P.current?.focus(),M.show())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},o=[M],S[1]=M,S[2]=i,S[3]=o):(i=S[2],o=S[3]),(0,n.useEffect)(i,o),S[4]!==x?(s=tX.get(x),S[4]=x,S[5]=s):s=S[5];let T=s;e:{let e,t;if(!C){let e;S[6]===Symbol.for("react.memo_cache_sentinel")?(e={type:"grouped",groups:tZ},S[6]=e):e=S[6],l=e;break e}S[7]!==C?(e=(0,tV.matchSorter)(tK,C,{keys:["displayName","missionName","missionTypes","groupName"]}),S[7]=C,S[8]=e):e=S[8];let a=e;S[9]!==a?(t={type:"flat",missions:a},S[9]=a,S[10]=t):t=S[10],l=t}let E=l,B=T?T.displayName||T.missionName:x,j="flat"===E.type?0===E.missions.length:0===E.groups.length,R=e=>(0,a.jsx)(tN.ComboboxItem,{value:e.missionName,className:tH.default.Item,focusOnHover:!0,onClick:t=>{if(t.target&&t.target instanceof HTMLElement){let a=t.target.dataset.missionType;a?(D.current=a,e.missionName===x&&w({missionName:e.missionName,missionType:a})):D.current=null}else D.current=null},children:(0,a.jsx)(tQ,{mission:e})},e.missionName),N=tU.ComboboxProvider;S[11]!==M?(c=()=>{try{document.exitPointerLock()}catch{}M.show()},d=e=>{"Escape"!==e.key||M.getState().open||P.current?.blur()},S[11]=M,S[12]=c,S[13]=d):(c=S[12],d=S[13]),S[14]!==I||S[15]!==B||S[16]!==c||S[17]!==d?(u=(0,a.jsx)(tR.Combobox,{ref:P,autoSelect:!0,disabled:I,placeholder:B,className:tH.default.Input,onFocus:c,onKeyDown:d}),S[14]=I,S[15]=B,S[16]=c,S[17]=d,S[18]=u):u=S[18],S[19]!==B?(h=(0,a.jsx)("span",{className:tH.default.SelectedName,children:B}),S[19]=B,S[20]=h):h=S[20],S[21]!==k?(m=k&&(0,a.jsx)("span",{className:tH.default.ItemType,"data-mission-type":k,children:k}),S[21]=k,S[22]=m):m=S[22],S[23]!==m||S[24]!==h?(f=(0,a.jsxs)("div",{className:tH.default.SelectedValue,children:[h,m]}),S[23]=m,S[24]=h,S[25]=f):f=S[25],S[26]===Symbol.for("react.memo_cache_sentinel")?(g=(0,a.jsx)("kbd",{className:tH.default.Shortcut,children:tJ?"⌘K":"^K"}),S[26]=g):g=S[26],S[27]!==f||S[28]!==u?(p=(0,a.jsxs)("div",{className:tH.default.InputWrapper,children:[u,f,g]}),S[27]=f,S[28]=u,S[29]=p):p=S[29];let A=tG.ComboboxPopover,G=tH.default,U=tA.ComboboxList,L=tH.default,z="flat"===E.type?E.missions.map(R):E.groups.map(e=>{let[t,r]=e;return t?(0,a.jsxs)(tL.ComboboxGroup,{className:tH.default.Group,children:[(0,a.jsx)(tz.ComboboxGroupLabel,{className:tH.default.GroupLabel,children:t}),r.map(R)]},t):(0,a.jsx)(n.Fragment,{children:r.map(R)},"ungrouped")});return S[30]!==j?(y=j&&(0,a.jsx)("div",{className:tH.default.NoResults,children:"No missions found"}),S[30]=j,S[31]=y):y=S[31],S[32]!==U||S[33]!==L.List||S[34]!==z||S[35]!==y?(v=(0,a.jsxs)(U,{className:L.List,children:[z,y]}),S[32]=U,S[33]=L.List,S[34]=z,S[35]=y,S[36]=v):v=S[36],S[37]!==A||S[38]!==G.Popover||S[39]!==v?(F=(0,a.jsx)(A,{gutter:4,fitViewport:!0,autoFocusOnHide:!1,className:G.Popover,children:v}),S[37]=A,S[38]=G.Popover,S[39]=v,S[40]=F):F=S[40],S[41]!==N||S[42]!==M||S[43]!==p||S[44]!==F?(b=(0,a.jsxs)(N,{store:M,children:[p,F]}),S[41]=N,S[42]=M,S[43]=p,S[44]=F,S[45]=b):b=S[45],b}var t2=e.i(11152),t3=e.i(40141);function t5(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M192 0c-41.8 0-77.4 26.7-90.5 64L64 64C28.7 64 0 92.7 0 128L0 448c0 35.3 28.7 64 64 64l256 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64l-37.5 0C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM305 273L177 401c-9.4 9.4-24.6 9.4-33.9 0L79 337c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L271 239c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"},child:[]}]})(e)}var t4=e.i(36679);function t6(e){let t,i,o,s,l,c=(0,r.c)(11),{cameraRef:d,missionName:u,missionType:h}=e,{fogEnabled:m}=(0,v.useSettings)(),[f,g]=(0,n.useState)(!1),p=(0,n.useRef)(null);c[0]!==d||c[1]!==m||c[2]!==u||c[3]!==h?(t=async()=>{clearTimeout(p.current);let e=d.current;if(!e)return;let t=function({position:e,quaternion:t}){let a=e=>parseFloat(e.toFixed(3)),r=`${a(e.x)},${a(e.y)},${a(e.z)}`,n=`${a(t.x)},${a(t.y)},${a(t.z)},${a(t.w)}`;return`#c${r}~${n}`}(e),a=new URLSearchParams;a.set("mission",`${u}~${h}`),a.set("fog",m.toString());let r=`${window.location.pathname}?${a}${t}`,n=`${window.location.origin}${r}`;window.history.replaceState(null,"",r);try{await navigator.clipboard.writeText(n),g(!0),p.current=setTimeout(()=>{g(!1)},1100)}catch(e){console.error(e)}},c[0]=d,c[1]=m,c[2]=u,c[3]=h,c[4]=t):t=c[4];let y=t,F=f?"true":"false";return c[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,a.jsx)(t2.FaMapPin,{className:t4.default.MapPin}),o=(0,a.jsx)(t5,{className:t4.default.ClipboardCheck}),s=(0,a.jsx)("span",{className:t4.default.ButtonLabel,children:" Copy coordinates URL"}),c[5]=i,c[6]=o,c[7]=s):(i=c[5],o=c[6],s=c[7]),c[8]!==y||c[9]!==F?(l=(0,a.jsxs)("button",{type:"button",className:t4.default.Root,"aria-label":"Copy coordinates URL",title:"Copy coordinates URL",onClick:y,"data-copied":F,id:"copyCoordinatesButton",children:[i,o,s]}),c[8]=y,c[9]=F,c[10]=l):l=c[10],l}function t8(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M21 3H3c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h5v2h8v-2h5c1.1 0 1.99-.9 1.99-2L23 5a2 2 0 0 0-2-2zm0 14H3V5h18v12zm-5-6-7 4V7z"},child:[]}]})(e)}var t7={},t9=function(e,t,a,r,n){var i=new Worker(t7[t]||(t7[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return i.onmessage=function(e){var t=e.data,a=t.$e$;if(a){var r=Error(a[0]);r.code=a[1],r.stack=a[2],n(r,null)}else n(null,t)},i.postMessage(a,r),i},ae=Uint8Array,at=Uint16Array,aa=Int32Array,ar=new ae([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),an=new ae([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ai=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ao=function(e,t){for(var a=new at(31),r=0;r<31;++r)a[r]=t+=1<>1|(21845&af)<<1;ag=(61680&(ag=(52428&ag)>>2|(13107&ag)<<2))>>4|(3855&ag)<<4,am[af]=((65280&ag)>>8|(255&ag)<<8)>>1}for(var ap=function(e,t,a){for(var r,n=e.length,i=0,o=new at(t);i>l]=c}else for(i=0,r=new at(n);i>15-e[i]);return r},ay=new ae(288),af=0;af<144;++af)ay[af]=8;for(var af=144;af<256;++af)ay[af]=9;for(var af=256;af<280;++af)ay[af]=7;for(var af=280;af<288;++af)ay[af]=8;for(var av=new ae(32),af=0;af<32;++af)av[af]=5;var aF=ap(ay,9,0),ab=ap(ay,9,1),aS=ap(av,5,0),ax=ap(av,5,1),ak=function(e){for(var t=e[0],a=1;at&&(t=e[a]);return t},aw=function(e,t,a){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&a},aI=function(e,t){var a=t/8|0;return(e[a]|e[a+1]<<8|e[a+2]<<16)>>(7&t)},aC=function(e){return(e+7)/8|0},a_=function(e,t,a){return(null==t||t<0)&&(t=0),(null==a||a>e.length)&&(a=e.length),new ae(e.subarray(t,a))},aP=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],aD=function(e,t,a){var r=Error(t||aP[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,aD),!a)throw r;return r},aM=function(e,t,a,r){var n=e.length,i=r?r.length:0;if(!n||t.f&&!t.l)return a||new ae(0);var o=!a,s=o||2!=t.i,l=t.i;o&&(a=new ae(3*n));var c=function(e){var t=a.length;if(e>t){var r=new ae(Math.max(2*t,e));r.set(a),a=r}},d=t.f||0,u=t.p||0,h=t.b||0,m=t.l,f=t.d,g=t.m,p=t.n,y=8*n;do{if(!m){d=aw(e,u,1);var v=aw(e,u+1,3);if(u+=3,v)if(1==v)m=ab,f=ax,g=9,p=5;else if(2==v){var F=aw(e,u,31)+257,b=aw(e,u+10,15)+4,S=F+aw(e,u+5,31)+1;u+=14;for(var x=new ae(S),k=new ae(19),w=0;w>4;if(D<16)x[w++]=D;else{var M=0,T=0;for(16==D?(T=3+aw(e,u,3),u+=2,M=x[w-1]):17==D?(T=3+aw(e,u,7),u+=3):18==D&&(T=11+aw(e,u,127),u+=7);T--;)x[w++]=M}}var E=x.subarray(0,F),B=x.subarray(F);g=ak(E),p=ak(B),m=ap(E,g,1),f=ap(B,p,1)}else aD(1);else{var D=aC(u)+4,j=e[D-4]|e[D-3]<<8,R=D+j;if(R>n){l&&aD(0);break}s&&c(h+j),a.set(e.subarray(D,R),h),t.b=h+=j,t.p=u=8*R,t.f=d;continue}if(u>y){l&&aD(0);break}}s&&c(h+131072);for(var N=(1<>4;if((u+=15&M)>y){l&&aD(0);break}if(M||aD(2),U<256)a[h++]=U;else if(256==U){G=u,m=null;break}else{var L=U-254;if(U>264){var w=U-257,z=ar[w];L=aw(e,u,(1<>4;O||aD(3),u+=15&O;var B=au[V];if(V>3){var z=an[V];B+=aI(e,u)&(1<y){l&&aD(0);break}s&&c(h+131072);var q=h+L;if(h>8},aE=function(e,t,a){a<<=7&t;var r=t/8|0;e[r]|=a,e[r+1]|=a>>8,e[r+2]|=a>>16},aB=function(e,t){for(var a=[],r=0;rh&&(h=i[r].s);var m=new at(h+1),f=aj(a[d-1],m,0);if(f>t){var r=0,g=0,p=f-t,y=1<t)g+=y-(1<>=p;g>0;){var F=i[r].s;m[F]=0&&g;--r){var b=i[r].s;m[b]==t&&(--m[b],++g)}f=t}return{t:new ae(m),l:f}},aj=function(e,t,a){return -1==e.s?Math.max(aj(e.l,t,a+1),aj(e.r,t,a+1)):t[e.s]=a},aR=function(e){for(var t=e.length;t&&!e[--t];);for(var a=new at(++t),r=0,n=e[0],i=1,o=function(e){a[r++]=e},s=1;s<=t;++s)if(e[s]==n&&s!=t)++i;else{if(!n&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(n),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(n);i=1,n=e[s]}return{c:a.subarray(0,r),n:t}},aN=function(e,t){for(var a=0,r=0;r>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var i=0;i4&&!M[ai[E-1]];--E);var B=c+5<<3,j=aN(n,ay)+aN(i,av)+o,R=aN(n,p)+aN(i,F)+o+14+3*E+aN(_,M)+2*_[16]+3*_[17]+7*_[18];if(l>=0&&B<=j&&B<=R)return aA(t,d,e.subarray(l,l+c));if(aT(t,d,1+(R15&&(aT(t,d,U[P]>>5&127),d+=U[P]>>12)}}else u=aF,h=ay,m=aS,f=av;for(var P=0;P255){var L=z>>18&31;aE(t,d,u[L+257]),d+=h[L+257],L>7&&(aT(t,d,z>>23&31),d+=ar[L]);var O=31&z;aE(t,d,m[O]),d+=f[O],O>3&&(aE(t,d,z>>5&8191),d+=an[O])}else aE(t,d,u[z]),d+=h[z]}return aE(t,d,u[256]),d+h[256]},aU=new aa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),aL=new ae(0),az=function(e,t,a,r,n,i){var o=i.z||e.length,s=new ae(r+o+5*(1+Math.ceil(o/7e3))+n),l=s.subarray(r,s.length-n),c=i.l,d=7&(i.r||0);if(t){d&&(l[0]=i.r>>3);for(var u=aU[t-1],h=u>>13,m=8191&u,f=(1<7e3||C>24576)&&(E>423||!c)){d=aG(e,l,0,b,S,x,w,C,P,I-P,d),C=k=w=0,P=I;for(var B=0;B<286;++B)S[B]=0;for(var B=0;B<30;++B)x[B]=0}var j=2,R=0,N=m,A=M-T&32767;if(E>2&&D==F(I-A))for(var G=Math.min(h,E)-1,U=Math.min(32767,I),L=Math.min(258,E);A<=U&&--N&&M!=T;){if(e[I+j]==e[I+j-A]){for(var z=0;zj){if(j=z,R=A,z>G)break;for(var O=Math.min(A,z-2),V=0,B=0;BV&&(V=W,T=q)}}}T=g[M=T],A+=M-T&32767}if(R){b[C++]=0x10000000|ac[j]<<18|ah[R];var $=31&ac[j],Y=31&ah[R];w+=ar[$]+an[Y],++S[257+$],++x[Y],_=I+j,++k}else b[C++]=e[I],++S[e[I]]}}for(I=Math.max(I,_);I=o&&(l[d/8|0]=c,K=o),d=aA(l,d+1,e.subarray(I,K))}i.i=o}return a_(s,0,r+aC(d)+n)},aO=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var a=t,r=9;--r;)a=(1&a&&-0x12477ce0)^a>>>1;e[t]=a}return e}(),aV=function(){var e=-1;return{p:function(t){for(var a=e,r=0;r>>8;e=a},d:function(){return~e}}},aq=function(){var e=1,t=0;return{p:function(a){for(var r=e,n=t,i=0|a.length,o=0;o!=i;){for(var s=Math.min(o+2655,i);o>16),n=(65535&n)+15*(n>>16)}e=r,t=n},d:function(){return e%=65521,t%=65521,(255&e)<<24|(65280&e)<<8|(255&t)<<8|t>>8}}},aH=function(e,t,a,r,n){if(!n&&(n={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new ae(i.length+e.length);o.set(i),o.set(e,i.length),e=o,n.w=i.length}return az(e,null==t.level?6:t.level,null==t.mem?n.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):20:12+t.mem,a,r,n)},aW=function(e,t){var a={};for(var r in e)a[r]=e[r];for(var r in t)a[r]=t[r];return a},a$=function(e,t,a){for(var r=e(),n=e.toString(),i=n.slice(n.indexOf("[")+1,n.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o>>0},a7=function(e,t){return a8(e,t)+0x100000000*a8(e,t+4)},a9=function(e,t,a){for(;a;++t)e[t]=a,a>>>=8},re=function(e,t){var a=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:2*(9==t.level),e[9]=3,0!=t.mtime&&a9(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),a){e[3]=8;for(var r=0;r<=a.length;++r)e[r+10]=a.charCodeAt(r)}},rt=function(e){(31!=e[0]||139!=e[1]||8!=e[2])&&aD(6,"invalid gzip data");var t=e[3],a=10;4&t&&(a+=(e[10]|e[11]<<8)+2);for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[a++]);return a+(2&t)},ra=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},rr=function(e){return 10+(e.filename?e.filename.length+1:0)},rn=function(e,t){var a=t.level;if(e[0]=120,e[1]=(0==a?0:a<6?1:9==a?3:2)<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=aq();r.p(t.dictionary),a9(e,2,r.d())}},ri=function(e,t){return((15&e[0])!=8||e[0]>>4>7||(e[0]<<8|e[1])%31)&&aD(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&aD(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),(e[1]>>3&4)+2};function ro(e,t){return"function"==typeof e&&(t=e,e={}),this.ondata=t,e}var rs=function(){function e(e,t){if("function"==typeof e&&(t=e,e={}),this.ondata=t,this.o=e||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new ae(98304),this.o.dictionary){var a=this.o.dictionary.subarray(-32768);this.b.set(a,32768-a.length),this.s.i=32768-a.length}}return e.prototype.p=function(e,t){this.ondata(aH(e,this.o,0,0,this.s),t)},e.prototype.push=function(e,t){this.ondata||aD(5),this.s.l&&aD(4);var a=e.length+this.s.z;if(a>this.b.length){if(a>2*this.b.length-32768){var r=new ae(-32768&a);r.set(this.b.subarray(0,this.s.z)),this.b=r}var n=this.b.length-this.s.z;this.b.set(e.subarray(0,n),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(e.subarray(n),32768),this.s.z=e.length-n+32768,this.s.i=32766,this.s.w=32768}else this.b.set(e,this.s.z),this.s.z+=e.length;this.s.l=1&t,(this.s.z>this.s.w+8191||t)&&(this.p(this.b,t||!1),this.s.w=this.s.i,this.s.i-=2)},e.prototype.flush=function(){this.ondata||aD(5),this.s.l&&aD(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},e}(),rl=function(e,t){a4([aJ,function(){return[a5,rs]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rs(e.data))},6,1)};function rc(e,t){return aH(e,t||{},0,0)}var rd=function(){function e(e,t){"function"==typeof e&&(t=e,e={}),this.ondata=t;var a=e&&e.dictionary&&e.dictionary.subarray(-32768);this.s={i:0,b:a?a.length:0},this.o=new ae(32768),this.p=new ae(0),a&&this.o.set(a)}return e.prototype.e=function(e){if(this.ondata||aD(5),this.d&&aD(4),this.p.length){if(e.length){var t=new ae(this.p.length+e.length);t.set(this.p),t.set(e,this.p.length),this.p=t}}else this.p=e},e.prototype.c=function(e){this.s.i=+(this.d=e||!1);var t=this.s.b,a=aM(this.p,this.s,this.o);this.ondata(a_(a,t,this.s.b),this.d),this.o=a_(a,this.s.b-32768),this.s.b=this.o.length,this.p=a_(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),ru=function(e,t){a4([aZ,function(){return[a5,rd]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rd(e.data))},7,0)};function rh(e,t){return aM(e,{i:2},t&&t.out,t&&t.dictionary)}(function(){function e(e,t){this.c=aV(),this.l=0,this.v=1,rs.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),this.l+=e.length,rs.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=aH(e,this.o,this.v&&rr(this.o),t&&8,this.s);this.v&&(re(a,this.o),this.v=0),t&&(a9(a,a.length-8,this.c.d()),a9(a,a.length-4,this.l)),this.ondata(a,t)},e.prototype.flush=function(){rs.prototype.flush.call(this)}})();var rm=function(){function e(e,t){this.v=1,this.r=0,rd.call(this,e,t)}return e.prototype.push=function(e,t){if(rd.prototype.e.call(this,e),this.r+=e.length,this.v){var a=this.p.subarray(this.v-1),r=a.length>3?rt(a):4;if(r>a.length){if(!t)return}else this.v>1&&this.onmember&&this.onmember(this.r-a.length);this.p=a.subarray(r),this.v=0}rd.prototype.c.call(this,t),!this.s.f||this.s.l||t||(this.v=aC(this.s.p)+9,this.s={i:0},this.o=new ae(0),this.push(new ae(0),t))},e}(),rf=function(e,t){var a=this;a4([aZ,aQ,function(){return[a5,rd,rm]}],this,ro.call(this,e,t),function(e){var t=new rm(e.data);t.onmember=function(e){return postMessage(e)},onmessage=a5(t)},9,0,function(e){return a.onmember&&a.onmember(e)})},rg=(function(){function e(e,t){this.c=aq(),this.v=1,rs.call(this,e,t)}e.prototype.push=function(e,t){this.c.p(e),rs.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){var a=aH(e,this.o,this.v&&(this.o.dictionary?6:2),t&&4,this.s);this.v&&(rn(a,this.o),this.v=0),t&&a9(a,a.length-4,this.c.d()),this.ondata(a,t)},e.prototype.flush=function(){rs.prototype.flush.call(this)}}(),function(){function e(e,t){rd.call(this,e,t),this.v=e&&e.dictionary?2:1}return e.prototype.push=function(e,t){if(rd.prototype.e.call(this,e),this.v){if(this.p.length<6&&!t)return;this.p=this.p.subarray(ri(this.p,this.v-1)),this.v=0}t&&(this.p.length<4&&aD(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),rd.prototype.c.call(this,t)},e}()),rp=function(e,t){a4([aZ,a0,function(){return[a5,rd,rg]}],this,ro.call(this,e,t),function(e){onmessage=a5(new rg(e.data))},11,0)},ry=function(){function e(e,t){this.o=ro.call(this,e,t)||{},this.G=rm,this.I=rd,this.Z=rg}return e.prototype.i=function(){var e=this;this.s.ondata=function(t,a){e.ondata(t,a)}},e.prototype.push=function(e,t){if(this.ondata||aD(5),this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var a=new ae(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length)}else this.p=e;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):(15&this.p[0])!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,t),this.p=null)}},e}();function rv(e,t){ry.call(this,e,t),this.queuedSize=0,this.G=rf,this.I=ru,this.Z=rp}rv.prototype.i=function(){var e=this;this.s.ondata=function(t,a,r){e.ondata(t,a,r)},this.s.ondrain=function(t){e.queuedSize-=t,e.ondrain&&e.ondrain(t)}},rv.prototype.push=function(e,t){this.queuedSize+=e.length,ry.prototype.push.call(this,e,t)};var rF="u">typeof TextEncoder&&new TextEncoder,rb="u">typeof TextDecoder&&new TextDecoder,rS=0;try{rb.decode(aL,{stream:!0}),rS=1}catch(e){}var rx=function(e){for(var t="",a=0;;){var r=e[a++],n=(r>127)+(r>223)+(r>239);if(a+n>e.length)return{s:t,r:a_(e,a-1)};n?3==n?t+=String.fromCharCode(55296|(r=((15&r)<<18|(63&e[a++])<<12|(63&e[a++])<<6|63&e[a++])-65536)>>10,56320|1023&r):1&n?t+=String.fromCharCode((31&r)<<6|63&e[a++]):t+=String.fromCharCode((15&r)<<12|(63&e[a++])<<6|63&e[a++]):t+=String.fromCharCode(r)}};function rk(e,t){if(t){for(var a=new ae(e.length),r=0;r>1)),o=0,s=function(e){i[o++]=e},r=0;ri.length){var l=new ae(o+8+(n-r<<1));l.set(i),i=l}var c=e.charCodeAt(r);c<128||t?s(c):(c<2048?s(192|c>>6):(c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++r))>>18),s(128|c>>12&63)):s(224|c>>12),s(128|c>>6&63)),s(128|63&c))}return a_(i,0,o)}(function(e){this.ondata=e,rS?this.t=new TextDecoder:this.p=aL}).prototype.push=function(e,t){if(this.ondata||aD(5),t=!!t,this.t){this.ondata(this.t.decode(e,{stream:!0}),t),t&&(this.t.decode().length&&aD(8),this.t=null);return}this.p||aD(4);var a=new ae(this.p.length+e.length);a.set(this.p),a.set(e,this.p.length);var r=rx(a),n=r.s,i=r.r;t?(i.length&&aD(8),this.p=null):this.p=i,this.ondata(n,t)},(function(e){this.ondata=e}).prototype.push=function(e,t){this.ondata||aD(5),this.d&&aD(4),this.ondata(rk(e),this.d=t||!1)};var rw=function(e){return 1==e?3:e<6?2:+(9==e)},rI=function(e,t){for(;1!=a6(e,t);t+=4+a6(e,t+2));return[a7(e,t+12),a7(e,t+4),a7(e,t+20)]},rC=function(e){var t=0;if(e)for(var a in e){var r=e[a].length;r>65535&&aD(9),t+=r+4}return t},r_=function(e,t,a,r,n,i,o,s){var l=r.length,c=a.extra,d=s&&s.length,u=rC(c);a9(e,t,null!=o?0x2014b50:0x4034b50),t+=4,null!=o&&(e[t++]=20,e[t++]=a.os),e[t]=20,t+=2,e[t++]=a.flag<<1|(i<0&&8),e[t++]=n&&8,e[t++]=255&a.compression,e[t++]=a.compression>>8;var h=new Date(null==a.mtime?Date.now():a.mtime),m=h.getFullYear()-1980;if((m<0||m>119)&&aD(10),a9(e,t,m<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,-1!=i&&(a9(e,t,a.crc),a9(e,t+4,i<0?-i-2:i),a9(e,t+8,a.size)),a9(e,t+12,l),a9(e,t+14,u),t+=16,null!=o&&(a9(e,t,d),a9(e,t+6,a.attrs),a9(e,t+10,o),t+=14),e.set(r,t),t+=l,u)for(var f in c){var g=c[f],p=g.length;a9(e,t,+f),a9(e,t+2,p),e.set(g,t+4),t+=4+p}return d&&(e.set(s,t),t+=d),t},rP=function(e,t,a,r,n){a9(e,t,0x6054b50),a9(e,t+8,a),a9(e,t+10,a),a9(e,t+12,r),a9(e,t+16,n)},rD=function(){function e(e){this.filename=e,this.c=aV(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){this.ondata||aD(5),this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}();function rM(e,t){var a=this;t||(t={}),rD.call(this,e),this.d=new rs(t,function(e,t){a.ondata(null,e,t)}),this.compression=8,this.flag=rw(t.level)}function rT(e,t){var a=this;t||(t={}),rD.call(this,e),this.d=new rl(t,function(e,t,r){a.ondata(e,t,r)}),this.compression=8,this.flag=rw(t.level),this.terminate=this.d.terminate}function rE(e){this.ondata=e,this.u=[],this.d=1}rM.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},rM.prototype.push=function(e,t){rD.prototype.push.call(this,e,t)},rT.prototype.process=function(e,t){this.d.push(e,t)},rT.prototype.push=function(e,t){rD.prototype.push.call(this,e,t)},rE.prototype.add=function(e){var t=this;if(this.ondata||aD(5),2&this.d)this.ondata(aD(4+(1&this.d)*8,0,1),null,!1);else{var a=rk(e.filename),r=a.length,n=e.comment,i=n&&rk(n),o=r!=e.filename.length||i&&n.length!=i.length,s=r+rC(e.extra)+30;r>65535&&this.ondata(aD(11,0,1),null,!1);var l=new ae(s);r_(l,0,e,a,o,-1);var c=[l],d=function(){for(var e=0,a=c;e0){var r=Math.min(this.c,e.length),n=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(n,!this.c):this.k[0].push(n),(e=e.subarray(r)).length)return this.push(e,t)}else{var i=0,o=0,s=void 0,l=void 0;this.p.length?e.length?((l=new ae(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,d=this.c,u=d&&this.d,h=this;oo+30+u+m){var f,g,p=[];h.k.unshift(p),i=2;var y=a8(l,o+18),v=a8(l,o+22),F=function(e,t){if(t){for(var a="",r=0;r=0&&(b.size=y,b.originalSize=v),h.onfile(b)}return"break"}if(d){if(0x8074b50==e)return s=o+=12+(-2==d&&8),i=3,h.c=0,"break";else if(0x2014b50==e)return s=o-=4,i=3,h.c=0,"break"}}();++o);if(this.p=aL,d<0){var m=i?l.subarray(0,s-12-(-2==d&&8)-(0x8074b50==a8(l,s-16)&&4)):l.subarray(0,o);u?u.push(m,!!i):this.k[+(2==i)].push(m)}if(2&i)return this.push(l.subarray(o),t);this.p=l.subarray(o)}t&&(this.c&&aD(13),this.p=null)},rN.prototype.register=function(e){this.o[e.compression]=e},"function"==typeof queueMicrotask&&queueMicrotask;var rA=e.i(48450);let rG=[0,0,0,0,0,0,0,0,0,329,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2809,68,0,27,0,58,3,62,4,7,0,0,15,65,554,3,394,404,189,117,30,51,27,15,34,32,80,1,142,3,142,39,0,144,125,44,122,275,70,135,61,127,8,12,113,246,122,36,185,1,149,309,335,12,11,14,54,151,0,0,2,0,0,211,0,2090,344,736,993,2872,701,605,646,1552,328,305,1240,735,1533,1713,562,3,1775,1149,1469,979,407,553,59,279,31,0,0,0,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function rU(e){return e.node?e.node.pop:e.leaf.pop}let rL=new class{nodes=[];leaves=[];tablesBuilt=!1;buildTables(){if(this.tablesBuilt)return;this.tablesBuilt=!0,this.leaves=[];for(let t=0;t<256;t++){var e;this.leaves.push({pop:rG[t]+ +((e=t)>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)+1,symbol:t,numBits:0,code:0})}this.nodes=[{pop:0,index0:0,index1:0}];let t=256,a=[];for(let e=0;e<256;e++)a.push({node:null,leaf:this.leaves[e]});for(;1!==t;){let e=0xfffffffe,r=0xffffffff,n=-1,i=-1;for(let o=0;oi?n:i;a[s]={node:o,leaf:null},l!==t-1&&(a[l]=a[t-1]),t--}this.nodes[0]=a[0].node,this.generateCodes(0,0,0)}determineIndex(e){return null!==e.leaf?-(this.leaves.indexOf(e.leaf)+1):this.nodes.indexOf(e.node)}generateCodes(e,t,a){if(t<0){let r=this.leaves[-(t+1)];r.code=e,r.numBits=a}else{let r=this.nodes[t];this.generateCodes(e,r.index0,a+1),this.generateCodes(e|1<=0)t=e.readFlag()?this.nodes[t].index1:this.nodes[t].index0;else{a.push(this.leaves[-(t+1)].symbol);break}}return String.fromCharCode(...a)}{let t=e.readInt(8);return String.fromCharCode(...e.readBytes(t))}}};class rz{data;bitNum;maxReadBitNum;error;stringBuffer=null;constructor(e,t=0){this.data=e,this.bitNum=t,this.maxReadBitNum=e.length<<3,this.error=!1}getCurPos(){return this.bitNum}setCurPos(e){this.bitNum=e}getBytePosition(){return this.bitNum+7>>3}isError(){return this.error}isFull(){return this.bitNum>this.maxReadBitNum}getRemainingBits(){return this.maxReadBitNum-this.bitNum}getMaxPos(){return this.maxReadBitNum}readFlag(){if(this.bitNum>=this.maxReadBitNum)return this.error=!0,!1;let e=1<<(7&this.bitNum),t=(this.data[this.bitNum>>3]&e)!=0;return this.bitNum++,t}readInt(e){if(0===e)return 0;if(this.bitNum+e>this.maxReadBitNum)return this.error=!0,0;let t=this.bitNum>>3,a=7&this.bitNum;if(this.bitNum+=e,e+a<=32){let r=0,n=e+a+7>>3;for(let e=0;e>>=a,32===e)?r>>>0:r&(1<>3;for(let e=0;e>>0:r&(1<>3,a=new Uint8Array(t),r=this.bitNum>>3,n=7&this.bitNum,i=8-n;if(0===n)a.set(this.data.subarray(r,r+t));else{let e=this.data[r];for(let o=0;o>n|t<this.maxReadBitNum)return this.error=!0,0;let e=this.bitNum>>3,t=7&this.bitNum,a=rz.f32U8;if(0===t)a[0]=this.data[e],a[1]=this.data[e+1],a[2]=this.data[e+2],a[3]=this.data[e+3];else{let r=8-t;for(let n=0;n<4;n++){let i=this.data[e+n],o=e+n+1>t|o<>>0)}getCompressionPoint(){return this.compressionPoint}getConnectionContext(){let e=this.dataBlockDataMap;return{compressionPoint:this.compressionPoint,ghostTracker:this.ghostTracker,getDataBlockParser:e=>this.registry.getDataBlockParser(e),getDataBlockData:e?t=>e.get(t):void 0,getGhostParser:e=>this.registry.getGhostParser(e)}}_setNextRecvEventSeq(e){this.nextRecvEventSeq=e>>>0}setConnectionProtocolState(e){for(this.lastSeqRecvdAtSend=e.lastSeqRecvdAtSend.slice(0,32);this.lastSeqRecvdAtSend.length<32;)this.lastSeqRecvdAtSend.push(0);this.lastSeqRecvd=e.lastSeqRecvd>>>0,this.highestAckedSeq=e.highestAckedSeq>>>0,this.lastSendSeq=e.lastSendSeq>>>0,this.recvAckMask=e.ackMask>>>0,this.connectSequence=e.connectSequence>>>0,this.lastRecvAckAck=e.lastRecvAckAck>>>0,this._connectionEstablished=e.connectionEstablished}onSendPacketTrigger(){this.lastSendSeq=this.lastSendSeq+1>>>0,this.lastSeqRecvdAtSend[31&this.lastSendSeq]=this.lastSeqRecvd>>>0}applyProtocolHeader(e){if(e.connectSeqBit!==(1&this.connectSequence)||e.ackByteCount>4||e.packetType>2)return{accepted:!1,dispatchData:!1};let t=(e.seqNumber|0xfffffe00&this.lastSeqRecvd)>>>0;if(t>>0),this.lastSeqRecvd+31>>0;if(a>>0),this.lastSendSeq>>0,0===e.packetType&&(this.recvAckMask=(1|this.recvAckMask)>>>0);for(let t=this.highestAckedSeq+1;t<=a;t++)(e.ackMask&1<<(a-t&31))!=0&&(this.lastRecvAckAck=this.lastSeqRecvdAtSend[31&t]>>>0);t-this.lastRecvAckAck>32&&(this.lastRecvAckAck=t-32),this.highestAckedSeq=a;let n=this.lastSeqRecvd!==t&&0===e.packetType;return this.lastSeqRecvd=t,{accepted:!0,dispatchData:n}}parsePacket(e){let t=new rz(e),a=this.readDnetHeader(t),r=this.applyProtocolHeader(a);if(this.packetsParsed++,!r.accepted)return this.protocolRejected++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};if(!r.dispatchData)return this.protocolNoDispatch++,{dnetHeader:a,rateInfo:{},gameState:this.emptyGameState(),events:[],ghosts:[]};let n=this.readRateInfo(t);t.setStringBuffer(!0);let i=this.readGameState(t),o=void 0===i.controlObjectDataStart||void 0!==i.controlObjectData,s=o?this.readEvents(t):[],l=s[s.length-1],c=!l||l.dataBitsEnd!==l.dataBitsStart,d=o&&c?t.getCurPos():void 0,u=o&&c?this.readGhosts(t,a.seqNumber):[];return t.setStringBuffer(!1),{dnetHeader:a,rateInfo:n,gameState:i,events:s,ghosts:u,ghostSectionStart:d}}readDnetHeader(e){let t=e.readFlag(),a=e.readInt(1),r=e.readInt(9),n=e.readInt(9),i=e.readInt(2),o=e.readInt(3),s=o>0?e.readInt(8*o):0;return{gameFlag:t,connectSeqBit:a,seqNumber:r,highestAck:n,packetType:i,ackByteCount:o,ackMask:s}}readRateInfo(e){let t={};return e.readFlag()&&(t.updateDelay=e.readInt(10),t.packetSize=e.readInt(10)),e.readFlag()&&(t.maxUpdateDelay=e.readInt(10),t.maxPacketSize=e.readInt(10)),t}readGameState(e){let t,a,r,n,i,o,s,l,c,d,u,h,m,f,g,p=e.readInt(32);e.readFlag()&&(e.readFlag()&&(t=e.readFloat(7)),e.readFlag()&&(a=1.5*e.readFloat(7))),e.readFlag()&&(r=e.readFlag(),n=e.readFlag()),e.readFlag()&&((i=e.readFlag())&&(o={x:e.readF32(),y:e.readF32(),z:e.readF32()}),1===(s=e.readRangedU32(0,2))?e.readFlag()&&(l=e.readRangedU32(0,1023)):2===s&&(c={x:e.readF32(),y:e.readF32(),z:e.readF32()}));let y=e.readFlag(),v=e.readFlag();if(e.readFlag())if(e.readFlag()){let g=e.readInt(10);d=g,u=e.getCurPos();let F=e.savePos(),b=this.ghostTracker.getGhost(g),S=b?this.registry.getGhostParser(b.classId):void 0,x=this.controlParserByGhostIndex.get(g),k=this.registry.getGhostParser(25),w=this.registry.getGhostParser(4),I=[],C=new Set,_=e=>{!e?.readPacketData||C.has(e.name)||(C.add(e.name),I.push(e))};_(S),_(x),_(k),_(w);let P=!1;for(let t of I){e.restorePos(F);try{let a=this.getConnectionContext(),r=t.readPacketData(e,a);if(e.getCurPos()-u<=0||e.isError())continue;m=r,h=e.getCurPos(),this.controlParserByGhostIndex.set(g,t),a.compressionPoint!==this.compressionPoint&&(this.compressionPoint=a.compressionPoint,f=this.compressionPoint),this.controlObjectParsed++,P=!0;break}catch{}}if(!P)return e.restorePos(F),h=u,this.controlObjectFailed++,{lastMoveAck:p,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:c,pinged:y,jammed:v,controlObjectGhostIndex:d,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:m,targetVisibility:[]}}else f={x:e.readF32(),y:e.readF32(),z:e.readF32()},this.compressionPoint=f;let F=[];for(;e.readFlag();)F.push({index:e.readInt(4),mask:e.readInt(32)});return e.readFlag()&&(g=e.readInt(8)),{lastMoveAck:p,damageFlash:t,whiteOut:a,selfLocked:r,selfHomed:n,seekerTracking:i,seekerTrackingPos:o,seekerMode:s,seekerObjectGhostIndex:l,targetPos:c,pinged:y,jammed:v,controlObjectGhostIndex:d,controlObjectDataStart:u,controlObjectDataEnd:h,controlObjectData:m,compressionPoint:f,targetVisibility:F.length>0?F:void 0,cameraFov:g}}readEvents(e){let t=[],a=!0,r=-2;for(;;){let n,i,o,s=e.readFlag();if(a&&!s){if(a=!1,!e.readFlag()){this.dispatchGuaranteedEvents(t);break}}else if(a||s){if(!s)break}else{this.dispatchGuaranteedEvents(t);break}!a&&(r=n=e.readFlag()?r+1&127:e.readInt(7),(i=n|0xffffff80&this.nextRecvEventSeq)0&&this.pendingGuaranteedEvents[0].absoluteSequenceNumber===this.nextRecvEventSeq;){let t=this.pendingGuaranteedEvents.shift();if(!t)break;this.nextRecvEventSeq=this.nextRecvEventSeq+1>>>0,e.push(t.event),t.event.parsedData&&this.applyEventSideEffects(t.event.parsedData)}}applyEventSideEffects(e){let t=e.type;if("GhostingMessageEvent"===t){let t=e.message;"number"==typeof t&&2===t&&this.ghostTracker.clear();return}if("GhostAlwaysObjectEvent"===t){let t=e.ghostIndex,a=e.classId;if("number"==typeof t&&"number"==typeof a){let e=this.registry.getGhostParser(a);this.ghostTracker.createGhost(t,a,e?.name??`unknown_${a}`)}}"SimDataBlockEvent"===t&&this.dataBlockDataMap&&e.dataBlockData&&"number"==typeof e.objectId&&this.dataBlockDataMap.set(e.objectId,e.dataBlockData)}readGhosts(e,t){let a=[];if(!e.readFlag())return a;let r=e.readInt(3)+3;for(;e.readFlag();){let n;if(e.isError())break;let i=e.readInt(r);if(e.isError())break;if(e.readFlag()){this.ghostTracker.deleteGhost(i),this.ghostDeletes++,a.push({index:i,type:"delete",updateBitsStart:e.getCurPos(),updateBitsEnd:e.getCurPos()});continue}let o=!this.ghostTracker.hasGhost(i);n=o?e.readInt(7)+0:this.ghostTracker.getGhost(i)?.classId;let s=e.getCurPos(),l=void 0!==n?this.registry.getGhostParser(n):void 0;if(o&&!l){this.ghostsTrackerDiverged++,rH("DIVERGED pkt=%d seq=%d idx=%d classId=%d bit=%d/%d trackerSize=%d (server sent UPDATE for ghost not in our tracker; 7-bit classId is actually update data)",this.packetsParsed,t,i,n,s,e.getMaxPos(),this.ghostTracker.size()),a.push({index:i,type:"create",classId:n,updateBitsStart:s,updateBitsEnd:s});break}let c=!1;if(l)try{let t=this.getConnectionContext();t.currentGhostIndex=i;let r=l.unpackUpdate(e,o,t),d=e.getCurPos();o&&void 0!==n?(this.ghostTracker.createGhost(i,n,l.name),this.ghostCreatesParsed++):this.ghostUpdatesParsed++,a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:d,parsedData:r}),c=!0}catch(d){this.ghostsFailed++;let r=o?"create":"update",c=d instanceof Error?d.message:String(d);rH("FAIL pkt=%d seq=%d #%d idx=%d op=%s classId=%d parser=%s bit=%d/%d trackerSize=%d err=%s",this.packetsParsed,t,a.length,i,r,n,l.name,s,e.getMaxPos(),this.ghostTracker.size(),c)}if(!c){rH("STOP pkt=%d seq=%d idx=%d op=%s classId=%d parser=%s bit=%d/%d",this.packetsParsed,t,i,o?"create":"update",n,l?.name??"NONE",s,e.getMaxPos()),a.push({index:i,type:o?"create":"update",classId:n,updateBitsStart:s,updateBitsEnd:s});break}}return a}emptyGameState(){return{lastMoveAck:0,pinged:!1,jammed:!1}}}class r${eventParsers=new Map;ghostParsers=new Map;dataBlockParsers=new Map;eventCatalog=new Map;ghostCatalog=new Map;dataBlockCatalog=new Map;catalogEvent(e){this.eventCatalog.set(e.name,e)}catalogGhost(e){this.ghostCatalog.set(e.name,e)}catalogDataBlock(e){this.dataBlockCatalog.set(e.name,e)}bindDeterministicDataBlocks(e,t){let a=0,r=[];for(let n=0;n0&&(r.sounds=t)}if(e.readFlag()){let t=[];for(let a=0;a<4;a++)e.readFlag()&&t.push({index:a,sequence:e.readInt(5),state:e.readInt(2),forward:e.readFlag(),atEnd:e.readFlag()});t.length>0&&(r.threads=t)}let n=!1;if(e.readFlag()){let a=[];for(let r=0;r<8;r++)if(e.readFlag()){let i={index:r};e.readFlag()?i.dataBlockId=rX(e):i.dataBlockId=0,e.readFlag()&&(e.readFlag()?i.skinTagIndex=e.readInt(10):i.skinName=e.readString(),n=!0),i.triggerDown=e.readFlag(),i.loaded=e.readFlag(),i.ammo=e.readFlag(),i.wet=e.readFlag(),i.target=e.readFlag(),i.fireCount=e.readInt(3),t&&(i.imageExtraFlag=e.readFlag()),a.push(i)}a.length>0&&(r.images=a)}if(e.readFlag()){if(e.readFlag()){r.stateAEnabled=e.readFlag(),r.stateB=e.readFlag();let t=e.readFlag();r.hasInvulnerability=t,t?(r.invulnerabilityVisual=e.readFlag(),r.invulnerabilityTicks=e.readU32()):r.binaryCloak=e.readFlag()}if(e.readFlag())if(e.readFlag()){let t=e.readFlag();r.stateBMode=t,t?r.energyPackOn=!0:r.energyPackOn=!1}else r.shieldNormal=e.readNormalVector(8),r.energyPercent=e.readFloat(5);e.readFlag()&&(r.stateValue1=e.readU32(),r.stateValue2=e.readU32())}return n&&(r.imageSkinDirty=!0),e.readFlag()&&(e.readFlag()?(r.mountObject=e.readInt(10),r.mountNode=e.readInt(5)):r.mountObject=-1),r}function rQ(e,t,a){let r=rJ(e,t,a);if(e.readFlag()&&(r.impactSound=e.readInt(3)),e.readFlag()&&(r.action=e.readInt(8),r.actionHoldAtEnd=e.readFlag(),r.actionAtEnd=e.readFlag(),r.actionFirstPerson=e.readFlag(),!r.actionAtEnd&&e.readFlag()&&(r.actionAnimPos=e.readSignedFloat(6))),e.readFlag()&&(r.armAction=e.readInt(8)),e.readFlag())return r;if(e.readFlag()){if(r.actionState=e.readInt(3),e.readFlag()&&(r.recoverTicks=e.readInt(7)),r.moveFlag0=e.readFlag(),r.moveFlag1=e.readFlag(),r.position=e.readCompressedPoint(a.compressionPoint),e.readFlag()){let t=e.readInt(13)/32,a=e.readNormalVector(10);r.velocity={x:a.x*t,y:a.y*t,z:a.z*t}}else r.velocity={x:0,y:0,z:0};r.headX=e.readSignedFloat(6),r.headZ=e.readSignedFloat(6),r.rotationZ=2*e.readFloat(7)*Math.PI,r.move=rK(e),r.allowWarp=e.readFlag()}return r.energy=e.readFloat(5),r}function r0(e,t){let a={};if(a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.actionState=e.readInt(3),e.readFlag()&&(a.recoverTicks=e.readInt(7)),e.readFlag()&&(a.jumpDelay=e.readInt(7)),e.readFlag()){let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};a.position=r,t.compressionPoint=r,a.velocity={x:e.readF32(),y:e.readF32(),z:e.readF32()},a.jumpSurfaceLastContact=e.readInt(4)}if(a.headX=e.readF32(),a.headZ=e.readF32(),a.rotationZ=e.readF32(),e.readFlag()){let r=e.readInt(10);a.controlObjectGhost=r;let n=t.ghostTracker.getGhost(r),i=n?t.getGhostParser?.(n.classId):void 0;if(i?.readPacketData){let n=t.currentGhostIndex;t.currentGhostIndex=r,a.controlObjectData=i.readPacketData(e,t),t.currentGhostIndex=n}}return a.disableMove=e.readFlag(),a.pilot=e.readFlag(),a}function r1(e,t,a){let r=rJ(e,t,a);return(r.jetting=e.readFlag(),e.readFlag())?r._controlledEarlyReturn=!0:(r.steeringYaw=e.readFloat(9),r.steeringPitch=e.readFloat(9),r.move=rK(e),r.frozen=e.readFlag(),e.readFlag()&&(r.position=e.readCompressedPoint(a.compressionPoint),r.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},r.linMomentum=e.readPoint3F(),r.angMomentum=e.readPoint3F()),e.readFlag()&&(r.energy=e.readFloat(8))),r}function r2(e,t){let a={};a.energyLevel=e.readF32(),a.rechargeRate=e.readF32(),a.steering={x:e.readF32(),y:e.readF32()};let r={x:e.readF32(),y:e.readF32(),z:e.readF32()};return a.linPosition=r,a.angPosition={x:e.readF32(),y:e.readF32(),z:e.readF32(),w:e.readF32()},a.linMomentum=e.readPoint3F(),a.angMomentum=e.readPoint3F(),a.disableMove=e.readFlag(),a.frozen=e.readFlag(),t.compressionPoint=r,a}function r3(e,t){let a=r2(e,t);a.braking=e.readFlag();let r=4,n=t.currentGhostIndex;if(void 0!==n){let e=nR.get(n);void 0!==e&&(r=e)}let i=[];for(let t=0;t64)throw Error(`Invalid Sky fogVolumeCount: ${t}`);r.fogVolumeCount=t,r.useSkyTextures=e.readBool(),r.renderBottomTexture=e.readBool(),r.skySolidColor={r:e.readF32(),g:e.readF32(),b:e.readF32()},r.windEffectPrecipitation=e.readBool();let a=[];for(let r=0;r3)throw Error(`Invalid precipitation colorCount: ${t}`);let a=[];for(let r=0;rMath.floor(e.getRemainingBits()/96))throw Error(`Invalid physicalZone point count: ${t}`);let a=[];for(let r=0;rMath.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone plane count: ${n}`);let i=[];for(let t=0;tMath.floor(e.getRemainingBits()/128))throw Error(`Invalid physicalZone edge count: ${o}`);let s=[];for(let t=0;t0&&(a.audioData=e.readBitsBuffer(8*r)),a}function n4(e,t){return{type:"GhostingMessageEvent",sequence:e.readU32(),message:e.readInt(3),ghostCount:e.readInt(11)}}function n6(e,t){let a={type:"GhostAlwaysObjectEvent"};a.ghostIndex=e.readInt(10);let r=e.readFlag();if(a._hasObjectData=r,r){let r=e.readInt(7);a.classId=r;let n=t.getGhostParser?.(r);if(!n)throw Error(`No ghost parser for GhostAlwaysObjectEvent classId=${r}`);a.objectData=n.unpackUpdate(e,!0,t)}return a}function n8(e,t){let a={type:"PathManagerEvent"};if(e.readFlag()){a.messageType="NewPaths";let t=e.readU32(),r=[];for(let a=0;a0&&(t.hudImages=a),t}function ig(e){let t={};e.readFlag()&&(t.crc=e.readU32()),t.shapeName=e.readString(),t.mountPoint=e.readU32(),e.readFlag()||(t.offset=e.readAffineTransform()),t.firstPerson=e.readFlag(),t.mass=e.readF32(),t.usesEnergy=e.readFlag(),t.minEnergy=e.readF32(),t.hasFlash=e.readFlag(),t.projectile=il(e),t.muzzleFlash=il(e),t.isSeeker=e.readFlag(),t.isSeeker&&(t.seekerRadius=e.readF32(),t.maxSeekAngle=e.readF32(),t.seekerLockTime=e.readF32(),t.seekerFreeTime=e.readF32(),t.isTargetLockRequired=e.readFlag(),t.maxLockRange=e.readF32()),t.cloakable=e.readFlag(),t.lightType=e.readRangedU32(0,3),0!==t.lightType&&(t.lightRadius=e.readF32(),t.lightTime=e.readS32(),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)}),t.shellExitDir={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.shellExitVariance=e.readF32(),t.shellVelocity=e.readF32(),t.casing=il(e),t.accuFire=e.readFlag();let a=[];for(let t=0;t<31;t++){if(!e.readFlag())continue;let t={};t.name=e.readString(),t.transitionOnAmmo=e.readInt(5),t.transitionOnNoAmmo=e.readInt(5),t.transitionOnTarget=e.readInt(5),t.transitionOnNoTarget=e.readInt(5),t.transitionOnWet=e.readInt(5),t.transitionOnNotWet=e.readInt(5),t.transitionOnTriggerUp=e.readInt(5),t.transitionOnTriggerDown=e.readInt(5),t.transitionOnTimeout=e.readInt(5),t.transitionGeneric0In=e.readInt(5),t.transitionGeneric0Out=e.readInt(5),e.readFlag()&&(t.timeoutValue=e.readF32()),t.waitForTimeout=e.readFlag(),t.fire=e.readFlag(),t.ejectShell=e.readFlag(),t.scaleAnimation=e.readFlag(),t.direction=e.readFlag(),t.reload=e.readFlag(),e.readFlag()&&(t.energyDrain=e.readF32()),t.loaded=e.readInt(3),t.spin=e.readInt(3),t.recoil=e.readInt(3),e.readFlag()&&(t.sequence=e.readSignedInt(16)),e.readFlag()&&(t.sequenceVis=e.readSignedInt(16)),t.flashSequence=e.readFlag(),t.ignoreLoadedForReady=e.readFlag(),t.emitter=il(e),null!==t.emitter&&(t.emitterTime=e.readF32(),t.emitterNode=e.readS32()),t.sound=il(e),a.push(t)}return t.states=a,t}function ip(e){let t=im(e);t.renderFirstPerson=e.readFlag(),t.minLookAngle=e.readF32(),t.maxLookAngle=e.readF32(),t.maxFreelookAngle=e.readF32(),t.maxTimeScale=e.readF32(),t.maxStepHeight=e.readF32(),t.runForce=e.readF32(),t.runEnergyDrain=e.readF32(),t.minRunEnergy=e.readF32(),t.maxForwardSpeed=e.readF32(),t.maxBackwardSpeed=e.readF32(),t.maxSideSpeed=e.readF32(),t.maxUnderwaterForwardSpeed=e.readF32(),t.maxUnderwaterBackwardSpeed=e.readF32(),t.maxUnderwaterSideSpeedRef=il(e),e.readFlag()&&(t.runSurfaceAngleRef=e.readInt(11)),t.runSurfaceAngle=e.readF32(),t.recoverDelay=e.readF32(),t.recoverRunForceScale=e.readF32(),t.jumpForce=e.readF32(),t.jumpEnergyDrain=e.readF32(),t.minJumpEnergy=e.readF32(),t.minJumpSpeed=e.readF32(),t.maxJumpSpeed=e.readF32(),t.jumpSurfaceAngle=e.readF32(),t.minJetEnergy=e.readF32(),t.splashVelocity=e.readF32(),t.splashAngle=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.bubbleEmitTime=e.readF32(),t.medSplashSoundVel=e.readF32(),t.hardSplashSoundVel=e.readF32(),t.exitSplashSoundVel=e.readF32(),t.jumpDelay=e.readInt(7),t.horizMaxSpeed=e.readF32(),t.horizResistSpeed=e.readF32(),t.horizResistFactor=e.readF32(),t.upMaxSpeed=e.readF32(),t.upResistSpeed=e.readF32(),t.upResistFactor=e.readF32(),t.jetEnergyDrain=e.readF32(),t.canJet=e.readF32(),t.maxJetHorizontalPercentage=e.readF32(),t.maxJetForwardSpeed=e.readF32(),t.jetForce=e.readF32(),t.minJetSpeed=e.readF32(),t.maxDamage=e.readF32(),t.minImpactDamageSpeed=e.readF32(),t.impactDamageScale=e.readF32(),t.footSplashHeight=e.readF32();let a=[];for(let t=0;t<32;t++)e.readFlag()?a.push(e.readInt(11)):a.push(null);t.sounds=a,t.boxSize={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.footPuffEmitter=il(e),t.footPuffNumParts=e.readF32(),t.footPuffRadius=e.readF32(),t.decalData=il(e),t.decalOffset=e.readF32(),t.dustEmitter=il(e),t.splash=il(e);let r=[];for(let t=0;t<3;t++)r.push(il(e));return t.splashEmitters=r,t.groundImpactMinSpeed=e.readF32(),t.groundImpactShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.groundImpactShakeDuration=e.readF32(),t.groundImpactShakeFalloff=e.readF32(),t.boundingRadius=e.readF32(),t.moveBubbleSize=e.readF32(),t}function iy(e){let t=im(e);t.bodyRestitution=e.readF32(),t.bodyFriction=e.readF32();let a=[];for(let t=0;t<2;t++)a.push(il(e));t.impactSounds=a,t.minImpactSpeed=e.readF32(),t.softImpactSpeed=e.readF32(),t.hardImpactSpeed=e.readF32(),t.minRollSpeed=e.readF32(),t.maxSteeringAngle=e.readF32(),t.maxDrag=e.readF32(),t.minDrag=e.readF32(),t.cameraOffset=e.readF32(),t.cameraLag=e.readF32(),t.jetForce=e.readF32(),t.jetEnergyDrain=e.readF32(),t.minJetEnergy=e.readF32(),t.integration=e.readF32(),t.collisionTol=e.readF32(),t.massCenter=e.readF32(),t.exitSplashSoundVelocity=e.readF32(),t.softSplashSoundVelocity=e.readF32(),t.mediumSplashSoundVelocity=e.readF32(),t.hardSplashSoundVelocity=e.readF32();let r=[];for(let t=0;t<5;t++)r.push(il(e));t.waterSounds=r,t.dustEmitter=il(e);let n=[];for(let t=0;t<3;t++)n.push(il(e));t.damageEmitters=n;let i=[];for(let t=0;t<2;t++)i.push(il(e));return t.splashEmitters=i,t.damageEmitterOffset0={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageEmitterOffset1={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.damageLevelTolerance0=e.readF32(),t.damageLevelTolerance1=e.readF32(),t.splashFreqMod=e.readF32(),t.splashVelEpsilon=e.readF32(),t.collDamageThresholdVel=e.readF32(),t.collDamageMultiplier=e.readF32(),t}function iv(e){let t=iy(e);t.jetActivateSound=il(e),t.jetDeactivateSound=il(e);let a=[];for(let t=0;t<4;t++)a.push(il(e));return t.jetEmitters=a,t.maneuveringForce=e.readF32(),t.horizontalSurfaceForce=e.readF32(),t.verticalSurfaceForce=e.readF32(),t.autoInputDamping=e.readF32(),t.steeringForce=e.readF32(),t.steeringRollForce=e.readF32(),t.rollForce=e.readF32(),t.autoAngularForce=e.readF32(),t.rotationalDrag=e.readF32(),t.maxAutoSpeed=e.readF32(),t.autoLinearForce=e.readF32(),t.hoverHeight=e.readF32(),t.createHoverHeight=e.readF32(),t.minTrailSpeed=e.readF32(),t.vertThrustMultiple=e.readF32(),t.maxForwardSpeed=e.readF32(),t}function iF(e){let t=iy(e);t.dragForce=e.readF32(),t.mainThrustForce=e.readF32(),t.reverseThrustForce=e.readF32(),t.strafeThrustForce=e.readF32(),t.turboFactor=e.readF32(),t.stabLenMin=e.readF32(),t.stabLenMax=e.readF32(),t.stabSpringConstant=e.readF32(),t.stabDampingConstant=e.readF32(),t.gyroDrag=e.readF32(),t.normalForce=e.readF32(),t.restorativeForce=e.readF32(),t.steeringForce=e.readF32(),t.rollForce=e.readF32(),t.pitchForce=e.readF32(),t.floatingThrustFactor=e.readF32(),t.brakingForce=e.readF32(),t.dustTrailOffset={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.dustTrailFreqMod=e.readF32(),t.triggerTrailHeight=e.readF32(),t.floatSound=il(e),t.thrustSound=il(e),t.turboSound=il(e);let a=[];for(let t=0;t<3;t++)a.push(il(e));return t.jetEmitters=a,t.dustTrailEmitter=il(e),t.mainThrustEmitterFactor=e.readF32(),t.strafeThrustEmitterFactor=e.readF32(),t.reverseThrustEmitterFactor=e.readF32(),t}function ib(e){let t=iy(e);return t.tireRadius=e.readF32(),t.tireStaticFriction=e.readF32(),t.tireKineticFriction=e.readF32(),t.tireRestitution=e.readF32(),t.tireLateralForce=e.readF32(),t.tireLateralDamping=e.readF32(),t.tireLateralRelaxation=e.readF32(),t.tireLongitudinalForce=e.readF32(),t.tireLongitudinalDamping=e.readF32(),t.tireEmitter=il(e),t.jetSound=il(e),t.engineSound=il(e),t.squealSound=il(e),t.wadeSound=il(e),t.spring=e.readF32(),t.springDamping=e.readF32(),t.springLength=e.readF32(),t.brakeTorque=e.readF32(),t.engineTorque=e.readF32(),t.engineBrake=e.readF32(),t.maxWheelSpeed=e.readF32(),t.steeringAngle=e.readF32(),t.steeringReturn=e.readF32(),t.steeringDamping=e.readF32(),t.powerSteeringFactor=e.readF32(),t}function iS(e){let t=im(e);return t.noIndividualDamage=e.readFlag(),t.dynamicTypeField=e.readS32(),t}function ix(e){let t=iS(e);return t.thetaMin=e.readF32(),t.thetaMax=e.readF32(),t.thetaNull=e.readF32(),t.neverUpdateControl=e.readFlag(),t.primaryAxis=e.readRangedU32(0,3),t.maxCapacitorEnergy=e.readF32(),t.capacitorRechargeRate=e.readF32(),t}function ik(e){let t=ig(e);return t.activationMS=e.readInt(8),t.deactivateDelayMS=e.readInt(8),t.degPerSecTheta=e.readRangedU32(0,1080),t.degPerSecPhi=e.readRangedU32(0,1080),t.dontFireInsideDamageRadius=e.readFlag(),t.damageRadius=e.readF32(),t.useCapacitor=e.readFlag(),t}function iw(e){let t=im(e);return t.friction=e.readFloat(10),t.elasticity=e.readFloat(10),t.sticky=e.readFlag(),e.readFlag()&&(t.gravityMod=e.readFloat(10)),e.readFlag()&&(t.maxVelocity=e.readF32()),e.readFlag()&&(t.lightType=e.readInt(2),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7),a:e.readFloat(7)},t.lightTime=e.readS32(),t.lightRadius=e.readF32(),t.lightOnlyStatic=e.readFlag()),t}function iI(e){let t={};t.projectileShapeName=e.readString(),t.faceViewerLinkTime=e.readS32(),t.lifetime=e.readS32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.scale={x:e.readF32(),y:e.readF32(),z:e.readF32()}),t.baseEmitter=il(e),t.delayEmitter=il(e),t.bubbleEmitter=il(e),t.explosion=il(e),t.underwaterExplosion=il(e),t.splash=il(e),t.sound=il(e),t.wetFireSound=il(e),t.fireSound=il(e);let a=[];for(let t=0;t<6;t++)a.push(il(e));return t.decals=a,e.readFlag()&&(t.lightRadius=e.readFloat(8),t.lightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),e.readFlag()&&(t.underwaterLightColor={r:e.readFloat(7),g:e.readFloat(7),b:e.readFloat(7)}),t.explodeOnWaterImpact=iu(e),t.depthTolerance=e.readF32(),t}function iC(e){let t=iI(e);return t.dryVelocity=e.readF32(),t.wetVelocity=e.readF32(),t.fizzleTime=e.readU32(),t.fizzleType=e.readU32(),t.hardRetarget=e.readFlag(),t.inheritedVelocityScale=e.readRangedU32(0,90),t.lifetimeMS=e.readRangedU32(0,90),t.collideWithOwnerTimeMS=e.readU32(),t.proximityRadius=e.readU32(),t.tracerProjectile=e.readFlag(),t}function i_(e){let t=iI(e);return t.armingDelayMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.grenadeElasticity=e.readF32(),t.grenadeFriction=e.readF32(),t.drag=e.readF32(),t.density=e.readF32(),t.gravityMod=e.readF32(),t.lifetimeMS=e.readS32(),t}function iP(e){let t=iI(e);return t.lifetimeMS=e.readS32(),t.muzzleVelocity=e.readF32(),t.turningSpeed=e.readF32(),t.proximityRadius=e.readF32(),t.terrainAvoidanceSpeed=e.readF32(),t.terrainScanAhead=e.readF32(),t.terrainHeightFail=e.readF32(),t.terrainAvoidanceRadius=e.readF32(),t.flareDistance=e.readF32(),t.flareAngle=e.readF32(),t.useFlechette=iu(e),t.maxVelocity=e.readF32(),t.acceleration=e.readF32(),t.flechetteDelayMs=e.readS32(),t.exhaustTimeMs=e.readS32(),t.exhaustNodeName=e.readString(),t.casingShapeName=e.readString(),t.casingDebris=il(e),t.puffEmitter=il(e),t.exhaustEmitter=il(e),t}function iD(e){let t=iI(e);t.maxRifleRange=e.readF32(),t.rifleHeadMultiplier=e.readF32(),t.beamColor=id(e),t.fadeTime=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32(),t.lightColor=id(e),t.lightRadius=e.readF32();let a=[];for(let t=0;t<12;t++)a.push(e.readString());return t.textures=a,t}function iM(e){let t=iI(e);t.zapDuration=e.readF32(),t.boltLength=e.readF32(),t.numParts=e.readF32(),t.lightningFreq=e.readF32(),t.lightningDensity=e.readF32(),t.lightningAmp=e.readF32(),t.lightningWidth=e.readF32(),t.shockwave=il(e);let a=[],r=[],n=[],i=[];for(let t=0;t<2;t++)a.push(e.readF32()),r.push(e.readF32()),n.push(e.readF32()),i.push(e.readF32());t.startWidth=a,t.endWidth=r,t.boltSpeed=n,t.texWrap=i;let o=[];for(let t=0;t<4;t++)o.push(e.readString());return t.textures=o,t.emitter=il(e),t}function iT(e){let t=iI(e);return t.beamRange=e.readF32(),t.beamDrainRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t.flareTexture=e.readString(),t.hitEmitter=il(e),t}function iE(e){let t=iI(e);return t.beamRange=e.readF32(),t.beamRepairRate=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=e.readF32(),t.startWidth=e.readF32(),t.endWidth=e.readF32(),t.startBeamWidth=e.readF32(),t.endBeamWidth=e.readF32(),t.mainBeamTexture=e.readString(),t.innerBeamTexture=e.readString(),t}function iB(e){let t=iI(e);t.maxRifleRange=e.readF32(),t.beamColor=id(e),t.startBeamWidth=e.readF32(),t.pulseBeamWidth=e.readF32(),t.beamFlareAngle=e.readF32(),t.minFlareSize=e.readF32(),t.maxFlareSize=e.readF32(),t.pulseSpeed=e.readF32(),t.pulseLength=e.readF32();let a=[];for(let t=0;t<4;t++)a.push(e.readString());return t.textures=a,t}function ij(e){let t=iC(e);return t.tracerLength=e.readF32(),t.tracerAlpha=e.readF32(),t.tracerMinPixels=e.readF32(),t.crossViewFraction=iu(e),t.tracerColor=id(e),t.tracerWidth=e.readF32(),t.muzzleVelocity=e.readF32(),t.proximityRadius=iu(e),t.textureName0=e.readString(),t.textureName1=e.readString(),t}function iR(e){let t=i_(e);return t.energyDrainPerSecond=e.readF32(),t.energyMinDrain=e.readF32(),t.beamWidth=e.readF32(),t.beamRange=e.readF32(),t.numSegments=e.readF32(),t.texRepeat=e.readF32(),t.beamFlareAngle=e.readF32(),t.beamTexture=e.readString(),t.flareTexture=e.readString(),t}function iN(e){let t=iC(e);return t.numFlares=e.readF32(),t.flareColor=id(e),t.flareTexture=e.readString(),t.smokeTexture=e.readString(),t.size=e.readF32(),t.flareModTexture=e.readF32(),t.smokeSize=e.readF32(),t}function iA(e){let t=i_(e);return t.smokeDist=e.readF32(),t.noSmoke=e.readF32(),t.boomTime=e.readF32(),t.casingDist=e.readF32(),t.smokeCushion=e.readF32(),t.noSmokeCounter=e.readF32(),t.smokeTexture=e.readString(),t.bombTexture=e.readString(),t}function iG(e){let t=i_(e);return t.size=e.readF32(),t.useLensFlare=iu(e),t.flareTexture=e.readString(),t.lensFlareTexture=e.readString(),t}function iU(e){let t={};t.dtsFileName=e.readString(),t.soundProfile=il(e),t.particleEmitter=il(e),t.particleDensity=e.readInt(14),t.particleRadius=e.readF32(),t.faceViewer=e.readFlag(),e.readFlag()&&(t.explosionScale={x:e.readInt(16),y:e.readInt(16),z:e.readInt(16)}),t.playSpeed=e.readInt(14),t.debrisThetaMin=e.readRangedU32(0,180),t.debrisThetaMax=e.readRangedU32(0,180),t.debrisPhiMin=e.readRangedU32(0,360),t.debrisPhiMax=e.readRangedU32(0,360),t.debrisMinVelocity=e.readRangedU32(0,1e3),t.debrisMaxVelocity=e.readRangedU32(0,1e3),t.debrisNum=e.readInt(14),t.debrisVariance=e.readRangedU32(0,1e4),t.delayMS=e.readInt(16),t.delayVariance=e.readInt(16),t.lifetimeMS=e.readInt(16),t.lifetimeVariance=e.readInt(16),t.offset=e.readF32(),t.shakeCamera=e.readFlag(),t.hasLight=e.readFlag(),t.camShakeFreq={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeAmp={x:e.readF32(),y:e.readF32(),z:e.readF32()},t.camShakeDuration=e.readF32(),t.camShakeRadius=e.readF32(),t.camShakeFalloff=e.readF32(),t.shockwave=il(e),t.debris=il(e);let a=[];for(let t=0;t<4;t++)a.push(il(e));t.emitters=a;let r=[];for(let t=0;t<5;t++)r.push(il(e));t.subExplosions=r;let n=e.readRangedU32(0,4),i=[];for(let t=0;t0&&oi("DataBlock binding: %d/%d bound, missing parsers: %s",t,rO.length,a.join(", "));const{bound:r,missing:n}=this.registry.bindDeterministicGhosts(rV,0);n.length>0&&oi("Ghost binding: %d/%d bound, missing parsers: %s",r,rV.length,n.join(", "));const{bound:i,missing:o}=this.registry.bindDeterministicEvents(rq,255);o.length>0&&oi("Event binding: %d/%d bound, missing parsers: %s",i,rq.length,o.join(", ")),this.packetParser=new rW(this.registry,this.ghostTracker)}getRegistry(){return this.registry}getGhostTracker(){return this.ghostTracker}getPacketParser(){return this.packetParser}get loaded(){return this._loaded}get header(){if(!this._loaded)throw Error("must call load() first");return this._header}get initialBlock(){if(!this._loaded)throw Error("must call load() first");return this._initialBlock}get blockCount(){if(!this._loaded)throw Error("must call load() first");if(void 0===this._blockCount){let e=this._decompressedData,t=this._decompressedView,a=0,r=0;for(;r+2<=e.length;){let n=4095&t.getUint16(r,!0);if((r+=2+n)>e.length)break;a++}this._blockCount=a}return this._blockCount}get blockCursor(){if(!this._loaded)throw Error("must call load() first");return this._blockCursor}async load(){if(this._loaded)return{header:this._header,initialBlock:this._initialBlock};let e=this.readHeader();oi('header: "%s" version=0x%s length=%dms (%smin) initialBlockSize=%d',e.identString,e.protocolVersion.toString(16),e.demoLengthMs,(e.demoLengthMs/1e3/60).toFixed(1),e.initialBlockSize);let t=this.buffer.subarray(this.offset,this.offset+e.initialBlockSize),a=this.readInitialBlock(t);this.offset+=e.initialBlockSize;let r=this.buffer.subarray(this.offset);oi("compressed block stream: %d bytes",r.length);let n=await new Promise((e,t)=>{var a,n;a=(a,r)=>{a?t(a):e(r)},n||(n=a,a={}),"function"!=typeof n&&aD(7),a3(r,a,[aZ],function(e){return a1(rh(e.data[0],a2(e.data[1])))},1,n)});return oi("decompressed block stream: %d bytes",n.length),this._decompressedData=n,this._decompressedView=new DataView(n.buffer,n.byteOffset,n.byteLength),this.setupPacketParser(a),this._header=e,this._initialBlock=a,this._blockStreamOffset=0,this._blockCursor=0,this._loaded=!0,{header:e,initialBlock:a}}nextBlock(){if(!this._loaded)throw Error("must call load() first");let e=this._decompressedData,t=this._decompressedView,a=this._blockStreamOffset;if(a+2>e.length)return;let r=t.getUint16(a,!0),n=r>>12,i=4095&r;if(a+2+i>e.length)return void os("block %d: size %d would exceed decompressed data (offset=%d remaining=%d), stopping",this._blockCursor,i,a+2,e.length-a-2);let o=e.subarray(a+2,a+2+i);this._blockStreamOffset=a+2+i;let s={index:this._blockCursor,type:n,size:i,data:o};if(this._blockCursor++,0===n)try{s.parsed=this.packetParser.parsePacket(o)}catch{}else if(1===n)this.packetParser.onSendPacketTrigger();else if(2===n&&64===i)try{s.parsed=this.readRawMove(o)}catch{}else if(3===n&&8===i)try{s.parsed=this.readInfoBlock(o)}catch{}return s}reset(){if(!this._loaded)throw Error("must call load() first");this._blockStreamOffset=0,this._blockCursor=0,this._blockCount=void 0,this.setupPacketParser(this._initialBlock)}processBlocks(e){if(!this._loaded)throw Error("must call load() first");let t=0;for(let a=0;a=128&&t<128+rO.length?rO[t-128]:`unknown(${t})`;throw Error(`No parser for DataBlock classId ${t} (${e}) at bit ${i}`)}}oi("all %d/%d DataBlocks parsed (%d payloads), bit position after DataBlocks: %d",l,i,s.size,r.getCurPos());let c=r.readU8(),d=[];for(let e=0;e<6;e++)d.push(r.readU32());let u=[];for(let e=0;e<16;e++)u.push(r.readU32());let h=r.readU32(),m=[];for(let e=0;e>3<<3),this.readSimpleTargetManager(r),this.readSimpleTargetManager(r),oo('after sequential tail bit=%d mission="%s" CRC=0x%s',r.getCurPos(),M,T.toString(16))}catch(e){a=e instanceof Error?e.message:String(e)}finally{this.ghostTracker=w}let E=x-r.getCurPos(),B=M.length>0?M.split("").filter(e=>{let t=e.charCodeAt(0);return t>=32&&t<=126}).length/M.length:1,j=M.length>0&&B>=.8&&void 0===a;return oi('initial block: events=%d ghosts=%d ghostingSeq=%d controlObj=%d mission="%s" CRC=0x%s valid=%s%s',I.length,P.length,_,D,M,T.toString(16),j,a?` error=${a}`:""),{taggedStrings:n,dataBlockHeaders:o,dataBlockCount:l,dataBlocks:s,demoSetting:c,connectionFields:d,stateArray:u,scoreEntries:m,demoValues:f,sensorGroupColors:g,targetEntries:p,connectionState:y,roundTripTime:v,packetLoss:F,pathManager:b,notifyCount:S,nextRecvEventSeq:C,ghostingSequence:_,initialGhosts:P,initialEvents:I,controlObjectGhostIndex:D,controlObjectData:t,missionName:M,missionCRC:T,phase2TrailingBits:E,phase2Valid:j,phase2Error:a}}readScoreEntry(e){let t=e.readFlag()?e.readInt(16):0,a=e.readFlag()?e.readInt(16):0,r=e.readFlag()?e.readInt(16):0,n=e.readInt(6),i=e.readInt(6),o=e.readInt(6),s=e.readFlag(),l=[];for(let t=0;t<6;t++)l.push(e.readFlag());return{clientId:t,teamId:a,score:r,field0:n,field1:i,field2:o,isBot:s,triggerFlags:l}}readDemoValues(e){let t=[];for(;e.readFlag();)t.push(e.readString());return t}readComplexTargetManager(e){e.readU8(),e.readU8(),e.readU8(),e.readU8();let t=[];for(let a=0;a<32;a++)for(let r=0;r<32;r++)e.readFlag()&&t.push({group:a,targetGroup:r,r:e.readU8(),g:e.readU8(),b:e.readU8(),a:e.readU8()});let a=[];for(let t=0;t<512;t++){if(!e.readFlag())continue;let r={targetId:t,sensorGroup:0,targetData:0,damageLevel:0};e.readFlag()&&(r.sensorData=e.readU32()),e.readFlag()&&(r.voiceMapData=e.readU32()),e.readFlag()&&(r.name=e.readString()),e.readFlag()&&(r.skin=e.readString()),e.readFlag()&&(r.skinPref=e.readString()),e.readFlag()&&(r.voice=e.readString()),e.readFlag()&&(r.typeDescription=e.readString()),r.sensorGroup=e.readInt(5),r.targetData=e.readInt(9),t>=32&&e.readFlag()&&(r.dataBlockRef=e.readInt(11)),r.damageLevel=e.readFloat(7),a.push(r)}return{sensorGroupColors:t,targets:a}}readPathManager(e){let t=[],a=e.readU32();for(let r=0;rthis.registry.getDataBlockParser(e)};t=i.unpack(e,a)}catch{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}else{a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:n});break}a.push({classId:r,guaranteed:!0,dataBitsStart:n,dataBitsEnd:e.getCurPos(),parsedData:t}),oo(" event classId=%d bits=%d",r,e.getCurPos()-n)}return{nextRecvEventSeq:t,events:a}}readGhostStartBlock(e,t){let a=e.readU32(),r=[];oo("ghost block: seq=%d bit=%d",a,e.getCurPos());let n=this.registry.getGhostCatalog(),i=8*e.getBuffer().length,o=new Map;for(let[e,a]of t)o.set(e,a.data);for(;e.readFlag()&&!e.isError();){let a=e.readInt(10),s=e.readInt(7)+0,l=e.getCurPos(),c=[],d=new Set,{entry:u}=this.identifyGhostViaDataBlock(e,t,n),h=this.registry.getGhostParser(s);h&&(c.push({entry:h,method:"registry"}),d.add(h)),u&&!d.has(u)&&(c.push({entry:u,method:"datablock"}),d.add(u));let m={getDataBlockData:e=>o.get(e),getDataBlockParser:e=>this.registry.getDataBlockParser(e)},f=!1;for(let{entry:t,method:n}of c){let o="registry"===n,c=this.tryGhostParser(e,t,l,i,!1,m,o);if(!1!==c){this.ghostTracker.createGhost(a,s,t.name),oo(" ghost idx=%d classId=%d parser=%s bits=%d via=%s",a,s,t.name,e.getCurPos()-l,n),r.push({index:a,type:"create",classId:s,updateBitsStart:l,updateBitsEnd:e.getCurPos(),parsedData:c}),f=!0;break}}if(!f){oo(" ghost idx=%d classId=%d NO PARSER (stopping at bit=%d, remaining=%d)",a,s,l,i-l);break}}return oo("ghost loop ended at bit=%d remaining=%d count=%d",e.getCurPos(),i-e.getCurPos(),r.length),{ghostingSequence:a,ghosts:r}}tryGhostParser(e,t,a,r,n=!1,i,o=!1){let s=e.savePos();n||oo(" try %s: startBit=%d",t.name,a);try{let l=t.unpackUpdate(e,!0,{compressionPoint:{x:0,y:0,z:0},ghostTracker:this.ghostTracker,...i}),c=e.getCurPos()-a,d=r-e.getCurPos();if(e.isError()||!o&&c<3)return n||oo(" reject %s: bits=%d isError=%s",t.name,c,e.isError()),e.restorePos(s),!1;if(d>1e3){let a=e.getCurPos(),r=e.readFlag();if(e.setCurPos(a),!r)return n||oo(" reject %s: bits=%d misaligned (remaining=%d)",t.name,c,d),e.restorePos(s),!1}return l??{}}catch(a){return n||oo(" reject %s: error at bit=%d: %s",t.name,e.getCurPos(),a instanceof Error?a.message:String(a)),e.restorePos(s),!1}}identifyGhostViaDataBlock(e,t,a){let r;if(!t)return{entry:void 0,dbFlag:!1};let n=e.savePos(),i=!1;try{if(i=e.readFlag()){let n=e.readInt(11),i=t.get(n);if(i){let e=i.className.replace(/Data$/,"");(r=a.get(e))||oo(" identifyGhostViaDataBlock: dbId=%d className=%s ghostName=%s (no ghost parser)",n,i.className,e)}else oo(" identifyGhostViaDataBlock: dbId=%d (no DataBlock found)",n)}else oo(" identifyGhostViaDataBlock: DataBlock flag=0")}catch{}return e.restorePos(n),{entry:r,dbFlag:i}}readRawMove(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),a=t.getInt32(0,!0),r=t.getInt32(4,!0),n=t.getInt32(8,!0),i=t.getUint32(12,!0),o=t.getUint32(16,!0),s=t.getUint32(20,!0),l=t.getFloat32(24,!0),c=t.getFloat32(28,!0),d=t.getFloat32(32,!0),u=t.getFloat32(36,!0),h=t.getFloat32(40,!0),m=t.getFloat32(44,!0),f=t.getUint32(48,!0),g=t.getUint32(52,!0),p=0!==e[56],y=[];for(let t=0;t<6;t++)y.push(0!==e[57+t]);return{px:a,py:r,pz:n,pyaw:i,ppitch:o,proll:s,x:l,y:c,z:d,yaw:u,pitch:h,roll:m,id:f,sendCount:g,freeLook:p,trigger:y}}readInfoBlock(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{value1:t.getUint32(0,!0),value2:t.getFloat32(4,!0)}}}let oc=Object.freeze({r:0,g:255,b:0}),od=Object.freeze({r:255,g:0,b:0}),ou=new Set(["FlyingVehicle","HoverVehicle","WheeledVehicle"]),oh=new Set(["BombProjectile","EnergyProjectile","FlareProjectile","GrenadeProjectile","LinearFlareProjectile","LinearProjectile","Projectile","SeekerProjectile","TracerProjectile"]),om=new Set(["LinearProjectile","TracerProjectile","LinearFlareProjectile","Projectile"]),of=new Set(["GrenadeProjectile","EnergyProjectile","FlareProjectile","BombProjectile"]),og=new Set(["SeekerProjectile"]),op=new Set(["StaticShape","ScopeAlwaysShape","Turret","BeaconObject","ForceFieldBare"]),oy=new Set(["TSStatic","InteriorInstance","TerrainBlock","Sky","Sun","MissionArea","PhysicalZone","MissionMarker","SpawnSphere","VehicleBlocker","Camera"]),ov=.494*Math.PI,oF=new o.Matrix4,ob=new o.Quaternion,oS=new Map([["gui/hud_new_packammo",0],["gui/hud_new_packcloak",1],["gui/hud_new_packenergy",2],["gui/hud_new_packrepair",3],["gui/hud_new_packsatchel",4],["gui/hud_new_packshield",5],["gui/hud_new_packinventory",6],["gui/hud_new_packmotionsens",7],["gui/hud_new_packradar",8],["gui/hud_new_packturretout",9],["gui/hud_new_packturretin",10],["gui/hud_new_packsensjam",11],["gui/hud_new_packturret",12],["gui/hud_satchel_unarmed",18]]);function ox(e){return null!=e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.z)}function ok(e,t,a){return ea?a:e}function ow(e){let t=-e/2;return[0,Math.sin(t),0,Math.cos(t)]}function oI(e){if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(e.z)||!Number.isFinite(e.w))return null;let t=-e.y,a=-e.z,r=-e.x,n=e.w,i=t*t+a*a+r*r+n*n;if(i<=1e-12)return null;let o=1/Math.sqrt(i);return[t*o,a*o,r*o,n*o]}function oC(e){let t="";for(let a=0;a=32&&(t+=e[a]);return t}let o_={2:0,3:1,4:2,5:3,6:4,7:5,8:6,11:7,12:8,14:9};function oP(e){for(let t=0;t=32)break}}function oD(e){let t=e.indexOf("~w");return -1===t?{text:e,wavPath:null}:{text:e.substring(0,t),wavPath:e.substring(t+2)}}function oM(e){return"Player"===e?"Player":ou.has(e)?"Vehicle":"Item"===e?"Item":oh.has(e)?"Projectile":op.has(e)?"Deployable":"Ghost"}function oT(e,t){return"Player"===e?`player_${t}`:ou.has(e)?`vehicle_${t}`:"Item"===e?`item_${t}`:oh.has(e)?`projectile_${t}`:op.has(e)?`deployable_${t}`:`ghost_${t}`}function oE(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z&&"number"==typeof e.w}function oB(e){return!!e&&"object"==typeof e&&"number"==typeof e.x&&"number"==typeof e.y&&"number"==typeof e.z}function oj(e){if(e){for(let t of[e.shapeName,e.projectileShapeName,e.shapeFileName,e.shapeFile,e.model])if("string"==typeof t&&t.length>0)return t}}function oR(e,t){if(e)for(let a of t){let t=e[a];if("number"==typeof t&&Number.isFinite(t))return t}}function oN(e,t){if(e)for(let a of t){let t=e[a];if("string"==typeof t&&t.length>0)return t}}function oA(e){return e?"number"==typeof e.cameraMode?"camera":"number"==typeof e.rotationZ?"player":null:null}class oG{parser;initialBlock;registry;netStrings=new Map;targetNames=new Map;targetTeams=new Map;targetRenderFlags=new Map;sensorGroupColors=new Map;state;_teamScoresGen=0;_rosterGen=0;_weaponsHudGen=0;_inventoryHudGen=0;_cachedSnapshot=null;_cachedSnapshotTick=-1;_snap=null;constructor(e){this.parser=e,this.registry=e.getRegistry();const t=e.initialBlock;this.initialBlock={dataBlocks:t.dataBlocks,initialGhosts:t.initialGhosts,controlObjectGhostIndex:t.controlObjectGhostIndex,controlObjectData:t.controlObjectData,targetEntries:t.targetEntries,sensorGroupColors:t.sensorGroupColors,taggedStrings:t.taggedStrings,initialEvents:t.initialEvents,demoValues:t.demoValues},this.state={moveTicks:0,absoluteYaw:0,absolutePitch:0,lastAbsYaw:0,lastAbsPitch:0,lastControlType:"player",isPiloting:!1,lastOrbitDistance:void 0,exhausted:!1,latestFov:100,latestControl:{ghostIndex:t.controlObjectGhostIndex,data:t.controlObjectData,position:ox(t.controlObjectData?.position)?t.controlObjectData?.position:void 0},camera:null,entitiesById:new Map,entityIdByGhostIndex:new Map,lastStatus:{health:1,energy:1},nextExplosionId:0,playerSensorGroup:0,chatMessages:[],pendingAudioEvents:[],weaponsHud:{slots:new Map,activeIndex:-1},backpackHud:{packIndex:-1,active:!1,text:""},inventoryHud:{slots:new Map,activeSlot:-1},teamScores:[],playerRoster:new Map},this.reset()}reset(){for(let[e,t]of(this.parser.reset(),this._cachedSnapshot=null,this._cachedSnapshotTick=-1,this._snap=null,this.netStrings.clear(),this.targetNames.clear(),this.targetTeams.clear(),this.targetRenderFlags.clear(),this.sensorGroupColors.clear(),this.state.entitiesById.clear(),this.state.entityIdByGhostIndex.clear(),this.initialBlock.taggedStrings))this.netStrings.set(e,t);for(let e of this.initialBlock.targetEntries)e.name&&this.targetNames.set(e.targetId,oC(e.name)),this.targetTeams.set(e.targetId,e.sensorGroup),this.targetRenderFlags.set(e.targetId,e.targetData);for(let e of this.initialBlock.sensorGroupColors){let t=this.sensorGroupColors.get(e.group);t||(t=new Map,this.sensorGroupColors.set(e.group,t)),t.set(e.targetGroup,{r:e.r,g:e.g,b:e.b})}if(this.state.playerSensorGroup=0,this.state.chatMessages=[],this.state.pendingAudioEvents=[],this.state.weaponsHud={slots:new Map,activeIndex:-1},this.state.backpackHud={packIndex:-1,active:!1,text:""},this.state.inventoryHud={slots:new Map,activeSlot:-1},this.state.teamScores=[],this.state.playerRoster=new Map,this.state.moveTicks=0,this.state.absoluteYaw=0,this.state.absolutePitch=0,this.state.lastAbsYaw=0,this.state.lastAbsPitch=0,this.state.lastControlType=oA(this.initialBlock.controlObjectData)??"player",this.state.isPiloting="player"===this.state.lastControlType&&!!(this.initialBlock.controlObjectData?.pilot||this.initialBlock.controlObjectData?.controlObjectGhost!=null),this.state.lastCameraMode="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.cameraMode?this.initialBlock.controlObjectData.cameraMode:void 0,this.state.lastOrbitGhostIndex="camera"===this.state.lastControlType&&"number"==typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex?this.initialBlock.controlObjectData.orbitObjectGhostIndex:void 0,"camera"===this.state.lastControlType){let e=this.initialBlock.controlObjectData?.minOrbitDist,t=this.initialBlock.controlObjectData?.maxOrbitDist,a=this.initialBlock.controlObjectData?.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof a&&Number.isFinite(a)?this.state.lastOrbitDistance=Math.max(0,a):this.state.lastOrbitDistance=void 0}else this.state.lastOrbitDistance=void 0;let e=this.getAbsoluteRotation(this.initialBlock.controlObjectData);for(let t of(e&&(this.state.absoluteYaw=e.yaw,this.state.absolutePitch=e.pitch,this.state.lastAbsYaw=e.yaw,this.state.lastAbsPitch=e.pitch),this.state.exhausted=!1,this.state.latestFov=100,this.state.latestControl={ghostIndex:this.initialBlock.controlObjectGhostIndex,data:this.initialBlock.controlObjectData,position:ox(this.initialBlock.controlObjectData?.position)?this.initialBlock.controlObjectData?.position:void 0},this.state.controlPlayerGhostId="player"===this.state.lastControlType&&this.initialBlock.controlObjectGhostIndex>=0?`player_${this.initialBlock.controlObjectGhostIndex}`:void 0,this.state.camera=null,this.state.lastStatus={health:1,energy:1},this.state.nextExplosionId=0,this.initialBlock.initialGhosts)){if("create"!==t.type||null==t.classId)continue;let e=this.registry.getGhostParser(t.classId)?.name??`ghost_${t.classId}`,a=oT(e,t.index),r={id:a,ghostIndex:t.index,className:e,spawnTick:0,type:oM(e),rotation:[0,0,0,1]};this.applyGhostData(r,t.parsedData),this.state.entitiesById.set(a,r),this.state.entityIdByGhostIndex.set(t.index,a)}if(0===this.state.playerSensorGroup&&"player"===this.state.lastControlType&&this.state.latestControl.ghostIndex>=0){let e=this.state.entityIdByGhostIndex.get(this.state.latestControl.ghostIndex),t=e?this.state.entitiesById.get(e):void 0;t?.sensorGroup!=null&&t.sensorGroup>0&&(this.state.playerSensorGroup=t.sensorGroup)}for(let e of this.initialBlock.initialEvents){let t=this.registry.getEventParser(e.classId)?.name;if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.state.playerSensorGroup=t)}else if("RemoteCommandEvent"===t&&e.parsedData){let t=this.resolveNetString(e.parsedData.funcName),a=e.parsedData.args;"ServerMessage"===t&&this.handleServerMessage(a),this.handleHudRemoteCommand(t,a)}}let t=function(e){let t={weaponsHud:null,backpackHud:null,inventoryHud:null,teamScores:[],playerRoster:new Map,chatMessages:[],gravity:-20};if(!e.length)return t;let a=0,r=()=>{let t=e[a++];return""===t?"":t??""};if(r(),a>=e.length)return t;let n=parseInt(r(),10)||0,i=new Map;for(let e=0;e0&&i.set(o,(i.get(o)??0)+1)}if(a>=e.length||(r(),a>=e.length))return t;{let e=r().split(" "),a=e[0]??"",n="1"===e[1]||"true"===e[1],i=e[2]??"",o="1"===e[4]||"true"===e[4];n&&a&&(t.backpackHud={packIndex:function(e){let t=e.toLowerCase();for(let[e,a]of oS)if(e===t)return a;return -1}(a),active:o,text:i})}if(a>=e.length)return t;let o=r().split(" "),s=parseInt(o[4],10)||0,l=parseInt(o[5],10)||0,c=parseInt(o[6],10);for(let e=0;e=e.length)return t;let u=r().split(" "),h=parseInt(u[4],10)||0,m=parseInt(u[5],10)||0,f=parseInt(u[6],10);for(let e=0;e0)||e.set(a,n)}e.size>0&&(t.inventoryHud={slots:e,activeSlot:isNaN(f)?-1:f})}if(a>=e.length)return t;let g=r().split(" "),p=g[1]??"",y=parseInt(g[2],10)||0,v=[];for(let e=0;e=8)for(let e=0;e<2;e++){let a=4*e,r=e+1;t.teamScores.push({teamId:r,name:v[a]??"",score:parseInt(v[a+1],10)||0,playerCount:i.get(r)??0})}else if("TR2Game"===p&&y>=4)for(let e=0;e<2;e++){let a=2*e,r=e+1;t.teamScores.push({teamId:r,name:v[a+1]??"",score:parseInt(v[a],10)||0,playerCount:i.get(r)??0})}if(a>=e.length)return t;r();for(let n=0;n<10&&!(a>=e.length);n++){let e=r();e&&t.chatMessages.push(e)}if(a=32&&(r+=e[i]);continue}let s=o_[o];void 0!==s?(r&&(t.push({text:r,colorCode:a}),r=""),a=s):15===o?(r&&(t.push({text:r,colorCode:a}),r=""),a=0):o>=32&&(r+=e[i])}return r&&t.push({text:r,colorCode:a}),t}(e);if(!t.length)continue;let a=t.map(e=>e.text).join("");if(!a.trim())continue;let r=t[0].colorCode;if(t.some(e=>3===e.colorCode||4===e.colorCode)&&a.includes(": ")){let e=a.indexOf(": ");this.state.chatMessages.push({timeSec:0,sender:a.slice(0,e),text:a.slice(e+2),kind:"chat",colorCode:r,segments:t})}else this.state.chatMessages.push({timeSec:0,sender:"",text:a,kind:"server",colorCode:r,segments:t})}this.updateCameraAndHud()}getSnapshot(){if(this._cachedSnapshot&&this._cachedSnapshotTick===this.state.moveTicks)return this._cachedSnapshot;let e=this.buildSnapshot();return this._cachedSnapshot=e,this._cachedSnapshotTick=this.state.moveTicks,e}getEffectShapes(){let e=new Set,t=t=>{let a=t.dtsFileName;a&&e.add(a);let r=t.subExplosions;if(Array.isArray(r))for(let t of r){if(null==t)continue;let a=this.getDataBlockData(t);a?.dtsFileName&&e.add(a.dtsFileName)}};for(let[,e]of this.initialBlock.dataBlocks){let a=e.data?.explosion;if(null==a)continue;let r=this.getDataBlockData(a);r&&t(r)}return[...e]}stepToTime(e,t=1/0){let a=Math.floor(1e3*(Number.isFinite(e)?Math.max(0,e):0)/32),r=!1;a0&&(this.state.playerSensorGroup=t.sensorGroup)}if(a){let e=oA(a);if(e&&(this.state.lastControlType=e),"player"===this.state.lastControlType)this.state.isPiloting=!!(a.pilot||null!=a.controlObjectGhost);else if(this.state.isPiloting=!1,"number"==typeof a.cameraMode)if(this.state.lastCameraMode=a.cameraMode,3===a.cameraMode){"number"==typeof a.orbitObjectGhostIndex&&(this.state.lastOrbitGhostIndex=a.orbitObjectGhostIndex);let e=a.minOrbitDist,t=a.maxOrbitDist,r=a.curOrbitDist;"number"==typeof e&&"number"==typeof t&&Number.isFinite(e)&&Number.isFinite(t)?this.state.lastOrbitDistance=Math.max(0,t-e):"number"==typeof r&&Number.isFinite(r)&&(this.state.lastOrbitDistance=Math.max(0,r))}else this.state.lastOrbitGhostIndex=void 0,this.state.lastOrbitDistance=void 0;let t=this.getAbsoluteRotation(a);t&&(this.state.absoluteYaw=t.yaw,this.state.absolutePitch=t.pitch,this.state.lastAbsYaw=t.yaw,this.state.lastAbsPitch=t.pitch)}for(let e of t.events){let t=this.registry.getEventParser(e.classId)?.name;if("NetStringEvent"===t&&e.parsedData){let t=e.parsedData.id,a=e.parsedData.value;null!=t&&"string"==typeof a&&this.netStrings.set(t,a);continue}if("TargetInfoEvent"===t&&e.parsedData){let t=e.parsedData.targetId,a=e.parsedData.nameTag;if(null!=t&&null!=a){let e=this.netStrings.get(a);e&&this.targetNames.set(t,oC(e))}let r=e.parsedData.sensorGroup;null!=t&&null!=r&&this.targetTeams.set(t,r);let n=e.parsedData.renderFlags;if(null!=t&&null!=n)for(let e of(this.targetRenderFlags.set(t,n),this.state.entitiesById.values()))e.targetId===t&&(e.targetRenderFlags=n)}else if("SetSensorGroupEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup;null!=t&&(this.state.playerSensorGroup=t)}else if("SensorGroupColorEvent"===t&&e.parsedData){let t=e.parsedData.sensorGroup,a=e.parsedData.colors;if(a){let e=this.sensorGroupColors.get(t);for(let r of(e||(e=new Map,this.sensorGroupColors.set(t,e)),a))r.default?e.delete(r.index):e.set(r.index,{r:r.r??0,g:r.g??0,b:r.b??0})}}else if("RemoteCommandEvent"===t&&e.parsedData){let t=this.resolveNetString(e.parsedData.funcName),a=e.parsedData.args,r=.032*this.state.moveTicks;if("ChatMessage"===t&&a.length>=4){let e=oP(this.resolveNetString(a[3])),t=a[4]?oC(this.resolveNetString(a[4])):"",n=this.formatRemoteArgs(a[3],a.slice(4));if(n){let i,o,s=n.indexOf(": "),{text:l,wavPath:c}=oD(s>=0?n.slice(s+2):n);if(c){let e=this.resolveNetString(a[1]);i=e?`voice/${e}/${c}.wav`:c;let t=this.resolveNetString(a[2]);if(t){let e=parseFloat(t);Number.isFinite(e)&&(o=Math.max(.5,Math.min(2,e)))}}let d=e??0;this.pushChatMessage({timeSec:r,sender:t,text:l,kind:"chat",colorCode:d,segments:[{text:t?`${t}: ${l}`:l,colorCode:d}],soundPath:i,soundPitch:o})}}else if("CannedChatMessage"===t&&a.length>=6){let e=oP(this.resolveNetString(a[1])),t=oC(this.resolveNetString(a[2])),n=oC(this.resolveNetString(a[4])),i=this.formatRemoteArgs(a[1],a.slice(2));if(i){let o,s,{wavPath:l}=oD(i),c=oD(oC(this.resolveNetString(a[3]))).text;if(l){let e=this.resolveNetString(a[5]);if(o=e?`voice/${e}/${l}.wav`:l,a[6]){let e=parseFloat(this.resolveNetString(a[6]));Number.isFinite(e)&&(s=Math.max(.5,Math.min(2,e)))}}let d=e??0,u=[];n&&u.push({text:`[${n}] `,colorCode:0}),u.push({text:t?`${t}: ${c}`:c,colorCode:d}),this.pushChatMessage({timeSec:r,sender:t,text:c,kind:"chat",colorCode:d,segments:u,soundPath:o,soundPitch:s})}}else if("ServerMessage"===t&&a.length>=2){this.handleServerMessage(a);let e=oP(this.resolveNetString(a[1])),t=this.formatRemoteArgs(a[1],a.slice(2));if(t){let{text:a,wavPath:n}=oD(t),i=e??0;this.pushChatMessage({timeSec:r,sender:"",text:a,kind:"server",colorCode:i,segments:[{text:a,colorCode:i}],soundPath:n??void 0})}}else this.handleHudRemoteCommand(t,a)}else if(("Sim3DAudioEvent"===t||"Sim2DAudioEvent"===t)&&e.parsedData){let a=e.parsedData.profileId;if("number"==typeof a){let r=.032*this.state.moveTicks,n="Sim3DAudioEvent"===t?e.parsedData.position:void 0;this.state.pendingAudioEvents.push({profileId:a,position:n,timeSec:r}),this.state.pendingAudioEvents.length>100&&this.state.pendingAudioEvents.splice(0,this.state.pendingAudioEvents.length-100)}}}for(let e of t.ghosts)this.applyPacketGhost(e);return}if(3===e.type&&this.isInfoData(e.parsed)){Number.isFinite(e.parsed.value2)&&(this.state.latestFov=e.parsed.value2);return}if(2===e.type&&this.isMoveData(e.parsed)){this.state.absoluteYaw+=e.parsed.yaw??0;let t=2*Math.PI;this.state.absoluteYaw=(this.state.absoluteYaw%t+t)%t,this.state.absolutePitch=ok(this.state.absolutePitch+(e.parsed.pitch??0),-ov,ov)}}applyPacketGhost(e){let t,a=e.index,r=this.state.entityIdByGhostIndex.get(a);if(r){let t=this.state.entitiesById.get(r);t&&"Projectile"===t.type&&!t.hasExploded&&null!=t.explosionDataBlockId&&t.position&&("delete"===e.type||"create"===e.type)&&this.spawnExplosion(t,[...t.position])}if("delete"===e.type){r&&(this.state.entitiesById.delete(r),this.state.entityIdByGhostIndex.delete(a));return}let n=this.resolveGhostClassName(a,e.classId);if(!n)return;let i=oT(n,a);r&&r!==i&&this.state.entitiesById.delete(r);let o=this.state.entitiesById.get(i);o&&"create"===e.type?(o.spawnTick=this.state.moveTicks,o.rotation=[0,0,0,1],o.hasExploded=void 0,o.explosionShape=void 0,o.explosionLifetimeTicks=void 0,o.faceViewer=void 0,o.simulatedVelocity=void 0,o.projectilePhysics=void 0,o.gravityMod=void 0,o.direction=void 0,o.velocity=void 0,o.position=void 0,o.dataBlock=void 0,o.dataBlockId=void 0,o.shapeHint=void 0,o.visual=void 0,o.targetId=void 0,o.targetRenderFlags=void 0,o.carryingFlag=void 0,o.sensorGroup=void 0,o.playerName=void 0,o.weaponShape=void 0,o.weaponImageState=void 0,o.weaponImageStates=void 0,o.weaponImageStatesDbId=void 0,o.itemPhysics=void 0,o.threads=void 0,o.headPitch=void 0,o.headYaw=void 0,o.health=void 0,o.energy=void 0,o.maxEnergy=void 0,o.damageState=void 0,o.actionAnim=void 0,o.actionAtEnd=void 0,o.explosionDataBlockId=void 0,o.maintainEmitterId=void 0,t=o):o?t=o:(t={id:i,ghostIndex:a,className:n,spawnTick:this.state.moveTicks,type:oM(n),rotation:[0,0,0,1]},this.state.entitiesById.set(i,t)),t.ghostIndex=a,t.className=n,t.type=oM(n),this.state.entityIdByGhostIndex.set(a,i),this.applyGhostData(t,e.parsedData)}resolveGhostClassName(e,t){if("number"==typeof t){let e=this.registry.getGhostParser(t)?.name;if(e)return e}let a=this.state.entityIdByGhostIndex.get(e);if(a){let e=this.state.entitiesById.get(a);if(e?.className)return e.className}let r=this.parser.getGhostTracker().getGhost(e);if(r?.className)return r.className}resolveEntityIdForGhostIndex(e){let t=this.state.entityIdByGhostIndex.get(e);if(t)return t;let a=this.parser.getGhostTracker().getGhost(e);if(a)return oT(a.className,e)}getDataBlockData(e){let t=this.initialBlock.dataBlocks.get(e);if(t?.data)return t.data;let a=this.parser.getPacketParser();return a.dataBlockDataMap?.get(e)}resolveExplosionInfo(e){let t=this.getDataBlockData(e);if(!t)return;let a=t.explosion;if(null==a)return;let r=this.getDataBlockData(a);if(!r)return;let n=r.dtsFileName||void 0,i=r.lifetimeMS??31;return{shape:n,faceViewer:!1!==r.faceViewer&&0!==r.faceViewer,lifetimeTicks:i,explosionDataBlockId:a}}applyGhostData(e,t){if(!t)return;let a=t.dataBlockId;if(null!=a){e.dataBlockId=a;let t=this.getDataBlockData(a),r=oj(t);if(e.visual=function(e,t){if(!t)return;let a=oN(t,["tracerTex0","textureName0","texture0"])??"";if(!("TracerProjectile"===e||a.length>0&&null!=oR(t,["tracerLength"]))||!a)return;let r=oN(t,["tracerTex1","textureName1","texture1"]),n=oR(t,["tracerLength"])??10,i=oR(t,["tracerWidth"]),o=oR(t,["tracerAlpha"]),s=null!=i&&(null!=oR(t,["crossViewAng"])||i<=.7)?i:o??i??.5,l=oR(t,["crossViewAng","crossViewFraction"])??("number"==typeof t.tracerWidth&&t.tracerWidth>.7?t.tracerWidth:.98);return{kind:"tracer",texture:a,crossTexture:r,tracerLength:n,tracerWidth:s,crossViewAng:l,crossSize:oR(t,["crossSize","muzzleVelocity"])??.45,renderCross:function(e,t){if(e)for(let a of t){let t=e[a];if("boolean"==typeof t)return t}}(t,["renderCross","proximityRadius"])??!0}}(e.className,t)??function(e,t){if(t){if("LinearFlareProjectile"===e){let e=oN(t,["smokeTexture","flareTexture"]);if(!e)return;let a=t.flareColor,r=oR(t,["size"])??.5;return{kind:"sprite",texture:e,color:a?{r:a.r,g:a.g,b:a.b}:{r:1,g:1,b:1},size:r}}if("FlareProjectile"===e){let e=oN(t,["flareTexture"]);if(!e)return;return{kind:"sprite",texture:e,color:{r:1,g:.9,b:.5},size:oR(t,["size"])??4}}}}(e.className,t),"string"==typeof r&&(e.shapeHint=r,e.dataBlock=r),"Player"===e.type&&"number"==typeof t?.maxEnergy&&(e.maxEnergy=t.maxEnergy),"Projectile"===e.type&&(om.has(e.className)?e.projectilePhysics="linear":of.has(e.className)?(e.projectilePhysics="ballistic",e.gravityMod=oR(t,["gravityMod"])??1):og.has(e.className)&&(e.projectilePhysics="seeker")),"Projectile"===e.type&&null==e.explosionDataBlockId){let t=this.resolveExplosionInfo(a);t&&(e.explosionShape=t.shape,e.faceViewer=t.faceViewer,e.explosionLifetimeTicks=t.lifetimeTicks,e.explosionDataBlockId=t.explosionDataBlockId)}if("Projectile"===e.type&&null==e.maintainEmitterId){let a=t?.baseEmitter;"number"==typeof a&&a>0&&(e.maintainEmitterId=a)}}if("Player"===e.type){let a=t.images;if(Array.isArray(a)&&a.length>0){let t=a.find(e=>0===e.index);if(t?.dataBlockId&&t.dataBlockId>0){let a=this.getDataBlockData(t.dataBlockId),r=oj(a);if(r){let t=a?.mountPoint;(null==t||t<=0)&&!/pack_/i.test(r)&&(e.weaponShape=r)}let n=e.weaponImageState;e.weaponImageState={dataBlockId:t.dataBlockId,triggerDown:t.triggerDown??n?.triggerDown??!1,ammo:t.ammo??n?.ammo??!0,loaded:t.loaded??n?.loaded??!0,target:t.target??n?.target??!1,wet:t.wet??n?.wet??!1,fireCount:t.fireCount??n?.fireCount??0},a&&e.weaponImageStatesDbId!==t.dataBlockId&&(e.weaponImageStates=function(e){let t=e.states;if(Array.isArray(t)&&0!==t.length)return t.map(e=>{let t=e=>null==e?-1:e-1;return{name:e.name??"",transitionOnNotLoaded:t(e.transitionOnAmmo),transitionOnLoaded:t(e.transitionOnNoAmmo),transitionOnNoAmmo:t(e.transitionOnTarget),transitionOnAmmo:t(e.transitionOnNoTarget),transitionOnNoTarget:t(e.transitionOnWet),transitionOnTarget:t(e.transitionOnNotWet),transitionOnNotWet:t(e.transitionOnTriggerUp),transitionOnWet:t(e.transitionOnTriggerDown),transitionOnTriggerUp:t(e.transitionOnTimeout),transitionOnTriggerDown:t(e.transitionGeneric0In),transitionOnTimeout:t(e.transitionGeneric0Out),timeoutValue:e.timeoutValue,waitForTimeout:e.waitForTimeout??!1,fire:e.fire??!1,sequence:e.sequence,spin:e.spin??0,direction:e.direction??!0,scaleAnimation:e.scaleAnimation??!1,loaded:e.loaded??0,soundDataBlockId:e.sound??-1}})}(a),e.weaponImageStatesDbId=t.dataBlockId)}else t&&!t.dataBlockId&&(e.weaponShape=void 0,e.weaponImageState=void 0,e.weaponImageStates=void 0);let r=a.find(e=>3===e.index);if(r){let t=!!r.dataBlockId&&r.dataBlockId>0;if(e.carryingFlag=t,null!=e.targetId&&e.targetId>=0){let a=this.targetRenderFlags.get(e.targetId)??0,r=t?2|a:-3&a;r!==a&&(this.targetRenderFlags.set(e.targetId,r),e.targetRenderFlags=r)}}}}let r=ox(t.position)?t.position:ox(t.initialPosition)?t.initialPosition:ox(t.explodePosition)?t.explodePosition:ox(t.endPoint)?t.endPoint:ox(t.transform?.position)?t.transform.position:void 0;r&&(e.position=[r.x,r.y,r.z]);let n=oB(t.direction)?t.direction:void 0;if(n&&(e.direction=[n.x,n.y,n.z]),"Player"===e.type&&"number"==typeof t.rotationZ&&(e.rotation=ow(t.rotationZ)),"Player"===e.type&&("number"==typeof t.headX&&(e.headPitch=t.headX),"number"==typeof t.headZ&&(e.headYaw=t.headZ)),oE(t.angPosition)){let a=oI(t.angPosition);a&&(e.rotation=a)}else if(oE(t.transform?.rotation)){let a=oI(t.transform.rotation);a&&(e.rotation=a)}else if("Item"===e.type&&"number"==typeof t.rotation?.angle){let a=t.rotation;e.rotation=ow((a.zSign??1)*a.angle)}else if("Projectile"===e.type){let a=t.velocity??t.direction??(ox(t.initialPosition)&&ox(t.endPos)?{x:t.endPos.x-t.initialPosition.x,y:t.endPos.y-t.initialPosition.y,z:t.endPos.z-t.initialPosition.z}:void 0);oB(a)&&(0!==a.x||0!==a.y)&&(e.rotation=ow(Math.atan2(a.x,a.y)))}if(oB(t.velocity)&&(e.velocity=[t.velocity.x,t.velocity.y,t.velocity.z],e.direction||(e.direction=[t.velocity.x,t.velocity.y,t.velocity.z])),"Item"===e.type){let a=t.atRest,n=t.warp;if(!0===a||!1===n)e.itemPhysics=void 0;else if(!1===a&&oB(t.velocity)){let a=null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0;e.itemPhysics={velocity:[t.velocity.x,t.velocity.y,t.velocity.z],atRest:!1,elasticity:oR(a,["elasticity"])??.2,friction:oR(a,["friction"])??.6,gravityMod:oR(a,["gravityMod"])??1}}else r&&!oB(t.velocity)&&(e.itemPhysics=void 0)}if(e.projectilePhysics)if("linear"===e.projectilePhysics){let a=oR(null!=e.dataBlockId?this.getDataBlockData(e.dataBlockId):void 0,["dryVelocity","muzzleVelocity","bulletVelocity"])??80,r=e.direction??[0,1,0],n=r[0]*a,i=r[1]*a,o=r[2]*a,s=t.excessVel,l=t.excessDir;"number"==typeof s&&s>0&&oB(l)&&(n+=l.x*s,i+=l.y*s,o+=l.z*s),e.simulatedVelocity=[n,i,o]}else oB(t.velocity)&&(e.simulatedVelocity=[t.velocity.x,t.velocity.y,t.velocity.z]);if(e.projectilePhysics){let a=t.currTick;if("number"==typeof a&&a>0&&e.simulatedVelocity&&e.position){let t=.032*a,r=e.simulatedVelocity;if(e.position[0]+=r[0]*t,e.position[1]+=r[1]*t,e.position[2]+=r[2]*t,"ballistic"===e.projectilePhysics){let a=-9.81*(e.gravityMod??1);e.position[2]+=.5*a*t*t,r[2]+=a*t}}}let i=ox(t.explodePosition)?t.explodePosition:ox(t.explodePoint)?t.explodePoint:void 0;if("Projectile"===e.type&&!e.hasExploded&&i&&null!=e.explosionDataBlockId&&this.spawnExplosion(e,[i.x,i.y,i.z]),"number"==typeof t.damageLevel&&(e.health=ok(1-t.damageLevel,0,1)),"number"==typeof t.damageState&&(e.damageState=t.damageState),"number"==typeof t.action&&(e.actionAnim=t.action,e.actionAtEnd=!!t.actionAtEnd),Array.isArray(t.threads)){let a=t.threads;if(e.threads){let t=[...e.threads];for(let e of a){let a=t.findIndex(t=>t.index===e.index);a>=0?t[a]=e:t.push(e)}e.threads=t}else e.threads=a}if("number"==typeof t.energy&&(e.energy=ok(t.energy,0,1)),"number"==typeof t.targetId){e.targetId=t.targetId;let a=this.targetNames.get(t.targetId);a&&(e.playerName=a);let r=this.targetTeams.get(t.targetId);null!=r&&(e.sensorGroup=r,e.ghostIndex===this.state.latestControl.ghostIndex&&"player"===this.state.lastControlType&&(this.state.playerSensorGroup=r));let n=this.targetRenderFlags.get(t.targetId);null!=n&&(e.targetRenderFlags=n)}let o=t.sounds;if(Array.isArray(o)){let t=.032*this.state.moveTicks;for(let a of o)if(a.playing&&"number"==typeof a.profileId){let r=e.position;this.state.pendingAudioEvents.push({profileId:a.profileId,position:r?{x:r[0],y:r[1],z:r[2]}:void 0,timeSec:t})}}}advanceProjectiles(){for(let e of this.state.entitiesById.values()){if(!e.simulatedVelocity||!e.position)continue;let t=e.simulatedVelocity,a=e.position;"ballistic"===e.projectilePhysics&&(t[2]+=-9.81*(e.gravityMod??1)*.032),a[0]+=.032*t[0],a[1]+=.032*t[1],a[2]+=.032*t[2],(0!==t[0]||0!==t[1])&&(e.rotation=ow(Math.atan2(t[0],t[1])))}}advanceItems(){for(let a of this.state.entitiesById.values()){var e,t;let r=a.itemPhysics;if(!r||r.atRest||!a.position)continue;let n=r.velocity,i=a.position;n[2]+=-20*r.gravityMod*.032,i[0]+=.032*n[0],i[1]+=.032*n[1],i[2]+=.032*n[2];let o=(e=i[0],t=i[1],_?_(e,t):null);if(null!=o&&i[2]0){let e=Math.max(0,1-t/a);n[0]*=e,n[1]*=e}.15>Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2])&&(n[0]=n[1]=n[2]=0,r.atRest=!0)}}}spawnExplosion(e,t){e.hasExploded=!0;let a=e.explosionLifetimeTicks??31,r=`fx_${this.state.nextExplosionId++}`,n={id:r,ghostIndex:-1,className:"Explosion",spawnTick:this.state.moveTicks,type:"Explosion",dataBlock:e.explosionShape,explosionDataBlockId:e.explosionDataBlockId,position:t,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==e.faceViewer,expiryTick:this.state.moveTicks+a};if(this.state.entitiesById.set(r,n),null!=e.explosionDataBlockId){let a=this.getDataBlockData(e.explosionDataBlockId),r=a?.subExplosions;if(Array.isArray(r))for(let e of r){if(null==e)continue;let a=this.getDataBlockData(e);if(!a)continue;let r=a.dtsFileName||void 0;if(!r)continue;let n=a.lifetimeMS??31,i=a.offset??0,o=Math.random()*Math.PI*2,s=[t[0]+Math.cos(o)*i,t[1]+Math.sin(o)*i,t[2]],l=`fx_${this.state.nextExplosionId++}`,c={id:l,ghostIndex:-1,className:"Explosion",spawnTick:this.state.moveTicks,type:"Explosion",dataBlock:r,explosionDataBlockId:e,position:s,rotation:[0,0,0,1],isExplosion:!0,faceViewer:!1!==a.faceViewer&&0!==a.faceViewer,expiryTick:this.state.moveTicks+n};this.state.entitiesById.set(l,c)}}e.position=void 0,e.simulatedVelocity=void 0}removeExpiredExplosions(){for(let[e,t]of this.state.entitiesById)t.isExplosion&&null!=t.expiryTick&&this.state.moveTicks>=t.expiryTick&&this.state.entitiesById.delete(e)}updateCameraAndHud(){let e=this.state.latestControl,t=.032*this.state.moveTicks,a=e.data,r=this.state.lastControlType;if(e.position){var n;let i,o,s,l,c=!this.state.isPiloting&&"player"===r,d=c?this.state.absoluteYaw:this.state.lastAbsYaw,u=c?this.state.absolutePitch:this.state.lastAbsPitch;if(c&&(this.state.lastAbsYaw=d,this.state.lastAbsPitch=u),this.state.camera={time:t,position:[e.position.x,e.position.y,e.position.z],rotation:(i=Math.sin(n=ok(u,-ov,ov)),o=Math.cos(n),s=Math.sin(d),l=Math.cos(d),oF.set(-s,l*i,-l*o,0,0,o,i,0,l,s*i,-s*o,0,0,0,0,1),ob.setFromRotationMatrix(oF),[ob.x,ob.y,ob.z,ob.w]),fov:this.state.latestFov,mode:"observer",yaw:d,pitch:u},"camera"===r)if(("number"==typeof a?.cameraMode?a.cameraMode:this.state.lastCameraMode)===3){this.state.camera.mode="third-person","number"==typeof this.state.lastOrbitDistance&&(this.state.camera.orbitDistance=this.state.lastOrbitDistance);let e="number"==typeof a?.orbitObjectGhostIndex?a.orbitObjectGhostIndex:this.state.lastOrbitGhostIndex;"number"==typeof e&&e>=0&&(this.state.camera.orbitTargetId=this.resolveEntityIdForGhostIndex(e))}else this.state.camera.mode="observer";else this.state.camera.mode="first-person",e.ghostIndex>=0&&(this.state.controlPlayerGhostId=`player_${e.ghostIndex}`),this.state.controlPlayerGhostId&&(this.state.camera.controlEntityId=this.state.controlPlayerGhostId);if("player"===r&&!this.state.isPiloting&&this.state.controlPlayerGhostId&&e.position){let t=this.state.entitiesById.get(this.state.controlPlayerGhostId);t&&(t.position=[e.position.x,e.position.y,e.position.z],t.rotation=ow(d),t.headPitch=ok(this.state.absolutePitch/ov,-1,1))}}else this.state.camera&&(this.state.camera={...this.state.camera,time:t,fov:this.state.latestFov});let i={health:1,energy:1};if(this.state.camera?.mode==="first-person"){let e=this.state.controlPlayerGhostId,t=e?this.state.entitiesById.get(e):void 0;i.health=t?.health??1;let r=a?.energyLevel;if("number"==typeof r){let e=t?.maxEnergy??60;e>0&&(i.energy=ok(r/e,0,1))}else i.energy=t?.energy??1}else if(this.state.camera?.mode==="third-person"&&this.state.camera.orbitTargetId){let e=this.state.entitiesById.get(this.state.camera.orbitTargetId);i.health=e?.health??1,i.energy=e?.energy??1}this.state.lastStatus=i}pushChatMessage(e){this.state.chatMessages.push(e),this.state.chatMessages.length>200&&this.state.chatMessages.splice(0,this.state.chatMessages.length-200)}handleServerMessage(e){if(e.length<2)return;let t=this.resolveNetString(e[0]);if("MsgTeamScoreIs"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.state.teamScores.find(e=>e.teamId===t);e&&(e.score=a,this._teamScoresGen++)}}else if("MsgCTFAddTeam"===t&&e.length>=6){let t=parseInt(this.resolveNetString(e[2]),10),a=oC(this.resolveNetString(e[3])),r=parseInt(this.resolveNetString(e[5]),10);if(!isNaN(t)){let e=t+1,n=this.state.teamScores.find(t=>t.teamId===e);n?(n.name=a,n.score=isNaN(r)?n.score:r):this.state.teamScores.push({teamId:e,name:a,score:isNaN(r)?0:r,playerCount:0}),this._teamScoresGen++}}else if("MsgClientJoin"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=oC(this.resolveNetString(e[3]));if(!isNaN(t)){let e=this.state.playerRoster.get(t);this.state.playerRoster.set(t,{name:a,teamId:e?.teamId??0}),this._rosterGen++}}else if("MsgClientDrop"===t&&e.length>=3){let t=parseInt(this.resolveNetString(e[2]),10);!isNaN(t)&&(this.state.playerRoster.delete(t),this._rosterGen++)}else if("MsgClientJoinTeam"===t&&e.length>=4){let t=parseInt(this.resolveNetString(e[2]),10),a=parseInt(this.resolveNetString(e[3]),10);if(!isNaN(t)&&!isNaN(a)){let e=this.state.playerRoster.get(t);e?e.teamId=a:this.state.playerRoster.set(t,{name:"",teamId:a}),this._rosterGen++}}}handleHudRemoteCommand(e,t){if("setWeaponsHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];!isNaN(e)&&(r?this.state.weaponsHud.slots.set(e,isNaN(a)?-1:a):this.state.weaponsHud.slots.delete(e),this._weaponsHudGen++)}else if("setWeaponsHudAmmo"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);!isNaN(e)&&(this.state.weaponsHud.slots.set(e,isNaN(a)?-1:a),this._weaponsHudGen++)}else if("setWeaponsHudActive"===e&&t.length>=1){let e=parseInt(t[0],10);this.state.weaponsHud.activeIndex=isNaN(e)?-1:e,isNaN(e)||!(e>=0)||this.state.weaponsHud.slots.has(e)||this.state.weaponsHud.slots.set(e,-1),this._weaponsHudGen++}else if("setWeaponsHudClearAll"===e)this.state.weaponsHud.slots.clear(),this.state.weaponsHud.activeIndex=-1,this._weaponsHudGen++;else if("setBackpackHudItem"===e&&t.length>=2){let e=parseInt(t[0],10);"1"!==t[1]&&"true"!==t[1]||isNaN(e)?this.state.backpackHud.packIndex=-1:this.state.backpackHud.packIndex=e,this.state.backpackHud.active=!1,this.state.backpackHud.text=""}else if("setSatchelArmed"===e)this.state.backpackHud.active=!0;else if("setCloakIconOn"===e||"setRepairPackIconOn"===e||"setShieldIconOn"===e||"setSenJamIconOn"===e)this.state.backpackHud.active=!0;else if("setCloakIconOff"===e||"setRepairPackIconOff"===e||"setShieldIconOff"===e||"setSenJamIconOff"===e)this.state.backpackHud.active=!1;else if("updatePackText"===e&&t.length>=1)this.state.backpackHud.text=t[0]??"";else if("setInventoryHudItem"===e&&t.length>=3){let e=parseInt(t[0],10),a=parseInt(t[1],10),r="1"===t[2]||"true"===t[2];!isNaN(e)&&(r&&!isNaN(a)?this.state.inventoryHud.slots.set(e,a):this.state.inventoryHud.slots.delete(e),this._inventoryHudGen++)}else if("setInventoryHudAmount"===e&&t.length>=2){let e=parseInt(t[0],10),a=parseInt(t[1],10);!isNaN(e)&&!isNaN(a)&&(this.state.inventoryHud.slots.set(e,a),this._inventoryHudGen++)}else"setInventoryHudClearAll"===e&&(this.state.inventoryHud.slots.clear(),this.state.inventoryHud.activeSlot=-1,this._inventoryHudGen++)}buildSnapshot(){let e,t=[];for(let e of this.state.entitiesById.values()){if(!(e.spawnTick>0||!oy.has(e.className)))continue;let a=null!=e.targetId&&e.targetId>=0?this.targetRenderFlags.get(e.targetId)??e.targetRenderFlags:e.targetRenderFlags;"Player"!==e.type||e.carryingFlag||(a=null!=a?-3&a:a),t.push({id:e.id,type:e.type,visual:e.visual,direction:e.direction,ghostIndex:e.ghostIndex,className:e.className,dataBlockId:e.dataBlockId,shapeHint:e.shapeHint,dataBlock:e.dataBlock,weaponShape:e.weaponShape,playerName:e.playerName,targetRenderFlags:a,iffColor:("Player"===e.type||((a??0)&2)!=0)&&null!=e.sensorGroup?this.resolveIffColor(e.sensorGroup):void 0,position:e.position&&(e.simulatedVelocity||e.itemPhysics&&!e.itemPhysics.atRest)?[...e.position]:e.position,rotation:e.rotation,velocity:e.velocity,health:e.health,energy:e.energy,actionAnim:e.actionAnim,actionAtEnd:e.actionAtEnd,damageState:e.damageState,faceViewer:e.faceViewer,threads:e.threads,explosionDataBlockId:e.explosionDataBlockId,maintainEmitterId:e.maintainEmitterId,weaponImageState:e.weaponImageState,weaponImageStates:e.weaponImageStates,headPitch:e.headPitch,headYaw:e.headYaw})}let a=.032*this.state.moveTicks,r=this._snap,n=this.state.chatMessages.filter(e=>e.timeSec>a-15),i=this.state.pendingAudioEvents.filter(e=>e.timeSec>a-.5&&e.timeSec<=a),o=r&&r.weaponsHudGen===this._weaponsHudGen?r.weaponsHud:{slots:Array.from(this.state.weaponsHud.slots.entries()).map(([e,t])=>({index:e,ammo:t})),activeIndex:this.state.weaponsHud.activeIndex},s=r&&r.inventoryHudGen===this._inventoryHudGen?r.inventoryHud:{slots:Array.from(this.state.inventoryHud.slots.entries()).map(([e,t])=>({slot:e,count:t})),activeSlot:this.state.inventoryHud.activeSlot},l=r&&r.backpackPackIndex===this.state.backpackHud.packIndex&&r.backpackActive===this.state.backpackHud.active&&r.backpackText===this.state.backpackHud.text?r.backpackHud:this.state.backpackHud.packIndex>=0?{...this.state.backpackHud}:null;if(r&&r.teamScoresGen===this._teamScoresGen&&r.rosterGen===this._rosterGen)e=r.teamScores;else{e=this.state.teamScores.map(e=>({...e}));let t=new Map;for(let{teamId:e}of this.state.playerRoster.values())e>0&&t.set(e,(t.get(e)??0)+1);for(let a of e)a.playerCount=t.get(a.teamId)??0}return this._snap={teamScoresGen:this._teamScoresGen,rosterGen:this._rosterGen,teamScores:e,weaponsHudGen:this._weaponsHudGen,weaponsHud:o,inventoryHudGen:this._inventoryHudGen,inventoryHud:s,backpackPackIndex:this.state.backpackHud.packIndex,backpackActive:this.state.backpackHud.active,backpackText:this.state.backpackHud.text,backpackHud:l},{timeSec:a,exhausted:this.state.exhausted,camera:this.state.camera,entities:t,controlPlayerGhostId:this.state.controlPlayerGhostId,playerSensorGroup:this.state.playerSensorGroup,status:this.state.lastStatus,chatMessages:n,audioEvents:i,weaponsHud:o,backpackHud:l,inventoryHud:s,teamScores:e}}resolveIffColor(e){if(0===this.state.playerSensorGroup)return;let t=this.sensorGroupColors.get(this.state.playerSensorGroup);if(t){let a=t.get(e);if(a)return a}return e===this.state.playerSensorGroup?oc:0!==e?od:void 0}getAbsoluteRotation(e){return e?"number"==typeof e.rotationZ&&"number"==typeof e.headX?{yaw:e.rotationZ,pitch:e.headX}:"number"==typeof e.rotZ&&"number"==typeof e.rotX?{yaw:e.rotZ,pitch:e.rotX}:null:null}isPacketData(e){return!!e&&"object"==typeof e&&"gameState"in e&&"events"in e&&"ghosts"in e}isMoveData(e){return!!e&&"object"==typeof e&&"yaw"in e}isInfoData(e){return!!e&&"object"==typeof e&&"value2"in e&&"number"==typeof e.value2}resolveNetString(e){if(e.length>=2&&1===e.charCodeAt(0)){let t=parseInt(e.slice(1),10);if(Number.isFinite(t))return this.netStrings.get(t)??e}return e}formatRemoteArgs(e,t){let a=this.resolveNetString(e);for(let e=0;e{if(h){g.current=g.current+1,m(null);return}f.current?.click()},u[0]=h,u[1]=m,u[2]=e):e=u[2];let p=e;u[3]!==m?(t=async e=>{let t=e.target.files?.[0];if(t){e.target.value="";try{let e=await t.arrayBuffer(),a=g.current+1;g.current=a;let r=await oU(e);if(g.current!==a)return;m(r)}catch(e){console.error("Failed to load demo:",e)}}},u[3]=m,u[4]=t):t=u[4];let y=t;u[5]===Symbol.for("react.memo_cache_sentinel")?(i={display:"none"},u[5]=i):i=u[5],u[6]!==y?(o=(0,a.jsx)("input",{ref:f,type:"file",accept:".rec",style:i,onChange:y}),u[6]=y,u[7]=o):o=u[7];let v=h?"Unload demo":"Load demo (.rec)",F=h?"Unload demo":"Load demo (.rec)",b=h?"true":void 0;u[8]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsx)(t8,{className:oL.default.DemoIcon}),u[8]=s):s=u[8];let S=h?"Unload demo":"Demo";return u[9]!==S?(l=(0,a.jsx)("span",{className:oL.default.ButtonLabel,children:S}),u[9]=S,u[10]=l):l=u[10],u[11]!==p||u[12]!==v||u[13]!==F||u[14]!==b||u[15]!==l?(c=(0,a.jsxs)("button",{type:"button",className:oL.default.Root,"aria-label":v,title:F,onClick:p,"data-active":b,children:[s,l]}),u[11]=p,u[12]=v,u[13]=F,u[14]=b,u[15]=l,u[16]=c):c=u[16],u[17]!==c||u[18]!==o?(d=(0,a.jsxs)(a.Fragment,{children:[o,c]}),u[17]=c,u[18]=o,u[19]=d):d=u[19],d}function oO(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(e)}function oV(e){return(0,t3.GenIcon)({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(e)}var oq=e.i(65883);function oH(e){let t,i,o,s,l,c,d,u,h,m,f,g,p,y,F,b,S,x,k,w,I,C,_,P,D,M,T,E,B,j,R,N,A,G,U,L,z,O,V,q=(0,r.c)(92),{missionName:H,missionType:W,onChangeMission:$,onOpenMapInfo:Y,isTouch:K,cameraRef:X}=e,{fogEnabled:Z,setFogEnabled:J,fov:Q,setFov:ee,audioEnabled:et,setAudioEnabled:ea,animationEnabled:er,setAnimationEnabled:en}=(0,v.useSettings)(),{speedMultiplier:ei,setSpeedMultiplier:eo,touchMode:es,setTouchMode:el}=(0,v.useControls)(),{debugMode:ec,setDebugMode:ed}=(0,v.useDebug)(),eu=null!=ts(),[eh,em]=(0,n.useState)(!1),ef=(0,n.useRef)(null),eg=(0,n.useRef)(null),ep=(0,n.useRef)(null);q[0]!==eh?(t=()=>{eh&&ef.current?.focus()},i=[eh],q[0]=eh,q[1]=t,q[2]=i):(t=q[1],i=q[2]),(0,n.useEffect)(t,i),q[3]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{let t=e.relatedTarget;t&&ep.current?.contains(t)||em(!1)},q[3]=o):o=q[3];let ey=o;q[4]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{"Escape"===e.key&&(em(!1),eg.current?.focus())},q[4]=s):s=q[4];let ev=s;return q[5]!==eu||q[6]!==H||q[7]!==W||q[8]!==$?(l=(0,a.jsx)("div",{className:oq.default.MissionSelectWrapper,children:(0,a.jsx)(t1,{value:H,missionType:W,onChange:$,disabled:eu})}),q[5]=eu,q[6]=H,q[7]=W,q[8]=$,q[9]=l):l=q[9],q[10]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{em(oW)},q[10]=c):c=q[10],q[11]===Symbol.for("react.memo_cache_sentinel")?(d=(0,a.jsx)(oV,{}),q[11]=d):d=q[11],q[12]!==eh?(u=(0,a.jsx)("button",{ref:eg,className:oq.default.Toggle,onClick:c,"aria-expanded":eh,"aria-controls":"settingsPanel","aria-label":"Settings",children:d}),q[12]=eh,q[13]=u):u=q[13],q[14]!==X||q[15]!==H||q[16]!==W?(h=(0,a.jsx)(t6,{missionName:H,missionType:W,cameraRef:X}),q[14]=X,q[15]=H,q[16]=W,q[17]=h):h=q[17],q[18]===Symbol.for("react.memo_cache_sentinel")?(m=(0,a.jsx)(oz,{}),q[18]=m):m=q[18],q[19]===Symbol.for("react.memo_cache_sentinel")?(f=(0,a.jsx)(oO,{}),g=(0,a.jsx)("span",{className:oq.default.ButtonLabel,children:"Show map info"}),q[19]=f,q[20]=g):(f=q[19],g=q[20]),q[21]!==Y?(p=(0,a.jsxs)("button",{type:"button",className:oq.default.MapInfoButton,"aria-label":"Show map info",onClick:Y,children:[f,g]}),q[21]=Y,q[22]=p):p=q[22],q[23]!==p||q[24]!==h?(y=(0,a.jsxs)("div",{className:oq.default.Group,children:[h,m,p]}),q[23]=p,q[24]=h,q[25]=y):y=q[25],q[26]!==J?(F=e=>{J(e.target.checked)},q[26]=J,q[27]=F):F=q[27],q[28]!==Z||q[29]!==F?(b=(0,a.jsx)("input",{id:"fogInput",type:"checkbox",checked:Z,onChange:F}),q[28]=Z,q[29]=F,q[30]=b):b=q[30],q[31]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)("label",{htmlFor:"fogInput",children:"Fog?"}),q[31]=S):S=q[31],q[32]!==b?(x=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[b,S]}),q[32]=b,q[33]=x):x=q[33],q[34]!==ea?(k=e=>{ea(e.target.checked)},q[34]=ea,q[35]=k):k=q[35],q[36]!==et||q[37]!==k?(w=(0,a.jsx)("input",{id:"audioInput",type:"checkbox",checked:et,onChange:k}),q[36]=et,q[37]=k,q[38]=w):w=q[38],q[39]===Symbol.for("react.memo_cache_sentinel")?(I=(0,a.jsx)("label",{htmlFor:"audioInput",children:"Audio?"}),q[39]=I):I=q[39],q[40]!==w?(C=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[w,I]}),q[40]=w,q[41]=C):C=q[41],q[42]!==x||q[43]!==C?(_=(0,a.jsxs)("div",{className:oq.default.Group,children:[x,C]}),q[42]=x,q[43]=C,q[44]=_):_=q[44],q[45]!==en?(P=e=>{en(e.target.checked)},q[45]=en,q[46]=P):P=q[46],q[47]!==er||q[48]!==P?(D=(0,a.jsx)("input",{id:"animationInput",type:"checkbox",checked:er,onChange:P}),q[47]=er,q[48]=P,q[49]=D):D=q[49],q[50]===Symbol.for("react.memo_cache_sentinel")?(M=(0,a.jsx)("label",{htmlFor:"animationInput",children:"Animation?"}),q[50]=M):M=q[50],q[51]!==D?(T=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[D,M]}),q[51]=D,q[52]=T):T=q[52],q[53]!==ed?(E=e=>{ed(e.target.checked)},q[53]=ed,q[54]=E):E=q[54],q[55]!==ec||q[56]!==E?(B=(0,a.jsx)("input",{id:"debugInput",type:"checkbox",checked:ec,onChange:E}),q[55]=ec,q[56]=E,q[57]=B):B=q[57],q[58]===Symbol.for("react.memo_cache_sentinel")?(j=(0,a.jsx)("label",{htmlFor:"debugInput",children:"Debug?"}),q[58]=j):j=q[58],q[59]!==B?(R=(0,a.jsxs)("div",{className:oq.default.CheckboxField,children:[B,j]}),q[59]=B,q[60]=R):R=q[60],q[61]!==T||q[62]!==R?(N=(0,a.jsxs)("div",{className:oq.default.Group,children:[T,R]}),q[61]=T,q[62]=R,q[63]=N):N=q[63],q[64]!==Q||q[65]!==eu||q[66]!==ee?(A=eu?null:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"fovInput",children:"FOV"}),(0,a.jsx)("input",{id:"fovInput",type:"range",min:75,max:120,step:5,value:Q,disabled:eu,onChange:e=>ee(parseInt(e.target.value))}),(0,a.jsx)("output",{htmlFor:"fovInput",children:Q})]}),q[64]=Q,q[65]=eu,q[66]=ee,q[67]=A):A=q[67],q[68]!==eu||q[69]!==eo||q[70]!==ei?(G=eu?null:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"speedInput",children:"Speed"}),(0,a.jsx)("input",{id:"speedInput",type:"range",min:.1,max:5,step:.05,value:ei,disabled:eu,onChange:e=>eo(parseFloat(e.target.value))})]}),q[68]=eu,q[69]=eo,q[70]=ei,q[71]=G):G=q[71],q[72]!==A||q[73]!==G?(U=(0,a.jsxs)("div",{className:oq.default.Group,children:[A,G]}),q[72]=A,q[73]=G,q[74]=U):U=q[74],q[75]!==K||q[76]!==el||q[77]!==es?(L=K&&(0,a.jsx)("div",{className:oq.default.Group,children:(0,a.jsxs)("div",{className:oq.default.Field,children:[(0,a.jsx)("label",{htmlFor:"touchModeInput",children:"Joystick:"})," ",(0,a.jsxs)("select",{id:"touchModeInput",value:es,onChange:e=>el(e.target.value),children:[(0,a.jsx)("option",{value:"dualStick",children:"Dual Stick"}),(0,a.jsx)("option",{value:"moveLookStick",children:"Single Stick"})]})]})}),q[75]=K,q[76]=el,q[77]=es,q[78]=L):L=q[78],q[79]!==eh||q[80]!==y||q[81]!==_||q[82]!==N||q[83]!==U||q[84]!==L?(z=(0,a.jsxs)("div",{className:oq.default.Dropdown,ref:ef,id:"settingsPanel",tabIndex:-1,onKeyDown:ev,onBlur:ey,"data-open":eh,children:[y,_,N,U,L]}),q[79]=eh,q[80]=y,q[81]=_,q[82]=N,q[83]=U,q[84]=L,q[85]=z):z=q[85],q[86]!==z||q[87]!==u?(O=(0,a.jsxs)("div",{ref:ep,children:[u,z]}),q[86]=z,q[87]=u,q[88]=O):O=q[88],q[89]!==O||q[90]!==l?(V=(0,a.jsxs)("div",{id:"controls",className:oq.default.Controls,onKeyDown:oK,onPointerDown:oY,onClick:o$,children:[l,O]}),q[89]=O,q[90]=l,q[91]=V):V=q[91],V}function oW(e){return!e}function o$(e){return e.stopPropagation()}function oY(e){return e.stopPropagation()}function oK(e){return e.stopPropagation()}let oX=()=>null;var oZ=e.i(31067);let oJ=n.forwardRef(({envMap:e,resolution:t=256,frames:a=1/0,makeDefault:r,children:i,...s},l)=>{let c=(0,h.useThree)(({set:e})=>e),d=(0,h.useThree)(({camera:e})=>e),m=(0,h.useThree)(({size:e})=>e),f=n.useRef(null);n.useImperativeHandle(l,()=>f.current,[]);let g=n.useRef(null),p=function(e,t,a){let r=(0,h.useThree)(e=>e.size),i=(0,h.useThree)(e=>e.viewport),s="number"==typeof e?e:r.width*i.dpr,l=r.height*i.dpr,c=("number"==typeof e?void 0:e)||{},{samples:d=0,depth:u,...m}=c,f=null!=u?u:c.depthBuffer,g=n.useMemo(()=>{let e=new o.WebGLRenderTarget(s,l,{minFilter:o.LinearFilter,magFilter:o.LinearFilter,type:o.HalfFloatType,...m});return f&&(e.depthTexture=new o.DepthTexture(s,l,o.FloatType)),e.samples=d,e},[]);return n.useLayoutEffect(()=>{g.setSize(s,l),d&&(g.samples=d)},[d,g,s,l]),n.useEffect(()=>()=>g.dispose(),[]),g}(t);n.useLayoutEffect(()=>{s.manual||(f.current.aspect=m.width/m.height)},[m,s]),n.useLayoutEffect(()=>{f.current.updateProjectionMatrix()});let y=0,v=null,F="function"==typeof i;return(0,u.useFrame)(t=>{F&&(a===1/0||y{if(r)return c(()=>({camera:f.current})),()=>c(()=>({camera:d}))},[f,r,c]),n.createElement(n.Fragment,null,n.createElement("perspectiveCamera",(0,oZ.default)({ref:f},s),!F&&i),n.createElement("group",{ref:g},F&&i(p.texture)))});function oQ(){let e,t,n=(0,r.c)(3),{fov:i}=(0,v.useSettings)();return n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[0,256,0],n[0]=e):e=n[0],n[1]!==i?(t=(0,a.jsx)(oJ,{makeDefault:!0,position:e,fov:i}),n[1]=i,n[2]=t):t=n[2],t}var o0=e.i(51434),o1=e.i(86855),o2=e.i(71832),o3=n,o5=e.i(82816);class o4{states;seqIndexToName;currentStateIndex=0;delayTime=0;lastFireCount=-1;spinTimeScale=0;constructor(e,t){this.states=e,this.seqIndexToName=t,e.length>0&&(this.delayTime=e[0].timeoutValue??0)}get stateIndex(){return this.currentStateIndex}reset(){this.currentStateIndex=0,this.delayTime=this.states.length>0?this.states[0].timeoutValue??0:0,this.lastFireCount=-1}tick(e,t){if(0===this.states.length)return{sequenceName:null,isFiring:!1,spinTimeScale:0,reverse:!1,scaleAnimation:!1,timeoutValue:0,transitioned:!1,soundDataBlockIds:[],stateIndex:-1};let a=this.lastFireCount>=0&&t.fireCount!==this.lastFireCount;this.lastFireCount=t.fireCount;let r=[];if(a){let e=this.states.findIndex(e=>e.fire);if(e>=0&&e!==this.currentStateIndex){this.currentStateIndex=e,this.delayTime=this.states[e].timeoutValue??0;let t=this.states[e].soundDataBlockId;t>=0&&r.push(t)}}this.delayTime-=e;let n=a,i=this.evaluateTickTransitions(t),o=0;for(;i>=0&&o<32;){if(o++,n=!0,i===this.currentStateIndex){this.delayTime=this.states[i].timeoutValue??0;break}let e=this.states[this.currentStateIndex].spin,a=this.delayTime;this.currentStateIndex=i;let s=this.states[i].timeoutValue??0;this.delayTime=s;let l=this.states[i].soundDataBlockId;switch(l>=0&&r.push(l),this.states[i].spin){case 1:this.spinTimeScale=0;break;case 4:this.spinTimeScale=1;break;case 2:3===e&&s>0&&(this.delayTime*=1-a/s);break;case 3:2===e&&s>0&&(this.delayTime*=1-a/s)}i=this.evaluateEntryTransitions(t)}let s=this.states[this.currentStateIndex],l=s.timeoutValue??0;switch(s.spin){case 1:this.spinTimeScale=0;break;case 2:this.spinTimeScale=l>0?Math.max(0,1-this.delayTime/l):1;break;case 4:this.spinTimeScale=1;break;case 3:this.spinTimeScale=l>0?Math.max(0,this.delayTime/l):0}return{sequenceName:this.resolveSequenceName(s),isFiring:s.fire,spinTimeScale:this.spinTimeScale,reverse:!s.direction,scaleAnimation:s.scaleAnimation,timeoutValue:s.timeoutValue??0,transitioned:n,soundDataBlockIds:r,stateIndex:this.currentStateIndex}}evaluateTickTransitions(e){let t=this.states[this.currentStateIndex],a=this.delayTime<=0;if(!(a||!t.waitForTimeout))return -1;let r=this.evaluateConditions(t,e);if(-1!==r)return r;if(a){let e=t.transitionOnTimeout;if(-1!==e)return e}return -1}evaluateEntryTransitions(e){let t=this.states[this.currentStateIndex];return this.evaluateConditions(t,e)}evaluateConditions(e,t){let a=t.loaded?e.transitionOnLoaded:e.transitionOnNotLoaded;if(-1!==a)return a;let r=t.ammo?e.transitionOnAmmo:e.transitionOnNoAmmo;if(-1!==r)return r;let n=t.target?e.transitionOnTarget:e.transitionOnNoTarget;if(-1!==n)return n;let i=t.wet?e.transitionOnWet:e.transitionOnNotWet;if(-1!==i)return i;let o=t.triggerDown?e.transitionOnTriggerDown:e.transitionOnTriggerUp;return -1!==o?o:-1}resolveSequenceName(e){return null==e.sequence||e.sequence<0?null:this.seqIndexToName[e.sequence]??null}}var o6=e.i(43595),o8=e.i(29055);function o7(e,t,a){let r=e.current;if(r){(0,o8.untrackDemoSound)(r);try{r.stop()}catch{}r.disconnect(),a?.remove(r),e.current=null,t.current=-1}}function o9(e){let t,i,s,l,c,d,h,m,f,g,p,y,v,F,b,S,x,k,w,C=(0,r.c)(44),{entity:_,timeRef:P}=e,D=(0,I.useEngineStoreApi)(),M=(0,ev.useStaticShape)(_.dataBlock);C[0]!==_.dataBlock?(t=e=>{let t=_.dataBlock?.toLowerCase();return t?e.runtime.sequenceAliases.get(t):void 0},C[0]=_.dataBlock,C[1]=t):t=C[1];let T=(0,I.useEngineSelector)(t);C[2]!==M.scene?(c=o5.clone(M.scene),i=(0,o2.processShapeScene)(c),c.traverse(sn),l=new o.AnimationMixer(c),s=null,c.traverse(e=>{s||"Mount0"!==e.name||(s=e)}),C[2]=M.scene,C[3]=i,C[4]=s,C[5]=l,C[6]=c):(i=C[3],s=C[4],l=C[5],c=C[6]),C[7]!==i||C[8]!==s||C[9]!==l||C[10]!==c?(d={clonedScene:c,mixer:l,mount0:s,iflInitializers:i},C[7]=i,C[8]=s,C[9]=l,C[10]=c,C[11]=d):d=C[11];let{clonedScene:E,mixer:B,mount0:j,iflInitializers:R}=d;C[12]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,C[12]=h):h=C[12];let N=(0,n.useRef)(h);C[13]===Symbol.for("react.memo_cache_sentinel")?(m={head:null,headside:null},C[13]=m):m=C[13];let A=(0,n.useRef)(m);C[14]===Symbol.for("react.memo_cache_sentinel")?(f=new Map,C[14]=f):f=C[14];let G=(0,n.useRef)(f),U=(0,n.useRef)(null);C[15]===Symbol.for("react.memo_cache_sentinel")?(g={name:"root",timeScale:1},C[15]=g):g=C[15];let L=(0,n.useRef)(g),z=(0,n.useRef)(!1);return C[16]!==M.animations||C[17]!==B||C[18]!==T?(p=()=>{let e=(0,o6.getAliasedActions)(M.animations,B,T);N.current=e;let t=e.get("root");t&&t.play(),L.current={name:"root",timeScale:1};let a={head:null,headside:null};for(let{key:e,names:t}of[{key:"head",names:["head"]},{key:"headside",names:["headside"]}]){let r=M.animations.find(e=>t.includes(e.name.toLowerCase()));if(!r)continue;let n=r.clone(),i=Math.round(30*r.duration/2);o.AnimationUtils.makeClipAdditive(n,i,r,30);let s=B.clipAction(n);s.blendMode=o.AdditiveAnimationBlendMode,s.timeScale=0,s.weight=1,s.play(),a[e]=s}A.current=a;let r=new Map,n=M.animations.find(sr),i=n?Math.round(30*n.duration/2):0;for(let e of["lookde","lookms","looksn"]){let t=M.animations.find(t=>t.name.toLowerCase()===e);if(!t)continue;let a=t.clone(),s=n??t;o.AnimationUtils.makeClipAdditive(a,i,s,30);let l=B.clipAction(a);l.blendMode=o.AdditiveAnimationBlendMode,l.timeScale=0,l.weight=0,l.play(),r.set(e,l)}G.current=r;let s=r.get("lookde");return s&&(s.weight=1,U.current="lookde"),B.update(0),()=>{B.stopAllAction(),N.current=new Map,A.current={head:null,headside:null},G.current=new Map,U.current=null}},y=[B,M.animations,T],C[16]=M.animations,C[17]=B,C[18]=T,C[19]=p,C[20]=y):(p=C[19],y=C[20]),(0,n.useEffect)(p,y),C[21]!==R||C[22]!==P?(v=()=>{let e=[];for(let{mesh:t,initialize:a}of R)a(t,()=>P.current).then(t=>e.push(t)).catch(sa);return()=>e.forEach(st)},C[21]=R,C[22]=P,C[23]=v):v=C[23],C[24]!==R?(F=[R],C[24]=R,C[25]=F):F=C[25],(0,n.useEffect)(v,F),C[26]!==D||C[27]!==_.headPitch||C[28]!==_.headYaw||C[29]!==_.keyframes||C[30]!==_.weaponShape||C[31]!==B||C[32]!==P?(b=(e,t)=>{let a=D.getState().playback,r="playing"===a.status,n=P.current,i=(0,o2.getKeyframeAtTime)(_.keyframes,n),s=i?.damageState!=null&&i.damageState>=1,l=N.current;if(s&&!z.current){z.current=!0;let e=[...l.keys()].filter(se);if(e.length>0){let t=e[Math.floor(Math.random()*e.length)],a=l.get(L.current.name.toLowerCase());a&&a.fadeOut(o2.ANIM_TRANSITION_TIME);let r=l.get(t);r.setLoop(o.LoopOnce,1),r.clampWhenFinished=!0,r.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play(),L.current={name:t,timeScale:1}}}if(!s&&z.current){z.current=!1;let e=l.get(L.current.name.toLowerCase());e&&(e.stop(),e.setLoop(o.LoopRepeat,1/0),e.clampWhenFinished=!1),L.current={name:"root",timeScale:1};let t=l.get("root");t&&t.reset().play()}if(!z.current){let e=function(e,t){if(!e)return{animation:"root",timeScale:1};let[a,r,n]=e;if(n<-10)return{animation:"fall",timeScale:1};let i=-2*Math.atan2(t[1],t[3]),o=Math.cos(i),s=Math.sin(i),l=a*o+r*s,c=-a*s+r*o,d=-c,u=-l,h=Math.max(c,d,u,l);return h<.1?{animation:"root",timeScale:1}:h===c?{animation:"run",timeScale:1}:h===d?{animation:"back",timeScale:1}:h===u?{animation:"side",timeScale:1}:{animation:"side",timeScale:-1}}(i?.velocity,i?.rotation??[0,0,0,1]),t=L.current;if(e.animation!==t.name||e.timeScale!==t.timeScale){let a=l.get(t.name.toLowerCase()),n=l.get(e.animation.toLowerCase());n&&(r&&a&&a!==n?(a.fadeOut(o2.ANIM_TRANSITION_TIME),n.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play()):(a&&a!==n&&a.stop(),n.reset().play()),n.timeScale=e.timeScale,L.current={name:e.animation,timeScale:e.timeScale})}}let c=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(_.weaponShape);if(c!==U.current){let e=G.current,t=U.current?e.get(U.current):null,a=e.get(c);a&&(t&&(t.weight=0),a.weight=+!s,U.current=c)}let{head:d,headside:u}=A.current,h=U.current?G.current.get(U.current):null,m=+!s,f=_.headPitch??0,g=_.headYaw??0,p=(f+1)/2;h&&(h.time=p*h.getClip().duration,h.weight=m),d&&(d.time=p*d.getClip().duration,d.weight=m),u&&(u.time=(g+1)/2*u.getClip().duration,u.weight=m),r?B.update(t*a.rate):B.update(0)},C[26]=D,C[27]=_.headPitch,C[28]=_.headYaw,C[29]=_.keyframes,C[30]=_.weaponShape,C[31]=B,C[32]=P,C[33]=b):b=C[33],(0,u.useFrame)(b),C[34]===Symbol.for("react.memo_cache_sentinel")?(S=[0,Math.PI/2,0],C[34]=S):S=C[34],C[35]!==E?(x=(0,a.jsx)("group",{rotation:S,children:(0,a.jsx)("primitive",{object:E})}),C[35]=E,C[36]=x):x=C[36],C[37]!==_||C[38]!==j||C[39]!==P?(k=_.weaponShape&&j&&(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(si,{entity:_,mount0:j,timeRef:P})})}),C[37]=_,C[38]=j,C[39]=P,C[40]=k):k=C[40],C[41]!==x||C[42]!==k?(w=(0,a.jsxs)(a.Fragment,{children:[x,k]}),C[41]=x,C[42]=k,C[43]=w):w=C[43],w}function se(e){return e.startsWith("death")}function st(e){return e()}function sa(){}function sr(e){return"lookde"===e.name.toLowerCase()}function sn(e){if(e.isMesh&&e.material)for(let t of Array.isArray(e.material)?e.material:[e.material])t.side=o.FrontSide}function si(e){let t,a,i,s,l,d,h,m,f,g,p,y,F,b,S=(0,r.c)(40),{entity:x,mount0:k,timeRef:w}=e,C=(0,I.useEngineStoreApi)(),_=(0,ev.useStaticShape)(x.weaponShape);if(S[0]!==_.animations||S[1]!==_.scene){t=o5.clone(_.scene),a=(0,o2.processShapeScene)(t);let e=(0,o2.getPosedNodeTransform)(_.scene,_.animations,"Mountpoint");if(e){let a=e.quaternion.clone().invert(),r=e.position.clone().negate().applyQuaternion(a);t.position.copy(r),t.quaternion.copy(a)}s=new Map,t.traverse(e=>{if(!e.isMesh)return;let t=e.userData,a=(t?.vis_sequence??"").toLowerCase();if(!a)return;let r=s.get(a);r||(r=[],s.set(a,r)),r.push(e)}),i=new o.AnimationMixer(t),S[0]=_.animations,S[1]=_.scene,S[2]=t,S[3]=a,S[4]=i,S[5]=s}else t=S[2],a=S[3],i=S[4],s=S[5];let P=i,D=_.scene;S[6]!==D||S[7]!==_.animations?(l=function(e,t){let a=e.userData?.dts_sequence_names;if("string"==typeof a)try{return JSON.parse(a).map(e=>e.toLowerCase())}catch{}return t.map(e=>e.name.toLowerCase())}(D,_.animations),S[6]=D,S[7]=_.animations,S[8]=l):l=S[8];let M=l;S[9]!==t||S[10]!==a||S[11]!==P||S[12]!==M||S[13]!==s?(d={weaponClone:t,weaponMixer:P,seqIndexToName:M,visNodesBySequence:s,weaponIflInitializers:a},S[9]=t,S[10]=a,S[11]=P,S[12]=M,S[13]=s,S[14]=d):d=S[14];let{weaponClone:T,weaponMixer:E,seqIndexToName:B,visNodesBySequence:j,weaponIflInitializers:R}=d;S[15]===Symbol.for("react.memo_cache_sentinel")?(h=new Map,S[15]=h):h=S[15];let N=(0,n.useRef)(h),A=(0,n.useRef)(null);S[16]!==_.animations||S[17]!==E?(m=()=>{let e=new Map;for(let t of _.animations)e.set(t.name.toLowerCase(),E.clipAction(t));N.current=e;let t=e.get("spin");return t&&(t.setLoop(o.LoopRepeat,1/0),t.timeScale=0,t.play()),A.current=t??null,E.update(0),()=>{E.stopAllAction(),N.current=new Map,A.current=null,o7(H,W)}},f=[E,_.animations],S[16]=_.animations,S[17]=E,S[18]=m,S[19]=f):(m=S[18],f=S[19]),(0,n.useEffect)(m,f),S[20]!==w||S[21]!==R?(g=()=>{let e=[];for(let{mesh:t,initialize:a}of R)a(t,()=>w.current).then(t=>e.push(t)).catch(ss);return()=>e.forEach(so)},S[20]=w,S[21]=R,S[22]=g):g=S[22],S[23]!==R?(p=[R],S[23]=R,S[24]=p):p=S[24],(0,n.useEffect)(g,p);let{audioLoader:G,audioListener:U}=(0,o0.useAudio)(),L=(0,v.useSettings)(),z=L?.audioEnabled??!1,O=(0,n.useRef)(null),V=(0,n.useRef)(null),q=(0,n.useRef)(x.weaponImageStates),H=(0,n.useRef)(null),W=(0,n.useRef)(-1);return S[25]!==k||S[26]!==T?(y=()=>(k.add(T),()=>{k.remove(T)}),F=[T,k],S[25]=k,S[26]=T,S[27]=y,S[28]=F):(y=S[27],F=S[28]),(0,n.useEffect)(y,F),S[29]!==z||S[30]!==U||S[31]!==G||S[32]!==C||S[33]!==x.weaponImageState||S[34]!==x.weaponImageStates||S[35]!==B||S[36]!==j||S[37]!==T||S[38]!==E?(b=(e,t)=>{let a=C.getState().playback,r="playing"===a.status,n=N.current,i=x.weaponImageState,s=x.weaponImageStates;s!==q.current&&(q.current=s,s&&s.length>0?O.current=new o4(s,B):O.current=null,V.current=null,o7(H,W,T)),!O.current&&s&&s.length>0&&(O.current=new o4(s,B));let l=O.current;if(l&&i&&r){let e=t*a.rate,r=l.tick(e,i);if(function(e,t,a,r){let n=e.sequenceName,i=a.current;if(n===i&&!e.transitioned)return;if(n!==i){if(i){let e=r.get(i);if(e)for(let t of e)t.visible=!1}if(n){let e=r.get(n);if(e)for(let t of e)t.visible=!0}}if(!n){if(i){let e=t.get(i);e&&e.fadeOut(o2.ANIM_TRANSITION_TIME),a.current=null}return}let s=t.get(n);if(s&&(e.transitioned||n!==i)){let r=i?t.get(i):null;if(e.isFiring||e.timeoutValue>0?(s.setLoop(o.LoopOnce,1),s.clampWhenFinished=!0):(s.setLoop(o.LoopRepeat,1/0),s.clampWhenFinished=!1),e.scaleAnimation&&e.timeoutValue>0){let t=s.getClip().duration;s.timeScale=t>0?t/e.timeoutValue:1}else s.timeScale=e.reverse?-1:1;r&&r!==s?(r.fadeOut(o2.ANIM_TRANSITION_TIME),s.reset().fadeIn(o2.ANIM_TRANSITION_TIME).play()):s.reset().play(),a.current=n}}(r,n,V,j),H.current&&r.stateIndex!==W.current&&o7(H,W,T),z&&G&&U&&r.soundDataBlockIds.length>0){let e=a.recording?.streamingPlayback.getDataBlockData.bind(a.recording.streamingPlayback);if(e)for(let t of r.soundDataBlockIds){let r=(0,o8.resolveAudioProfile)(t,e);if(r)if(r.isLooping){if(!H.current)try{let e=(0,c.audioToUrl)(r.filename);(0,o8.getCachedAudioBuffer)(e,G,e=>{if(H.current)return;let t=l.stateIndex,n=new o.PositionalAudio(U);n.setBuffer(e),n.setDistanceModel("inverse"),n.setRefDistance(r.refDist),n.setMaxDistance(r.maxDist),n.setRolloffFactor(1),n.setVolume(r.volume),n.setPlaybackRate(a.rate),n.setLoop(!0),T.add(n),(0,o8.trackDemoSound)(n),n.play(),H.current=n,W.current=t})}catch{}}else(0,o8.playOneShotSound)(r,U,G,void 0,T)}}A.current&&(A.current.timeScale=r.spinTimeScale)}r?E.update(t*a.rate):E.update(0)},S[29]=z,S[30]=U,S[31]=G,S[32]=C,S[33]=x.weaponImageState,S[34]=x.weaponImageStates,S[35]=B,S[36]=j,S[37]=T,S[38]=E,S[39]=b):b=S[39],(0,u.useFrame)(b),null}function so(e){return e()}function ss(){}function sl(e){let t,a,i=(0,r.c)(7),{shapeName:o,eyeOffsetRef:s}=e,l=(0,ev.useStaticShape)(o);return i[0]!==s||i[1]!==l.animations||i[2]!==l.scene?(t=()=>{let e=(0,o2.getPosedNodeTransform)(l.scene,l.animations,"Eye");e?s.current.set(e.position.z,e.position.y,-e.position.x):s.current.set(0,o2.DEFAULT_EYE_HEIGHT,0)},i[0]=s,i[1]=l.animations,i[2]=l.scene,i[3]=t):t=i[3],i[4]!==s||i[5]!==l?(a=[l,s],i[4]=s,i[5]=l,i[6]=a):a=i[6],(0,n.useEffect)(t,a),null}var sc=e.i(71505);function sd(e){let t,n,i,o=(0,r.c)(8),{shapeName:s,entityId:l,threads:c}=e,d="number"==typeof l?l:0;o[0]!==d?(t={_class:"player",_className:"Player",_id:d},o[0]=d,o[1]=t):t=o[1];let u=t;return o[2]!==c?(n=(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"#00ff88",demoThreads:c}),o[2]=c,o[3]=n):n=o[3],o[4]!==s||o[5]!==n||o[6]!==u?(i=(0,a.jsx)(eF.ShapeInfoProvider,{object:u,shapeName:s,type:"StaticShape",children:n}),o[4]=s,o[5]=n,o[6]=u,o[7]=i):i=o[7],i}function su({shapeName:e,playerShapeName:t}){let r=(0,ev.useStaticShape)(t),i=(0,ev.useStaticShape)(e),o=(0,n.useMemo)(()=>{let t,a,n=function(e){if(!e)return"lookde";let t=e.toLowerCase();return t.includes("missile")?"lookms":t.includes("sniper")?"looksn":"lookde"}(e),o=(0,o2.getPosedNodeTransform)(r.scene,r.animations,"Mount0",[n]);if(!o)return{position:void 0,quaternion:void 0};let s=(0,o2.getPosedNodeTransform)(i.scene,i.animations,"Mountpoint");if(s){let e=s.quaternion.clone().invert(),r=s.position.clone().negate().applyQuaternion(e);a=o.quaternion.clone().multiply(e),t=r.clone().applyQuaternion(o.quaternion).add(o.position)}else t=o.position.clone(),a=o.quaternion.clone();return{position:t.applyQuaternion(o2._r90),quaternion:o2._r90.clone().multiply(a).multiply(o2._r90inv)}},[r,i]),s=(0,n.useMemo)(()=>({_class:"weapon",_className:"Weapon",_id:0}),[]);return(0,a.jsx)(eF.ShapeInfoProvider,{object:s,shapeName:e,type:"Item",children:(0,a.jsx)("group",{position:o.position,quaternion:o.quaternion,children:(0,a.jsx)(ev.ShapeRenderer,{loadingColor:"#4488ff"})})})}function sh({entity:e,playback:t}){let r=(0,ev.useStaticShape)(e.dataBlock),i=(0,n.useRef)(null),s=(0,n.useRef)((0,I.demoEffectNow)()),l=(0,n.useRef)(Math.random()*Math.PI*2),c=(0,n.useRef)([]),d=(0,n.useMemo)(()=>{if(e.explosionDataBlockId)return t.getDataBlockData(e.explosionDataBlockId)},[e.explosionDataBlockId,t]),h=(0,n.useMemo)(()=>d?function(e){let t=e.sizes,a=e.times;if(!Array.isArray(t)||0===t.length)return{times:[0,1],sizes:[[1,1,1],[1,1,1]]};let r=t.map(e=>[e.x/100,e.y/100,e.z/100]);return{times:Array.isArray(a)?a:r.map((e,t)=>t/Math.max(r.length-1,1)),sizes:r}}(d):void 0,[d]),m=(0,n.useMemo)(()=>{let e=d?.explosionScale;return e?[e.x/100,e.y/100,e.z/100]:[1,1,1]},[d]),f=32*(d?.lifetimeMS??31),g=!1!==e.faceViewer,{scene:p,mixer:y,visNodes:v,iflInfos:F,materials:b}=(0,n.useMemo)(()=>{let e=o5.clone(r.scene),t=[];e.traverse(e=>{if(!e.isMesh||!e.material)return;let a=Array.isArray(e.material)?e.material[0]:e.material;if(!a?.userData)return;let r=new Set(a.userData.flag_names??[]),n=a.userData.resource_path;if(r.has("IflMaterial")&&n){let a=e.userData;t.push({mesh:e,iflPath:`textures/${n}.ifl`,sequenceName:a?.ifl_sequence?String(a.ifl_sequence).toLowerCase():void 0,duration:a?.ifl_duration?Number(a.ifl_duration):void 0,cyclic:a?.ifl_sequence?!!a.ifl_cyclic:void 0,toolBegin:a?.ifl_tool_begin!=null?Number(a.ifl_tool_begin):void 0})}}),(0,o2.processShapeScene)(e);let a=[];for(let t of(e.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let r=t.vis_keyframes,n=t.vis_duration,i=(t.vis_sequence??"").toLowerCase();i&&Array.isArray(r)&&!(r.length<=1)&&n&&!(n<=0)&&"ambient"===i&&a.push({mesh:e,keyframes:r,duration:n,cyclic:!!t.vis_cyclic})}),a))t.mesh.visible=!0,t.mesh.material&&!Array.isArray(t.mesh.material)&&(t.mesh.material.transparent=!0,t.mesh.material.depthWrite=!1);for(let e of t)e.mesh.userData?.vis_sequence||(e.mesh.visible=!0);let n=new Map;for(let e of r.animations)n.set(e.name.toLowerCase(),e);let i=n.get("ambient"),s=null;if(i){let t=(s=new o.AnimationMixer(e)).clipAction(i);t.setLoop(o.LoopOnce,1),t.clampWhenFinished=!0,t.timeScale=(d?.playSpeed??20)/20,t.play()}let l=[];return e.traverse(e=>{e.isMesh&&(Array.isArray(e.material)?l.push(...e.material):e.material&&l.push(e.material))}),e.traverse(e=>{e.frustumCulled=!1}),{scene:e,mixer:s,visNodes:a,iflInfos:t,materials:l}},[r,d]);return(0,n.useEffect)(()=>{for(let e of(c.current=[],F))(0,sc.loadIflAtlas)(e.iflPath).then(t=>{let a=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;a&&(a.map=t.texture,a.needsUpdate=!0),c.current.push({atlas:t,info:e})}).catch(()=>{})},[F]),(0,u.useFrame)((e,t)=>{let a=i.current;if(!a)return;let r=I.engineStore.getState().playback,n="playing"===r.status?t*r.rate:0,o=(0,I.demoEffectNow)()-s.current,d=Math.min(o/f,1),u=o/1e3;y&&y.update(n);let p=d>.8?1-(d-.8)/.2:1;for(let{mesh:e,keyframes:t,duration:a,cyclic:r}of v){let n=e.material;if(!n||Array.isArray(n))continue;let i=u/a,o=r?i%1:Math.min(i,1),s=t.length,l=o*s,c=Math.floor(l)%s,d=(c+1)%s,h=l-Math.floor(l);n.opacity=(t[c]+(t[d]-t[c])*h)*p}if(p<1)for(let e of b)"opacity"in e&&(e.transparent=!0,e.opacity*=p);for(let{atlas:e,info:t}of c.current){let a;a=t.sequenceName&&t.duration?(t.cyclic?u/t.duration%1:Math.min(u/t.duration,1))*t.duration+(t.toolBegin??0):u,(0,sc.updateAtlasFrame)(e,(0,sc.getFrameIndexForTime)(e,a))}if(h){let e=function(e,t){let{times:a,sizes:r}=e;if(0===a.length)return[1,1,1];if(t<=a[0])return r[0];if(t>=a[a.length-1])return r[r.length-1];for(let e=0;e=a[e]&&t<=a[e+1]){let n=(t-a[e])/(a[e+1]-a[e]);return[r[e][0]+(r[e+1][0]-r[e][0])*n,r[e][1]+(r[e+1][1]-r[e][1])*n,r[e][2]+(r[e+1][2]-r[e][2])*n]}return r[r.length-1]}(h,d);a.scale.set(e[0]*m[0],e[1]*m[1],e[2]*m[2])}g&&(a.lookAt(e.camera.position),a.rotateZ(l.current))}),(0,a.jsx)("group",{ref:i,children:(0,a.jsx)("group",{rotation:[0,Math.PI,0],children:(0,a.jsx)("primitive",{object:p})})})}let sm=new o.Vector3,sf=new o.Vector3,sg=new o.Vector3,sp=new o.Vector3,sy=new o.Vector3,sv=new o.Vector3,sF=new o.Vector3(0,1,0);function sb(e){let t,n,i,s,l,d=(0,r.c)(14),{visual:u}=e;d[0]!==u.texture?(t=(0,c.textureToUrl)(u.texture),d[0]=u.texture,d[1]=t):t=d[1];let h=t,m=(0,g.useTexture)(h,sS),f=Array.isArray(m)?m[0]:m;d[2]!==u.color.b||d[3]!==u.color.g||d[4]!==u.color.r?(n=new o.Color().setRGB(u.color.r,u.color.g,u.color.b,o.SRGBColorSpace),d[2]=u.color.b,d[3]=u.color.g,d[4]=u.color.r,d[5]=n):n=d[5];let p=n;return d[6]!==u.size?(i=[u.size,u.size,1],d[6]=u.size,d[7]=i):i=d[7],d[8]!==p||d[9]!==f?(s=(0,a.jsx)("spriteMaterial",{map:f,color:p,transparent:!0,blending:o.AdditiveBlending,depthWrite:!1,toneMapped:!1}),d[8]=p,d[9]=f,d[10]=s):s=d[10],d[11]!==i||d[12]!==s?(l=(0,a.jsx)("sprite",{scale:i,children:s}),d[11]=i,d[12]=s,d[13]=l):l=d[13],l}function sS(e){let t=Array.isArray(e)?e[0]:e;(0,o2.setupEffectTexture)(t)}function sx(e){let t,i,s,l,d,h,m,f,p,y,v,F,b=(0,r.c)(28),{entity:S,visual:x}=e,k=(0,n.useRef)(null),w=(0,n.useRef)(null),I=(0,n.useRef)(null);b[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Quaternion,b[0]=t):t=b[0];let C=(0,n.useRef)(t);b[1]!==x.texture?(i=(0,c.textureToUrl)(x.texture),b[1]=x.texture,b[2]=i):i=b[2];let _=x.crossTexture??x.texture;b[3]!==_?(s=(0,c.textureToUrl)(_),b[3]=_,b[4]=s):s=b[4],b[5]!==i||b[6]!==s?(l=[i,s],b[5]=i,b[6]=s,b[7]=l):l=b[7];let P=l,D=(0,g.useTexture)(P,sk);b[8]!==D?(d=Array.isArray(D)?D:[D,D],b[8]=D,b[9]=d):d=b[9];let[M,T]=d;return b[10]!==S||b[11]!==x.crossSize||b[12]!==x.crossViewAng||b[13]!==x.renderCross||b[14]!==x.tracerLength||b[15]!==x.tracerWidth?(h=e=>{let{camera:t}=e,a=k.current,r=w.current;if(!a||!r)return;let n=S.keyframes[0],i=n?.position,o=S.direction??n?.velocity;if(!i||!o||((0,o2.torqueVecToThree)(o,sm),1e-8>sm.lengthSq())){a.visible=!1,I.current&&(I.current.visible=!1);return}sm.normalize(),a.visible=!0,(0,o2.torqueVecToThree)(i,sv),sf.copy(sv).sub(t.position),sg.crossVectors(sf,sm),1e-8>sg.lengthSq()&&(sg.crossVectors(sF,sm),1e-8>sg.lengthSq()&&sg.set(1,0,0)),sg.normalize().multiplyScalar(x.tracerWidth);let s=.5*x.tracerLength;sp.copy(sm).multiplyScalar(-s),sy.copy(sm).multiplyScalar(s);let l=r.array;l[0]=sp.x+sg.x,l[1]=sp.y+sg.y,l[2]=sp.z+sg.z,l[3]=sp.x-sg.x,l[4]=sp.y-sg.y,l[5]=sp.z-sg.z,l[6]=sy.x-sg.x,l[7]=sy.y-sg.y,l[8]=sy.z-sg.z,l[9]=sy.x+sg.x,l[10]=sy.y+sg.y,l[11]=sy.z+sg.z,r.needsUpdate=!0;let c=I.current;if(!c)return;if(!x.renderCross){c.visible=!1;return}sf.normalize();let d=sm.dot(sf);if(d>-x.crossViewAng&&d{let e=v.current;if(!e)return;e.getWorldPosition(sP);let t=y.position.distanceTo(sP),a=y.matrixWorld.elements,r=!(-((sP.x-a[12])*a[8])+-((sP.y-a[13])*a[9])+-((sP.z-a[14])*a[10])<0)&&t<150;if(k!==r&&w(r),!r)return;let n=(0,o2.getKeyframeAtTime)(f.keyframes,g.current),i=n?.health??1;if(n?.damageState!=null&&n.damageState>=1){F.current&&(F.current.style.opacity="0"),b.current&&(b.current.style.opacity="0");return}let o=Math.max(0,Math.min(1,1-t/150)).toString();if(F.current&&(F.current.style.opacity=o),b.current&&(b.current.style.opacity=o),x.current&&f.iffColor){let e=f.iffColor.r>f.iffColor.g?s_:sC;x.current.src!==e&&(x.current.src=e)}S.current&&_&&(S.current.style.width=`${Math.max(0,Math.min(100,100*i))}%`,S.current.style.background=f.iffColor?`rgb(${f.iffColor.r}, ${f.iffColor.g}, ${f.iffColor.b})`:"")},m[7]=y,m[8]=f.iffColor,m[9]=f.keyframes,m[10]=_,m[11]=k,m[12]=g,m[13]=l):l=m[13],(0,u.useFrame)(l);let P=f.iffColor&&f.iffColor.r>f.iffColor.g?s_:sC;return m[14]!==I||m[15]!==_||m[16]!==C||m[17]!==P||m[18]!==k?(c=k&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(sw.Html,{position:[0,C,0],center:!0,children:(0,a.jsx)("div",{ref:F,className:sI.default.Top,children:(0,a.jsx)("img",{ref:x,className:sI.default.IffArrow,src:P,alt:""})})}),(0,a.jsx)(sw.Html,{position:[0,-.2,0],center:!0,children:(0,a.jsxs)("div",{ref:b,className:sI.default.Bottom,children:[(0,a.jsx)("div",{className:sI.default.Name,children:I}),_&&(0,a.jsx)("div",{className:sI.default.HealthBar,children:(0,a.jsx)("div",{ref:S,className:sI.default.HealthFill})})]})})]}),m[14]=I,m[15]=_,m[16]=C,m[17]=P,m[18]=k,m[19]=c):c=m[19],m[20]!==c?(d=(0,a.jsx)("group",{ref:v,children:c}),m[20]=c,m[21]=d):d=m[21],d}function sM(e){return null!=e.health}var sT=e.i(78779);let sE=(0,c.textureToUrl)("commander/MiniIcons/com_flag_grey"),sB=new o.Vector3;function sj(e){let t,i,o,s,l,c=(0,r.c)(9),{entity:d}=e,m=(0,n.useRef)(null),f=(0,n.useRef)(null),g=(0,n.useRef)(null),{camera:p}=(0,h.useThree)();c[0]!==p||c[1]!==d.iffColor?(t=()=>{if(f.current&&d.iffColor){let{r:e,g:t,b:a}=d.iffColor;f.current.style.backgroundColor=`rgb(${e},${t},${a})`}if(g.current&&m.current){m.current.getWorldPosition(sB);let e=p.position.distanceTo(sB);g.current.textContent=e.toFixed(1)}},c[0]=p,c[1]=d.iffColor,c[2]=t):t=c[2],(0,u.useFrame)(t);let y=d.iffColor?`rgb(${d.iffColor.r},${d.iffColor.g},${d.iffColor.b})`:"rgb(200,200,200)";c[3]===Symbol.for("react.memo_cache_sentinel")?(i=[0,1.5,0],c[3]=i):i=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,a.jsx)("span",{ref:g,className:sT.default.Distance}),c[4]=o):o=c[4],c[5]!==y?(s={backgroundColor:y,"--flag-icon-url":`url(${sE})`},c[5]=y,c[6]=s):s=c[6];let v=s;return c[7]!==v?(l=(0,a.jsx)("group",{ref:m,children:(0,a.jsx)(sw.Html,{position:i,center:!0,children:(0,a.jsxs)("div",{className:sT.default.Root,children:[o,(0,a.jsx)("div",{ref:f,className:sT.default.Icon,style:v})]})})}),c[7]=v,c[8]=l):l=c[8],l}let sR=(0,o3.memo)(function(e){let t,n,i,o,s,l,c,d,u,h=(0,r.c)(100),{entity:m,timeRef:f,playback:g}=e,p=(0,v.useDebug)(),y=p?.debugMode??!1,F=(0,I.useEngineSelector)(sG),b=String(m.id);if(m.visual?.kind==="tracer"){let e,t,r,n,i;return h[0]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"tracer"},h[0]=e):e=h[0],h[1]!==m?(t=(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sx,{entity:m,visual:m.visual})}),h[1]=m,h[2]=t):t=h[2],h[3]!==y||h[4]!==m?(r=y?(0,a.jsx)(sN,{entity:m}):null,h[3]=y,h[4]=m,h[5]=r):r=h[5],h[6]!==t||h[7]!==r?(n=(0,a.jsxs)("group",{name:"model",userData:e,children:[t,r]}),h[6]=t,h[7]=r,h[8]=n):n=h[8],h[9]!==b||h[10]!==n?(i=(0,a.jsx)("group",{name:b,children:n}),h[9]=b,h[10]=n,h[11]=i):i=h[11],i}if(m.visual?.kind==="sprite"){let e,t,r,n,i;return h[12]===Symbol.for("react.memo_cache_sentinel")?(e={demoVisualKind:"sprite"},h[12]=e):e=h[12],h[13]!==m.visual?(t=(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sb,{visual:m.visual})}),h[13]=m.visual,h[14]=t):t=h[14],h[15]!==y||h[16]!==m?(r=y?(0,a.jsx)(sN,{entity:m}):null,h[15]=y,h[16]=m,h[17]=r):r=h[17],h[18]!==t||h[19]!==r?(n=(0,a.jsxs)("group",{name:"model",userData:e,children:[t,r]}),h[18]=t,h[19]=r,h[20]=n):n=h[20],h[21]!==b||h[22]!==n?(i=(0,a.jsx)("group",{name:b,children:n}),h[21]=b,h[22]=n,h[23]=i):i=h[23],i}if(!m.dataBlock){let e,t,r,n,i,o,s,l=((m.targetRenderFlags??0)&2)!=0;return h[24]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("sphereGeometry",{args:[.3,6,4]}),h[24]=e):e=h[24],h[25]!==m.type?(t=(0,o2.entityTypeColor)(m.type),h[25]=m.type,h[26]=t):t=h[26],h[27]!==t?(r=(0,a.jsxs)("mesh",{children:[e,(0,a.jsx)("meshBasicMaterial",{color:t,wireframe:!0})]}),h[27]=t,h[28]=r):r=h[28],h[29]!==y||h[30]!==m?(n=y?(0,a.jsx)(sN,{entity:m}):null,h[29]=y,h[30]=m,h[31]=n):n=h[31],h[32]!==r||h[33]!==n?(i=(0,a.jsxs)("group",{name:"model",children:[r,n]}),h[32]=r,h[33]=n,h[34]=i):i=h[34],h[35]!==m||h[36]!==l||h[37]!==f?(o=l&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[35]=m,h[36]=l,h[37]=f,h[38]=o):o=h[38],h[39]!==b||h[40]!==i||h[41]!==o?(s=(0,a.jsxs)("group",{name:b,children:[i,o]}),h[39]=b,h[40]=i,h[41]=o,h[42]=s):s=h[42],s}h[43]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("sphereGeometry",{args:[.5,8,6]}),h[43]=t):t=h[43],h[44]!==m.type?(n=(0,o2.entityTypeColor)(m.type),h[44]=m.type,h[45]=n):n=h[45],h[46]!==n?(i=(0,a.jsxs)("mesh",{children:[t,(0,a.jsx)("meshBasicMaterial",{color:n,wireframe:!0})]}),h[46]=n,h[47]=i):i=h[47];let S=i;if("Player"===m.type){let e,t,r,n,i,o,s,l=m.id===F,c=((m.targetRenderFlags??0)&2)!=0;return h[48]!==m||h[49]!==f?(e=(0,a.jsx)(o9,{entity:m,timeRef:f}),h[48]=m,h[49]=f,h[50]=e):e=h[50],h[51]!==S||h[52]!==e?(t=(0,a.jsx)(o3.Suspense,{fallback:S,children:e}),h[51]=S,h[52]=e,h[53]=t):t=h[53],h[54]!==S||h[55]!==t?(r=(0,a.jsx)(sA,{fallback:S,children:t}),h[54]=S,h[55]=t,h[56]=r):r=h[56],h[57]!==m||h[58]!==l||h[59]!==f?(n=!l&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sD,{entity:m,timeRef:f})}),h[57]=m,h[58]=l,h[59]=f,h[60]=n):n=h[60],h[61]!==m||h[62]!==c||h[63]!==f?(i=c&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[61]=m,h[62]=c,h[63]=f,h[64]=i):i=h[64],h[65]!==r||h[66]!==n||h[67]!==i?(o=(0,a.jsxs)("group",{name:"model",children:[r,n,i]}),h[65]=r,h[66]=n,h[67]=i,h[68]=o):o=h[68],h[69]!==b||h[70]!==o?(s=(0,a.jsx)("group",{name:b,children:o}),h[69]=b,h[70]=o,h[71]=s):s=h[71],s}if("Explosion"===m.type&&m.dataBlock&&g){let e,t;return h[72]!==g||h[73]!==m?(e=(0,a.jsx)("group",{name:"model",children:(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sh,{entity:m,playback:g})})})}),h[72]=g,h[73]=m,h[74]=e):e=h[74],h[75]!==b||h[76]!==e?(t=(0,a.jsx)("group",{name:b,children:e}),h[75]=b,h[76]=e,h[77]=t):t=h[77],t}let x=((m.targetRenderFlags??0)&2)!=0;return h[78]!==m.dataBlock||h[79]!==m.id||h[80]!==m.threads?(o=(0,a.jsx)(sd,{shapeName:m.dataBlock,entityId:m.id,threads:m.threads}),h[78]=m.dataBlock,h[79]=m.id,h[80]=m.threads,h[81]=o):o=h[81],h[82]!==S||h[83]!==o?(s=(0,a.jsx)(o3.Suspense,{fallback:S,children:o}),h[82]=S,h[83]=o,h[84]=s):s=h[84],h[85]!==S||h[86]!==s?(l=(0,a.jsx)("group",{name:"model",children:(0,a.jsx)(sA,{fallback:S,children:s})}),h[85]=S,h[86]=s,h[87]=l):l=h[87],h[88]!==m.dataBlock||h[89]!==m.weaponShape?(c=m.weaponShape&&(0,a.jsx)("group",{name:"weapon",children:(0,a.jsx)(sA,{fallback:null,children:(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(su,{shapeName:m.weaponShape,playerShapeName:m.dataBlock})})})}),h[88]=m.dataBlock,h[89]=m.weaponShape,h[90]=c):c=h[90],h[91]!==m||h[92]!==x||h[93]!==f?(d=x&&(0,a.jsx)(o3.Suspense,{fallback:null,children:(0,a.jsx)(sj,{entity:m,timeRef:f})}),h[91]=m,h[92]=x,h[93]=f,h[94]=d):d=h[94],h[95]!==b||h[96]!==l||h[97]!==c||h[98]!==d?(u=(0,a.jsxs)("group",{name:b,children:[l,c,d]}),h[95]=b,h[96]=l,h[97]=c,h[98]=d,h[99]=u):u=h[99],u});function sN(e){let t,n,i=(0,r.c)(9),{entity:o}=e,s=String(o.id);i[0]!==o.className||i[1]!==o.dataBlockId||i[2]!==o.ghostIndex||i[3]!==o.shapeHint||i[4]!==o.type||i[5]!==s?((t=[]).push(`${s} (${o.type})`),o.className&&t.push(`class ${o.className}`),"number"==typeof o.ghostIndex&&t.push(`ghost ${o.ghostIndex}`),"number"==typeof o.dataBlockId&&t.push(`db ${o.dataBlockId}`),t.push(o.shapeHint?`shapeHint ${o.shapeHint}`:"shapeHint "),i[0]=o.className,i[1]=o.dataBlockId,i[2]=o.ghostIndex,i[3]=o.shapeHint,i[4]=o.type,i[5]=s,i[6]=t):t=i[6];let l=t.join(" | ");return i[7]!==l?(n=(0,a.jsx)(z.FloatingLabel,{color:"#ff6688",children:l}),i[7]=l,i[8]=n):n=i[8],n}class sA extends o3.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.warn("[demo] Shape load failed:",e.message,t.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}function sG(e){return e.playback.streamSnapshot?.controlPlayerGhostId}let sU=Math.PI/180,sL=Math.PI/18e4;function sz(e,t,a){let r=e[t];return"number"==typeof r&&Number.isFinite(r)?r:a}function sO(e,t,a){let r=e[t];return"boolean"==typeof r?r:"number"==typeof r?0!==r:a}function sV(e,t){let a,r=e.particles;if(Array.isArray(r)){for(let e of r)if("number"==typeof e&&(a=t(e)))break}return a?{ejectionPeriodMS:sz(e,"ejectionPeriodMS",100),periodVarianceMS:sz(e,"periodVarianceMS",0),ejectionVelocity:.01*sz(e,"ejectionVelocity",200),velocityVariance:.01*sz(e,"velocityVariance",100),ejectionOffset:.01*sz(e,"ejectionOffset",0),thetaMin:sz(e,"thetaMin",0),thetaMax:sz(e,"thetaMax",90),phiReferenceVel:sz(e,"phiReferenceVel",0),phiVariance:sz(e,"phiVariance",360),overrideAdvances:sO(e,"overrideAdvances",!1),orientParticles:sO(e,"orientParticles",!1),orientOnVelocity:sO(e,"orientOnVelocity",!0),lifetimeMS:sz(e,"lifetimeMS",0)<<5,lifetimeVarianceMS:sz(e,"lifetimeVarianceMS",0)<<5,particles:function(e){let t=e.keys,a=[];if(Array.isArray(t)&&t.length>0)for(let e=0;e0&&t[0]&&(r=t[0])}return{dragCoefficient:5*sz(e,"dragCoefficient",0),windCoefficient:sz(e,"windCoefficient",1),gravityCoefficient:10*sz(e,"gravityCoefficient",0),inheritedVelFactor:sz(e,"inheritedVelFactor",0),constantAcceleration:sz(e,"constantAcceleration",0),lifetimeMS:sz(e,"lifetimeMS",31)<<5,lifetimeVarianceMS:sz(e,"lifetimeVarianceMS",0)<<5,spinSpeed:sz(e,"spinSpeed",0),spinRandomMin:sz(e,"spinRandomMin",1e3)+-1e3,spinRandomMax:sz(e,"spinRandomMax",1e3)+-1e3,useInvAlpha:sO(e,"useInvAlpha",!1),keys:a,textureName:r}}(a)}:null}function sq(e,t){return e+(2*Math.random()-1)*t}function sH(e,t,a,r,n,i,o){let s=Math.cos(o),l=Math.sin(o),c=e*r+t*n+a*i;return[e*s+(n*a-i*t)*l+r*c*(1-s),t*s+(i*e-r*a)*l+n*c*(1-s),a*s+(r*t-n*e)*l+i*c*(1-s)]}class sW{data;particles=[];maxParticles;internalClock=0;nextParticleTime=0;emitterAge=0;emitterLifetime;emitterDead=!1;constructor(e,t=256,a){this.data=e,this.maxParticles=t;let r=a??e.lifetimeMS;!a&&e.lifetimeVarianceMS>0&&(r+=Math.round(sq(0,e.lifetimeVarianceMS))),this.emitterLifetime=r}emitBurst(e,t,a=[0,0,1]){for(let r=0;r0;){if(this.nextParticleTime>0){let e=Math.min(r,this.nextParticleTime);this.nextParticleTime-=e,r-=e,this.internalClock+=e;continue}if(this.particles.length0)){let e=this.particles[this.particles.length-1];e.currentAge+=r,e.currentAge>=e.totalLifetime&&this.particles.pop()}let t=this.data.ejectionPeriodMS;this.data.periodVarianceMS>0&&(t+=Math.round(sq(0,this.data.periodVarianceMS))),this.nextParticleTime=Math.max(1,t)}}update(e){this.emitterAge+=e,this.emitterLifetime>0&&this.emitterAge>this.emitterLifetime&&(this.emitterDead=!0);let t=e/1e3,a=this.data.particles;for(let r=this.particles.length-1;r>=0;r--){let n=this.particles[r];if(n.currentAge+=e,n.currentAge>=n.totalLifetime){this.particles[r]=this.particles[this.particles.length-1],this.particles.pop();continue}let i=a.dragCoefficient,o=a.gravityCoefficient,s=n.acc[0]-n.vel[0]*i,l=n.acc[1]-n.vel[1]*i,c=n.acc[2]-n.vel[2]*i+-9.81*o;n.vel[0]+=s*t,n.vel[1]+=l*t,n.vel[2]+=c*t,n.pos[0]+=n.vel[0]*t,n.pos[1]+=n.vel[1]*t,n.pos[2]+=n.vel[2]*t;let d=n.currentAge/n.totalLifetime,u=function(e,t){for(let a=1;a=t){let r=e[a-1],n=e[a],i=n.time-r.time,o=i>0?(t-r.time)/i:0;return{r:r.r+(n.r-r.r)*o,g:r.g+(n.g-r.g)*o,b:r.b+(n.b-r.b)*o,a:r.a+(n.a-r.a)*o,size:r.size+(n.size-r.size)*o}}let a=e[e.length-1];return{r:a.r,g:a.g,b:a.b,a:a.a,size:a.size}}(a.keys,d);n.r=u.r,n.g=u.g,n.b=u.b,n.a=u.a,n.size=u.size,n.currentSpin=n.spinSpeed*n.currentAge*sL}}isDead(){return this.emitterDead&&0===this.particles.length}kill(){this.emitterDead=!0}addParticle(e,t){var a,r,n,i;let o,s,l,c,d=this.data,u=d.particles,h=t[0],m=t[1],f=t[2],g=(a=h,r=m,.9>Math.abs(n=f)?(o=r,s=-a,l=0):(o=-n,s=0,l=a),(c=Math.sqrt(o*o+s*s+l*l))<1e-8?[1,0,0]:[o/c,s/c,l/c]),p=(d.thetaMin+Math.random()*(d.thetaMax-d.thetaMin))*sU,y=(this.internalClock/1e3*d.phiReferenceVel+Math.random()*d.phiVariance)*sU;[h,m,f]=sH(h,m,f,g[0],g[1],g[2],p),[h,m,f]=sH(h,m,f,t[0],t[1],t[2],y);let v=Math.sqrt(h*h+m*m+f*f);v>1e-8&&(h/=v,m/=v,f/=v);let F=sq(d.ejectionVelocity,d.velocityVariance),b=[e[0]+h*d.ejectionOffset,e[1]+m*d.ejectionOffset,e[2]+f*d.ejectionOffset],S=[h*F,m*F,f*F],x=u.constantAcceleration,k=[S[0]*x,S[1]*x,S[2]*x],w=u.lifetimeMS;u.lifetimeVarianceMS>0&&(w+=Math.round(sq(0,u.lifetimeVarianceMS))),w=Math.max(1,w);let I=u.spinSpeed+((i=u.spinRandomMin)+Math.random()*(u.spinRandomMax-i)),C=u.keys[0];this.particles.push({pos:b,vel:S,acc:k,orientDir:[h,m,f],currentAge:0,totalLifetime:w,dataIndex:0,spinSpeed:I,currentSpin:0,r:C.r,g:C.g,b:C.b,a:C.a,size:C.size})}}let s$=` -// 'position' is auto-declared by Three.js for ShaderMaterial. -attribute vec4 particleColor; -attribute float particleSize; -attribute float particleSpin; -attribute vec2 quadCorner; // (-0.5,-0.5) to (0.5,0.5) -attribute vec3 orientDir; - -uniform bool uOrientParticles; -// cameraPosition is a built-in Three.js uniform. - -varying vec2 vUv; -varying vec4 vColor; - -void main() { - vUv = quadCorner + 0.5; // [0,1] range - vColor = particleColor; - - if (uOrientParticles) { - if (length(orientDir) < 0.0001) { - // V12: don't render oriented particles with zero velocity. - gl_Position = vec4(0.0, 0.0, 0.0, 0.0); - return; - } - // V12 oriented particle: quad aligned along direction, facing camera. - vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz; - vec3 dir = normalize(orientDir); - vec3 dirFromCam = worldPos - cameraPosition; - vec3 crossDir = normalize(cross(dirFromCam, dir)); - - // V12 maps U along dir (velocity) — match by using quadCorner.x for dir. - vec3 offset = dir * quadCorner.x + crossDir * quadCorner.y; - worldPos += offset * particleSize; - - gl_Position = projectionMatrix * viewMatrix * vec4(worldPos, 1.0); - } else { - // Standard camera-facing billboard. - vec3 viewPos = (modelViewMatrix * vec4(position, 1.0)).xyz; - - // Apply spin rotation to quad corner. - float c = cos(particleSpin); - float s = sin(particleSpin); - vec2 rotated = vec2( - c * quadCorner.x - s * quadCorner.y, - s * quadCorner.x + c * quadCorner.y - ); - - // Offset in view space (camera-facing billboard). - viewPos.xy += rotated * particleSize; - - gl_Position = projectionMatrix * vec4(viewPos, 1.0); - } -} -`,sY=` -uniform sampler2D particleTexture; -uniform bool hasTexture; -uniform float debugOpacity; - -varying vec2 vUv; -varying vec4 vColor; - -void main() { - if (hasTexture) { - vec4 texColor = texture2D(particleTexture, vUv); - gl_FragColor = texColor * vColor; - } else { - gl_FragColor = vColor; - } - gl_FragColor.a *= debugOpacity; -} -`,sK=new Float32Array([-.5,-.5,.5,-.5,.5,.5,-.5,.5]),sX=new Map,sZ=new Set,sJ=new o.DataTexture(new Uint8Array([255,255,255,255]),1,1,o.RGBAFormat,o.UnsignedByteType);function sQ(e){if(!e)return sJ;let t=sX.get(e);if(t)return t;try{let t=(0,c.textureToUrl)(e),a=(0,f.loadTexture)(t,e=>{(0,o2.setupEffectTexture)(e),sZ.add(e)});return(0,o2.setupEffectTexture)(a),sX.set(e,a),a}catch{return sJ}}sJ.needsUpdate=!0;let s0=new o.SphereGeometry(1,6,6),s1=new o.MeshBasicMaterial({color:0xff0000,wireframe:!0}),s2=new o.BoxGeometry(.3,.3,.3),s3=new o.MeshBasicMaterial({color:65280,wireframe:!0}),s5=new o.SphereGeometry(1,12,8),s4=` - attribute vec4 vertexColor; - attribute vec2 texCoord; - varying vec4 vColor; - varying vec2 vUV; - void main() { - vColor = vertexColor; - vUV = texCoord; - gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); - } -`,s6=` - uniform sampler2D uTexture; - varying vec4 vColor; - varying vec2 vUV; - void main() { - vec4 tex = texture2D(uTexture, vUV); - gl_FragColor = vec4(vColor.rgb * tex.rgb, vColor.a * tex.a); - } -`;function s8(e){let t=(e+1)*2,a=new Float32Array(3*t),r=new Float32Array(2*t),n=new Float32Array(4*t),i=new Uint16Array(6*e);for(let t=0;t{let a=D.current,r=x.current;if(!a||!r)return;let n=I.engineStore.getState().playback,i="playing"===n.status,s=i?t*n.rate:0,l=1e3*s,d=S.getDataBlockData.bind(S);for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position||T.current.has(e.id))continue;T.current.add(e.id);let t=function(e,t){let a=t(e);if(!a)return null;let r=[],n=[],i=a.particleEmitter;if("number"==typeof i){let e=t(i);if(e){let n=sV(e,t);if(n){let e=a.particleDensity??10;r.push({data:n,density:e})}}}let o=a.emitters;if(Array.isArray(o))for(let e of o){if("number"!=typeof e)continue;let a=t(e);if(!a)continue;let r=sV(a,t);r&&n.push(r)}return 0===r.length&&0===n.length?null:{burstEmitters:r,streamingEmitters:n,lifetimeMS:32*(a.lifetimeMS??31)}}(e.explosionDataBlockId,d);if(!t)continue;let r=[...e.position];for(let e of t.burstEmitters){let t=new sW(e.data,256);t.emitBurst(r,e.density);let n=sQ(e.data.particles.textureName),i=s9(256),s=le(n,e.data.particles.useInvAlpha,e.data.orientParticles),l=new o.Mesh(i,s);l.frustumCulled=!1,a.add(l),M.current.push({emitter:t,mesh:l,geometry:i,material:s,targetTexture:n,origin:r,isBurst:!0,hasBurst:!0})}for(let e of t.streamingEmitters){let n=new sW(e,256,t.lifetimeMS),i=sQ(e.particles.textureName),s=s9(256),l=le(i,e.particles.useInvAlpha,e.orientParticles),c=new o.Mesh(s,l);c.frustumCulled=!1,a.add(c),M.current.push({emitter:n,mesh:c,geometry:s,material:l,targetTexture:i,origin:r,isBurst:!1,hasBurst:!1})}let n=d(e.explosionDataBlockId);if(k){let i=n?function(e){let t=e.sizes;if(Array.isArray(t)&&t.length>0){let e=0;for(let a of t)e=Math.max(e,a.x,a.y,a.z);if(e>0)return e/1e3}let a=e.particleRadius;return"number"==typeof a&&a>0?a:5}(n):5,s=function(e){if(!e)return 0xff00ff;let t=e.toLowerCase();return t.includes("disc")?4491519:t.includes("grenade")?0xff8800:t.includes("mortar")?0xff4400:t.includes("plasma")?4521796:t.includes("laser")?0xff2222:t.includes("blaster")?0xffff00:t.includes("missile")?0xff6600:t.includes("bomb")?0xff0000:t.includes("mine")?0xff8844:t.includes("concussion")?0xffaa00:t.includes("shocklance")?8930559:t.includes("chaingun")||t.includes("bullet")?0xcccccc:0xff00ff}(e.dataBlock),l=new o.MeshBasicMaterial({color:s,wireframe:!0,transparent:!0,opacity:1,depthWrite:!1}),c=new o.Mesh(s5,l);c.frustumCulled=!1,c.scale.setScalar(i),c.position.set(r[1],r[2],r[0]),a.add(c);let{sprite:d,material:u}=function(e,t){let a=document.createElement("canvas"),r=a.getContext("2d");r.font="bold 32px monospace",a.width=Math.ceil(r.measureText(e).width)+16,a.height=48,r.font="bold 32px monospace",r.fillStyle=`#${t.toString(16).padStart(6,"0")}`,r.textBaseline="middle",r.fillText(e,8,a.height/2);let n=new o.CanvasTexture(a),i=new o.SpriteMaterial({map:n,transparent:!0,depthTest:!1,depthWrite:!1}),s=new o.Sprite(i),l=a.width/a.height;return s.scale.set(2*l,2,1),{sprite:s,material:i}}(`${e.id}: ${e.dataBlock??`expId:${e.explosionDataBlockId}`}`,s);d.position.set(r[1],r[2]+i+2,r[0]),d.frustumCulled=!1,a.add(d),R.current.push({entityId:e.id,mesh:c,material:l,label:d,labelMaterial:u,creationTime:(0,I.demoEffectNow)(),lifetimeMS:Math.max(t.lifetimeMS,3e3),targetRadius:i})}let i=n?.shockwave;if("number"==typeof i){let t=function(e,t){let a=t(e);if(!a)return null;let r=a.colors??[],n=a.times??[0,.5,1,1];return{width:a.width??1,numSegments:Math.max(a.numSegments??16,4),velocity:a.velocity??0,height:a.height??0,verticalCurve:a.verticalCurve??0,acceleration:a.acceleration??0,texWrap:a.texWrap??1,lifetimeMS:a.lifetimeMS??500,is2D:!!a.is2D,renderSquare:!!a.renderSquare,renderBottom:!!a.renderBottom,mapToTerrain:!!a.mapToTerrain,colors:r,times:n,textureName:a.textureName??"",mapToTexture:a.mapToTexture??""}}(i,d);if(t){let n=sQ(t.textureName),i=s8(t.numSegments),s=new o.ShaderMaterial({vertexShader:s4,fragmentShader:s6,uniforms:{uTexture:{value:n}},transparent:!0,depthWrite:!1,blending:o.AdditiveBlending,side:o.DoubleSide}),l=new o.Mesh(i,s);l.frustumCulled=!1,l.position.set(r[1],r[2],r[0]),a.add(l);let c=null,d=null;t.renderBottom&&(d=s8(t.numSegments),(c=new o.Mesh(d,s)).frustumCulled=!1,c.position.set(r[1],r[2],r[0]),c.scale.y=-1,a.add(c));let u=Math.abs(t.velocity)>1e-10?t.velocity:0;N.current.push({entityId:e.id,mesh:l,bottomMesh:c,geometry:i,bottomGeometry:d,material:s,creationTime:(0,I.demoEffectNow)(),lifetimeMS:t.lifetimeMS,data:t,radius:0,velocity:u})}}}let u=new Set;for(let e of r.entities){if(u.add(e.id),!e.maintainEmitterId||E.current.has(e.id))continue;E.current.add(e.id);let t=d(e.maintainEmitterId);if(!t)continue;let r=sV(t,d);if(!r)continue;let n=e.position?[...e.position]:[0,0,0],i=new sW(r,256),s=sQ(r.particles.textureName),l=s9(256),c=le(s,r.particles.useInvAlpha,r.orientParticles),h=new o.Mesh(l,c);h.frustumCulled=!1,a.add(h),M.current.push({emitter:i,mesh:h,geometry:l,material:c,targetTexture:s,origin:n,isBurst:!1,hasBurst:!1,followEntityId:e.id})}for(let e of M.current)e.followEntityId&&!u.has(e.followEntityId)&&e.emitter.kill();for(let e of E.current)u.has(e)||E.current.delete(e);let h=M.current;for(let e=h.length-1;e>=0;e--){let t=h[e];if(t.shaderChecked||(!function(e,t,a){let r=e.properties.get(t).currentProgram;if(!r)return;let n=r.program,i=e.getContext();i.getProgramParameter(n,i.LINK_STATUS)||console.error(`[ParticleFX] Shader LINK ERROR (${a}):`,i.getProgramInfoLog(n))}(P,t.material,t.isBurst?"burst":"stream"),t.shaderChecked=!0),t.followEntityId){let e=r.entities.find(e=>e.id===t.followEntityId);e?.position&&(t.origin[0]=e.position[0],t.origin[1]=e.position[1],t.origin[2]=e.position[2]),e?.direction&&(t.emitAxis=e.direction)}if(t.isBurst||t.emitter.emitPeriodic(t.origin,l,t.emitAxis),t.emitter.update(l),sZ.has(t.targetTexture)&&t.material.uniforms.particleTexture.value!==t.targetTexture&&(t.material.uniforms.particleTexture.value=t.targetTexture),t.material.uniforms.debugOpacity.value=k?.2:1,!function(e){let t=e.emitter.particles,a=e.geometry,r=a.getAttribute("position"),n=a.getAttribute("particleColor"),i=a.getAttribute("particleSize"),o=a.getAttribute("particleSpin"),s=a.getAttribute("orientDir"),l=r.array,c=n.array,d=i.array,u=o.array,h=s.array,m=Math.min(t.length,256),f=e.emitter.data.orientOnVelocity;for(let e=0;e=0;e--){let t=m[e],r=Math.min((f-t.creationTime)/t.lifetimeMS,1),n=Math.min(r/.1,1);t.mesh.scale.setScalar(t.targetRadius*n),t.material.opacity=1-r,t.labelMaterial.opacity=1-r,r>=1&&(a.remove(t.mesh),a.remove(t.label),t.material.dispose(),t.labelMaterial.dispose(),m.splice(e,1))}let g=N.current;for(let t=g.length-1;t>=0;t--){let r=g[t],n=Math.min((f-r.creationTime)/r.lifetimeMS,1);r.velocity=r.velocity+r.data.acceleration*s,r.radius=r.radius+r.velocity*s;let i=function(e,t){let{colors:a,times:r}=e;if(0===a.length)return[1,1,1,1];let n=0;for(let e=0;e=r[e]&&(n=e);let i=Math.min(n+1,a.length-1),o=r[n]??0,s=(r[i]??1)-o,l=s>0?Math.min((t-o)/s,1):0,c=a[n]??a[0],d=a[i]??a[0];return[c.r+(d.r-c.r)*l,c.g+(d.g-c.g)*l,c.b+(d.b-c.b)*l,c.a+(d.a-c.a)*l]}(r.data,n);s7(r.geometry,r.data,r.radius,i,r.data.is2D),r.bottomGeometry&&s7(r.bottomGeometry,r.data,r.radius,i,r.data.is2D),r.data.is2D&&r.mesh.lookAt(e.camera.position),n>=1&&(a.remove(r.mesh),r.bottomMesh&&a.remove(r.bottomMesh),r.geometry.dispose(),r.bottomGeometry?.dispose(),r.material.dispose(),g.splice(t,1))}if(i&&w&&C&&_&&D.current){for(let e of r.entities){if("Explosion"!==e.type||!e.explosionDataBlockId||!e.position)continue;let t=`snd:${e.id}`;if(j.current.has(t))continue;j.current.add(t);let a=d(e.explosionDataBlockId);if(!a)continue;let r=a.soundProfile;if("number"!=typeof r)continue;let n=(0,o8.resolveAudioProfile)(r,d);if(!n)continue;let i=new o.Vector3(e.position[1],e.position[2],e.position[0]);(0,o8.playOneShotSound)(n,_,C,i,D.current)}let e=B.current;for(let t of r.entities){if("Projectile"!==t.type||!t.dataBlockId||!t.position)continue;if(e.has(t.id)){e.get(t.id).position.set(t.position[1],t.position[2],t.position[0]);continue}if(e.size>=20)continue;let a=d(t.dataBlockId);if(!a)continue;let r=a.sound;if("number"!=typeof r)continue;let i=(0,o8.resolveAudioProfile)(r,d);if(i&&i.isLooping&&i.is3D)try{let a=(0,c.audioToUrl)(i.filename);(0,o8.getCachedAudioBuffer)(a,C,a=>{if(!u.has(t.id)||e.has(t.id))return;let r=D.current;if(!r)return;let s=new o.PositionalAudio(_);s.setBuffer(a),s.setDistanceModel("inverse"),s.setRefDistance(i.refDist),s.setMaxDistance(i.maxDist),s.setRolloffFactor(1),s.setVolume(i.volume),s.setPlaybackRate(n.rate),s.setLoop(!0),s.position.set(t.position[1],t.position[2],t.position[0]),r.add(s),(0,o8.trackDemoSound)(s),s.play(),e.set(t.id,s)})}catch{}}for(let[t,a]of e)if(!u.has(t)){(0,o8.untrackDemoSound)(a);try{a.stop()}catch{}a.disconnect(),D.current?.remove(a),e.delete(t)}for(let e of r.audioEvents){let t=`${e.timeSec}:${e.profileId}:${e.position?.x??""}`;if(j.current.has(t))continue;j.current.add(t);let a=(0,o8.resolveAudioProfile)(e.profileId,d);if(!a)continue;let r=e.position?new o.Vector3(e.position.y,e.position.z,e.position.x):void 0;(0,o8.playOneShotSound)(a,_,C,r,D.current)}}if(T.current.size>500){let e=new Set(r.entities.map(lr));for(let t of T.current)e.has(t)||T.current.delete(t)}if(j.current.size>500){let e=new Set(r.entities.map(la));for(let t of j.current)t.startsWith("snd:")&&e.has(t.slice(4))||j.current.delete(t)}},b[7]=w,b[8]=_,b[9]=C,b[10]=k,b[11]=P,b[12]=S,b[13]=x,b[14]=g):g=b[14],(0,u.useFrame)(g),b[15]===Symbol.for("react.memo_cache_sentinel")?(y=()=>()=>{let e=D.current;for(let t of M.current){if(e&&(e.remove(t.mesh),t.debugOriginMesh&&e.remove(t.debugOriginMesh),t.debugParticleMeshes))for(let a of t.debugParticleMeshes)e.remove(a);t.geometry.dispose(),t.material.dispose()}for(let t of(M.current=[],R.current))e&&(e.remove(t.mesh),e.remove(t.label)),t.material.dispose(),t.labelMaterial.dispose();for(let t of(R.current=[],N.current))e&&(e.remove(t.mesh),t.bottomMesh&&e.remove(t.bottomMesh)),t.geometry.dispose(),t.bottomGeometry?.dispose(),t.material.dispose();for(let[,t]of(N.current=[],T.current.clear(),E.current.clear(),B.current)){(0,o8.untrackDemoSound)(t);try{t.stop()}catch{}t.disconnect(),e&&e.remove(t)}B.current.clear(),j.current.clear()},p=[],b[15]=p,b[16]=y):(p=b[15],y=b[16]),(0,n.useEffect)(y,p),b[17]===Symbol.for("react.memo_cache_sentinel")?(F=(0,a.jsx)("group",{ref:D}),b[17]=F):F=b[17],F}function la(e){return e.id}function lr(e){return e.id}function ln(e){return e.gl}let li=new WeakMap;function lo(e){let t=li.get(e);return t||(t=new Map(e.entities.map(e=>[e.id,e])),li.set(e,t)),t}let ls=new o.Vector3,ll=new o.Quaternion,lc=new o.Quaternion,ld=new o.Quaternion(0,1,0,0),lu=new o.Vector3,lh=new o.Vector3,lm=new o.Vector3;function lf(e){let t,i,s,l,d,h,m,f,g,p,y,v,F=(0,r.c)(25),{recording:b}=e,S=(0,I.useEngineStoreApi)(),x=(0,n.useRef)(null),k=(0,n.useRef)(0),w=(0,n.useRef)(0),C=(0,n.useRef)(null),_=(0,n.useRef)(null);F[0]===Symbol.for("react.memo_cache_sentinel")?(t=new o.Vector3(0,o2.DEFAULT_EYE_HEIGHT,0),F[0]=t):t=F[0];let P=(0,n.useRef)(t),D=(0,n.useRef)(b.streamingPlayback??null),M=(0,n.useRef)(null);F[1]===Symbol.for("react.memo_cache_sentinel")?(i=new Map,F[1]=i):i=F[1];let T=(0,n.useRef)(i),E=(0,n.useRef)(null);F[2]===Symbol.for("react.memo_cache_sentinel")?(s=[],F[2]=s):s=F[2];let[B,j]=(0,n.useState)(s),[R,N]=(0,n.useState)(null);F[3]===Symbol.for("react.memo_cache_sentinel")?(l=e=>{if(e===E.current)return;E.current=e;let t=T.current,a=new Map,r=!1;for(let n of e.entities){let i=t.get(n.id);i&&i.type===n.type&&i.dataBlock===n.dataBlock&&i.weaponShape===n.weaponShape&&i.className===n.className&&i.ghostIndex===n.ghostIndex&&i.dataBlockId===n.dataBlockId&&i.shapeHint===n.shapeHint?(i.playerName!==n.playerName||i.iffColor!==n.iffColor||i.targetRenderFlags!==n.targetRenderFlags||i.threads!==n.threads||i.weaponImageState!==n.weaponImageState||i.weaponImageStates!==n.weaponImageStates||i.headPitch!==n.headPitch||i.headYaw!==n.headYaw||i.direction!==n.direction||i.visual!==n.visual)&&(i={...i,playerName:n.playerName,iffColor:n.iffColor,targetRenderFlags:n.targetRenderFlags,threads:n.threads,weaponImageState:n.weaponImageState,weaponImageStates:n.weaponImageStates,headPitch:n.headPitch,headYaw:n.headYaw,direction:n.direction,visual:n.visual},r=!0):((i=(0,o2.buildStreamDemoEntity)(n.id,n.type,n.dataBlock,n.visual,n.direction,n.weaponShape,n.playerName,n.className,n.ghostIndex,n.dataBlockId,n.shapeHint,n.explosionDataBlockId,n.faceViewer)).playerName=n.playerName,i.iffColor=n.iffColor,i.targetRenderFlags=n.targetRenderFlags,i.threads=n.threads,i.weaponImageState=n.weaponImageState,i.weaponImageStates=n.weaponImageStates,i.headPitch=n.headPitch,i.headYaw=n.headYaw,i.direction=n.direction,i.visual=n.visual,i.explosionDataBlockId=n.explosionDataBlockId,i.faceViewer=n.faceViewer,i.spawnTime=e.timeSec,r=!0),0===i.keyframes.length&&i.keyframes.push({time:e.timeSec,position:n.position??[0,0,0],rotation:n.rotation??[0,0,0,1]});let o=i.keyframes[0];o.time=e.timeSec,n.position&&(o.position=n.position),n.rotation&&(o.rotation=n.rotation),o.velocity=n.velocity,o.health=n.health,o.energy=n.energy,o.actionAnim=n.actionAnim,o.actionAtEnd=n.actionAtEnd,o.damageState=n.damageState,a.set(n.id,i)}for(let[n,i]of t)if(!a.has(n)){if("Explosion"===i.type&&i.dataBlock&&null!=i.spawnTime&&e.timeSec-i.spawnTime<5){a.set(n,i);continue}r=!0}a.size!==t.size&&(r=!0),T.current=a,r&&j(Array.from(a.values()));let n=null;if(e.camera?.mode==="first-person"&&e.camera.controlEntityId){let t=a.get(e.camera.controlEntityId);t?.dataBlock&&(n=t.dataBlock)}N(e=>e===n?e:n)},F[3]=l):l=F[3];let A=l;return F[4]!==S||F[5]!==b.streamingPlayback?(d=()=>{D.current=b.streamingPlayback??null,T.current=new Map,E.current=null,M.current=null,k.current=0,w.current=0,C.current=null,_.current=null;let e=D.current;if(!e)return void S.getState().setPlaybackStreamSnapshot(null);for(let t of(e.reset(),e.getEffectShapes()))L.useGLTF.preload((0,c.shapeToUrl)(t));let t=e.getSnapshot();return k.current=t.timeSec,w.current=t.timeSec,C.current=t,_.current=t,A(t),S.getState().setPlaybackStreamSnapshot(t),M.current=t,()=>{S.getState().setPlaybackStreamSnapshot(null)}},F[4]=S,F[5]=b.streamingPlayback,F[6]=d):d=F[6],F[7]!==S||F[8]!==b?(h=[b,S,A],F[7]=S,F[8]=b,F[9]=h):h=F[9],(0,n.useEffect)(d,h),F[10]!==S?(m=(e,t)=>{let a=D.current;if(!a)return;let r=S.getState(),n=r.playback,i="playing"===n.status,o=n.timeMs/1e3,s=!i&&Math.abs(o-w.current)>5e-4,l=i&&Math.abs(o-k.current)>.05,c=s||l;c&&(w.current=o),i&&((0,I.advanceEffectClock)(t,n.rate),w.current=w.current+t*n.rate);let d=Math.max(1,Math.ceil(1e3*t*Math.max(n.rate,.01)/32)+2),u=w.current+o2.STREAM_TICK_SEC,h=a.stepToTime(u,i&&!c?d:1/0),m=_.current;!m||h.timeSec1.5*o2.STREAM_TICK_SEC?(C.current=h,_.current=h):h.timeSec!==m.timeSec&&(C.current=m,_.current=h);let f=_.current??h,g=C.current??f,p=f.timeSec-o2.STREAM_TICK_SEC,y=Math.max(0,Math.min(1,(w.current-p)/o2.STREAM_TICK_SEC));k.current=w.current,h.exhausted&&i&&(w.current=Math.min(w.current,h.timeSec)),A(f);let v=M.current;(!v||f.timeSec!==v.timeSec||f.exhausted!==v.exhausted||f.status.health!==v.status.health||f.status.energy!==v.status.energy||f.camera?.mode!==v.camera?.mode||f.camera?.controlEntityId!==v.camera?.controlEntityId||f.camera?.orbitTargetId!==v.camera?.orbitTargetId||f.chatMessages.length!==v.chatMessages.length||f.teamScores.length!==v.teamScores.length||f.teamScores.some((e,t)=>e.score!==v.teamScores[t]?.score||e.playerCount!==v.teamScores[t]?.playerCount))&&(M.current=f,r.setPlaybackStreamSnapshot(f));let F=f.camera,b=F&&g.camera&&g.camera.mode===F.mode&&g.camera.controlEntityId===F.controlEntityId&&g.camera.orbitTargetId===F.orbitTargetId?g.camera:null;if(F){if(b){let t=b.position[0],a=b.position[1],r=b.position[2],n=F.position[0],i=F.position[1],o=F.position[2];e.camera.position.set(a+(i-a)*y,r+(o-r)*y,t+(n-t)*y),ll.set(...b.rotation),lc.set(...F.rotation),ll.slerp(lc,y),e.camera.quaternion.copy(ll)}else e.camera.position.set(F.position[1],F.position[2],F.position[0]),e.camera.quaternion.set(...F.rotation);if(Number.isFinite(F.fov)&&"isPerspectiveCamera"in e.camera&&e.camera.isPerspectiveCamera){let t=e.camera,a=b&&Number.isFinite(b.fov)?b.fov+(F.fov-b.fov)*y:F.fov,r=(0,o2.torqueHorizontalFovToThreeVerticalFov)(a,t.aspect);Math.abs(t.fov-r)>.01&&(t.fov=r,t.updateProjectionMatrix())}}let E=lo(f),B=lo(g),j=T.current,R=x.current;if(R)for(let t of R.children){let a=E.get(t.name);if(!a){let e=j.get(t.name);if(e?.keyframes[0]?.position){let a=e.keyframes[0];t.visible=!0,t.position.set(a.position[1],a.position[2],a.position[0]);continue}}if(!a?.position){t.visible=!1;continue}t.visible=!0;let r=B.get(t.name);if(r?.position){let e=r.position[0],n=r.position[1],i=r.position[2],o=a.position[0],s=a.position[1],l=a.position[2],c=e+(o-e)*y,d=n+(s-n)*y,u=i+(l-i)*y;t.position.set(d,u,c)}else t.position.set(a.position[1],a.position[2],a.position[0]);a.faceViewer?t.quaternion.copy(e.camera.quaternion).multiply(ld):a.visual?.kind==="tracer"?t.quaternion.identity():a.rotation&&(r?.rotation?(ll.set(...r.rotation),lc.set(...a.rotation),ll.slerp(lc,y),t.quaternion.copy(ll)):t.quaternion.set(...a.rotation))}let N=F?.mode;if("third-person"===N&&R&&F?.orbitTargetId){let t=R.children.find(e=>e.name===F.orbitTargetId);if(t){let a=E.get(F.orbitTargetId);lh.copy(t.position),a?.type==="Player"&&(lh.y=lh.y+1);let r=!1;if("number"==typeof F.yaw&&"number"==typeof F.pitch){let e=Math.sin(F.pitch),t=Math.cos(F.pitch),a=Math.sin(F.yaw),n=Math.cos(F.yaw);lu.set(-t,-a*e,-n*e),r=lu.lengthSq()>1e-8}if(r||(lu.copy(e.camera.position).sub(lh),r=lu.lengthSq()>1e-8),r){lu.normalize();let t=Math.max(.1,F.orbitDistance??4);lm.copy(lh).addScaledVector(lu,t),e.camera.position.copy(lm),e.camera.lookAt(lh)}}}if("first-person"===N&&R&&F?.controlEntityId){let t=R.children.find(e=>e.name===F.controlEntityId);t?(ls.copy(P.current).applyQuaternion(t.quaternion),e.camera.position.add(ls)):e.camera.position.y=e.camera.position.y+P.current.y}i&&h.exhausted&&r.setPlaybackStatus("paused");let G=1e3*w.current;Math.abs(G-n.timeMs)>.5&&r.setPlaybackTime(G)},F[10]=S,F[11]=m):m=F[11],(0,u.useFrame)(m),F[12]!==B||F[13]!==b.streamingPlayback?(f=B.map(e=>(0,a.jsx)(sR,{entity:e,timeRef:k,playback:b.streamingPlayback},e.id)),F[12]=B,F[13]=b.streamingPlayback,F[14]=f):f=F[14],F[15]!==f?(g=(0,a.jsx)("group",{ref:x,children:f}),F[15]=f,F[16]=g):g=F[16],F[17]!==b.streamingPlayback?(p=(0,a.jsx)(lt,{playback:b.streamingPlayback,snapshotRef:_}),F[17]=b.streamingPlayback,F[18]=p):p=F[18],F[19]!==R?(y=R&&(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(sl,{shapeName:R,eyeOffsetRef:P})}),F[19]=R,F[20]=y):y=F[20],F[21]!==p||F[22]!==y||F[23]!==g?(v=(0,a.jsxs)(eE.TickProvider,{children:[g,p,y]}),F[21]=p,F[22]=y,F[23]=g,F[24]=v):v=F[24],v}function lg(){let e,t=(0,r.c)(2),n=ts();return n?(t[0]!==n?(e=(0,a.jsx)(lf,{recording:n}),t[0]=n,t[1]=e):e=t[1],e):null}var lp=e.i(21629);let ly=[.25,.5,1,2,4];function lv(e){let t=Math.floor(e/60),a=Math.floor(e%60);return`${t}:${a.toString().padStart(2,"0")}`}function lF(){let e,t,i,o,s,l,c,d,u,h,m,f,g=(0,r.c)(33),p=ts(),y=(0,I.useEngineSelector)(tc),v=(0,I.useEngineSelector)(td),F=(0,I.useEngineSelector)(tu),b=(0,I.useEngineSelector)(th),{play:S,pause:x,seek:k,setSpeed:w}=tm();g[0]!==y||g[1]!==x||g[2]!==S||g[3]!==p?(e=()=>{if(!p)return;let e=e=>{if("Space"!==e.code)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||"SELECT"===t.tagName||"BUTTON"===t.tagName||t.isContentEditable||(e.preventDefault(),y?x():S())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},t=[p,y,S,x],g[0]=y,g[1]=x,g[2]=S,g[3]=p,g[4]=e,g[5]=t):(e=g[4],t=g[5]),(0,n.useEffect)(e,t),g[6]!==k?(i=e=>{k(parseFloat(e.target.value))},g[6]=k,g[7]=i):i=g[7];let C=i;g[8]!==w?(o=e=>{w(parseFloat(e.target.value))},g[8]=w,g[9]=o):o=g[9];let _=o;if(!p)return null;let P=y?x:S,D=y?"Pause":"Play",M=y?"❚❚":"▶";g[10]!==P||g[11]!==D||g[12]!==M?(s=(0,a.jsx)("button",{className:lp.default.PlayPause,onClick:P,"aria-label":D,children:M}),g[10]=P,g[11]=D,g[12]=M,g[13]=s):s=g[13],g[14]!==v?(l=lv(v),g[14]=v,g[15]=l):l=g[15],g[16]!==F?(c=lv(F),g[16]=F,g[17]=c):c=g[17];let T=`${l} / ${c}`;return g[18]!==T?(d=(0,a.jsx)("span",{className:lp.default.Time,children:T}),g[18]=T,g[19]=d):d=g[19],g[20]!==v||g[21]!==F||g[22]!==C?(u=(0,a.jsx)("input",{className:lp.default.Seek,type:"range",min:0,max:F,step:.01,value:v,onChange:C}),g[20]=v,g[21]=F,g[22]=C,g[23]=u):u=g[23],g[24]===Symbol.for("react.memo_cache_sentinel")?(h=ly.map(lb),g[24]=h):h=g[24],g[25]!==_||g[26]!==b?(m=(0,a.jsx)("select",{className:lp.default.Speed,value:b,onChange:_,children:h}),g[25]=_,g[26]=b,g[27]=m):m=g[27],g[28]!==d||g[29]!==u||g[30]!==m||g[31]!==s?(f=(0,a.jsxs)("div",{className:lp.default.Root,onKeyDown:lk,onPointerDown:lx,onClick:lS,children:[s,d,u,m]}),g[28]=d,g[29]=u,g[30]=m,g[31]=s,g[32]=f):f=g[32],f}function lb(e){return(0,a.jsxs)("option",{value:e,children:[e,"x"]},e)}function lS(e){return e.stopPropagation()}function lx(e){return e.stopPropagation()}function lk(e){return e.stopPropagation()}var lw=e.i(75840);let lI=(0,c.textureToUrl)("gui/hud_new_compass"),lC=(0,c.textureToUrl)("gui/hud_new_NSEW");function l_(e){let t,n,i=(0,r.c)(3),{yaw:o}=e;if(null==o)return null;let s=180*o/Math.PI;i[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)("img",{src:lI,alt:"",className:lw.default.CompassRing}),i[0]=t):t=i[0];let l=`rotate(${-s}deg)`;return i[1]!==l?(n=(0,a.jsxs)("div",{className:lw.default.Compass,children:[t,(0,a.jsx)("img",{src:lC,alt:"",className:lw.default.CompassNSEW,style:{transform:l}})]}),i[1]=l,i[2]=n):n=i[2],n}function lP(e){let t,n=(0,r.c)(2),{value:i}=e,o=Math.max(0,Math.min(100,100*i)),s=`${o}%`;return n[0]!==s?(t=(0,a.jsx)("div",{className:lw.default.BarTrack,children:(0,a.jsx)("div",{className:lw.default.BarFillHealth,style:{width:s}})}),n[0]=s,n[1]=t):t=n[1],t}function lD(e){let t,n=(0,r.c)(2),{value:i}=e,o=Math.max(0,Math.min(100,100*i)),s=`${o}%`;return n[0]!==s?(t=(0,a.jsx)("div",{className:lw.default.BarTrack,children:(0,a.jsx)("div",{className:lw.default.BarFillEnergy,style:{width:s}})}),n[0]=s,n[1]=t):t=n[1],t}let lM={weapon_sniper:"gui/hud_ret_sniper",weapon_shocklance:"gui/hud_ret_shocklance",weapon_targeting:"gui/hud_ret_targlaser"};function lT(){let e,t=(0,r.c)(5),n=(0,I.useEngineSelector)(lE);if(void 0===n)return null;let i=lM[!n?"":n.replace(/\.dts$/i,"").toLowerCase()];if(i){let e,r;return t[0]!==i?(e=(0,c.textureToUrl)(i),t[0]=i,t[1]=e):e=t[1],t[2]!==e?(r=(0,a.jsx)("div",{className:lw.default.Reticle,children:(0,a.jsx)("img",{src:e,alt:"",className:lw.default.ReticleImage})}),t[2]=e,t[3]=r):r=t[3],r}return t[4]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)("div",{className:lw.default.Reticle,children:(0,a.jsx)("div",{className:lw.default.ReticleDot})}),t[4]=e):e=t[4],e}function lE(e){let t=e.playback.streamSnapshot;if(!t||t.camera?.mode!=="first-person")return;let a=t.controlPlayerGhostId;if(a)return t.entities.find(e=>e.id===a)?.weaponShape}let lB={0:{icon:"gui/hud_blaster",label:"Blaster"},1:{icon:"gui/hud_plasma",label:"Plasma"},2:{icon:"gui/hud_chaingun",label:"Chaingun"},3:{icon:"gui/hud_disc",label:"Spinfusor"},4:{icon:"gui/hud_grenlaunch",label:"GL"},5:{icon:"gui/hud_sniper",label:"Laser Rifle"},6:{icon:"gui/hud_elfgun",label:"ELF Gun"},7:{icon:"gui/hud_new_mortar",label:"Mortar"},8:{icon:"gui/hud_missiles",label:"Missile"},9:{icon:"gui/hud_targetlaser",label:"Targeting"},10:{icon:"gui/hud_shocklance",label:"Shocklance"},11:{icon:"gui/hud_disc",label:"Spinfusor"},12:{icon:"gui/hud_grenlaunch",label:"GL"},13:{icon:"gui/hud_chaingun",label:"Chaingun"},14:{icon:"gui/hud_targetlaser",label:"Targeting"},15:{icon:"gui/hud_targetlaser",label:"Targeting"},16:{icon:"gui/hud_shocklance",label:"Shocklance"},17:{icon:"gui/hud_new_mortar",label:"Mortar"}},lj=new Map(Object.entries(lB).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t.icon)])),lR=new Set([9,14,15]),lN=(0,c.textureToUrl)("gui/hud_infinity");function lA(e){let t,n,i,o,s=(0,r.c)(12),{slot:l,isSelected:c}=e,d=lB[l.index];if(!d)return null;let u=l.ammo<0,h=`${lw.default.PackInvItem} ${c?lw.default.PackInvItemActive:lw.default.PackInvItemDim}`;return s[0]!==l.index?(t=lj.get(l.index),s[0]=l.index,s[1]=t):t=s[1],s[2]!==d.label||s[3]!==t?(n=(0,a.jsx)("img",{src:t,alt:d.label,className:lw.default.PackInvIcon}),s[2]=d.label,s[3]=t,s[4]=n):n=s[4],s[5]!==u||s[6]!==l.ammo?(i=u?(0,a.jsx)("img",{src:lN,alt:"\\u221E",className:lw.default.PackInvInfinity}):(0,a.jsx)("span",{className:lw.default.PackInvCount,children:l.ammo}),s[5]=u,s[6]=l.ammo,s[7]=i):i=s[7],s[8]!==h||s[9]!==n||s[10]!==i?(o=(0,a.jsxs)("div",{className:h,children:[n,i]}),s[8]=h,s[9]=n,s[10]=i,s[11]=o):o=s[11],o}function lG(){let e,t,n,i,o,s,l=(0,r.c)(15),c=(0,I.useEngineSelector)(lU);if(!c||!c.slots.length)return null;if(l[0]!==c.slots){for(let a of(t=[],e=[],c.slots))lR.has(a.index)?e.push(a):t.push(a);l[0]=c.slots,l[1]=e,l[2]=t}else e=l[1],t=l[2];return l[3]!==t||l[4]!==c?(n=t.map(e=>(0,a.jsx)(lA,{slot:e,isSelected:e.index===c.activeIndex},e.index)),l[3]=t,l[4]=c,l[5]=n):n=l[5],l[6]!==e.length?(i=e.length>0&&(0,a.jsx)("div",{className:lw.default.WeaponSeparator}),l[6]=e.length,l[7]=i):i=l[7],l[8]!==e||l[9]!==c?(o=e.map(e=>(0,a.jsx)(lA,{slot:e,isSelected:e.index===c.activeIndex},e.index)),l[8]=e,l[9]=c,l[10]=o):o=l[10],l[11]!==n||l[12]!==i||l[13]!==o?(s=(0,a.jsxs)("div",{className:lw.default.WeaponHUD,children:[n,i,o]}),l[11]=n,l[12]=i,l[13]=o,l[14]=s):s=l[14],s}function lU(e){return e.playback.streamSnapshot?.weaponsHud}let lL={1:"Storm",2:"Inferno",3:"Starwolf",4:"Diamond Sword",5:"Blood Eagle",6:"Phoenix"};function lz(){let e,t,n,i=(0,r.c)(11),o=(0,I.useEngineSelector)(lV),s=(0,I.useEngineSelector)(lO);if(!o?.length)return null;if(i[0]!==s||i[1]!==o){let r,n;i[4]!==s?(r=(e,t)=>{if(s){if(e.teamId===s)return -1;if(t.teamId===s)return 1}return e.teamId-t.teamId},i[4]=s,i[5]=r):r=i[5];let l=[...o].sort(r);e=lw.default.TeamScores,i[6]!==s?(n=e=>{let t=s>0&&e.teamId===s,r=e.name||(lL[e.teamId]??`Team ${e.teamId}`);return(0,a.jsxs)("div",{className:lw.default.TeamRow,children:[(0,a.jsx)("span",{className:t?lw.default.TeamNameFriendly:lw.default.TeamNameEnemy,children:r}),(0,a.jsx)("span",{className:lw.default.TeamScore,children:e.score}),(0,a.jsxs)("span",{className:lw.default.TeamCount,children:["(",e.playerCount,")"]})]},e.teamId)},i[6]=s,i[7]=n):n=i[7],t=l.map(n),i[0]=s,i[1]=o,i[2]=e,i[3]=t}else e=i[2],t=i[3];return i[8]!==e||i[9]!==t?(n=(0,a.jsx)("div",{className:e,children:t}),i[8]=e,i[9]=t,i[10]=n):n=i[10],n}function lO(e){return e.playback.streamSnapshot?.playerSensorGroup}function lV(e){return e.playback.streamSnapshot?.teamScores}let lq={0:lw.default.ChatColor0,1:lw.default.ChatColor1,2:lw.default.ChatColor2,3:lw.default.ChatColor3,4:lw.default.ChatColor4,5:lw.default.ChatColor5,6:lw.default.ChatColor6,7:lw.default.ChatColor7,8:lw.default.ChatColor8,9:lw.default.ChatColor9};function lH(){let e,t,n,i,o=(0,r.c)(13),s=(0,I.useEngineSelector)(lY),l=(0,I.useEngineSelector)(l$);if(!s||!s.length||null==l)return null;let c=l-7.5;if(o[0]!==c||o[1]!==s||o[2]!==l){n=Symbol.for("react.early_return_sentinel");e:{let r,i;o[6]!==c?(r=e=>e.timeSec>c&&""!==e.text.trim(),o[6]=c,o[7]=r):r=o[7];let d=s.filter(r);if(!d.length){n=null;break e}e=lw.default.ChatWindow,o[8]!==l?(i=(e,t)=>{let r=l-e.timeSec,n=r<=6?1:Math.max(0,1-(r-6)/1.5);return(0,a.jsx)("div",{className:lw.default.ChatMessage,style:{opacity:n},children:e.segments?e.segments.map(lW):(0,a.jsxs)("span",{className:null!=e.colorCode&&lq[e.colorCode]?lq[e.colorCode]:lq[0],children:[e.sender?`${e.sender}: `:"",e.text]})},`${e.timeSec}-${t}`)},o[8]=l,o[9]=i):i=o[9],t=d.map(i)}o[0]=c,o[1]=s,o[2]=l,o[3]=e,o[4]=t,o[5]=n}else e=o[3],t=o[4],n=o[5];return n!==Symbol.for("react.early_return_sentinel")?n:(o[10]!==e||o[11]!==t?(i=(0,a.jsx)("div",{className:e,children:t}),o[10]=e,o[11]=t,o[12]=i):i=o[12],i)}function lW(e,t){return(0,a.jsx)("span",{className:lq[e.colorCode]??lq[0],children:e.text},t)}function l$(e){return e.playback.streamSnapshot?.timeSec}function lY(e){return e.playback.streamSnapshot?.chatMessages}let lK=new Map(Object.entries({0:"gui/hud_new_packammo",1:"gui/hud_new_packcloak",2:"gui/hud_new_packenergy",3:"gui/hud_new_packrepair",4:"gui/hud_new_packsatchel",5:"gui/hud_new_packshield",6:"gui/hud_new_packinventory",7:"gui/hud_new_packmotionsens",8:"gui/hud_new_packradar",9:"gui/hud_new_packturretout",10:"gui/hud_new_packturretin",11:"gui/hud_new_packsensjam",12:"gui/hud_new_packturret",13:"gui/hud_new_packturret",14:"gui/hud_new_packturret",15:"gui/hud_new_packturret",16:"gui/hud_new_packturret",17:"gui/hud_new_packturret",18:"gui/hud_satchel_unarmed",19:"gui/hud_new_packenergy"}).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t)])),lX=new Map(Object.entries({1:"gui/hud_new_packcloak_armed",3:"gui/hud_new_packrepair_armed",4:"gui/hud_satchel_armed",5:"gui/hud_new_packshield_armed",11:"gui/hud_new_packsensjam_armed"}).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t)])),lZ={0:{icon:"gui/hud_handgren",label:"Grenade"},1:{icon:"gui/hud_mine",label:"Mine"},2:{icon:"gui/hud_beacon",label:"Beacon"},3:{icon:"gui/hud_medpack",label:"Repair Kit"}},lJ=new Map(Object.entries(lZ).map(([e,t])=>[Number(e),(0,c.textureToUrl)(t.icon)]));function lQ(){let e,t,n,i,o,s,l,c=(0,r.c)(25),d=(0,I.useEngineSelector)(l2),u=(0,I.useEngineSelector)(l1),h=d&&d.packIndex>=0;if(h){let t,a;c[0]!==d.active||c[1]!==d.packIndex?(t=d.active?lX.get(d.packIndex):void 0,c[0]=d.active,c[1]=d.packIndex,c[2]=t):t=c[2];let r=t;c[3]!==r||c[4]!==d.packIndex?(a=r??lK.get(d.packIndex),c[3]=r,c[4]=d.packIndex,c[5]=a):a=c[5],e=a}if(c[6]!==u){if(t=new Map,u)for(let e of u.slots)t.set(e.slot,e.count);c[6]=u,c[7]=t}else t=c[7];if(c[8]!==d||c[9]!==t||c[10]!==h||c[11]!==e){s=Symbol.for("react.early_return_sentinel");e:{let r,l=Object.keys(lZ).map(Number).sort(l0);if(!h&&!t.size){s=null;break e}n=lw.default.PackInventoryHUD,c[16]!==d||c[17]!==e?(i=e&&(0,a.jsxs)("div",{className:`${lw.default.PackInvItem} ${d.active?lw.default.PackInvItemActive:""}`,children:[(0,a.jsx)("img",{src:e,alt:"",className:lw.default.PackInvIcon}),(0,a.jsx)("span",{className:lw.default.PackInvCount,children:d.text||" "})]}),c[16]=d,c[17]=e,c[18]=i):i=c[18],c[19]!==t?(r=e=>{let r=lZ[e],n=lJ.get(e);return r&&n?(0,a.jsxs)("div",{className:lw.default.PackInvItem,children:[(0,a.jsx)("img",{src:n,alt:r.label,className:lw.default.PackInvIcon}),(0,a.jsx)("span",{className:lw.default.PackInvCount,children:t.get(e)??0})]},e):null},c[19]=t,c[20]=r):r=c[20],o=l.map(r)}c[8]=d,c[9]=t,c[10]=h,c[11]=e,c[12]=n,c[13]=i,c[14]=o,c[15]=s}else n=c[12],i=c[13],o=c[14],s=c[15];return s!==Symbol.for("react.early_return_sentinel")?s:(c[21]!==n||c[22]!==i||c[23]!==o?(l=(0,a.jsxs)("div",{className:n,children:[i,o]}),c[21]=n,c[22]=i,c[23]=o,c[24]=l):l=c[24],l)}function l0(e,t){return e-t}function l1(e){return e.playback.streamSnapshot?.inventoryHud}function l2(e){return e.playback.streamSnapshot?.backpackHud}function l3(){let e,t,n,i,o,s,l,c,d,u,h,m=(0,r.c)(19),f=ts(),g=(0,I.useEngineSelector)(l5);if(!f)return null;let p=g?.status;if(!p)return null;m[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)(lH,{}),m[0]=e):e=m[0],m[1]!==p.health?(t=(0,a.jsx)(lP,{value:p.health}),m[1]=p.health,m[2]=t):t=m[2],m[3]!==p.energy?(n=(0,a.jsx)(lD,{value:p.energy}),m[3]=p.energy,m[4]=n):n=m[4],m[5]!==t||m[6]!==n?(i=(0,a.jsxs)("div",{className:lw.default.Bars,children:[t,n]}),m[5]=t,m[6]=n,m[7]=i):i=m[7];let y=g?.camera?.yaw;return m[8]!==y?(o=(0,a.jsx)(l_,{yaw:y}),m[8]=y,m[9]=o):o=m[9],m[10]!==i||m[11]!==o?(s=(0,a.jsxs)("div",{className:lw.default.TopRight,children:[i,o]}),m[10]=i,m[11]=o,m[12]=s):s=m[12],m[13]===Symbol.for("react.memo_cache_sentinel")?(c=(0,a.jsx)(lG,{}),d=(0,a.jsx)(lQ,{}),u=(0,a.jsx)(lz,{}),l=(0,a.jsx)(lT,{}),m[13]=l,m[14]=c,m[15]=d,m[16]=u):(l=m[13],c=m[14],d=m[15],u=m[16]),m[17]!==s?(h=(0,a.jsxs)("div",{className:lw.default.PlayerHUD,children:[e,s,c,d,u,l]}),m[17]=s,m[18]=h):h=m[18],h}function l5(e){return e.playback.streamSnapshot}function l4(){let{audioLoader:e,audioListener:t}=(0,o0.useAudio)(),a=(0,v.useSettings)(),r=a?.audioEnabled??!1,i=(0,I.useEngineSelector)(e=>e.playback.streamSnapshot?.chatMessages),s=(0,I.useEngineSelector)(e=>e.playback.streamSnapshot?.timeSec),l=(0,n.useRef)(new WeakSet),d=(0,n.useRef)(new Map);return(0,n.useEffect)(()=>{if(!r||!e||!t||!i?.length||null==s)return;let a=l.current,n=d.current;for(let r of i){if(!a.has(r)){if((a.add(r),r.soundPath)&&!(Math.abs(s-r.timeSec)>2))try{let a=(0,c.audioToUrl)(r.soundPath),i=r.soundPitch??1,s=I.engineStore.getState().playback.rate,l=r.sender;(0,o8.getCachedAudioBuffer)(a,e,e=>{if(l){let e=n.get(l);if(e){try{e.stop()}catch{}(0,o8.untrackDemoSound)(e),e.disconnect(),n.delete(l)}}let a=new o.Audio(t);a.setBuffer(e),a.setPlaybackRate(i*s),(0,o8.trackDemoSound)(a,i),l&&n.set(l,a),a.play(),a.source.onended=()=>{(0,o8.untrackDemoSound)(a),a.disconnect(),l&&n.get(l)===a&&n.delete(l)}})}catch{}}}},[r,e,t,i,s]),null}var l6=e.i(38847),l8=e.i(3011);let l7=(0,n.lazy)(()=>e.A(59197).then(e=>({default:e.MapInfoDialog}))),l9=new eW.QueryClient,ce={toneMapping:o.NoToneMapping,outputColorSpace:o.SRGBColorSpace},ct=(0,l6.createParser)({parse(e){let[t,a]=e.split("~"),r=a,n=(0,eG.getMissionInfo)(t).missionTypes;return a&&n.includes(a)||(r=n[0]),{missionName:t,missionType:r}},serialize:({missionName:e,missionType:t})=>1===(0,eG.getMissionInfo)(e).missionTypes.length?e:`${e}~${t}`,eq:(e,t)=>e.missionName===t.missionName&&e.missionType===t.missionType}).withDefault({missionName:"RiverDance",missionType:"CTF"});function ca(){let e,t,s,l,c,d,u,h,m,f,g,p,y,F,b,S,x,k,w,I,C,_,P,D,M,T,E,B,j,R,N,A,G,U,L,z,O,V,q,H=(0,r.c)(69),[W,$]=(0,l6.useQueryState)("mission",ct),[Y,K]=(0,l6.useQueryState)("fog",l6.parseAsBoolean);H[0]!==K?(e=()=>{K(null)},H[0]=K,H[1]=e):e=H[1];let X=e;H[2]!==X||H[3]!==$?(t=e=>{window.location.hash="",X(),$(e)},H[2]=X,H[3]=$,H[4]=t):t=H[4];let Z=t,J=(z=(0,r.c)(2),O=(0,n.useRef)(null),z[0]===Symbol.for("react.memo_cache_sentinel")?(U=e=>{let t=window.matchMedia("(pointer: coarse)");return t.addEventListener("change",e),O.current=t,()=>{t.removeEventListener("change",e)}},z[0]=U):U=z[0],V=U,z[1]===Symbol.for("react.memo_cache_sentinel")?(L=()=>O.current?.matches??null,z[1]=L):L=z[1],q=L,(0,n.useSyncExternalStore)(V,q,oX)),{missionName:Q,missionType:ee}=W,[et,ea]=(0,n.useState)(!1),[er,en]=(0,n.useState)(0),[ei,eo]=(0,n.useState)(!0),es=er<1;H[5]!==es?(s=()=>{if(es)eo(!0);else{let e=setTimeout(()=>eo(!1),500);return()=>clearTimeout(e)}},l=[es],H[5]=es,H[6]=s,H[7]=l):(s=H[6],l=H[7]),(0,n.useEffect)(s,l),H[8]!==Z?(c=()=>(window.setMissionName=e=>{let t=(0,eG.getMissionInfo)(e).missionTypes;Z({missionName:e,missionType:t[0]})},window.getMissionList=eG.getMissionList,window.getMissionInfo=eG.getMissionInfo,cr),d=[Z],H[8]=Z,H[9]=c,H[10]=d):(c=H[9],d=H[10]),(0,n.useEffect)(c,d),H[11]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{let e=e=>{if("KeyI"!==e.code||e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target;"INPUT"===t.tagName||"TEXTAREA"===t.tagName||t.isContentEditable||ea(!0)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},h=[],H[11]=u,H[12]=h):(u=H[11],h=H[12]),(0,n.useEffect)(u,h),H[13]===Symbol.for("react.memo_cache_sentinel")?(m=(e,t)=>{en(void 0===t?0:t)},H[13]=m):m=H[13];let el=m,ec=(0,n.useRef)(null);H[14]===Symbol.for("react.memo_cache_sentinel")?(f={angle:0,force:0},H[14]=f):f=H[14];let ed=(0,n.useRef)(f),eu=(0,n.useRef)(null);H[15]===Symbol.for("react.memo_cache_sentinel")?(g={angle:0,force:0},H[15]=g):g=H[15];let eh=(0,n.useRef)(g),em=(0,n.useRef)(null);H[16]!==es||H[17]!==er||H[18]!==ei?(p=ei&&(0,a.jsxs)("div",{id:"loadingIndicator",className:l8.default.LoadingIndicator,"data-complete":!es,children:[(0,a.jsx)("div",{className:l8.default.Spinner}),(0,a.jsx)("div",{className:l8.default.Progress,children:(0,a.jsx)("div",{className:l8.default.ProgressBar,style:{width:`${100*er}%`}})}),(0,a.jsxs)("div",{className:l8.default.ProgressText,children:[Math.round(100*er),"%"]})]}),H[16]=es,H[17]=er,H[18]=ei,H[19]=p):p=H[19],H[20]===Symbol.for("react.memo_cache_sentinel")?(y={type:o.PCFShadowMap},F=e=>{ec.current=e.camera},H[20]=y,H[21]=F):(y=H[20],F=H[21]);let ef=`${Q}~${ee}`;return H[22]!==Q||H[23]!==ee||H[24]!==ef?(b=(0,a.jsx)(eH,{name:Q,missionType:ee,onLoadingChange:el},ef),H[22]=Q,H[23]=ee,H[24]=ef,H[25]=b):b=H[25],H[26]===Symbol.for("react.memo_cache_sentinel")?(S=(0,a.jsx)(oQ,{}),x=(0,a.jsx)(o1.DebugElements,{}),k=(0,a.jsx)(lg,{}),w=(0,a.jsx)(l4,{}),H[26]=S,H[27]=x,H[28]=k,H[29]=w):(S=H[26],x=H[27],k=H[28],w=H[29]),H[30]!==J?(I=(0,a.jsx)(co,{isTouch:J,joystickStateRef:ed,joystickZoneRef:eu,lookJoystickStateRef:eh,lookJoystickZoneRef:em}),H[30]=J,H[31]=I):I=H[31],H[32]!==b||H[33]!==I?(C=(0,a.jsx)(i.Canvas,{frameloop:"always",gl:ce,shadows:y,onCreated:F,children:(0,a.jsx)(ew,{children:(0,a.jsxs)(o0.AudioProvider,{children:[b,S,x,k,w,I]})})}),H[32]=b,H[33]=I,H[34]=C):C=H[34],H[35]!==p||H[36]!==C?(_=(0,a.jsxs)("div",{id:"canvasContainer",className:l8.default.CanvasContainer,children:[p,C]}),H[35]=p,H[36]=C,H[37]=_):_=H[37],H[38]===Symbol.for("react.memo_cache_sentinel")?(P=(0,a.jsx)(l3,{}),H[38]=P):P=H[38],H[39]!==J?(D=J&&(0,a.jsx)(tB,{joystickState:ed,joystickZone:eu,lookJoystickState:eh,lookJoystickZone:em}),H[39]=J,H[40]=D):D=H[40],H[41]!==J?(M=!1===J&&(0,a.jsx)(tF,{}),H[41]=J,H[42]=M):M=H[42],H[43]===Symbol.for("react.memo_cache_sentinel")?(T=()=>ea(!0),H[43]=T):T=H[43],H[44]!==Z||H[45]!==J||H[46]!==Q||H[47]!==ee?(E=(0,a.jsx)(oH,{missionName:Q,missionType:ee,onChangeMission:Z,onOpenMapInfo:T,cameraRef:ec,isTouch:J}),H[44]=Z,H[45]=J,H[46]=Q,H[47]=ee,H[48]=E):E=H[48],H[49]!==et||H[50]!==Q||H[51]!==ee?(B=et&&(0,a.jsx)(n.Suspense,{fallback:null,children:(0,a.jsx)(l7,{open:et,onClose:()=>ea(!1),missionName:Q,missionType:ee??""})}),H[49]=et,H[50]=Q,H[51]=ee,H[52]=B):B=H[52],H[53]!==Z||H[54]!==W?(j=(0,a.jsx)(ci,{changeMission:Z,currentMission:W}),H[53]=Z,H[54]=W,H[55]=j):j=H[55],H[56]===Symbol.for("react.memo_cache_sentinel")?(R=(0,a.jsx)(lF,{}),N=(0,a.jsx)(cs,{}),H[56]=R,H[57]=N):(R=H[56],N=H[57]),H[58]!==_||H[59]!==D||H[60]!==M||H[61]!==E||H[62]!==B||H[63]!==j?(A=(0,a.jsxs)(eJ,{map:ta,children:[_,P,D,M,E,B,j,R,N]}),H[58]=_,H[59]=D,H[60]=M,H[61]=E,H[62]=B,H[63]=j,H[64]=A):A=H[64],H[65]!==X||H[66]!==Y||H[67]!==A?(G=(0,a.jsx)(e$.QueryClientProvider,{client:l9,children:(0,a.jsx)("main",{children:(0,a.jsx)(to,{children:(0,a.jsx)(v.SettingsProvider,{fogEnabledOverride:Y,onClearFogEnabledOverride:X,children:A})})})}),H[65]=X,H[66]=Y,H[67]=A,H[68]=G):G=H[68],G}function cr(){delete window.setMissionName,delete window.getMissionList,delete window.getMissionInfo}let cn={"Capture the Flag":"CTF","Capture and Hold":"CnH",Deathmatch:"DM","Team Deathmatch":"TDM",Siege:"Siege",Bounty:"Bounty",Rabbit:"Rabbit"};function ci(e){let t,a,i=(0,r.c)(5),{changeMission:o,currentMission:s}=e,l=ts();return i[0]!==o||i[1]!==s||i[2]!==l?(t=()=>{if(!l?.missionName)return;let e=(0,eG.findMissionByDemoName)(l.missionName);if(!e)return void console.warn(`Demo mission "${l.missionName}" not found in manifest`);let t=(0,eG.getMissionInfo)(e),a=l.gameType?cn[l.gameType]:void 0,r=a&&t.missionTypes.includes(a)?a:t.missionTypes[0];(s.missionName!==e||s.missionType!==r)&&o({missionName:e,missionType:r})},a=[l,o,s],i[0]=o,i[1]=s,i[2]=l,i[3]=t,i[4]=a):(t=i[3],a=i[4]),(0,n.useEffect)(t,a),null}function co(e){let t,n=(0,r.c)(6),{isTouch:i,joystickStateRef:o,joystickZoneRef:s,lookJoystickStateRef:l,lookJoystickZoneRef:c}=e;if(ts()||null===i)return null;if(i){let e;return n[0]!==o||n[1]!==s||n[2]!==l||n[3]!==c?(e=(0,a.jsx)(tj,{joystickState:o,joystickZone:s,lookJoystickState:l,lookJoystickZone:c}),n[0]=o,n[1]=s,n[2]=l,n[3]=c,n[4]=e):e=n[4],e}return n[5]===Symbol.for("react.memo_cache_sentinel")?(t=(0,a.jsx)(tr,{}),n[5]=t):t=n[5],t}function cs(){let e,t,a=(0,r.c)(3),{setRecording:i}=tm();return a[0]!==i?(e=()=>(window.loadDemoRecording=i,cl),t=[i],a[0]=i,a[1]=e,a[2]=t):(e=a[1],t=a[2]),(0,n.useEffect)(e,t),null}function cl(){delete window.loadDemoRecording}function cc(){let e,t=(0,r.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,a.jsx)(n.Suspense,{children:(0,a.jsx)(ca,{})}),t[0]=e):e=t[0],e}e.s(["default",()=>cc],31713)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/e16c267496b8de91.js b/docs/_next/static/chunks/e16c267496b8de91.js new file mode 100644 index 00000000..c0ca6a51 --- /dev/null +++ b/docs/_next/static/chunks/e16c267496b8de91.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,29055,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(15080),o=e.i(71753),i=e.i(90072),u=e.i(12979),a=e.i(51434),c=e.i(79123),s=e.i(89887);e.i(13876);var l=e.i(58647);let f=new Map,d=new Map;function p(e,t=1){d.set(e,t)}function h(e){d.delete(e)}let y=0;function m(){return y}function g(){for(let[e]of(y++,d)){try{e.stop()}catch{}try{e.disconnect()}catch{}}d.clear()}function S(e,t){let r=t(e),n=r?.filename;if(!n)return null;let o=n.endsWith(".wav")?n:`${n}.wav`,i=r.description,u=null!=i?t(i):void 0,a=u?.is3D??!0,c=u?.isLooping??!1,s=u?.referenceDistance??20;return{filename:o,is3D:a,isLooping:c,refDist:s,maxDist:u?.maxDistance??100,volume:u?.volume??1}}function b(e,t,r,n,o){let a;try{a=(0,u.audioToUrl)(e.filename)}catch{return}let c=l.engineStore.getState().playback.rate,s=y;R(a,r,r=>{if(s===y)try{if(e.is3D&&o){let u=new i.PositionalAudio(t);u.setBuffer(r),u.setDistanceModel("inverse"),u.setRefDistance(e.refDist),u.setMaxDistance(e.maxDist),u.setRolloffFactor(1),u.setVolume(e.volume),u.setPlaybackRate(c),n&&u.position.copy(n),o.add(u),d.set(u,1),u.play(),u.source.onended=()=>{d.delete(u);try{u.disconnect()}catch{}o.remove(u)}}else{let n=new i.Audio(t);n.setBuffer(r),n.setVolume(e.volume),n.setPlaybackRate(c),d.set(n,1),n.play(),n.source.onended=()=>{d.delete(n);try{n.disconnect()}catch{}}}}catch{}})}function R(e,t,r){f.has(e)?r(f.get(e)):t.load(e,t=>{f.set(e,t),r(t)},void 0,t=>{console.error("Audio load error",e,t)})}l.engineStore.subscribe(e=>e.playback.rate,e=>{for(let[t,r]of d)try{t.setPlaybackRate(r*e)}catch{}});let v=(0,r.memo)(function({entity:e}){let{debugMode:l}=(0,c.useDebug)(),f=e.audioFileName??"",d=e.audioVolume??1,p=e.audioMinDistance??1,h=e.audioMaxDistance??1,y=e.audioMinLoopGap??0,m=e.audioMaxLoopGap??0,g=e.audioIs3D??!0?1:0,S=e.audioIsLooping??!0,[b,v,M]=e.position??[0,0,0],{scene:D,camera:k}=(0,n.useThree)(),{audioLoader:A,audioListener:P}=(0,a.useAudio)(),{audioEnabled:T}=(0,c.useSettings)(),w=(0,r.useRef)(null),x=(0,r.useRef)(null),B=(0,r.useRef)(null),E=(0,r.useRef)(!1),C=(0,r.useRef)(!1),G=(0,r.useRef)(new i.Vector3(b,v,M)),L=(0,r.useRef)(0),V=()=>{null!=x.current&&(clearTimeout(x.current),x.current=null),null!=B.current&&(clearTimeout(B.current),B.current=null)};(0,r.useEffect)(()=>{let e;if(A&&P){if(L.current++,g){let t=new i.PositionalAudio(P);t.position.copy(G.current),t.setDistanceModel("inverse"),t.setRefDistance(p),t.setMaxDistance(h),t.setRolloffFactor(1),t.setVolume(d),e=t,D.add(e)}else(e=new i.Audio(P)).setVolume(d);return w.current=e,()=>{V();try{e.stop()}catch{}try{e.disconnect()}catch{}g&&D.remove(e),w.current=null,E.current=!1,C.current=!1}}},[A,P,g,p,h,d,D]);let j=(e,t)=>{if(S)if(y>0||m>0){let r=Math.max(0,y),n=Math.max(r,m),o=r===n?r:Math.random()*(n-r)+r;e.loop=!1;let i=()=>{t===L.current&&(!1===e.isPlaying?x.current=setTimeout(()=>{if(t===L.current)try{e.play(),j(e,t)}catch{}},o):B.current=setTimeout(i,100))};B.current=setTimeout(i,100)}else e.setLoop(!0)},F=e=>{if(!A)return;let t=L.current;if(E.current)try{e.isPlaying||(e.play(),j(e,t))}catch{}else{let r;try{r=(0,u.audioToUrl)(f)}catch{return}R(r,A,r=>{if(t===L.current&&!e.buffer){e.setBuffer(r),E.current=!0;try{e.play(),j(e,t)}catch{}}})}};return(0,r.useEffect)(()=>{let e=w.current;e&&!g&&T&&f&&F(e)},[T,g,f,A,P]),(0,o.useFrame)(()=>{let e=w.current;if(!e||!g||!T||!f)return;let t=k.position.distanceTo(G.current),r=C.current,n=t<=h;if(n&&!r)C.current=!0,F(e);else if(!n&&r){C.current=!1,V();try{e.stop()}catch{}}}),(0,r.useEffect)(()=>{let e=w.current;if(e&&!T){V();try{e.stop()}catch{}C.current=!1}},[T]),l?(0,t.jsxs)("mesh",{position:G.current,children:[(0,t.jsx)("sphereGeometry",{args:[p,12,12]}),(0,t.jsx)("meshBasicMaterial",{color:"#00ff00",wireframe:!0,opacity:.05,transparent:!0,toneMapped:!1}),(0,t.jsx)(s.FloatingLabel,{color:"#00ff00",position:[0,p+1,0],children:f})]}):null});e.s(["AudioEmitter",0,v,"audioBufferCache",0,f,"getCachedAudioBuffer",()=>R,"getSoundGeneration",()=>m,"playOneShotSound",()=>b,"resolveAudioProfile",()=>S,"stopAllTrackedSounds",()=>g,"trackSound",()=>p,"untrackSound",()=>h])},9962,e=>{"use strict";var t=e.i(71645),r=e.i(90072),n=e.i(12979),o=e.i(51434),i=e.i(29055),u=e.i(79123);e.i(13876);var a=e.i(58647);function c(){let{audioLoader:e,audioListener:c}=(0,o.useAudio)(),s=(0,u.useSettings)(),l=s?.audioEnabled??!1,f=(0,a.useEngineSelector)(e=>e.playback.streamSnapshot?.chatMessages),d=(0,a.useEngineSelector)(e=>e.playback.streamSnapshot?.timeSec),p=(0,t.useRef)(new WeakSet),h=(0,t.useRef)(new Map);return(0,t.useEffect)(()=>{if(!l||!e||!c||!f?.length||null==d)return;let t=p.current,o=h.current;for(let u of f){if(!t.has(u)){if((t.add(u),u.soundPath)&&!(Math.abs(d-u.timeSec)>2))try{let t=(0,n.audioToUrl)(u.soundPath),s=u.soundPitch??1,l=a.engineStore.getState().playback.rate,f=u.sender,d=(0,i.getSoundGeneration)();(0,i.getCachedAudioBuffer)(t,e,e=>{if(d!==(0,i.getSoundGeneration)())return;if(f){let e=o.get(f);if(e){try{e.stop()}catch{}(0,i.untrackSound)(e);try{e.disconnect()}catch{}o.delete(f)}}let t=new r.Audio(c);t.setBuffer(e),t.setPlaybackRate(s*l),(0,i.trackSound)(t,s),f&&o.set(f,t),t.play(),t.source.onended=()=>{(0,i.untrackSound)(t);try{t.disconnect()}catch{}f&&o.get(f)===t&&o.delete(f)}})}catch{}}}},[l,e,c,f,d]),null}e.s(["ChatSoundPlayer",()=>c])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/e1a8caa90a5343cf.js b/docs/_next/static/chunks/e1a8caa90a5343cf.js new file mode 100644 index 00000000..e1854e20 --- /dev/null +++ b/docs/_next/static/chunks/e1a8caa90a5343cf.js @@ -0,0 +1,17 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,92552,(e,t,r)=>{"use strict";let n,s;function i(e,t){return t.reduce((e,[t,r])=>({type:"BinaryExpression",operator:t,left:e,right:r}),e)}function o(e,t){return{type:"UnaryExpression",operator:e,argument:t}}class a extends SyntaxError{constructor(e,t,r,n){super(e),this.expected=t,this.found=r,this.location=n,this.name="SyntaxError"}format(e){let t="Error: "+this.message;if(this.location){let r=null,n=e.find(e=>e.source===this.location.source);n&&(r=n.text.split(/\r\n|\n|\r/g));let s=this.location.start,i=this.location.source&&"function"==typeof this.location.source.offset?this.location.source.offset(s):s,o=this.location.source+":"+i.line+":"+i.column;if(r){let e=this.location.end,n="".padEnd(i.line.toString().length," "),a=r[s.line-1],l=(s.line===e.line?e.column:a.length+1)-s.column||1;t+="\n --> "+o+"\n"+n+" |\n"+i.line+" | "+a+"\n"+n+" | "+"".padEnd(s.column-1," ")+"".padEnd(l,"^")}else t+="\n at "+o}return t}static buildMessage(e,t){function r(e){return e.codePointAt(0).toString(16).toUpperCase()}let n=Object.prototype.hasOwnProperty.call(RegExp.prototype,"unicode")?RegExp("[\\p{C}\\p{Mn}\\p{Mc}]","gu"):null;function s(e){return n?e.replace(n,e=>"\\u{"+r(e)+"}"):e}function i(e){return s(e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}function o(e){return s(e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,e=>"\\x0"+r(e)).replace(/[\x10-\x1F\x7F-\x9F]/g,e=>"\\x"+r(e)))}let a={literal:e=>'"'+i(e.text)+'"',class(e){let t=e.parts.map(e=>Array.isArray(e)?o(e[0])+"-"+o(e[1]):o(e));return"["+(e.inverted?"^":"")+t.join("")+"]"+(e.unicode?"u":"")},any:()=>"any character",end:()=>"end of input",other:e=>e.description};function l(e){return a[e.type](e)}return"Expected "+function(e){let t=e.map(l);if(t.sort(),t.length>0){let e=1;for(let r=1;r]/,k=/^[+\-]/,R=/^[%*\/]/,L=/^[!\-~]/,N=/^[a-zA-Z_]/,O=/^[a-zA-Z0-9_]/,I=/^[ \t]/,j=/^[^"\\\n\r]/,T=/^[^'\\\n\r]/,M=/^[0-9a-fA-F]/,B=/^[0-9]/,P=/^[xX]/,H=/^[^\n\r]/,D=/^[\n\r]/,F=/^[ \t\n\r]/,G=tE(";",!1),U=tE("package",!1),q=tE("{",!1),J=tE("}",!1),K=tE("function",!1),W=tE("(",!1),z=tE(")",!1),V=tE("::",!1),Z=tE(",",!1),Q=tE("datablock",!1),X=tE(":",!1),Y=tE("new",!1),ee=tE("[",!1),et=tE("]",!1),er=tE("=",!1),en=tE(".",!1),es=tE("if",!1),ei=tE("else",!1),eo=tE("for",!1),ea=tE("while",!1),el=tE("do",!1),eu=tE("switch$",!1),ec=tE("switch",!1),ep=tE("case",!1),ef=tE("default",!1),eh=tE("or",!1),ed=tE("return",!1),eg=tE("break",!1),em=tE("continue",!1),eb=tE("+=",!1),e$=tE("-=",!1),ey=tE("*=",!1),ex=tE("/=",!1),eA=tE("%=",!1),eC=tE("<<=",!1),eS=tE(">>=",!1),ev=tE("&=",!1),ew=tE("|=",!1),eE=tE("^=",!1),e_=tE("?",!1),ek=tE("||",!1),eR=tE("&&",!1),eL=tE("|",!1),eN=tE("^",!1),eO=tE("&",!1),eI=tE("==",!1),ej=tE("!=",!1),eT=tE("<=",!1),eM=tE(">=",!1),eB=t_(["<",">"],!1,!1,!1),eP=tE("$=",!1),eH=tE("!$=",!1),eD=tE("@",!1),eF=tE("NL",!1),eG=tE("TAB",!1),eU=tE("SPC",!1),eq=tE("<<",!1),eJ=tE(">>",!1),eK=t_(["+","-"],!1,!1,!1),eW=t_(["%","*","/"],!1,!1,!1),ez=t_(["!","-","~"],!1,!1,!1),eV=tE("++",!1),eZ=tE("--",!1),eQ=tE("*",!1),eX=tE("%",!1),eY=t_([["a","z"],["A","Z"],"_"],!1,!1,!1),e0=t_([["a","z"],["A","Z"],["0","9"],"_"],!1,!1,!1),e1=tE("$",!1),e2=tE("parent",!1),e4=t_([" "," "],!1,!1,!1),e3=tE('"',!1),e9=tE("'",!1),e5=tE("\\",!1),e6=t_(['"',"\\","\n","\r"],!0,!1,!1),e8=t_(["'","\\","\n","\r"],!0,!1,!1),e7=tE("n",!1),te=tE("r",!1),tt=tE("t",!1),tr=tE("x",!1),tn=t_([["0","9"],["a","f"],["A","F"]],!1,!1,!1),ts=tE("cr",!1),ti=tE("cp",!1),to=tE("co",!1),ta=tE("c",!1),tl=t_([["0","9"]],!1,!1,!1),tu={type:"any"},tc=tE("0",!1),tp=t_(["x","X"],!1,!1,!1),tf=tE("-",!1),th=tE("true",!1),td=tE("false",!1),tg=tE("//",!1),tm=t_(["\n","\r"],!0,!1,!1),tb=t_(["\n","\r"],!1,!1,!1),t$=tE("/*",!1),ty=tE("*/",!1),tx=t_([" "," ","\n","\r"],!1,!1,!1),tA=0|t.peg$currPos,tC=[{line:1,column:1}],tS=tA,tv=t.peg$maxFailExpected||[],tw=0|t.peg$silentFails;if(t.startRule){if(!(t.startRule in c))throw Error("Can't start parsing from rule \""+t.startRule+'".');p=c[t.startRule]}function tE(e,t){return{type:"literal",text:e,ignoreCase:t}}function t_(e,t,r,n){return{type:"class",parts:e,inverted:t,ignoreCase:r,unicode:n}}function tk(t){let r,n=tC[t];if(n)return n;if(t>=tC.length)r=tC.length-1;else for(r=t;!tC[--r];);for(n={line:(n=tC[r]).line,column:n.column};rtS&&(tS=tA,tv=[]),tv.push(e))}function tN(){let e,t,r;for(rp(),e=[],t=tA,(r=rl())===l&&(r=tO()),r!==l?t=r=[r,rp()]:(tA=t,t=l);t!==l;)e.push(t),t=tA,(r=rl())===l&&(r=tO()),r!==l?t=r=[r,rp()]:(tA=t,t=l);return{type:"Program",body:e.map(([e])=>e).filter(Boolean),execScriptPaths:Array.from(n),hasDynamicExec:s}}function tO(){let t,r,n,s,i,o,a,u,c,p,d,y,x,v,w,E,_;return(t=function(){let t,r,n,s,i,o,a,u;if(t=tA,e.substr(tA,7)===f?(r=f,tA+=7):(r=l,0===tw&&tL(U)),r!==l)if(rc()!==l)if((n=rn())!==l)if(ru(),123===e.charCodeAt(tA)?(s="{",tA++):(s=l,0===tw&&tL(q)),s!==l){for(rp(),i=[],o=tA,(a=rl())===l&&(a=tO()),a!==l?o=a=[a,u=rp()]:(tA=o,o=l);o!==l;)i.push(o),o=tA,(a=rl())===l&&(a=tO()),a!==l?o=a=[a,u=rp()]:(tA=o,o=l);(125===e.charCodeAt(tA)?(o="}",tA++):(o=l,0===tw&&tL(J)),o!==l)?(a=ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),t={type:"PackageDeclaration",name:n,body:i.map(([e])=>e).filter(Boolean)}):(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a;if(t=tA,e.substr(tA,8)===h?(r=h,tA+=8):(r=l,0===tw&&tL(K)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s;if(t=tA,(r=rn())!==l)if("::"===e.substr(tA,2)?(n="::",tA+=2):(n=l,0===tw&&tL(V)),n!==l)if((s=rn())!==l)t={type:"MethodName",namespace:r,method:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=rn()),t}())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=function(){let t,r,n,s,i,o,a,u;if(t=tA,(r=rn())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=rn())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=rn())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=[r,...n.map(([,,,e])=>e)]}else tA=t,t=l;return t}())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l)if(ru(),(a=tF())!==l)t={type:"FunctionDeclaration",name:n,params:i||[],body:a};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&((n=tA,(s=tI())!==l)?(ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i===l&&(i=null),ru(),n=s):(tA=n,n=l),(t=n)===l&&((o=tA,(a=tj())!==l)?(ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),ru(),o=a):(tA=o,o=l),(t=o)===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p,f;if(t=tA,"if"===e.substr(tA,2)?(r="if",tA+=2):(r=l,0===tw&&tL(es)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),(o=tO())!==l){var h;a=tA,u=ru(),e.substr(tA,4)===g?(c=g,tA+=4):(c=l,0===tw&&tL(ei)),c!==l?(p=ru(),(f=tO())!==l?a=u=[u,c,p,f]:(tA=a,a=l)):(tA=a,a=l),a===l&&(a=null),t={type:"IfStatement",test:s,consequent:o,alternate:(h=a)?h[3]:null}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p;if(t=tA,"for"===e.substr(tA,3)?(r="for",tA+=3):(r=l,0===tw&&tL(eo)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())===l&&(s=null),ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i!==l)if(ru(),(o=tG())===l&&(o=null),ru(),59===e.charCodeAt(tA)?(a=";",tA++):(a=l,0===tw&&tL(G)),a!==l)if(ru(),(u=tG())===l&&(u=null),ru(),41===e.charCodeAt(tA)?(c=")",tA++):(c=l,0===tw&&tL(z)),c!==l)if(ru(),(p=tO())!==l){var f,h;f=s,h=o,t={type:"ForStatement",init:f,test:h,update:u,body:p}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u;if(t=tA,"do"===e.substr(tA,2)?(r="do",tA+=2):(r=l,0===tw&&tL(el)),r!==l)if(ru(),(n=tO())!==l)if(ru(),e.substr(tA,5)===m?(s=m,tA+=5):(s=l,0===tw&&tL(ea)),s!==l)if(ru(),40===e.charCodeAt(tA)?(i="(",tA++):(i=l,0===tw&&tL(W)),i!==l)if(ru(),(o=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(a=")",tA++):(a=l,0===tw&&tL(z)),a!==l)ru(),59===e.charCodeAt(tA)?(u=";",tA++):(u=l,0===tw&&tL(G)),u===l&&(u=null),t={type:"DoWhileStatement",test:o,body:n};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o;if(t=tA,e.substr(tA,5)===m?(r=m,tA+=5):(r=l,0===tw&&tL(ea)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),(o=tO())!==l)t={type:"WhileStatement",test:s,body:o};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a,u,c,p;if(t=tA,e.substr(tA,7)===b?(r=b,tA+=7):(r=l,0===tw&&tL(eu)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),123===e.charCodeAt(tA)?(o="{",tA++):(o=l,0===tw&&tL(q)),o!==l){for(rp(),a=[],u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);u!==l;)a.push(u),u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);(125===e.charCodeAt(tA)?(u="}",tA++):(u=l,0===tw&&tL(J)),u!==l)?t={type:"SwitchStatement",stringMode:!0,discriminant:s,cases:a.map(([e])=>e).filter(e=>e&&"SwitchCase"===e.type)}:(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;if(t===l)if(t=tA,e.substr(tA,6)===$?(r=$,tA+=6):(r=l,0===tw&&tL(ec)),r!==l)if(ru(),40===e.charCodeAt(tA)?(n="(",tA++):(n=l,0===tw&&tL(W)),n!==l)if(ru(),(s=tG())!==l)if(ru(),41===e.charCodeAt(tA)?(i=")",tA++):(i=l,0===tw&&tL(z)),i!==l)if(ru(),123===e.charCodeAt(tA)?(o="{",tA++):(o=l,0===tw&&tL(q)),o!==l){for(rp(),a=[],u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);u!==l;)a.push(u),u=tA,(c=rl())===l&&(c=tD()),c!==l?u=c=[c,p=rp()]:(tA=u,u=l);(125===e.charCodeAt(tA)?(u="}",tA++):(u=l,0===tw&&tL(J)),u!==l)?t={type:"SwitchStatement",stringMode:!1,discriminant:s,cases:a.map(([e])=>e).filter(e=>e&&"SwitchCase"===e.type)}:(tA=t,t=l)}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i;if(t=tA,e.substr(tA,6)===A?(r=A,tA+=6):(r=l,0===tw&&tL(ed)),r!==l)if(n=tA,(s=rc())!==l&&(i=tG())!==l?n=s=[s,i]:(tA=n,n=l),n===l&&(n=null),s=ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i!==l){var o;t={type:"ReturnStatement",value:(o=n)?o[1]:null}}else tA=t,t=l;else tA=t,t=l;return t}())===l&&(c=tA,e.substr(tA,5)===C?(p=C,tA+=5):(p=l,0===tw&&tL(eg)),p!==l?(ru(),59===e.charCodeAt(tA)?(d=";",tA++):(d=l,0===tw&&tL(G)),d!==l?c={type:"BreakStatement"}:(tA=c,c=l)):(tA=c,c=l),(t=c)===l&&(y=tA,e.substr(tA,8)===S?(x=S,tA+=8):(x=l,0===tw&&tL(em)),x!==l?(ru(),59===e.charCodeAt(tA)?(v=";",tA++):(v=l,0===tw&&tL(G)),v!==l?y={type:"ContinueStatement"}:(tA=y,y=l)):(tA=y,y=l),(t=y)===l&&((w=tA,(E=tG())!==l&&(ru(),59===e.charCodeAt(tA)?(_=";",tA++):(_=l,0===tw&&tL(G)),_!==l))?w={type:"ExpressionStatement",expression:E}:(tA=w,w=l),(t=w)===l&&(t=tF())===l&&(t=rl())===l)))))&&(t=tA,ru(),59===e.charCodeAt(tA)?(r=";",tA++):(r=l,0===tw&&tL(G)),r!==l?(ru(),t=null):(tA=t,t=l)),t}function tI(){let t,r,n,s,i,o,a,u,c,p,f,h,g,m;if(t=tA,e.substr(tA,9)===d?(r=d,tA+=9):(r=l,0===tw&&tL(Q)),r!==l)if(rc()!==l)if((n=rn())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=tM())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l){var b,$,y;if(ru(),a=tA,58===e.charCodeAt(tA)?(u=":",tA++):(u=l,0===tw&&tL(X)),u!==l?(c=ru(),(p=rn())!==l?a=u=[u,c,p]:(tA=a,a=l)):(tA=a,a=l),a===l&&(a=null),u=ru(),c=tA,123===e.charCodeAt(tA)?(p="{",tA++):(p=l,0===tw&&tL(q)),p!==l){for(f=ru(),h=[],g=tT();g!==l;)h.push(g),g=tT();g=ru(),125===e.charCodeAt(tA)?(m="}",tA++):(m=l,0===tw&&tL(J)),m!==l?c=p=[p,f,h,g,m,ru()]:(tA=c,c=l)}else tA=c,c=l;c===l&&(c=null),b=i,$=a,y=c,t={type:"DatablockDeclaration",className:n,instanceName:b,parent:$?$[2]:null,body:y?y[2].filter(Boolean):[]}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}function tj(){let t,r,n,s,i,o,a,u,c,p,f,h;if(t=tA,"new"===e.substr(tA,3)?(r="new",tA+=3):(r=l,0===tw&&tL(Y)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s,i,o,a,u,c,p;if((t=tA,40===e.charCodeAt(tA)?(r="(",tA++):(r=l,0===tw&&tL(W)),r!==l&&(n=ru(),(s=tG())!==l&&(i=ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l)))?t=s:(tA=t,t=l),t===l)if(t=tA,(r=rn())!==l){var f;for(n=[],s=tA,i=ru(),91===e.charCodeAt(tA)?(o="[",tA++):(o=l,0===tw&&tL(ee)),o!==l?(a=ru(),(u=tH())!==l?(c=ru(),93===e.charCodeAt(tA)?(p="]",tA++):(p=l,0===tw&&tL(et)),p!==l?s=i=[i,o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),91===e.charCodeAt(tA)?(o="[",tA++):(o=l,0===tw&&tL(ee)),o!==l?(a=ru(),(u=tH())!==l?(c=ru(),93===e.charCodeAt(tA)?(p="]",tA++):(p=l,0===tw&&tL(et)),p!==l?s=i=[i,o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);f=r,t=n.reduce((e,[,,,t])=>({type:"IndexExpression",object:e,index:t}),f)}else tA=t,t=l;return t}())!==l)if(ru(),40===e.charCodeAt(tA)?(s="(",tA++):(s=l,0===tw&&tL(W)),s!==l)if(ru(),(i=tM())===l&&(i=null),ru(),41===e.charCodeAt(tA)?(o=")",tA++):(o=l,0===tw&&tL(z)),o!==l){var d;if(ru(),a=tA,123===e.charCodeAt(tA)?(u="{",tA++):(u=l,0===tw&&tL(q)),u!==l){for(c=ru(),p=[],f=tT();f!==l;)p.push(f),f=tT();f=ru(),125===e.charCodeAt(tA)?(h="}",tA++):(h=l,0===tw&&tL(J)),h!==l?a=u=[u,c,p,f,h,ru()]:(tA=a,a=l)}else tA=a,a=l;a===l&&(a=null),t={type:"ObjectDeclaration",className:n,instanceName:i,body:(d=a)?d[2].filter(Boolean):[]}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}function tT(){let t,r,n;return(t=tA,(r=tj())!==l)?(ru(),59===e.charCodeAt(tA)?(n=";",tA++):(n=l,0===tw&&tL(G)),n===l&&(n=null),ru(),t=r):(tA=t,t=l),t===l&&((t=tA,(r=tI())!==l)?(ru(),59===e.charCodeAt(tA)?(n=";",tA++):(n=l,0===tw&&tL(G)),n===l&&(n=null),ru(),t=r):(tA=t,t=l),t===l&&(t=function(){let t,r,n,s,i;if(t=tA,ru(),(r=tB())!==l)if(ru(),61===e.charCodeAt(tA)?(n="=",tA++):(n=l,0===tw&&tL(er)),n!==l)if(ru(),(s=tG())!==l)ru(),59===e.charCodeAt(tA)?(i=";",tA++):(i=l,0===tw&&tL(G)),i===l&&(i=null),ru(),t={type:"Assignment",target:r,value:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t}())===l&&(t=rl())===l&&(t=function(){let t,r;if(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r!==l)for(;r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));else t=l;return t!==l&&(t=null),t}())),t}function tM(){let e;return(e=tY())===l&&(e=rn())===l&&(e=ra()),e}function tB(){let e,t,r,n;if(e=tA,(t=t8())!==l){for(r=[],n=tP();n!==l;)r.push(n),n=tP();e=r.reduce((e,t)=>"property"===t.type?{type:"MemberExpression",object:e,property:t.value}:{type:"IndexExpression",object:e,index:t.value},t)}else tA=e,e=l;return e}function tP(){let t,r,n,s;return(t=tA,46===e.charCodeAt(tA)?(r=".",tA++):(r=l,0===tw&&tL(en)),r!==l&&(ru(),(n=rn())!==l))?t={type:"property",value:n}:(tA=t,t=l),t===l&&((t=tA,91===e.charCodeAt(tA)?(r="[",tA++):(r=l,0===tw&&tL(ee)),r!==l&&(ru(),(n=tH())!==l&&(ru(),93===e.charCodeAt(tA)?(s="]",tA++):(s=l,0===tw&&tL(et)),s!==l)))?t={type:"index",value:n}:(tA=t,t=l)),t}function tH(){let t,r,n,s,i,o,a,u;if(t=tA,(r=tG())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=n.length>0?[r,...n.map(([,,,e])=>e)]:r}else tA=t,t=l;return t}function tD(){let t,r,n,s,i,o,a,u,c;if(t=tA,e.substr(tA,4)===y?(r=y,tA+=4):(r=l,0===tw&&tL(ep)),r!==l)if(rc()!==l)if((n=function(){let t,r,n,s,i,o,a,u;if(t=tA,(r=t3())!==l){for(n=[],s=tA,i=ru(),"or"===e.substr(tA,2)?(o="or",tA+=2):(o=l,0===tw&&tL(eh)),o!==l&&(a=rc())!==l&&(u=t3())!==l?s=i=[i,o,a,u]:(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),"or"===e.substr(tA,2)?(o="or",tA+=2):(o=l,0===tw&&tL(eh)),o!==l&&(a=rc())!==l&&(u=t3())!==l?s=i=[i,o,a,u]:(tA=s,s=l);t=n.length>0?[r,...n.map(([,,,e])=>e)]:r}else tA=t,t=l;return t}())!==l)if(ru(),58===e.charCodeAt(tA)?(s=":",tA++):(s=l,0===tw&&tL(X)),s!==l){for(i=rp(),o=[],a=tA,(u=rl())===l&&(u=tO()),u!==l?a=u=[u,c=rp()]:(tA=a,a=l);a!==l;)o.push(a),a=tA,(u=rl())===l&&(u=tO()),u!==l?a=u=[u,c=rp()]:(tA=a,a=l);t={type:"SwitchCase",test:n,consequent:o.map(([e])=>e).filter(Boolean)}}else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;if(t===l)if(t=tA,e.substr(tA,7)===x?(r=x,tA+=7):(r=l,0===tw&&tL(ef)),r!==l)if(ru(),58===e.charCodeAt(tA)?(n=":",tA++):(n=l,0===tw&&tL(X)),n!==l){for(rp(),s=[],i=tA,(o=rl())===l&&(o=tO()),o!==l?i=o=[o,a=rp()]:(tA=i,i=l);i!==l;)s.push(i),i=tA,(o=rl())===l&&(o=tO()),o!==l?i=o=[o,a=rp()]:(tA=i,i=l);t={type:"SwitchCase",test:null,consequent:s.map(([e])=>e).filter(Boolean)}}else tA=t,t=l;else tA=t,t=l;return t}function tF(){let t,r,n,s,i,o;if(t=tA,123===e.charCodeAt(tA)?(r="{",tA++):(r=l,0===tw&&tL(q)),r!==l){for(rp(),n=[],s=tA,(i=rl())===l&&(i=tO()),i!==l?s=i=[i,o=rp()]:(tA=s,s=l);s!==l;)n.push(s),s=tA,(i=rl())===l&&(i=tO()),i!==l?s=i=[i,o=rp()]:(tA=s,s=l);(125===e.charCodeAt(tA)?(s="}",tA++):(s=l,0===tw&&tL(J)),s!==l)?t={type:"BlockStatement",body:n.map(([e])=>e).filter(Boolean)}:(tA=t,t=l)}else tA=t,t=l;return t}function tG(){let t,r,n,s;if(t=tA,(r=tB())!==l)if(ru(),(n=tU())!==l)if(ru(),(s=tG())!==l)t={type:"AssignmentExpression",operator:n,target:r,value:s};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=function(){let t,r,n,s,i,o;if(t=tA,(r=tq())!==l)if(ru(),63===e.charCodeAt(tA)?(n="?",tA++):(n=l,0===tw&&tL(e_)),n!==l)if(ru(),(s=tG())!==l)if(ru(),58===e.charCodeAt(tA)?(i=":",tA++):(i=l,0===tw&&tL(X)),i!==l)if(ru(),(o=tG())!==l)t={type:"ConditionalExpression",test:r,consequent:s,alternate:o};else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;else tA=t,t=l;return t===l&&(t=tq()),t}()),t}function tU(){let t;return 61===e.charCodeAt(tA)?(t="=",tA++):(t=l,0===tw&&tL(er)),t===l&&("+="===e.substr(tA,2)?(t="+=",tA+=2):(t=l,0===tw&&tL(eb)),t===l&&("-="===e.substr(tA,2)?(t="-=",tA+=2):(t=l,0===tw&&tL(e$)),t===l&&("*="===e.substr(tA,2)?(t="*=",tA+=2):(t=l,0===tw&&tL(ey)),t===l&&("/="===e.substr(tA,2)?(t="/=",tA+=2):(t=l,0===tw&&tL(ex)),t===l&&("%="===e.substr(tA,2)?(t="%=",tA+=2):(t=l,0===tw&&tL(eA)),t===l&&("<<="===e.substr(tA,3)?(t="<<=",tA+=3):(t=l,0===tw&&tL(eC)),t===l&&(">>="===e.substr(tA,3)?(t=">>=",tA+=3):(t=l,0===tw&&tL(eS)),t===l&&("&="===e.substr(tA,2)?(t="&=",tA+=2):(t=l,0===tw&&tL(ev)),t===l&&("|="===e.substr(tA,2)?(t="|=",tA+=2):(t=l,0===tw&&tL(ew)),t===l&&("^="===e.substr(tA,2)?(t="^=",tA+=2):(t=l,0===tw&&tL(eE)))))))))))),t}function tq(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tJ())!==l){for(n=[],s=tA,o=ru(),"||"===e.substr(tA,2)?(a="||",tA+=2):(a=l,0===tw&&tL(ek)),a!==l?(u=ru(),(c=tJ())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),"||"===e.substr(tA,2)?(a="||",tA+=2):(a=l,0===tw&&tL(ek)),a!==l?(u=ru(),(c=tJ())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tJ(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tK())!==l){for(n=[],s=tA,o=ru(),"&&"===e.substr(tA,2)?(a="&&",tA+=2):(a=l,0===tw&&tL(eR)),a!==l?(u=ru(),(c=tK())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),"&&"===e.substr(tA,2)?(a="&&",tA+=2):(a=l,0===tw&&tL(eR)),a!==l?(u=ru(),(c=tK())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tK(){let t,r,n,s,o,a,u,c,p;if(t=tA,(r=tW())!==l){for(n=[],s=tA,o=ru(),124===e.charCodeAt(tA)?(a="|",tA++):(a=l,0===tw&&tL(eL)),a!==l?(u=tA,tw++,124===e.charCodeAt(tA)?(c="|",tA++):(c=l,0===tw&&tL(eL)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tW())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),124===e.charCodeAt(tA)?(a="|",tA++):(a=l,0===tw&&tL(eL)),a!==l?(u=tA,tw++,124===e.charCodeAt(tA)?(c="|",tA++):(c=l,0===tw&&tL(eL)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tW())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,,t])=>[e,t]))}else tA=t,t=l;return t}function tW(){let t,r,n,s,o,a,u,c;if(t=tA,(r=tz())!==l){for(n=[],s=tA,o=ru(),94===e.charCodeAt(tA)?(a="^",tA++):(a=l,0===tw&&tL(eN)),a!==l?(u=ru(),(c=tz())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),94===e.charCodeAt(tA)?(a="^",tA++):(a=l,0===tw&&tL(eN)),a!==l?(u=ru(),(c=tz())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function tz(){let t,r,n,s,o,a,u,c,p;if(t=tA,(r=tV())!==l){for(n=[],s=tA,o=ru(),38===e.charCodeAt(tA)?(a="&",tA++):(a=l,0===tw&&tL(eO)),a!==l?(u=tA,tw++,38===e.charCodeAt(tA)?(c="&",tA++):(c=l,0===tw&&tL(eO)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tV())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),38===e.charCodeAt(tA)?(a="&",tA++):(a=l,0===tw&&tL(eO)),a!==l?(u=tA,tw++,38===e.charCodeAt(tA)?(c="&",tA++):(c=l,0===tw&&tL(eO)),tw--,c===l?u=void 0:(tA=u,u=l),u!==l?(c=ru(),(p=tV())!==l?s=o=[o,a,u,c,p]:(tA=s,s=l)):(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,,t])=>[e,t]))}else tA=t,t=l;return t}function tV(){let e,t,r,n,s,o,a,u;if(e=tA,(t=tQ())!==l){for(r=[],n=tA,s=ru(),(o=tZ())!==l?(a=ru(),(u=tQ())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=tZ())!==l?(a=ru(),(u=tQ())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function tZ(){let t;return"=="===e.substr(tA,2)?(t="==",tA+=2):(t=l,0===tw&&tL(eI)),t===l&&("!="===e.substr(tA,2)?(t="!=",tA+=2):(t=l,0===tw&&tL(ej))),t}function tQ(){let e,t,r,n,s,o,a,u;if(e=tA,(t=tY())!==l){for(r=[],n=tA,s=ru(),(o=tX())!==l?(a=ru(),(u=tY())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=tX())!==l?(a=ru(),(u=tY())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function tX(){let t;return"<="===e.substr(tA,2)?(t="<=",tA+=2):(t=l,0===tw&&tL(eT)),t===l&&(">="===e.substr(tA,2)?(t=">=",tA+=2):(t=l,0===tw&&tL(eM)),t===l&&(t=e.charAt(tA),_.test(t)?tA++:(t=l,0===tw&&tL(eB)))),t}function tY(){let e,t,r,n,s,o,a,u;if(e=tA,(t=t2())!==l){for(r=[],n=tA,s=ru(),(o=t1())!==l?(a=ru(),(u=t0())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=t1())!==l?(a=ru(),(u=t0())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function t0(){let e,t,r,n;if(e=tA,(t=tB())!==l)if(ru(),(r=tU())!==l)if(ru(),(n=tG())!==l)e={type:"AssignmentExpression",operator:r,target:t,value:n};else tA=e,e=l;else tA=e,e=l;else tA=e,e=l;return e===l&&(e=t2()),e}function t1(){let t;return"$="===e.substr(tA,2)?(t="$=",tA+=2):(t=l,0===tw&&tL(eP)),t===l&&("!$="===e.substr(tA,3)?(t="!$=",tA+=3):(t=l,0===tw&&tL(eH)),t===l&&(64===e.charCodeAt(tA)?(t="@",tA++):(t=l,0===tw&&tL(eD)),t===l&&("NL"===e.substr(tA,2)?(t="NL",tA+=2):(t=l,0===tw&&tL(eF)),t===l&&("TAB"===e.substr(tA,3)?(t="TAB",tA+=3):(t=l,0===tw&&tL(eG)),t===l&&("SPC"===e.substr(tA,3)?(t="SPC",tA+=3):(t=l,0===tw&&tL(eU))))))),t}function t2(){let e,t,r,n,s,o,a,u;if(e=tA,(t=t3())!==l){for(r=[],n=tA,s=ru(),(o=t4())!==l?(a=ru(),(u=t3())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);n!==l;)r.push(n),n=tA,s=ru(),(o=t4())!==l?(a=ru(),(u=t3())!==l?n=s=[s,o,a,u]:(tA=n,n=l)):(tA=n,n=l);e=i(t,r.map(([,e,,t])=>[e,t]))}else tA=e,e=l;return e}function t4(){let t;return"<<"===e.substr(tA,2)?(t="<<",tA+=2):(t=l,0===tw&&tL(eq)),t===l&&(">>"===e.substr(tA,2)?(t=">>",tA+=2):(t=l,0===tw&&tL(eJ))),t}function t3(){let t,r,n,s,o,a,u,c;if(t=tA,(r=t9())!==l){for(n=[],s=tA,o=ru(),a=e.charAt(tA),k.test(a)?tA++:(a=l,0===tw&&tL(eK)),a!==l?(u=ru(),(c=t9())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),a=e.charAt(tA),k.test(a)?tA++:(a=l,0===tw&&tL(eK)),a!==l?(u=ru(),(c=t9())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function t9(){let t,r,n,s,o,a,u,c;if(t=tA,(r=t5())!==l){for(n=[],s=tA,o=ru(),a=e.charAt(tA),R.test(a)?tA++:(a=l,0===tw&&tL(eW)),a!==l?(u=ru(),(c=t5())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,o=ru(),a=e.charAt(tA),R.test(a)?tA++:(a=l,0===tw&&tL(eW)),a!==l?(u=ru(),(c=t5())!==l?s=o=[o,a,u,c]:(tA=s,s=l)):(tA=s,s=l);t=i(r,n.map(([,e,,t])=>[e,t]))}else tA=t,t=l;return t}function t5(){let t,r,n;return(t=tA,r=e.charAt(tA),L.test(r)?tA++:(r=l,0===tw&&tL(ez)),r!==l&&(ru(),(n=t6())!==l))?t=o(r,n):(tA=t,t=l),t===l&&((t=tA,"++"===e.substr(tA,2)?(r="++",tA+=2):(r=l,0===tw&&tL(eV)),r===l&&("--"===e.substr(tA,2)?(r="--",tA+=2):(r=l,0===tw&&tL(eZ))),r!==l&&(ru(),(n=t6())!==l))?t=o(r,n):(tA=t,t=l),t===l&&((t=tA,42===e.charCodeAt(tA)?(r="*",tA++):(r=l,0===tw&&tL(eQ)),r!==l&&(ru(),(n=t6())!==l))?t={type:"TagDereferenceExpression",argument:n}:(tA=t,t=l),t===l&&(t=function(){let t,r,n;if(t=tA,(r=t8())!==l)if(ru(),"++"===e.substr(tA,2)?(n="++",tA+=2):(n=l,0===tw&&tL(eV)),n===l&&("--"===e.substr(tA,2)?(n="--",tA+=2):(n=l,0===tw&&tL(eZ))),n!==l)t={type:"PostfixExpression",operator:n,argument:r};else tA=t,t=l;else tA=t,t=l;return t===l&&(t=t8()),t}()))),t}function t6(){let e,t,r,n;if(e=tA,(t=tB())!==l)if(ru(),(r=tU())!==l)if(ru(),(n=tG())!==l)e={type:"AssignmentExpression",operator:r,target:t,value:n};else tA=e,e=l;else tA=e,e=l;else tA=e,e=l;return e===l&&(e=t5()),e}function t8(){let t,r,i,o,a,u,c,p,f,h;if(t=tA,(r=function(){let t,r,n,s,i,o,a,u,c,p,f,h,d,g,m,b;if(t=tA,(a=tj())===l&&(a=tI())===l&&(a=function(){let t,r,n,s;if(t=tA,34===e.charCodeAt(tA)?(r='"',tA++):(r=l,0===tw&&tL(e3)),r!==l){for(n=[],s=rs();s!==l;)n.push(s),s=rs();(34===e.charCodeAt(tA)?(s='"',tA++):(s=l,0===tw&&tL(e3)),s!==l)?t={type:"StringLiteral",value:n.join("")}:(tA=t,t=l)}else tA=t,t=l;if(t===l)if(t=tA,39===e.charCodeAt(tA)?(r="'",tA++):(r=l,0===tw&&tL(e9)),r!==l){for(n=[],s=ri();s!==l;)n.push(s),s=ri();(39===e.charCodeAt(tA)?(s="'",tA++):(s=l,0===tw&&tL(e9)),s!==l)?t={type:"StringLiteral",value:n.join(""),tagged:!0}:(tA=t,t=l)}else tA=t,t=l;return t}())===l&&(a=ra())===l&&((u=tA,e.substr(tA,4)===w?(c=w,tA+=4):(c=l,0===tw&&tL(th)),c===l&&(e.substr(tA,5)===E?(c=E,tA+=5):(c=l,0===tw&&tL(td))),c!==l&&(p=tA,tw++,f=rh(),tw--,f===l?p=void 0:(tA=p,p=l),p!==l))?u={type:"BooleanLiteral",value:"true"===c}:(tA=u,u=l),(a=u)===l&&((h=re())===l&&(h=rt())===l&&(h=rr()),(a=h)===l))&&((d=tA,40===e.charCodeAt(tA)?(g="(",tA++):(g=l,0===tw&&tL(W)),g!==l&&(ru(),(m=tG())!==l&&(ru(),41===e.charCodeAt(tA)?(b=")",tA++):(b=l,0===tw&&tL(z)),b!==l)))?d=m:(tA=d,d=l),a=d),(r=a)!==l){for(n=[],s=tA,i=ru(),(o=tP())!==l?s=i=[i,o]:(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),(o=tP())!==l?s=i=[i,o]:(tA=s,s=l);t=n.reduce((e,[,t])=>"property"===t.type?{type:"MemberExpression",object:e,property:t.value}:{type:"IndexExpression",object:e,index:t.value},r)}else tA=t,t=l;return t}())!==l){for(i=[],o=tA,a=ru(),40===e.charCodeAt(tA)?(u="(",tA++):(u=l,0===tw&&tL(W)),u!==l?(c=ru(),(p=t7())===l&&(p=null),f=ru(),41===e.charCodeAt(tA)?(h=")",tA++):(h=l,0===tw&&tL(z)),h!==l?o=a=[a,u,c,p,f,h]:(tA=o,o=l)):(tA=o,o=l),o===l&&(o=tA,a=ru(),(u=tP())!==l?o=a=[a,u]:(tA=o,o=l));o!==l;)i.push(o),o=tA,a=ru(),40===e.charCodeAt(tA)?(u="(",tA++):(u=l,0===tw&&tL(W)),u!==l?(c=ru(),(p=t7())===l&&(p=null),f=ru(),41===e.charCodeAt(tA)?(h=")",tA++):(h=l,0===tw&&tL(z)),h!==l?o=a=[a,u,c,p,f,h]:(tA=o,o=l)):(tA=o,o=l),o===l&&(o=tA,a=ru(),(u=tP())!==l?o=a=[a,u]:(tA=o,o=l));t=i.reduce((e,t)=>{if("("===t[1]){var r;let[,,,i]=t;return r=i||[],"Identifier"===e.type&&"exec"===e.name.toLowerCase()&&(r.length>0&&"StringLiteral"===r[0].type?n.add(r[0].value):s=!0),{type:"CallExpression",callee:e,arguments:r}}let i=t[1];return"property"===i.type?{type:"MemberExpression",object:e,property:i.value}:{type:"IndexExpression",object:e,index:i.value}},r)}else tA=t,t=l;return t}function t7(){let t,r,n,s,i,o,a,u;if(t=tA,(r=tG())!==l){for(n=[],s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=ru(),44===e.charCodeAt(tA)?(o=",",tA++):(o=l,0===tw&&tL(Z)),o!==l?(a=ru(),(u=tG())!==l?s=i=[i,o,a,u]:(tA=s,s=l)):(tA=s,s=l);t=[r,...n.map(([,,,e])=>e)]}else tA=t,t=l;return t}function re(){let t,r,n,s,i,o,a;if(t=tA,37===e.charCodeAt(tA)?(r="%",tA++):(r=l,0===tw&&tL(eX)),r!==l){if(n=tA,s=tA,i=e.charAt(tA),N.test(i)?tA++:(i=l,0===tw&&tL(eY)),i!==l){for(o=[],a=e.charAt(tA),O.test(a)?tA++:(a=l,0===tw&&tL(e0));a!==l;)o.push(a),a=e.charAt(tA),O.test(a)?tA++:(a=l,0===tw&&tL(e0));s=i=[i,o]}else tA=s,s=l;(n=s!==l?e.substring(n,tA):s)!==l?t={type:"Variable",scope:"local",name:n}:(tA=t,t=l)}else tA=t,t=l;return t}function rt(){let t,r,n,s,i,o,a,u,c,p,f,h,d;if(t=tA,36===e.charCodeAt(tA)?(r="$",tA++):(r=l,0===tw&&tL(e1)),r!==l){if(n=tA,s=tA,"::"===e.substr(tA,2)?(i="::",tA+=2):(i=l,0===tw&&tL(V)),i===l&&(i=null),o=e.charAt(tA),N.test(o)?tA++:(o=l,0===tw&&tL(eY)),o!==l){for(a=[],u=e.charAt(tA),O.test(u)?tA++:(u=l,0===tw&&tL(e0));u!==l;)a.push(u),u=e.charAt(tA),O.test(u)?tA++:(u=l,0===tw&&tL(e0));if(u=[],c=tA,"::"===e.substr(tA,2)?(p="::",tA+=2):(p=l,0===tw&&tL(V)),p!==l)if(f=e.charAt(tA),N.test(f)?tA++:(f=l,0===tw&&tL(eY)),f!==l){for(h=[],d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));d!==l;)h.push(d),d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));c=p=[p,f,h]}else tA=c,c=l;else tA=c,c=l;for(;c!==l;)if(u.push(c),c=tA,"::"===e.substr(tA,2)?(p="::",tA+=2):(p=l,0===tw&&tL(V)),p!==l)if(f=e.charAt(tA),N.test(f)?tA++:(f=l,0===tw&&tL(eY)),f!==l){for(h=[],d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));d!==l;)h.push(d),d=e.charAt(tA),O.test(d)?tA++:(d=l,0===tw&&tL(e0));c=p=[p,f,h]}else tA=c,c=l;else tA=c,c=l;s=i=[i,o,a,u]}else tA=s,s=l;(n=s!==l?e.substring(n,tA):s)!==l?t={type:"Variable",scope:"global",name:n}:(tA=t,t=l)}else tA=t,t=l;return t}function rr(){let t,r,n,s,i,o,a,u,c,p,f;if(t=tA,r=tA,n=tA,e.substr(tA,6)===v?(s=v,tA+=6):(s=l,0===tw&&tL(e2)),s!==l){for(i=[],o=e.charAt(tA),I.test(o)?tA++:(o=l,0===tw&&tL(e4));o!==l;)i.push(o),o=e.charAt(tA),I.test(o)?tA++:(o=l,0===tw&&tL(e4));if("::"===e.substr(tA,2)?(o="::",tA+=2):(o=l,0===tw&&tL(V)),o!==l){for(a=[],u=e.charAt(tA),I.test(u)?tA++:(u=l,0===tw&&tL(e4));u!==l;)a.push(u),u=e.charAt(tA),I.test(u)?tA++:(u=l,0===tw&&tL(e4));if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));n=s=[s,i,o,a,u,c]}else tA=n,n=l}else tA=n,n=l}else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r.replace(/\s+/g,"")}),(t=r)===l){if(t=tA,r=tA,n=tA,e.substr(tA,6)===v?(s=v,tA+=6):(s=l,0===tw&&tL(e2)),s!==l){if(i=[],o=tA,"::"===e.substr(tA,2)?(a="::",tA+=2):(a=l,0===tw&&tL(V)),a!==l)if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));o=a=[a,u,c]}else tA=o,o=l;else tA=o,o=l;if(o!==l)for(;o!==l;)if(i.push(o),o=tA,"::"===e.substr(tA,2)?(a="::",tA+=2):(a=l,0===tw&&tL(V)),a!==l)if(u=e.charAt(tA),N.test(u)?tA++:(u=l,0===tw&&tL(eY)),u!==l){for(c=[],p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));p!==l;)c.push(p),p=e.charAt(tA),O.test(p)?tA++:(p=l,0===tw&&tL(e0));o=a=[a,u,c]}else tA=o,o=l;else tA=o,o=l;else i=l;i!==l?n=s=[s,i]:(tA=n,n=l)}else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r}),(t=r)===l){if(t=tA,r=tA,n=tA,s=e.charAt(tA),N.test(s)?tA++:(s=l,0===tw&&tL(eY)),s!==l){for(i=[],o=e.charAt(tA),O.test(o)?tA++:(o=l,0===tw&&tL(e0));o!==l;)i.push(o),o=e.charAt(tA),O.test(o)?tA++:(o=l,0===tw&&tL(e0));if(o=[],a=tA,"::"===e.substr(tA,2)?(u="::",tA+=2):(u=l,0===tw&&tL(V)),u!==l)if(c=e.charAt(tA),N.test(c)?tA++:(c=l,0===tw&&tL(eY)),c!==l){for(p=[],f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));f!==l;)p.push(f),f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));a=u=[u,c,p]}else tA=a,a=l;else tA=a,a=l;for(;a!==l;)if(o.push(a),a=tA,"::"===e.substr(tA,2)?(u="::",tA+=2):(u=l,0===tw&&tL(V)),u!==l)if(c=e.charAt(tA),N.test(c)?tA++:(c=l,0===tw&&tL(eY)),c!==l){for(p=[],f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));f!==l;)p.push(f),f=e.charAt(tA),O.test(f)?tA++:(f=l,0===tw&&tL(e0));a=u=[u,c,p]}else tA=a,a=l;else tA=a,a=l;n=s=[s,i,o]}else tA=n,n=l;(r=n!==l?e.substring(r,tA):n)!==l&&(r={type:"Identifier",name:r}),t=r}}return t}function rn(){let e;return(e=re())===l&&(e=rt())===l&&(e=rr()),e}function rs(){let t,r,n;return(t=tA,92===e.charCodeAt(tA)?(r="\\",tA++):(r=l,0===tw&&tL(e5)),r!==l&&(n=ro())!==l)?t=n:(tA=t,t=l),t===l&&(t=e.charAt(tA),j.test(t)?tA++:(t=l,0===tw&&tL(e6))),t}function ri(){let t,r,n;return(t=tA,92===e.charCodeAt(tA)?(r="\\",tA++):(r=l,0===tw&&tL(e5)),r!==l&&(n=ro())!==l)?t=n:(tA=t,t=l),t===l&&(t=e.charAt(tA),T.test(t)?tA++:(t=l,0===tw&&tL(e8))),t}function ro(){let t,r,n,s,i,o;return t=tA,110===e.charCodeAt(tA)?(r="n",tA++):(r=l,0===tw&&tL(e7)),r!==l&&(r="\n"),(t=r)===l&&(t=tA,114===e.charCodeAt(tA)?(r="r",tA++):(r=l,0===tw&&tL(te)),r!==l&&(r="\r"),(t=r)===l)&&(t=tA,116===e.charCodeAt(tA)?(r="t",tA++):(r=l,0===tw&&tL(tt)),r!==l&&(r=" "),(t=r)===l)&&((t=tA,120===e.charCodeAt(tA)?(r="x",tA++):(r=l,0===tw&&tL(tr)),r!==l&&(n=tA,s=tA,i=e.charAt(tA),M.test(i)?tA++:(i=l,0===tw&&tL(tn)),i!==l?(o=e.charAt(tA),M.test(o)?tA++:(o=l,0===tw&&tL(tn)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l),(n=s!==l?e.substring(n,tA):s)!==l))?t=String.fromCharCode(parseInt(n,16)):(tA=t,t=l),t===l&&(t=tA,"cr"===e.substr(tA,2)?(r="cr",tA+=2):(r=l,0===tw&&tL(ts)),r!==l&&(r="\x0f"),(t=r)===l&&(t=tA,"cp"===e.substr(tA,2)?(r="cp",tA+=2):(r=l,0===tw&&tL(ti)),r!==l&&(r="\x10"),(t=r)===l))&&(t=tA,"co"===e.substr(tA,2)?(r="co",tA+=2):(r=l,0===tw&&tL(to)),r!==l&&(r="\x11"),(t=r)===l)&&((t=tA,99===e.charCodeAt(tA)?(r="c",tA++):(r=l,0===tw&&tL(ta)),r!==l&&(n=e.charAt(tA),B.test(n)?tA++:(n=l,0===tw&&tL(tl)),n!==l))?t=String.fromCharCode([2,3,4,5,6,7,8,11,12,14][parseInt(n,10)]):(tA=t,t=l),t===l&&(t=tA,e.length>tA?(r=e.charAt(tA),tA++):(r=l,0===tw&&tL(tu)),t=r))),t}function ra(){let t,r,n,s,i,o,a,u,c;if(t=tA,r=tA,n=tA,48===e.charCodeAt(tA)?(s="0",tA++):(s=l,0===tw&&tL(tc)),s!==l)if(i=e.charAt(tA),P.test(i)?tA++:(i=l,0===tw&&tL(tp)),i!==l){if(o=[],a=e.charAt(tA),M.test(a)?tA++:(a=l,0===tw&&tL(tn)),a!==l)for(;a!==l;)o.push(a),a=e.charAt(tA),M.test(a)?tA++:(a=l,0===tw&&tL(tn));else o=l;o!==l?n=s=[s,i,o]:(tA=n,n=l)}else tA=n,n=l;else tA=n,n=l;if((r=n!==l?e.substring(r,tA):n)!==l&&(n=tA,tw++,s=rh(),tw--,s===l?n=void 0:(tA=n,n=l),n!==l)?t={type:"NumberLiteral",value:parseInt(r,16)}:(tA=t,t=l),t===l){if(t=tA,r=tA,n=tA,45===e.charCodeAt(tA)?(s="-",tA++):(s=l,0===tw&&tL(tf)),s===l&&(s=null),i=[],o=e.charAt(tA),B.test(o)?tA++:(o=l,0===tw&&tL(tl)),o!==l)for(;o!==l;)i.push(o),o=e.charAt(tA),B.test(o)?tA++:(o=l,0===tw&&tL(tl));else i=l;if(i!==l){if(o=tA,46===e.charCodeAt(tA)?(a=".",tA++):(a=l,0===tw&&tL(en)),a!==l){if(u=[],c=e.charAt(tA),B.test(c)?tA++:(c=l,0===tw&&tL(tl)),c!==l)for(;c!==l;)u.push(c),c=e.charAt(tA),B.test(c)?tA++:(c=l,0===tw&&tL(tl));else u=l;u!==l?o=a=[a,u]:(tA=o,o=l)}else tA=o,o=l;o===l&&(o=null),n=s=[s,i,o]}else tA=n,n=l;if(n===l)if(n=tA,45===e.charCodeAt(tA)?(s="-",tA++):(s=l,0===tw&&tL(tf)),s===l&&(s=null),46===e.charCodeAt(tA)?(i=".",tA++):(i=l,0===tw&&tL(en)),i!==l){if(o=[],a=e.charAt(tA),B.test(a)?tA++:(a=l,0===tw&&tL(tl)),a!==l)for(;a!==l;)o.push(a),a=e.charAt(tA),B.test(a)?tA++:(a=l,0===tw&&tL(tl));else o=l;o!==l?n=s=[s,i,o]:(tA=n,n=l)}else tA=n,n=l;(r=n!==l?e.substring(r,tA):n)!==l&&(n=tA,tw++,s=rh(),tw--,s===l?n=void 0:(tA=n,n=l),n!==l)?t={type:"NumberLiteral",value:parseFloat(r)}:(tA=t,t=l)}return t}function rl(){let t;return(t=function(){let t,r,n,s,i;if(t=tA,"//"===e.substr(tA,2)?(r="//",tA+=2):(r=l,0===tw&&tL(tg)),r!==l){for(n=tA,s=[],i=e.charAt(tA),H.test(i)?tA++:(i=l,0===tw&&tL(tm));i!==l;)s.push(i),i=e.charAt(tA),H.test(i)?tA++:(i=l,0===tw&&tL(tm));n=e.substring(n,tA),s=e.charAt(tA),D.test(s)?tA++:(s=l,0===tw&&tL(tb)),s===l&&(s=null),t={type:"Comment",value:n}}else tA=t,t=l;return t}())===l&&(t=function(){let t,r,n,s,i,o,a;if(t=tA,"/*"===e.substr(tA,2)?(r="/*",tA+=2):(r=l,0===tw&&tL(t$)),r!==l){for(n=tA,s=[],i=tA,o=tA,tw++,"*/"===e.substr(tA,2)?(a="*/",tA+=2):(a=l,0===tw&&tL(ty)),tw--,a===l?o=void 0:(tA=o,o=l),o!==l?(e.length>tA?(a=e.charAt(tA),tA++):(a=l,0===tw&&tL(tu)),a!==l?i=o=[o,a]:(tA=i,i=l)):(tA=i,i=l);i!==l;)s.push(i),i=tA,o=tA,tw++,"*/"===e.substr(tA,2)?(a="*/",tA+=2):(a=l,0===tw&&tL(ty)),tw--,a===l?o=void 0:(tA=o,o=l),o!==l?(e.length>tA?(a=e.charAt(tA),tA++):(a=l,0===tw&&tL(tu)),a!==l?i=o=[o,a]:(tA=i,i=l)):(tA=i,i=l);(n=e.substring(n,tA),"*/"===e.substr(tA,2)?(s="*/",tA+=2):(s=l,0===tw&&tL(ty)),s!==l)?t={type:"Comment",value:n}:(tA=t,t=l)}else tA=t,t=l;return t}()),t}function ru(){let t,r;for(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r===l&&(r=rf());r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx)),r===l&&(r=rf());return t}function rc(){let t,r,n,s;if(t=tA,r=[],n=e.charAt(tA),F.test(n)?tA++:(n=l,0===tw&&tL(tx)),n!==l)for(;n!==l;)r.push(n),n=e.charAt(tA),F.test(n)?tA++:(n=l,0===tw&&tL(tx));else r=l;if(r!==l){for(n=[],s=e.charAt(tA),F.test(s)?tA++:(s=l,0===tw&&tL(tx)),s===l&&(s=rf());s!==l;)n.push(s),s=e.charAt(tA),F.test(s)?tA++:(s=l,0===tw&&tL(tx)),s===l&&(s=rf());t=r=[r,n]}else tA=t,t=l;return t}function rp(){let t,r;for(t=[],r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));r!==l;)t.push(r),r=e.charAt(tA),F.test(r)?tA++:(r=l,0===tw&&tL(tx));return t}function rf(){let t,r,n,s,i,o;if(t=tA,"//"===e.substr(tA,2)?(r="//",tA+=2):(r=l,0===tw&&tL(tg)),r!==l){for(n=[],s=e.charAt(tA),H.test(s)?tA++:(s=l,0===tw&&tL(tm));s!==l;)n.push(s),s=e.charAt(tA),H.test(s)?tA++:(s=l,0===tw&&tL(tm));s=e.charAt(tA),D.test(s)?tA++:(s=l,0===tw&&tL(tb)),s===l&&(s=null),t=r=[r,n,s]}else tA=t,t=l;if(t===l)if(t=tA,"/*"===e.substr(tA,2)?(r="/*",tA+=2):(r=l,0===tw&&tL(t$)),r!==l){for(n=[],s=tA,i=tA,tw++,"*/"===e.substr(tA,2)?(o="*/",tA+=2):(o=l,0===tw&&tL(ty)),tw--,o===l?i=void 0:(tA=i,i=l),i!==l?(e.length>tA?(o=e.charAt(tA),tA++):(o=l,0===tw&&tL(tu)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l);s!==l;)n.push(s),s=tA,i=tA,tw++,"*/"===e.substr(tA,2)?(o="*/",tA+=2):(o=l,0===tw&&tL(ty)),tw--,o===l?i=void 0:(tA=i,i=l),i!==l?(e.length>tA?(o=e.charAt(tA),tA++):(o=l,0===tw&&tL(tu)),o!==l?s=i=[i,o]:(tA=s,s=l)):(tA=s,s=l);"*/"===e.substr(tA,2)?(s="*/",tA+=2):(s=l,0===tw&&tL(ty)),s!==l?t=r=[r,n,s]:(tA=t,t=l)}else tA=t,t=l;return t}function rh(){let t;return t=e.charAt(tA),O.test(t)?tA++:(t=l,0===tw&&tL(e0)),t}n=new Set,s=!1;let rd=(r=p())!==l&&tA===e.length;function rg(){var t,n,s;throw r!==l&&tA{"use strict";let n="[^\\\\/]",s="[^/]",i="(?:\\/|$)",o="(?:^|\\/)",a=`\\.{1,2}${i}`,l=`(?!${o}${a})`,u=`(?!\\.{0,1}${i})`,c=`(?!${a})`,p=`${s}*?`,f={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:"(?=.)",QMARK:s,END_ANCHOR:i,DOTS_SLASH:a,NO_DOT:"(?!\\.)",NO_DOTS:l,NO_DOT_SLASH:u,NO_DOTS_SLASH:c,QMARK_NO_DOT:"[^.\\/]",STAR:p,START_ANCHOR:o,SEP:"/"},h={...f,SLASH_LITERAL:"[\\\\/]",QMARK:n,STAR:`${n}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"};t.exports={MAX_LENGTH:65536,POSIX_REGEX_SOURCE:{alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"},REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars:e=>({"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}),globChars:e=>!0===e?h:f}},19241,(e,t,r)=>{"use strict";var n=e.i(47167);let{REGEX_BACKSLASH:s,REGEX_REMOVE_BACKSLASH:i,REGEX_SPECIAL_CHARS:o,REGEX_SPECIAL_CHARS_GLOBAL:a}=e.r(53487);r.isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r.hasRegexChars=e=>o.test(e),r.isRegexChar=e=>1===e.length&&r.hasRegexChars(e),r.escapeRegex=e=>e.replace(a,"\\$1"),r.toPosixSlashes=e=>e.replace(s,"/"),r.isWindows=()=>{if("u">typeof navigator&&navigator.platform){let e=navigator.platform.toLowerCase();return"win32"===e||"windows"===e}return void 0!==n.default&&!!n.default.platform&&"win32"===n.default.platform},r.removeBackslashes=e=>e.replace(i,e=>"\\"===e?"":e),r.escapeLast=(e,t,n)=>{let s=e.lastIndexOf(t,n);return -1===s?e:"\\"===e[s-1]?r.escapeLast(e,t,s-1):`${e.slice(0,s)}\\${e.slice(s)}`},r.removePrefix=(e,t={})=>{let r=e;return r.startsWith("./")&&(r=r.slice(2),t.prefix="./"),r},r.wrapOutput=(e,t={},r={})=>{let n=r.contains?"":"^",s=r.contains?"":"$",i=`${n}(?:${e})${s}`;return!0===t.negated&&(i=`(?:^(?!${i}).*$)`),i},r.basename=(e,{windows:t}={})=>{let r=e.split(t?/[\\/]/:"/"),n=r[r.length-1];return""===n?r[r.length-2]:n}},26094,(e,t,r)=>{"use strict";let n=e.r(19241),{CHAR_ASTERISK:s,CHAR_AT:i,CHAR_BACKWARD_SLASH:o,CHAR_COMMA:a,CHAR_DOT:l,CHAR_EXCLAMATION_MARK:u,CHAR_FORWARD_SLASH:c,CHAR_LEFT_CURLY_BRACE:p,CHAR_LEFT_PARENTHESES:f,CHAR_LEFT_SQUARE_BRACKET:h,CHAR_PLUS:d,CHAR_QUESTION_MARK:g,CHAR_RIGHT_CURLY_BRACE:m,CHAR_RIGHT_PARENTHESES:b,CHAR_RIGHT_SQUARE_BRACKET:$}=e.r(53487),y=e=>e===c||e===o,x=e=>{!0!==e.isPrefix&&(e.depth=e.isGlobstar?1/0:1)};t.exports=(e,t)=>{let r,A,C=t||{},S=e.length-1,v=!0===C.parts||!0===C.scanToEnd,w=[],E=[],_=[],k=e,R=-1,L=0,N=0,O=!1,I=!1,j=!1,T=!1,M=!1,B=!1,P=!1,H=!1,D=!1,F=!1,G=0,U={value:"",depth:0,isGlob:!1},q=()=>R>=S,J=()=>k.charCodeAt(R+1),K=()=>(r=A,k.charCodeAt(++R));for(;R0&&(z=k.slice(0,L),k=k.slice(L),N-=L),W&&!0===j&&N>0?(W=k.slice(0,N),V=k.slice(N)):!0===j?(W="",V=k):W=k,W&&""!==W&&"/"!==W&&W!==k&&y(W.charCodeAt(W.length-1))&&(W=W.slice(0,-1)),!0===C.unescape&&(V&&(V=n.removeBackslashes(V)),W&&!0===P&&(W=n.removeBackslashes(W)));let Z={prefix:z,input:e,start:L,base:W,glob:V,isBrace:O,isBracket:I,isGlob:j,isExtglob:T,isGlobstar:M,negated:H,negatedExtglob:D};if(!0===C.tokens&&(Z.maxDepth=0,y(A)||E.push(U),Z.tokens=E),!0===C.parts||!0===C.tokens){let t;for(let r=0;r{"use strict";let n=e.r(53487),s=e.r(19241),{MAX_LENGTH:i,POSIX_REGEX_SOURCE:o,REGEX_NON_SPECIAL_CHARS:a,REGEX_SPECIAL_CHARS_BACKREF:l,REPLACEMENTS:u}=n,c=(e,t)=>{if("function"==typeof t.expandRange)return t.expandRange(...e,t);e.sort();let r=`[${e.join("-")}]`;try{new RegExp(r)}catch(t){return e.map(e=>s.escapeRegex(e)).join("..")}return r},p=(e,t)=>`Missing ${e}: "${t}" - use "\\\\${t}" to match literal characters`,f=(e,t)=>{let r;if("string"!=typeof e)throw TypeError("Expected a string");e=u[e]||e;let h={...t},d="number"==typeof h.maxLength?Math.min(i,h.maxLength):i,g=e.length;if(g>d)throw SyntaxError(`Input length: ${g}, exceeds maximum allowed length: ${d}`);let m={type:"bos",value:"",output:h.prepend||""},b=[m],$=h.capture?"":"?:",y=n.globChars(h.windows),x=n.extglobChars(y),{DOT_LITERAL:A,PLUS_LITERAL:C,SLASH_LITERAL:S,ONE_CHAR:v,DOTS_SLASH:w,NO_DOT:E,NO_DOT_SLASH:_,NO_DOTS_SLASH:k,QMARK:R,QMARK_NO_DOT:L,STAR:N,START_ANCHOR:O}=y,I=e=>`(${$}(?:(?!${O}${e.dot?w:A}).)*?)`,j=h.dot?"":E,T=h.dot?R:L,M=!0===h.bash?I(h):N;h.capture&&(M=`(${M})`),"boolean"==typeof h.noext&&(h.noextglob=h.noext);let B={input:e,index:-1,start:0,dot:!0===h.dot,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:b};g=(e=s.removePrefix(e,B)).length;let P=[],H=[],D=[],F=m,G=()=>B.index===g-1,U=B.peek=(t=1)=>e[B.index+t],q=B.advance=()=>e[++B.index]||"",J=()=>e.slice(B.index+1),K=(e="",t=0)=>{B.consumed+=e,B.index+=t},W=e=>{B.output+=null!=e.output?e.output:e.value,K(e.value)},z=()=>{let e=1;for(;"!"===U()&&("("!==U(2)||"?"===U(3));)q(),B.start++,e++;return e%2!=0&&(B.negated=!0,B.start++,!0)},V=e=>{B[e]++,D.push(e)},Z=e=>{B[e]--,D.pop()},Q=e=>{if("globstar"===F.type){let t=B.braces>0&&("comma"===e.type||"brace"===e.type),r=!0===e.extglob||P.length&&("pipe"===e.type||"paren"===e.type);"slash"===e.type||"paren"===e.type||t||r||(B.output=B.output.slice(0,-F.output.length),F.type="star",F.value="*",F.output=M,B.output+=F.output)}if(P.length&&"paren"!==e.type&&(P[P.length-1].inner+=e.value),(e.value||e.output)&&W(e),F&&"text"===F.type&&"text"===e.type){F.output=(F.output||F.value)+e.value,F.value+=e.value;return}e.prev=F,b.push(e),F=e},X=(e,t)=>{let r={...x[t],conditions:1,inner:""};r.prev=F,r.parens=B.parens,r.output=B.output;let n=(h.capture?"(":"")+r.open;V("parens"),Q({type:e,value:t,output:B.output?"":v}),Q({type:"paren",extglob:!0,value:q(),output:n}),P.push(r)},Y=e=>{let n,s=e.close+(h.capture?")":"");if("negate"===e.type){let r=M;if(e.inner&&e.inner.length>1&&e.inner.includes("/")&&(r=I(h)),(r!==M||G()||/^\)+$/.test(J()))&&(s=e.close=`)$))${r}`),e.inner.includes("*")&&(n=J())&&/^\.[^\\/.]+$/.test(n)){let i=f(n,{...t,fastpaths:!1}).output;s=e.close=`)${i})${r})`}"bos"===e.prev.type&&(B.negatedExtglob=!0)}Q({type:"paren",extglob:!0,value:r,output:s}),Z("parens")};if(!1!==h.fastpaths&&!/(^[*!]|[/()[\]{}"])/.test(e)){let r=!1,n=e.replace(l,(e,t,n,s,i,o)=>"\\"===s?(r=!0,e):"?"===s?t?t+s+(i?R.repeat(i.length):""):0===o?T+(i?R.repeat(i.length):""):R.repeat(n.length):"."===s?A.repeat(n.length):"*"===s?t?t+s+(i?M:""):M:t?e:`\\${e}`);return(!0===r&&(n=!0===h.unescape?n.replace(/\\/g,""):n.replace(/\\+/g,e=>e.length%2==0?"\\\\":e?"\\":"")),n===e&&!0===h.contains)?B.output=e:B.output=s.wrapOutput(n,B,t),B}for(;!G();){if("\0"===(r=q()))continue;if("\\"===r){let e=U();if("/"===e&&!0!==h.bash||"."===e||";"===e)continue;if(!e){Q({type:"text",value:r+="\\"});continue}let t=/^\\+/.exec(J()),n=0;if(t&&t[0].length>2&&(n=t[0].length,B.index+=n,n%2!=0&&(r+="\\")),!0===h.unescape?r=q():r+=q(),0===B.brackets){Q({type:"text",value:r});continue}}if(B.brackets>0&&("]"!==r||"["===F.value||"[^"===F.value)){if(!1!==h.posix&&":"===r){let e=F.value.slice(1);if(e.includes("[")&&(F.posix=!0,e.includes(":"))){let e=F.value.lastIndexOf("["),t=F.value.slice(0,e),r=o[F.value.slice(e+2)];if(r){F.value=t+r,B.backtrack=!0,q(),m.output||1!==b.indexOf(F)||(m.output=v);continue}}}("["===r&&":"!==U()||"-"===r&&"]"===U())&&(r=`\\${r}`),"]"===r&&("["===F.value||"[^"===F.value)&&(r=`\\${r}`),!0===h.posix&&"!"===r&&"["===F.value&&(r="^"),F.value+=r,W({value:r});continue}if(1===B.quotes&&'"'!==r){r=s.escapeRegex(r),F.value+=r,W({value:r});continue}if('"'===r){B.quotes=+(1!==B.quotes),!0===h.keepQuotes&&Q({type:"text",value:r});continue}if("("===r){V("parens"),Q({type:"paren",value:r});continue}if(")"===r){if(0===B.parens&&!0===h.strictBrackets)throw SyntaxError(p("opening","("));let e=P[P.length-1];if(e&&B.parens===e.parens+1){Y(P.pop());continue}Q({type:"paren",value:r,output:B.parens?")":"\\)"}),Z("parens");continue}if("["===r){if(!0!==h.nobracket&&J().includes("]"))V("brackets");else{if(!0!==h.nobracket&&!0===h.strictBrackets)throw SyntaxError(p("closing","]"));r=`\\${r}`}Q({type:"bracket",value:r});continue}if("]"===r){if(!0===h.nobracket||F&&"bracket"===F.type&&1===F.value.length){Q({type:"text",value:r,output:`\\${r}`});continue}if(0===B.brackets){if(!0===h.strictBrackets)throw SyntaxError(p("opening","["));Q({type:"text",value:r,output:`\\${r}`});continue}Z("brackets");let e=F.value.slice(1);if(!0===F.posix||"^"!==e[0]||e.includes("/")||(r=`/${r}`),F.value+=r,W({value:r}),!1===h.literalBrackets||s.hasRegexChars(e))continue;let t=s.escapeRegex(F.value);if(B.output=B.output.slice(0,-F.value.length),!0===h.literalBrackets){B.output+=t,F.value=t;continue}F.value=`(${$}${t}|${F.value})`,B.output+=F.value;continue}if("{"===r&&!0!==h.nobrace){V("braces");let e={type:"brace",value:r,output:"(",outputIndex:B.output.length,tokensIndex:B.tokens.length};H.push(e),Q(e);continue}if("}"===r){let e=H[H.length-1];if(!0===h.nobrace||!e){Q({type:"text",value:r,output:r});continue}let t=")";if(!0===e.dots){let e=b.slice(),r=[];for(let t=e.length-1;t>=0&&(b.pop(),"brace"!==e[t].type);t--)"dots"!==e[t].type&&r.unshift(e[t].value);t=c(r,h),B.backtrack=!0}if(!0!==e.comma&&!0!==e.dots){let n=B.output.slice(0,e.outputIndex),s=B.tokens.slice(e.tokensIndex);for(let i of(e.value=e.output="\\{",r=t="\\}",B.output=n,s))B.output+=i.output||i.value}Q({type:"brace",value:r,output:t}),Z("braces"),H.pop();continue}if("|"===r){P.length>0&&P[P.length-1].conditions++,Q({type:"text",value:r});continue}if(","===r){let e=r,t=H[H.length-1];t&&"braces"===D[D.length-1]&&(t.comma=!0,e="|"),Q({type:"comma",value:r,output:e});continue}if("/"===r){if("dot"===F.type&&B.index===B.start+1){B.start=B.index+1,B.consumed="",B.output="",b.pop(),F=m;continue}Q({type:"slash",value:r,output:S});continue}if("."===r){if(B.braces>0&&"dot"===F.type){"."===F.value&&(F.output=A);let e=H[H.length-1];F.type="dots",F.output+=r,F.value+=r,e.dots=!0;continue}if(B.braces+B.parens===0&&"bos"!==F.type&&"slash"!==F.type){Q({type:"text",value:r,output:A});continue}Q({type:"dot",value:r,output:A});continue}if("?"===r){if(!(F&&"("===F.value)&&!0!==h.noextglob&&"("===U()&&"?"!==U(2)){X("qmark",r);continue}if(F&&"paren"===F.type){let e=U(),t=r;("("!==F.value||/[!=<:]/.test(e))&&("<"!==e||/<([!=]|\w+>)/.test(J()))||(t=`\\${r}`),Q({type:"text",value:r,output:t});continue}if(!0!==h.dot&&("slash"===F.type||"bos"===F.type)){Q({type:"qmark",value:r,output:L});continue}Q({type:"qmark",value:r,output:R});continue}if("!"===r){if(!0!==h.noextglob&&"("===U()&&("?"!==U(2)||!/[!=<:]/.test(U(3)))){X("negate",r);continue}if(!0!==h.nonegate&&0===B.index){z();continue}}if("+"===r){if(!0!==h.noextglob&&"("===U()&&"?"!==U(2)){X("plus",r);continue}if(F&&"("===F.value||!1===h.regex){Q({type:"plus",value:r,output:C});continue}if(F&&("bracket"===F.type||"paren"===F.type||"brace"===F.type)||B.parens>0){Q({type:"plus",value:r});continue}Q({type:"plus",value:C});continue}if("@"===r){if(!0!==h.noextglob&&"("===U()&&"?"!==U(2)){Q({type:"at",extglob:!0,value:r,output:""});continue}Q({type:"text",value:r});continue}if("*"!==r){("$"===r||"^"===r)&&(r=`\\${r}`);let e=a.exec(J());e&&(r+=e[0],B.index+=e[0].length),Q({type:"text",value:r});continue}if(F&&("globstar"===F.type||!0===F.star)){F.type="star",F.star=!0,F.value+=r,F.output=M,B.backtrack=!0,B.globstar=!0,K(r);continue}let t=J();if(!0!==h.noextglob&&/^\([^?]/.test(t)){X("star",r);continue}if("star"===F.type){if(!0===h.noglobstar){K(r);continue}let n=F.prev,s=n.prev,i="slash"===n.type||"bos"===n.type,o=s&&("star"===s.type||"globstar"===s.type);if(!0===h.bash&&(!i||t[0]&&"/"!==t[0])){Q({type:"star",value:r,output:""});continue}let a=B.braces>0&&("comma"===n.type||"brace"===n.type),l=P.length&&("pipe"===n.type||"paren"===n.type);if(!i&&"paren"!==n.type&&!a&&!l){Q({type:"star",value:r,output:""});continue}for(;"/**"===t.slice(0,3);){let r=e[B.index+4];if(r&&"/"!==r)break;t=t.slice(3),K("/**",3)}if("bos"===n.type&&G()){F.type="globstar",F.value+=r,F.output=I(h),B.output=F.output,B.globstar=!0,K(r);continue}if("slash"===n.type&&"bos"!==n.prev.type&&!o&&G()){B.output=B.output.slice(0,-(n.output+F.output).length),n.output=`(?:${n.output}`,F.type="globstar",F.output=I(h)+(h.strictSlashes?")":"|$)"),F.value+=r,B.globstar=!0,B.output+=n.output+F.output,K(r);continue}if("slash"===n.type&&"bos"!==n.prev.type&&"/"===t[0]){let e=void 0!==t[1]?"|$":"";B.output=B.output.slice(0,-(n.output+F.output).length),n.output=`(?:${n.output}`,F.type="globstar",F.output=`${I(h)}${S}|${S}${e})`,F.value+=r,B.output+=n.output+F.output,B.globstar=!0,K(r+q()),Q({type:"slash",value:"/",output:""});continue}if("bos"===n.type&&"/"===t[0]){F.type="globstar",F.value+=r,F.output=`(?:^|${S}|${I(h)}${S})`,B.output=F.output,B.globstar=!0,K(r+q()),Q({type:"slash",value:"/",output:""});continue}B.output=B.output.slice(0,-F.output.length),F.type="globstar",F.output=I(h),F.value+=r,B.output+=F.output,B.globstar=!0,K(r);continue}let n={type:"star",value:r,output:M};if(!0===h.bash){n.output=".*?",("bos"===F.type||"slash"===F.type)&&(n.output=j+n.output),Q(n);continue}if(F&&("bracket"===F.type||"paren"===F.type)&&!0===h.regex){n.output=r,Q(n);continue}(B.index===B.start||"slash"===F.type||"dot"===F.type)&&("dot"===F.type?(B.output+=_,F.output+=_):!0===h.dot?(B.output+=k,F.output+=k):(B.output+=j,F.output+=j),"*"!==U()&&(B.output+=v,F.output+=v)),Q(n)}for(;B.brackets>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing","]"));B.output=s.escapeLast(B.output,"["),Z("brackets")}for(;B.parens>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing",")"));B.output=s.escapeLast(B.output,"("),Z("parens")}for(;B.braces>0;){if(!0===h.strictBrackets)throw SyntaxError(p("closing","}"));B.output=s.escapeLast(B.output,"{"),Z("braces")}if(!0!==h.strictSlashes&&("star"===F.type||"bracket"===F.type)&&Q({type:"maybe_slash",value:"",output:`${S}?`}),!0===B.backtrack)for(let e of(B.output="",B.tokens))B.output+=null!=e.output?e.output:e.value,e.suffix&&(B.output+=e.suffix);return B};f.fastpaths=(e,t)=>{let r={...t},o="number"==typeof r.maxLength?Math.min(i,r.maxLength):i,a=e.length;if(a>o)throw SyntaxError(`Input length: ${a}, exceeds maximum allowed length: ${o}`);e=u[e]||e;let{DOT_LITERAL:l,SLASH_LITERAL:c,ONE_CHAR:p,DOTS_SLASH:f,NO_DOT:h,NO_DOTS:d,NO_DOTS_SLASH:g,STAR:m,START_ANCHOR:b}=n.globChars(r.windows),$=r.dot?d:h,y=r.dot?g:h,x=r.capture?"":"?:",A=!0===r.bash?".*?":m;r.capture&&(A=`(${A})`);let C=e=>!0===e.noglobstar?A:`(${x}(?:(?!${b}${e.dot?f:l}).)*?)`,S=e=>{switch(e){case"*":return`${$}${p}${A}`;case".*":return`${l}${p}${A}`;case"*.*":return`${$}${A}${l}${p}${A}`;case"*/*":return`${$}${A}${c}${p}${y}${A}`;case"**":return $+C(r);case"**/*":return`(?:${$}${C(r)}${c})?${y}${p}${A}`;case"**/*.*":return`(?:${$}${C(r)}${c})?${y}${A}${l}${p}${A}`;case"**/.*":return`(?:${$}${C(r)}${c})?${l}${p}${A}`;default:{let t=/^(.*?)\.(\w+)$/.exec(e);if(!t)return;let r=S(t[1]);if(!r)return;return r+l+t[2]}}},v=S(s.removePrefix(e,{negated:!1,prefix:""}));return v&&!0!==r.strictSlashes&&(v+=`${c}?`),v},t.exports=f},53174,(e,t,r)=>{"use strict";let n=e.r(26094),s=e.r(17932),i=e.r(19241),o=e.r(53487),a=(e,t,r=!1)=>{if(Array.isArray(e)){let n=e.map(e=>a(e,t,r));return e=>{for(let t of n){let r=t(e);if(r)return r}return!1}}let n=e&&"object"==typeof e&&!Array.isArray(e)&&e.tokens&&e.input;if(""===e||"string"!=typeof e&&!n)throw TypeError("Expected pattern to be a non-empty string");let s=t||{},i=s.windows,o=n?a.compileRe(e,t):a.makeRe(e,t,!1,!0),l=o.state;delete o.state;let u=()=>!1;if(s.ignore){let e={...t,ignore:null,onMatch:null,onResult:null};u=a(s.ignore,e,r)}let c=(r,n=!1)=>{let{isMatch:c,match:p,output:f}=a.test(r,o,t,{glob:e,posix:i}),h={glob:e,state:l,regex:o,posix:i,input:r,output:f,match:p,isMatch:c};return("function"==typeof s.onResult&&s.onResult(h),!1===c)?(h.isMatch=!1,!!n&&h):u(r)?("function"==typeof s.onIgnore&&s.onIgnore(h),h.isMatch=!1,!!n&&h):("function"==typeof s.onMatch&&s.onMatch(h),!n||h)};return r&&(c.state=l),c};a.test=(e,t,r,{glob:n,posix:s}={})=>{if("string"!=typeof e)throw TypeError("Expected input to be a string");if(""===e)return{isMatch:!1,output:""};let o=r||{},l=o.format||(s?i.toPosixSlashes:null),u=e===n,c=u&&l?l(e):e;return!1===u&&(u=(c=l?l(e):e)===n),(!1===u||!0===o.capture)&&(u=!0===o.matchBase||!0===o.basename?a.matchBase(e,t,r,s):t.exec(c)),{isMatch:!!u,match:u,output:c}},a.matchBase=(e,t,r)=>(t instanceof RegExp?t:a.makeRe(t,r)).test(i.basename(e)),a.isMatch=(e,t,r)=>a(t,r)(e),a.parse=(e,t)=>Array.isArray(e)?e.map(e=>a.parse(e,t)):s(e,{...t,fastpaths:!1}),a.scan=(e,t)=>n(e,t),a.compileRe=(e,t,r=!1,n=!1)=>{if(!0===r)return e.output;let s=t||{},i=s.contains?"":"^",o=s.contains?"":"$",l=`${i}(?:${e.output})${o}`;e&&!0===e.negated&&(l=`^(?!${l}).*$`);let u=a.toRegex(l,t);return!0===n&&(u.state=e),u},a.makeRe=(e,t={},r=!1,n=!1)=>{if(!e||"string"!=typeof e)throw TypeError("Expected a non-empty string");let i={negated:!1,fastpaths:!0};return!1!==t.fastpaths&&("."===e[0]||"*"===e[0])&&(i.output=s.fastpaths(e,t)),i.output||(i=s(e,t)),a.compileRe(i,t,r,n)},a.toRegex=(e,t)=>{try{let r=t||{};return new RegExp(e,r.flags||(r.nocase?"i":""))}catch(e){if(t&&!0===t.debug)throw e;return/$^/}},a.constants=o,t.exports=a},54970,(e,t,r)=>{"use strict";let n=e.r(53174),s=e.r(19241);function i(e,t,r=!1){return t&&(null===t.windows||void 0===t.windows)&&(t={...t,windows:s.isWindows()}),n(e,t,r)}Object.assign(i,n),t.exports=i},12979,91996,33870,38433,86608,62395,e=>{"use strict";function t(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")}let r=e.i(87447).default;function n(e){return t(e).toLowerCase()}function s(){return r.resources}function i(e){let[t,...n]=r.resources[e],[s,i]=n[n.length-1];return[s,i??t]}function o(e){let t=n(e);if(r.resources[t])return t;let s=t.replace(/\d+(\.(png))$/i,"$1");if(r.resources[s])return s;throw Error(`Resource not found in manifest: ${e}`)}function a(){return Object.keys(r.resources)}let l=["",".jpg",".png",".gif",".bmp"];function u(e){let t=n(e);for(let e of l){let n=`${t}${e}`;if(r.resources[n])return n}return t}function c(e){let t=r.missions[e];if(!t)throw Error(`Mission not found: ${e}`);return t}function p(){return Object.keys(r.missions)}e.s(["getActualResourceKey",()=>o,"getMissionInfo",()=>c,"getMissionList",()=>p,"getResourceKey",()=>n,"getResourceList",()=>a,"getResourceMap",()=>s,"getSourceAndPath",()=>i,"getStandardTextureResourceKey",()=>u],91996),e.s(["parse",()=>q,"runServer",()=>W],86608);var f=e.i(92552);function h(e){let t=e.indexOf("::");return -1===t?null:{namespace:e.slice(0,t),method:e.slice(t+2)}}let d={"+":"$.add","-":"$.sub","*":"$.mul","/":"$.div","<":"$.lt","<=":"$.le",">":"$.gt",">=":"$.ge","==":"$.eq","!=":"$.ne","%":"$.mod","&":"$.bitand","|":"$.bitor","^":"$.bitxor","<<":"$.shl",">>":"$.shr"};class g{indent;runtime;functions;globals;locals;indentLevel=0;currentClass=null;currentFunction=null;constructor(e={}){this.indent=e.indent??" ",this.runtime=e.runtime??"$",this.functions=e.functions??"$f",this.globals=e.globals??"$g",this.locals=e.locals??"$l"}getAccessInfo(e){if("Variable"===e.type){let t=JSON.stringify(e.name),r="global"===e.scope?this.globals:this.locals;return{getter:`${r}.get(${t})`,setter:e=>`${r}.set(${t}, ${e})`,postIncHelper:`${r}.postInc(${t})`,postDecHelper:`${r}.postDec(${t})`}}if("MemberExpression"===e.type){let t=this.expression(e.object),r="Identifier"===e.property.type?JSON.stringify(e.property.name):this.expression(e.property);return{getter:`${this.runtime}.prop(${t}, ${r})`,setter:e=>`${this.runtime}.setProp(${t}, ${r}, ${e})`,postIncHelper:`${this.runtime}.propPostInc(${t}, ${r})`,postDecHelper:`${this.runtime}.propPostDec(${t}, ${r})`}}if("IndexExpression"===e.type){let t=Array.isArray(e.index)?e.index.map(e=>this.expression(e)):[this.expression(e.index)];if("Variable"===e.object.type){let r=JSON.stringify(e.object.name),n="global"===e.object.scope?this.globals:this.locals,s=t.join(", ");return{getter:`${n}.get(${r}, ${s})`,setter:e=>`${n}.set(${r}, ${s}, ${e})`,postIncHelper:`${n}.postInc(${r}, ${s})`,postDecHelper:`${n}.postDec(${r}, ${s})`}}if("MemberExpression"===e.object.type){let r=e.object,n=this.expression(r.object),s="Identifier"===r.property.type?JSON.stringify(r.property.name):this.expression(r.property),i=`${this.runtime}.key(${s}, ${t.join(", ")})`;return{getter:`${this.runtime}.prop(${n}, ${i})`,setter:e=>`${this.runtime}.setProp(${n}, ${i}, ${e})`,postIncHelper:`${this.runtime}.propPostInc(${n}, ${i})`,postDecHelper:`${this.runtime}.propPostDec(${n}, ${i})`}}let r=this.expression(e.object),n=1===t.length?t[0]:`${this.runtime}.key(${t.join(", ")})`;return{getter:`${this.runtime}.getIndex(${r}, ${n})`,setter:e=>`${this.runtime}.setIndex(${r}, ${n}, ${e})`,postIncHelper:`${this.runtime}.indexPostInc(${r}, ${n})`,postDecHelper:`${this.runtime}.indexPostDec(${r}, ${n})`}}return null}generate(e){let t=[];for(let r of e.body){let e=this.statement(r);e&&t.push(e)}return t.join("\n\n")}statement(e){switch(e.type){case"Comment":return"";case"ExpressionStatement":return this.line(`${this.expression(e.expression)};`);case"FunctionDeclaration":return this.functionDeclaration(e);case"PackageDeclaration":return this.packageDeclaration(e);case"DatablockDeclaration":return this.datablockDeclaration(e);case"ObjectDeclaration":return this.line(`${this.objectDeclaration(e)};`);case"IfStatement":return this.ifStatement(e);case"ForStatement":return this.forStatement(e);case"WhileStatement":return this.whileStatement(e);case"DoWhileStatement":return this.doWhileStatement(e);case"SwitchStatement":return this.switchStatement(e);case"ReturnStatement":return this.returnStatement(e);case"BreakStatement":return this.line("break;");case"ContinueStatement":return this.line("continue;");case"BlockStatement":return this.blockStatement(e);default:throw Error(`Unknown statement type: ${e.type}`)}}functionDeclaration(e){let t=h(e.name.name);if(t){let r=t.namespace,n=t.method;this.currentClass=r.toLowerCase(),this.currentFunction=n.toLowerCase();let s=this.functionBody(e.body,e.params);return this.currentClass=null,this.currentFunction=null,`${this.line(`${this.runtime}.registerMethod(${JSON.stringify(r)}, ${JSON.stringify(n)}, function() {`)} +${s} +${this.line("});")}`}{let t=e.name.name;this.currentFunction=t.toLowerCase();let r=this.functionBody(e.body,e.params);return this.currentFunction=null,`${this.line(`${this.runtime}.registerFunction(${JSON.stringify(t)}, function() {`)} +${r} +${this.line("});")}`}}functionBody(e,t){this.indentLevel++;let r=[];r.push(this.line(`const ${this.locals} = ${this.runtime}.locals();`));for(let e=0;ethis.statement(e)).join("\n\n");return this.indentLevel--,`${this.line(`${this.runtime}.package(${t}, function() {`)} +${r} +${this.line("});")}`}datablockDeclaration(e){let t=JSON.stringify(e.className.name),r=e.instanceName?JSON.stringify(e.instanceName.name):"null",n=e.parent?JSON.stringify(e.parent.name):"null",s=this.objectBody(e.body);return this.line(`${this.runtime}.datablock(${t}, ${r}, ${n}, ${s});`)}objectDeclaration(e){let t="Identifier"===e.className.type?JSON.stringify(e.className.name):this.expression(e.className),r=null===e.instanceName?"null":"Identifier"===e.instanceName.type?JSON.stringify(e.instanceName.name):this.expression(e.instanceName),n=[],s=[];for(let t of e.body)"Assignment"===t.type?n.push(t):s.push(t);let i=this.objectBody(n);if(s.length>0){let e=s.map(e=>this.objectDeclaration(e)).join(",\n");return`${this.runtime}.create(${t}, ${r}, ${i}, [ +${e} +])`}return`${this.runtime}.create(${t}, ${r}, ${i})`}objectBody(e){if(0===e.length)return"{}";let t=[];for(let r of e)if("Assignment"===r.type){let e=this.expression(r.value);if("Identifier"===r.target.type){let n=r.target.name;/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?t.push(`${n}: ${e}`):t.push(`[${JSON.stringify(n)}]: ${e}`)}else if("IndexExpression"===r.target.type){let n=this.objectPropertyKey(r.target);t.push(`[${n}]: ${e}`)}else{let n=this.expression(r.target);t.push(`[${n}]: ${e}`)}}if(t.length<=1)return`{ ${t.join(", ")} }`;let r=this.indent.repeat(this.indentLevel+1),n=this.indent.repeat(this.indentLevel);return`{ +${r}${t.join(",\n"+r)} +${n}}`}objectPropertyKey(e){let t="Identifier"===e.object.type?JSON.stringify(e.object.name):this.expression(e.object),r=Array.isArray(e.index)?e.index.map(e=>this.expression(e)).join(", "):this.expression(e.index);return`${this.runtime}.key(${t}, ${r})`}ifStatement(e){let t=this.expression(e.test),r=this.statementAsBlock(e.consequent);if(e.alternate)if("IfStatement"===e.alternate.type){let n=this.ifStatement(e.alternate).replace(/^\s*/,"");return this.line(`if (${t}) ${r} else ${n}`)}else{let n=this.statementAsBlock(e.alternate);return this.line(`if (${t}) ${r} else ${n}`)}return this.line(`if (${t}) ${r}`)}forStatement(e){let t=e.init?this.expression(e.init):"",r=e.test?this.expression(e.test):"",n=e.update?this.expression(e.update):"",s=this.statementAsBlock(e.body);return this.line(`for (${t}; ${r}; ${n}) ${s}`)}whileStatement(e){let t=this.expression(e.test),r=this.statementAsBlock(e.body);return this.line(`while (${t}) ${r}`)}doWhileStatement(e){let t=this.statementAsBlock(e.body),r=this.expression(e.test);return this.line(`do ${t} while (${r});`)}switchStatement(e){if(e.stringMode)return this.switchStringStatement(e);let t=this.expression(e.discriminant);this.indentLevel++;let r=[];for(let t of e.cases)r.push(this.switchCase(t));return this.indentLevel--,`${this.line(`switch (${t}) {`)} +${r.join("\n")} +${this.line("}")}`}switchCase(e){let t=[];if(null===e.test)t.push(this.line("default:"));else if(Array.isArray(e.test))for(let r of e.test)t.push(this.line(`case ${this.expression(r)}:`));else t.push(this.line(`case ${this.expression(e.test)}:`));for(let r of(this.indentLevel++,e.consequent))t.push(this.statement(r));return t.push(this.line("break;")),this.indentLevel--,t.join("\n")}switchStringStatement(e){let t=this.expression(e.discriminant),r=[];for(let t of e.cases)if(null===t.test)r.push(`default: () => { ${this.blockContent(t.consequent)} }`);else if(Array.isArray(t.test))for(let e of t.test)r.push(`${this.expression(e)}: () => { ${this.blockContent(t.consequent)} }`);else r.push(`${this.expression(t.test)}: () => { ${this.blockContent(t.consequent)} }`);return this.line(`${this.runtime}.switchStr(${t}, { ${r.join(", ")} });`)}returnStatement(e){return e.value?this.line(`return ${this.expression(e.value)};`):this.line("return;")}blockStatement(e){this.indentLevel++;let t=e.body.map(e=>this.statement(e)).join("\n");return this.indentLevel--,`{ +${t} +${this.line("}")}`}statementAsBlock(e){if("BlockStatement"===e.type)return this.blockStatement(e);this.indentLevel++;let t=this.statement(e);return this.indentLevel--,`{ +${t} +${this.line("}")}`}blockContent(e){return e.map(e=>this.statement(e).trim()).join(" ")}expression(e){switch(e.type){case"Identifier":return this.identifier(e);case"Variable":return this.variable(e);case"NumberLiteral":case"BooleanLiteral":return String(e.value);case"StringLiteral":return JSON.stringify(e.value);case"BinaryExpression":return this.binaryExpression(e);case"UnaryExpression":return this.unaryExpression(e);case"PostfixExpression":return this.postfixExpression(e);case"AssignmentExpression":return this.assignmentExpression(e);case"ConditionalExpression":return`(${this.expression(e.test)} ? ${this.expression(e.consequent)} : ${this.expression(e.alternate)})`;case"CallExpression":return this.callExpression(e);case"MemberExpression":return this.memberExpression(e);case"IndexExpression":return this.indexExpression(e);case"TagDereferenceExpression":return`${this.runtime}.deref(${this.expression(e.argument)})`;case"ObjectDeclaration":return this.objectDeclaration(e);case"DatablockDeclaration":return`${this.runtime}.datablock(${JSON.stringify(e.className.name)}, ${e.instanceName?JSON.stringify(e.instanceName.name):"null"}, ${e.parent?JSON.stringify(e.parent.name):"null"}, ${this.objectBody(e.body)})`;default:throw Error(`Unknown expression type: ${e.type}`)}}identifier(e){let t=h(e.name);return t&&"parent"===t.namespace.toLowerCase()?e.name:t?`${this.runtime}.nsRef(${JSON.stringify(t.namespace)}, ${JSON.stringify(t.method)})`:JSON.stringify(e.name)}variable(e){return"global"===e.scope?`${this.globals}.get(${JSON.stringify(e.name)})`:`${this.locals}.get(${JSON.stringify(e.name)})`}binaryExpression(e){let t=this.expression(e.left),r=this.expression(e.right),n=e.operator,s=this.concatExpression(t,n,r);if(s)return s;if("$="===n)return`${this.runtime}.streq(${t}, ${r})`;if("!$="===n)return`!${this.runtime}.streq(${t}, ${r})`;if("&&"===n||"||"===n)return`(${t} ${n} ${r})`;let i=d[n];return i?`${i}(${t}, ${r})`:`(${t} ${n} ${r})`}unaryExpression(e){if("++"===e.operator||"--"===e.operator){let t=this.getAccessInfo(e.argument);if(t){let r="++"===e.operator?1:-1;return t.setter(`${this.runtime}.add(${t.getter}, ${r})`)}}let t=this.expression(e.argument);return"~"===e.operator?`${this.runtime}.bitnot(${t})`:"-"===e.operator?`${this.runtime}.neg(${t})`:`${e.operator}${t}`}postfixExpression(e){let t=this.getAccessInfo(e.argument);if(t){let r="++"===e.operator?t.postIncHelper:t.postDecHelper;if(r)return r}return`${this.expression(e.argument)}${e.operator}`}assignmentExpression(e){let t=this.expression(e.value),r=e.operator,n=this.getAccessInfo(e.target);if(!n)throw Error(`Unhandled assignment target type: ${e.target.type}`);if("="===r)return n.setter(t);{let e=r.slice(0,-1),s=this.compoundAssignmentValue(n.getter,e,t);return n.setter(s)}}callExpression(e){let t=e.arguments.map(e=>this.expression(e)).join(", ");if("Identifier"===e.callee.type){let r=e.callee.name,n=h(r);if(n&&"parent"===n.namespace.toLowerCase())if(this.currentClass)return`${this.runtime}.parent(${JSON.stringify(this.currentClass)}, ${JSON.stringify(n.method)}, arguments[0]${t?", "+t:""})`;else if(this.currentFunction)return`${this.runtime}.parentFunc(${JSON.stringify(this.currentFunction)}${t?", "+t:""})`;else throw Error("Parent:: call outside of function context");return n?`${this.runtime}.nsCall(${JSON.stringify(n.namespace)}, ${JSON.stringify(n.method)}${t?", "+t:""})`:`${this.functions}.call(${JSON.stringify(r)}${t?", "+t:""})`}if("MemberExpression"===e.callee.type){let r=this.expression(e.callee.object),n="Identifier"===e.callee.property.type?JSON.stringify(e.callee.property.name):this.expression(e.callee.property);return`${this.runtime}.call(${r}, ${n}${t?", "+t:""})`}let r=this.expression(e.callee);return`${r}(${t})`}memberExpression(e){let t=this.expression(e.object);return e.computed||"Identifier"!==e.property.type?`${this.runtime}.prop(${t}, ${this.expression(e.property)})`:`${this.runtime}.prop(${t}, ${JSON.stringify(e.property.name)})`}indexExpression(e){let t=Array.isArray(e.index)?e.index.map(e=>this.expression(e)):[this.expression(e.index)];if("Variable"===e.object.type){let r=JSON.stringify(e.object.name),n="global"===e.object.scope?this.globals:this.locals;return`${n}.get(${r}, ${t.join(", ")})`}if("MemberExpression"===e.object.type){let r=e.object,n=this.expression(r.object),s="Identifier"===r.property.type?JSON.stringify(r.property.name):this.expression(r.property),i=`${this.runtime}.key(${s}, ${t.join(", ")})`;return`${this.runtime}.prop(${n}, ${i})`}let r=this.expression(e.object);return 1===t.length?`${this.runtime}.getIndex(${r}, ${t[0]})`:`${this.runtime}.getIndex(${r}, ${this.runtime}.key(${t.join(", ")}))`}line(e){return this.indent.repeat(this.indentLevel)+e}concatExpression(e,t,r){switch(t){case"@":return`${this.runtime}.concat(${e}, ${r})`;case"SPC":return`${this.runtime}.concat(${e}, " ", ${r})`;case"TAB":return`${this.runtime}.concat(${e}, "\\t", ${r})`;case"NL":return`${this.runtime}.concat(${e}, "\\n", ${r})`;default:return null}}compoundAssignmentValue(e,t,r){let n=this.concatExpression(e,t,r);if(n)return n;let s=d[t];return s?`${s}(${e}, ${r})`:`(${e} ${t} ${r})`}}e.s(["createRuntime",()=>G,"createScriptCache",()=>P],33870);var m=e.i(54970);class b{map=new Map;keyLookup=new Map;constructor(e){if(e)for(const[t,r]of e)this.set(t,r)}get size(){return this.map.size}get(e){let t=this.keyLookup.get(e.toLowerCase());return void 0!==t?this.map.get(t):void 0}set(e,t){let r=e.toLowerCase(),n=this.keyLookup.get(r);return void 0!==n?this.map.set(n,t):(this.keyLookup.set(r,e),this.map.set(e,t)),this}has(e){return this.keyLookup.has(e.toLowerCase())}delete(e){let t=e.toLowerCase(),r=this.keyLookup.get(t);return void 0!==r&&(this.keyLookup.delete(t),this.map.delete(r))}clear(){this.map.clear(),this.keyLookup.clear()}keys(){return this.map.keys()}values(){return this.map.values()}entries(){return this.map.entries()}[Symbol.iterator](){return this.map[Symbol.iterator]()}forEach(e){for(let[t,r]of this.map)e(r,t,this)}get[Symbol.toStringTag](){return"CaseInsensitiveMap"}getOriginalKey(e){return this.keyLookup.get(e.toLowerCase())}}class ${set=new Set;constructor(e){if(e)for(const t of e)this.add(t)}get size(){return this.set.size}add(e){return this.set.add(e.toLowerCase()),this}has(e){return this.set.has(e.toLowerCase())}delete(e){return this.set.delete(e.toLowerCase())}clear(){this.set.clear()}[Symbol.iterator](){return this.set[Symbol.iterator]()}get[Symbol.toStringTag](){return"CaseInsensitiveSet"}}function y(e){return e.replace(/\\/g,"/").toLowerCase()}function x(e){return String(e??"")}function A(e){return Number(e)||0}function C(e){let t=x(e||"0 0 0").split(" ").map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function S(e,t,r){let n=0;for(;t+n0;){if(n>=e.length)return"";let s=S(e,n,r);if(n+s>=e.length)return"";n+=s+1,t--}let s=S(e,n,r);return 0===s?"":e.substring(n,n+s)}function w(e,t,r,n){let s=0,i=t;for(;i>0;){if(s>=e.length)return"";let t=S(e,s,n);if(s+t>=e.length)return"";s+=t+1,i--}let o=s,a=r-t+1;for(;a>0;){let t=S(e,s,n);if((s+=t)>=e.length)break;s++,a--}let l=s;return l>o&&n.includes(e[l-1])&&l--,e.substring(o,l)}function E(e,t){if(""===e)return 0;let r=0;for(let n=0;nt&&o>=e.length)break}return i.join(s)}function k(e,t,r,n){let s=[],i=0,o=0;for(;it().$f.call(x(e),...r),eval(e){throw Error("eval() not implemented: requires runtime parsing and execution")},collapseescape:e=>x(e).replace(/\\([ntr\\])/g,(e,t)=>"n"===t?"\n":"t"===t?" ":"r"===t?"\r":"\\"),expandescape:e=>x(e).replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r"),export(e,t,r){console.warn(`export(${e}): not implemented`)},quit(){console.warn("quit(): not implemented in browser")},trace(e){},isobject:e=>t().$.isObject(e),nametoid:e=>t().$.nameToId(e),strlen:e=>x(e).length,strchr(e,t){let r=x(e),n=x(t)[0]??"",s=r.indexOf(n);return s>=0?r.substring(s):""},strpos:(e,t,r)=>x(e).indexOf(x(t),A(r)),strcmp(e,t){let r=x(e),n=x(t);return rn)},stricmp(e,t){let r=x(e).toLowerCase(),n=x(t).toLowerCase();return rn)},strstr:(e,t)=>x(e).indexOf(x(t)),getsubstr(e,t,r){let n=x(e),s=A(t);return void 0===r?n.substring(s):n.substring(s,s+A(r))},getword:(e,t)=>v(x(e),A(t)," \n"),getwordcount:e=>E(x(e)," \n"),getfield:(e,t)=>v(x(e),A(t)," \n"),getfieldcount:e=>E(x(e)," \n"),setword:(e,t,r)=>_(x(e),A(t),x(r)," \n"," "),setfield:(e,t,r)=>_(x(e),A(t),x(r)," \n"," "),firstword:e=>v(x(e),0," \n"),restwords:e=>w(x(e),1,1e6," \n"),trim:e=>x(e).trim(),ltrim:e=>x(e).replace(/^\s+/,""),rtrim:e=>x(e).replace(/\s+$/,""),strupr:e=>x(e).toUpperCase(),strlwr:e=>x(e).toLowerCase(),strreplace:(e,t,r)=>x(e).split(x(t)).join(x(r)),filterstring:(e,t)=>x(e),stripchars(e,t){let r=x(e),n=new Set(x(t).split(""));return r.split("").filter(e=>!n.has(e)).join("")},getfields(e,t,r){let n=void 0!==r?Number(r):1e6;return w(x(e),A(t),n," \n")},getwords(e,t,r){let n=void 0!==r?Number(r):1e6;return w(x(e),A(t),n," \n")},removeword:(e,t)=>k(x(e),A(t)," \n"," "),removefield:(e,t)=>k(x(e),A(t)," \n"," "),getrecord:(e,t)=>v(x(e),A(t),"\n"),getrecordcount:e=>E(x(e),"\n"),setrecord:(e,t,r)=>_(x(e),A(t),x(r),"\n","\n"),removerecord:(e,t)=>k(x(e),A(t),"\n","\n"),nexttoken(e,t,r){throw Error("nextToken() is not implemented: it requires variable mutation")},strtoplayername:e=>x(e).replace(/[^\w\s-]/g,"").trim(),mabs:e=>Math.abs(A(e)),mfloor:e=>Math.floor(A(e)),mceil:e=>Math.ceil(A(e)),msqrt:e=>Math.sqrt(A(e)),mpow:(e,t)=>Math.pow(A(e),A(t)),msin:e=>Math.sin(A(e)),mcos:e=>Math.cos(A(e)),mtan:e=>Math.tan(A(e)),masin:e=>Math.asin(A(e)),macos:e=>Math.acos(A(e)),matan:(e,t)=>Math.atan2(A(e),A(t)),mlog:e=>Math.log(A(e)),getrandom(e,t){if(void 0===e)return Math.random();if(void 0===t)return Math.floor(Math.random()*(A(e)+1));let r=A(e);return Math.floor(Math.random()*(A(t)-r+1))+r},mdegtorad:e=>A(e)*(Math.PI/180),mradtodeg:e=>A(e)*(180/Math.PI),mfloatlength:(e,t)=>A(e).toFixed(A(t)),getboxcenter(e){let t=x(e).split(" ").map(Number),r=t[0]||0,n=t[1]||0,s=t[2]||0,i=t[3]||0,o=t[4]||0,a=t[5]||0;return`${(r+i)/2} ${(n+o)/2} ${(s+a)/2}`},vectoradd(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${r+i} ${n+o} ${s+a}`},vectorsub(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${r-i} ${n-o} ${s-a}`},vectorscale(e,t){let[r,n,s]=C(e),i=A(t);return`${r*i} ${n*i} ${s*i}`},vectordot(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return r*i+n*o+s*a},vectorcross(e,t){let[r,n,s]=C(e),[i,o,a]=C(t);return`${n*a-s*o} ${s*i-r*a} ${r*o-n*i}`},vectorlen(e){let[t,r,n]=C(e);return Math.sqrt(t*t+r*r+n*n)},vectornormalize(e){let[t,r,n]=C(e),s=Math.sqrt(t*t+r*r+n*n);return 0===s?"0 0 0":`${t/s} ${r/s} ${n/s}`},vectordist(e,t){let[r,n,s]=C(e),[i,o,a]=C(t),l=r-i,u=n-o,c=s-a;return Math.sqrt(l*l+u*u+c*c)},matrixcreate(e,t){throw Error("MatrixCreate() not implemented: requires axis-angle rotation math")},matrixcreatefromeuler(e){throw Error("MatrixCreateFromEuler() not implemented: requires Euler→Quaternion→AxisAngle conversion")},matrixmultiply(e,t){throw Error("MatrixMultiply() not implemented: requires full 4x4 matrix multiplication")},matrixmulpoint(e,t){throw Error("MatrixMulPoint() not implemented: requires full transform application")},matrixmulvector(e,t){throw Error("MatrixMulVector() not implemented: requires rotation matrix application")},getsimtime:()=>Date.now()-t().state.startTime,getrealtime:()=>Date.now(),schedule(e,r,n,...s){let i=Number(e)||0,o=t(),a=setTimeout(()=>{o.state.pendingTimeouts.delete(a);try{o.$f.call(String(n),...s)}catch(e){throw console.error(`schedule: error calling ${n}:`,e),e}},i);return o.state.pendingTimeouts.add(a),a},cancel(e){clearTimeout(e),t().state.pendingTimeouts.delete(e)},iseventpending:e=>t().state.pendingTimeouts.has(e),exec(e){let r=String(e??"");if(console.debug(`exec(${JSON.stringify(r)}): preparing to execute…`),!r.includes("."))return console.error(`exec: invalid script file name ${JSON.stringify(r)}.`),!1;let n=y(r),s=t(),{executedScripts:i,scripts:o}=s.state;if(i.has(n))return console.debug(`exec(${JSON.stringify(r)}): skipping (already executed)`),!0;let a=o.get(n);return null==a?(console.warn(`exec(${JSON.stringify(r)}): script not found`),!1):(i.add(n),console.debug(`exec(${JSON.stringify(r)}): executing!`),s.executeAST(a),!0)},compile(e){throw Error("compile() not implemented: requires DSO bytecode compiler")},isdemo:()=>!1,isfile:e=>r?r.isFile(x(e)):(console.warn("isFile(): no fileSystem handler configured"),!1),fileext(e){let t=x(e),r=t.lastIndexOf(".");return r>=0?t.substring(r):""},filebase(e){let t=x(e),r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),n=t.lastIndexOf("."),s=r>=0?r+1:0,i=n>s?n:t.length;return t.substring(s,i)},filepath(e){let t=x(e),r=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return r>=0?t.substring(0,r):""},expandfilename(e){throw Error("expandFilename() not implemented: requires filesystem path expansion")},findfirstfile:e=>r?(i=x(e),n=r.findFiles(i),s=0,n[s++]??""):(console.warn("findFirstFile(): no fileSystem handler configured"),""),findnextfile(e){let t=x(e);if(t!==i){if(!r)return"";i=t,n=r.findFiles(t)}return n[s++]??""},getfilecrc:e=>x(e),iswriteablefilename:e=>!1,activatepackage(e){t().$.activatePackage(x(e))},deactivatepackage(e){t().$.deactivatePackage(x(e))},ispackage:e=>t().$.isPackage(x(e)),isactivepackage:e=>t().$.isActivePackage(x(e)),getpackagelist:()=>t().$.getPackageList(),addmessagecallback(e,t){},alxcreatesource:(...e)=>0,alxgetwavelen:e=>0,alxlistenerf(e,t){},alxplay:(...e)=>0,alxsetchannelvolume(e,t){},alxsourcef(e,t,r){},alxstop(e){},alxstopall(){},activatedirectinput(){},activatekeyboard(){},deactivatedirectinput(){},deactivatekeyboard(){},disablejoystick(){},enablejoystick(){},enablewinconsole(e){},isjoystickdetected:()=>!1,lockmouse(e){},addmaterialmapping(e,t){},flushtexturecache(){},getdesktopresolution:()=>"1920 1080 32",getdisplaydevicelist:()=>"OpenGL",getresolutionlist:e=>"640 480 800 600 1024 768 1280 720 1920 1080",getvideodriverinfo:()=>"WebGL",isdevicefullscreenonly:e=>!1,isfullscreen:()=>!1,screenshot(e){},setdisplaydevice:e=>!0,setfov(e){},setinteriorrendermode(e){},setopenglanisotropy(e){},setopenglmipreduction(e){},setopenglskymipreduction(e){},setopengltexturecompressionhint(e){},setscreenmode(e,t,r,n){},setverticalsync(e){},setzoomspeed(e){},togglefullscreen(){},videosetgammacorrection(e){},snaptoggle(){},addtaggedstring:e=>0,buildtaggedstring:(e,...t)=>"",detag:e=>x(e),gettag:e=>0,gettaggedstring:e=>"",removetaggedstring(e){},commandtoclient(e,t){},commandtoserver(e){},cancelserverquery(){},querymasterserver(){},querysingleserver(){},setnetport:e=>!0,allowconnections(e){},startheartbeat(){},stopheartbeat(){},gotowebpage(e){},deletedatablocks(){},preloaddatablock:e=>!0,containerboxempty:(...e)=>!0,containerraycast:(...e)=>"",containersearchcurrdist:()=>0,containersearchnext:()=>0,initcontainerradiussearch(){},calcexplosioncoverage:(...e)=>1,getcontrolobjectaltitude:()=>0,getcontrolobjectspeed:()=>0,getterrainheight:e=>0,lightscene(){},pathonmissionloaddone(){}}}function L(e){return e.toLowerCase()}function N(e){let t=e.trim();return L(t.startsWith("$")?t.slice(1):t)}function O(e,t){let r=e.get(t);return r||(r=new Set,e.set(t,r)),r}function I(e,t){for(let r of t)e.add(L(r))}function j(e,t,r){if(e.anyClassValues.has("*")||e.anyClassValues.has(r))return!0;for(let n of t){let t=e.valuesByClass.get(L(n));if(t&&(t.has("*")||t.has(r)))return!0}return!1}let T=[{classNames:["SceneObject","GameBase","ShapeBase","Item","Player"],fields:["position","rotation","scale","transform","hidden","renderingdistance","datablock","shapename","shapefile","initialbarrel","skin","team","health","energy","energylevel","damagelevel","damageflash","damagepercent","damagestate","mountobject","mountedimage","targetposition","targetrotation","targetscale","missiontypeslist","renderenabled","vis","velocity","name"]},{classNames:["*"],fields:["position","rotation","scale","hidden","shapefile","datablock"]}],M=[{classNames:["SceneObject","GameBase","ShapeBase","SimObject"],methods:["settransform","setposition","setrotation","setscale","sethidden","setdatablock","setshapename","mountimage","unmountimage","mountobject","unmountobject","setdamagelevel","setenergylevel","schedule","delete","deleteallobjects","add","remove","playthread","stopthread","setthreaddir","pausethread"]},{classNames:["*"],methods:["settransform","setscale","delete","add","remove"]}],B=["missionrunning","loadingmission"];function P(){return{scripts:new Map,generatedCode:new WeakMap}}function H(e){return e.toLowerCase()}function D(e){return Number(e)>>>0}function F(e){if(null==e)return null;if("string"==typeof e)return e||null;if("number"==typeof e)return String(e);throw Error(`Invalid instance name type: ${typeof e}`)}function G(e={}){let t,r,n,s=e.reactiveFieldRules??T,i=e.reactiveMethodRules??M,o=e.reactiveGlobalNames??B,a=(t=function(e){let t=new Set,r=new Map;for(let n of e)for(let e of n.classNames){let s=L(e);if("*"===s){I(t,n.fields);continue}I(O(r,s),n.fields)}return{anyClassValues:t,valuesByClass:r}}(s),(e,r)=>j(t,e,L(r))),l=(r=function(e){let t=new Set,r=new Map;for(let n of e)for(let e of n.classNames){let s=L(e);if("*"===s){I(t,n.methods);continue}I(O(r,s),n.methods)}return{anyClassValues:t,valuesByClass:r}}(i),(e,t)=>j(r,e,L(t))),u=(n=function(e){let t=new Set;for(let r of e)t.add(N(r));return t}(o),e=>{let t=N(e);return n.has("*")||n.has(t)}),c=new b,p=new b,f=new b,h=[],d=new $,x=3,A=1027,C=new Map,S=new b,v=new b,w=new b,E=new b,_=new b,k=new Set,U=[],J=!1,K=0;if(e.globals)for(let[t,r]of Object.entries(e.globals)){if(!t.startsWith("$"))throw Error(`Global variable "${t}" must start with $, e.g. "$${t}"`);w.set(t.slice(1),r)}let W=new Set,z=new Set,V=e.ignoreScripts&&e.ignoreScripts.length>0?(0,m.default)(e.ignoreScripts,{nocase:!0}):null,Z=e.cache??P(),Q=Z.scripts,X=Z.generatedCode,Y=new Map;function ee(e){let t=Y.get(e);return t&&t.length>0?t[t.length-1]:void 0}function et(e,t,r){let n;(n=Y.get(e))||(n=[],Y.set(e,n)),n.push(t);try{return r()}finally{let t;(t=Y.get(e))&&t.pop()}}function er(e,t){return`${e.toLowerCase()}::${t.toLowerCase()}`}function en(e,t){return c.get(e)?.get(t)??null}function es(e){if(!e)return[];let t=[],r=new Set,n=e.class||e._className||e._class,s=n?H(String(n)):"";for(;s&&!r.has(s);)t.push(s),r.add(s),s=_.get(s)??"";return e._superClass&&!r.has(e._superClass)&&t.push(e._superClass),t}function ei(){if(J=!1,0===U.length)return;let e=U.splice(0,U.length);for(let t of(K+=1,k))t({type:"batch.flushed",tick:K,events:e})}function eo(e){for(let t of(U.push(e),k))t(e);J||(J=!0,queueMicrotask(ei))}function ea(e){eo({type:"object.created",objectId:e._id,object:e})}function el(e,t,r,n){let s=H(t);Object.is(r,n)||a(es(e),s)&&eo({type:"field.changed",objectId:e._id,field:s,value:r,previousValue:n,object:e})}let eu=new Set,ec=null,ep=null,ef=(e.builtins??R)({runtime:()=>ep,fileSystem:e.fileSystem??null});function eh(e){let t=f.get(e);if(!t)return void d.add(e);if(!t.active){for(let[e,r]of(t.active=!0,h.push(t.name),t.methods)){c.has(e)||c.set(e,new b);let t=c.get(e);for(let[e,n]of r)t.has(e)||t.set(e,[]),t.get(e).push(n)}for(let[e,r]of t.functions)p.has(e)||p.set(e,[]),p.get(e).push(r)}}function ed(e){return null==e||""===e?null:"object"==typeof e&&null!=e._id?e:"string"==typeof e?S.get(e)??null:"number"==typeof e?C.get(e)??null:null}function eg(e,t,r){let n=ed(e);if(null==n)return 0;let s=ey(n[t]);return n[t]=s+r,el(n,t,n[t],s),s}function em(e,t){let r=en(e,t);return r&&r.length>0?r[r.length-1]:null}function eb(e,t,r,n){let s=en(e,t);return s&&0!==s.length?{found:!0,result:et(er(e,t),s.length-1,()=>s[s.length-1](r,...n))}:{found:!1}}function e$(e,t,r,n){let s;l((s=es(r)).length?s:[e],t)&&eo({type:"method.called",className:H(e),methodName:H(t),objectId:r._id,args:[...n]});let i=E.get(e);if(i){let e=i.get(t);if(e)for(let t of e)t(r,...n)}}function ey(e){if(null==e||""===e)return 0;let t=Number(e);return isNaN(t)?0:t}function ex(e){if(!e||""===e)return null;e.startsWith("/")&&(e=e.slice(1));let t=e.split("/"),r=null;for(let e=0;et._name?.toLowerCase()===e)??null}if(!r)return null}}return r}function eA(e){return null==e||""===e?null:ex(String(e))}function eC(e,t){function r(e,t){return e+t.join("_")}return{get:(t,...n)=>e.get(r(t,n))??"",set(n,...s){if(0===s.length)throw Error("set() requires at least a value argument");if(1===s.length){let r=e.get(n);return e.set(n,s[0]),t?.onSet?.(n,s[0],r),s[0]}let i=s[s.length-1],o=r(n,s.slice(0,-1)),a=e.get(o);return e.set(o,i),t?.onSet?.(o,i,a),i},postInc(n,...s){let i=r(n,s),o=ey(e.get(i)),a=o+1;return e.set(i,a),t?.onSet?.(i,a,o),o},postDec(n,...s){let i=r(n,s),o=ey(e.get(i)),a=o-1;return e.set(i,a),t?.onSet?.(i,a,o),o}}}function eS(){return eC(new b)}let ev={registerMethod:function(e,t,r){if(ec)ec.methods.has(e)||ec.methods.set(e,new b),ec.methods.get(e).set(t,r);else{c.has(e)||c.set(e,new b);let n=c.get(e);n.has(t)||n.set(t,[]),n.get(t).push(r)}},registerFunction:function(e,t){ec?ec.functions.set(e,t):(p.has(e)||p.set(e,[]),p.get(e).push(t))},package:function(e,t){let r=f.get(e);r||(r={name:e,active:!1,methods:new b,functions:new b},f.set(e,r));let n=ec;ec=r,t(),ec=n,d.has(e)&&(d.delete(e),eh(e))},activatePackage:eh,deactivatePackage:function(e){let t=f.get(e);if(!t||!t.active)return;t.active=!1;let r=h.findIndex(t=>t.toLowerCase()===e.toLowerCase());for(let[e,n]of(-1!==r&&h.splice(r,1),t.methods)){let t=c.get(e);if(t)for(let[e,r]of n){let n=t.get(e);if(n){let e=n.indexOf(r);-1!==e&&n.splice(e,1)}}}for(let[e,r]of t.functions){let t=p.get(e);if(t){let e=t.indexOf(r);-1!==e&&t.splice(e,1)}}},create:function(e,t,r,n){let s=H(e),i=function(){for(;C.has(A);)A+=1;let e=A;return A+=1,e}(),o={_class:s,_className:e,_id:i};for(let[e,t]of Object.entries(r))o[H(e)]=t;o.superclass&&(o._superClass=H(String(o.superclass)),o.class&&_.set(H(String(o.class)),o._superClass)),C.set(i,o);let a=F(t);if(a&&(o._name=a,S.set(a,o)),n){for(let e of n)e._parent=o;o._children=n}let l=em(e,"onAdd");return l&&l(o),ea(o),o},datablock:function(e,t,r,n){let s=H(e),i=function(){for(;C.has(x);)x+=1;let e=x;return x+=1,e}(),o={_class:s,_className:e,_id:i,_isDatablock:!0},a=F(r);if(a){let e=v.get(a);if(e){for(let[t,r]of Object.entries(e))t.startsWith("_")||(o[t]=r);o._parent=e}}for(let[e,t]of Object.entries(n))o[H(e)]=t;C.set(i,o);let l=F(t);return l&&(o._name=l,S.set(l,o),v.set(l,o)),ea(o),o},deleteObject:function e(t){var r;let n;if(null==t||("number"==typeof t?n=C.get(t):"string"==typeof t?n=S.get(t):"object"==typeof t&&t._id&&(n=t),!n))return!1;let s=em(n._className,"onRemove");if(s&&s(n),C.delete(n._id),n._name&&S.delete(n._name),n._isDatablock&&n._name&&v.delete(n._name),n._parent&&n._parent._children){let e=n._parent._children.indexOf(n);-1!==e&&n._parent._children.splice(e,1)}if(n._children)for(let t of[...n._children])e(t);return eo({type:"object.deleted",objectId:(r=n)._id,object:r}),!0},prop:function(e,t){let r=ed(e);return null==r?"":r[H(t)]??""},setProp:function(e,t,r){let n=ed(e);if(null==n)return r;let s=H(t),i=n[s];return n[s]=r,el(n,s,r,i),r},getIndex:function(e,t){let r=ed(e);return null==r?"":r[String(t)]??""},setIndex:function(e,t,r){let n=ed(e);if(null==n)return r;let s=String(t),i=n[s];return n[s]=r,el(n,s,r,i),r},propPostInc:function(e,t){return eg(e,H(t),1)},propPostDec:function(e,t){return eg(e,H(t),-1)},indexPostInc:function(e,t){return eg(e,String(t),1)},indexPostDec:function(e,t){return eg(e,String(t),-1)},key:function(e,...t){return e+t.join("_")},call:function(e,t,...r){if(null==e||("string"==typeof e||"number"==typeof e)&&null==(e=eA(e)))return"";let n=e.class||e._className||e._class;if(n){let s=eb(n,t,e,r);if(s.found)return e$(n,t,e,r),s.result}let s=e._superClass||_.get(n);for(;s;){let n=eb(s,t,e,r);if(n.found)return e$(s,t,e,r),n.result;s=_.get(s)}return""},nsCall:function(e,t,...r){let n=en(e,t);if(!n||0===n.length)return"";let s=er(e,t),i=n[n.length-1],o=et(s,n.length-1,()=>i(...r)),a=r[0];return a&&"object"==typeof a&&e$(e,t,a,r.slice(1)),o},nsRef:function(e,t){let r=en(e,t);if(!r||0===r.length)return null;let n=er(e,t),s=r[r.length-1];return(...e)=>et(n,r.length-1,()=>s(...e))},parent:function(e,t,r,...n){let s=en(e,t),i=er(e,t),o=ee(i);if(s&&void 0!==o&&o>=1){let a=o-1,l=et(i,a,()=>s[a](r,...n));return r&&"object"==typeof r&&e$(e,t,r,n),l}let a=_.get(e);for(;a;){let e=en(a,t);if(e&&e.length>0){let s=et(er(a,t),e.length-1,()=>e[e.length-1](r,...n));return r&&"object"==typeof r&&e$(a,t,r,n),s}a=_.get(a)}return""},parentFunc:function(e,...t){let r=p.get(e);if(!r)return"";let n=e.toLowerCase(),s=ee(n);if(void 0===s||s<1)return"";let i=s-1;return et(n,i,()=>r[i](...t))},add:function(e,t){return ey(e)+ey(t)},sub:function(e,t){return ey(e)-ey(t)},mul:function(e,t){return ey(e)*ey(t)},div:function(e,t){return ey(e)/ey(t)},neg:function(e){return-ey(e)},lt:function(e,t){return ey(e)ey(t)},ge:function(e,t){return ey(e)>=ey(t)},eq:function(e,t){return ey(e)===ey(t)},ne:function(e,t){return ey(e)!==ey(t)},mod:function(e,t){let r=0|Number(t);return 0===r?0:(0|Number(e))%r},bitand:function(e,t){return D(e)&D(t)},bitor:function(e,t){return D(e)|D(t)},bitxor:function(e,t){return D(e)^D(t)},shl:function(e,t){return D(D(e)<<(31&D(t)))},shr:function(e,t){return D(e)>>>(31&D(t))},bitnot:function(e){return~D(e)>>>0},concat:function(...e){return e.map(e=>String(e??"")).join("")},streq:function(e,t){return String(e??"").toLowerCase()===String(t??"").toLowerCase()},switchStr:function(e,t){let r=String(e??"").toLowerCase();for(let[e,n]of Object.entries(t))if("default"!==e&&H(e)===r)return void n();t.default&&t.default()},deref:eA,nameToId:function(e){let t=ex(e);return t?t._id:-1},isObject:function(e){return null!=e&&("object"==typeof e&&!!e._id||("number"==typeof e?C.has(e):"string"==typeof e&&S.has(e)))},isFunction:function(e){return p.has(e)||e.toLowerCase()in ef},isPackage:function(e){return f.has(e)},isActivePackage:function(e){let t=f.get(e);return t?.active??!1},getPackageList:function(){return h.join(" ")},locals:eS,onMethodCalled(e,t,r){let n=E.get(e);n||(n=new b,E.set(e,n));let s=n.get(t);return s||(s=[],n.set(t,s)),s.push(r),()=>{let e=s.indexOf(r);-1!==e&&s.splice(e,1)}}},ew={call(e,...t){let r=p.get(e);if(r&&r.length>0)return et(e.toLowerCase(),r.length-1,()=>r[r.length-1](...t));let n=ef[e.toLowerCase()];return n?n(...t):(console.warn(`Unknown function: ${e}(${t.map(e=>JSON.stringify(e)).join(", ")})`),"")}},eE=eC(w,{onSet:function(e,t,r){let n=H(e.startsWith("$")?e.slice(1):e);Object.is(t,r)||u(n)&&eo({type:"global.changed",name:n,value:t,previousValue:r})}}),e_={methods:c,functions:p,packages:f,activePackages:h,objectsById:C,objectsByName:S,datablocks:v,globals:w,executedScripts:W,failedScripts:z,scripts:Q,generatedCode:X,pendingTimeouts:eu,startTime:Date.now()};function ek(e){let t=function(e){let t=X.get(e);null==t&&(t=new g(void 0).generate(e),X.set(e,t));return t}(e),r=eS();Function("$","$f","$g","$l",t)(ev,ew,eE,r)}function eR(e,t){return{execute(){if(t){let e=y(t);e_.executedScripts.add(e)}ek(e)}}}async function eL(t,r,n){let s=e.loadScript;if(!s){t.length>0&&console.warn("Script has exec() calls but no loadScript provided:",t);return}async function i(t){e.signal?.throwIfAborted();let i=y(t);if(e_.scripts.has(i)||e_.failedScripts.has(i))return;if(V&&V(i)){console.warn(`Ignoring script: ${t}`),e_.failedScripts.add(i);return}if(n.has(i))return;let o=r.get(i);if(o)return void await o;e.progress?.addItem(t);let a=(async()=>{let o,a=await s(t);if(null==a){console.warn(`Script not found: ${t}`),e_.failedScripts.add(i),e.progress?.completeItem();return}try{o=q(a,{filename:t})}catch(r){console.warn(`Failed to parse script: ${t}`,r),e_.failedScripts.add(i),e.progress?.completeItem();return}let l=new Set(n);l.add(i),await eL(o.execScriptPaths,r,l),e_.scripts.set(i,o),e.progress?.completeItem()})();r.set(i,a),await a}await Promise.all(t.map(i))}async function eN(t){let r=e.loadScript;if(!r)throw Error("loadFromPath requires loadScript option to be set");let n=y(t);if(e_.scripts.has(n))return eR(e_.scripts.get(n),t);e.progress?.addItem(t);let s=await r(t);if(null==s)throw e.progress?.completeItem(),Error(`Script not found: ${t}`);let i=await eO(s,{path:t});return e.progress?.completeItem(),i}async function eO(e,t){if(t?.path){let e=y(t.path);if(e_.scripts.has(e))return eR(e_.scripts.get(e),t.path)}return eI(q(e,{filename:t?.path}),t)}async function eI(t,r){let n=new Map,s=new Set;if(r?.path){let e=y(r.path);e_.scripts.set(e,t),s.add(e)}let i=[...t.execScriptPaths,...e.preloadScripts??[]];return await eL(i,n,s),eR(t,r?.path)}return ep={$:ev,$f:ew,$g:eE,state:e_,destroy:function(){for(let e of(U.length>0&&ei(),e_.pendingTimeouts))clearTimeout(e);e_.pendingTimeouts.clear(),k.clear()},executeAST:ek,loadFromPath:eN,loadFromSource:eO,loadFromAST:eI,call:(e,...t)=>ew.call(e,...t),getObjectByName:e=>S.get(e),subscribeRuntimeEvents:e=>(k.add(e),()=>{k.delete(e)})}}function U(){let e=new Set,t=0,r=0,n=null;function s(){for(let t of e)t()}return{get total(){return t},get loaded(){return r},get current(){return n},get progress(){return 0===t?0:r/t},on(t,r){e.add(r)},off(t,r){e.delete(r)},addItem(e){t++,n=e,s()},completeItem(){r++,n=null,s()},setCurrent(e){n=e,s()}}}function q(e,t){try{return f.default.parse(e)}catch(e){if(t?.filename&&e.location)throw Error(`${t.filename}:${e.location.start.line}:${e.location.start.column}: ${e.message}`,{cause:e});throw e}}function J(e){if("boolean"==typeof e)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){let t=e.trim().toLowerCase();return""!==t&&"0"!==t&&"false"!==t}return!!e}function K(){let e=Error("Operation aborted");return e.name="AbortError",e}function W(e){let t,{missionName:r,missionType:n,runtimeOptions:s,onMissionLoadDone:i}=e,{signal:o,fileSystem:a,globals:l={},preloadScripts:u=[],reactiveGlobalNames:c}=s??{},p=a?.findFiles("scripts/*Game.cs")??[],f=c?Array.from(new Set([...c,"missionRunning"])):void 0,h=G({...s,reactiveGlobalNames:f,globals:{...l,"$Host::Map":r,"$Host::MissionType":n},preloadScripts:[...u,...p]});(t=h.$.registerMethod.bind(h.$))("ShapeBase","playThread",(e,t,r)=>{e._threads||(e._threads={}),e._threads[Number(t)]={sequence:String(r),playing:!0,direction:!0}}),t("ShapeBase","stopThread",(e,t)=>{e._threads&&delete e._threads[Number(t)]}),t("ShapeBase","setThreadDir",(e,t,r)=>{e._threads||(e._threads={});let n=Number(t);e._threads[n]?e._threads[n].direction=!!Number(r):e._threads[n]={sequence:"",playing:!1,direction:!!Number(r)}}),t("ShapeBase","pauseThread",(e,t)=>{e._threads?.[Number(t)]&&(e._threads[Number(t)].playing=!1)}),t("ShapeBase","playAudio",()=>{}),t("ShapeBase","stopAudio",()=>{}),t("SimObject","getDatablock",e=>{let t=e.datablock;return t?h.getObjectByName(String(t))??"":""}),t("SimObject","getGroup",e=>e._parent??""),t("SimObject","getName",e=>e._name??""),t("SimObject","getType",()=>16384),t("SimGroup","getCount",e=>e._children?e._children.length:0),t("SimGroup","getObject",(e,t)=>{let r=e._children;return r?r[Number(t)]??"":""}),t("GameBase","isEnabled",()=>!0),t("GameBase","isDisabled",()=>!1),t("GameBase","setPoweredState",()=>{}),t("GameBase","setRechargeRate",()=>{}),t("GameBase","getRechargeRate",()=>0),t("GameBase","setEnergyLevel",()=>{}),t("GameBase","getEnergyLevel",()=>0),t("ShapeBase","getDamageLevel",()=>0),t("ShapeBase","setDamageLevel",()=>{}),t("ShapeBase","getRepairRate",()=>0),t("ShapeBase","setRepairRate",()=>{}),t("ShapeBase","getDamagePercent",()=>0),t("GameBase","getControllingClient",()=>0),t("SimObject","schedule",(e,t,r,...n)=>{let s=setTimeout(()=>{h.state.pendingTimeouts.delete(s);try{h.$.call(e,String(r),...n)}catch(t){console.error(`schedule: error calling ${r} on ${e._id}:`,t)}},Number(t)||0);return h.state.pendingTimeouts.add(s),s});let d=async function(){try{let e=await h.loadFromPath("scripts/server.cs");o?.throwIfAborted(),await h.loadFromPath(`missions/${r}.mis`),o?.throwIfAborted(),e.execute();let t=function(e,t){let{signal:r,onMissionLoadDone:n}=t;return new Promise((t,s)=>{let i=!1,o=!1,a=()=>J(e.$g.get("missionRunning")),l=()=>{i||(i=!0,h(),t())},u=e=>{i||(i=!0,h(),s(e))},c=t=>{if(!n||o)return;let r=t??e.getObjectByName("Game");r&&(o=!0,n(r))},p=()=>u(K()),f=e.subscribeRuntimeEvents(e=>{if("global.changed"===e.type&&"missionrunning"===e.name){J(e.value)&&(c(),l());return}"batch.flushed"===e.type&&a()&&(c(),l())});function h(){f(),r?.removeEventListener("abort",p)}if(r){if(r.aborted)return void u(K());r.addEventListener("abort",p,{once:!0})}a()&&(c(),l())})}(h,{signal:o,onMissionLoadDone:i}),n=await h.loadFromSource("CreateServer($Host::Map, $Host::MissionType);");o?.throwIfAborted(),n.execute(),await t}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}}();return{runtime:h,ready:d}}e.s(["createProgressTracker",()=>U],38433);let z=/^[ \t]*(DisplayName|MissionTypes|BriefingWAV|Bitmap|PlanetName)[ \t]*=[ \t]*(.+)$/i,V=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+BEGIN[ \t]*-+$/i,Z=/^[ \t]*-+[ \t]*([A-Z ]+)[ \t]+END[ \t]*-+$/i,Q={arena:"Arena",bounty:"Bounty",cnh:"CnH",ctf:"CTF",dm:"DM",dnd:"DnD",hunters:"Hunters",lakrabbit:"LakRabbit",lakzm:"LakZM",lctf:"LCTF",none:"None",rabbit:"Rabbit",sctf:"SCtF",siege:"Siege",singleplayer:"SinglePlayer",tdm:"TDM",teamhunters:"TeamHunters",teamlak:"TeamLak",tr2:"TR2"};function X(e){let t=q(e),{pragma:r,sections:n}=function(e){let t={},r=[],n={name:null,comments:[]};for(let s of e.body)if("Comment"===s.type){let e=function(e){let t;return(t=e.match(V))?{type:"sectionBegin",name:t[1]}:(t=e.match(Z))?{type:"sectionEnd",name:t[1]}:(t=e.match(z))?{type:"definition",identifier:t[1],value:t[2]}:null}(s.value);if(e)switch(e.type){case"definition":null===n.name?t[e.identifier.toLowerCase()]=e.value:n.comments.push(s.value);break;case"sectionBegin":(null!==n.name||n.comments.length>0)&&r.push(n),n={name:e.name.toUpperCase(),comments:[]};break;case"sectionEnd":null!==n.name&&r.push(n),n={name:null,comments:[]}}else n.comments.push(s.value)}return(null!==n.name||n.comments.length>0)&&r.push(n),{pragma:t,sections:r}}(t);function s(e){return n.find(t=>t.name===e)?.comments.map(e=>e.trimStart()).join("\n")??null}return{displayName:r.displayname??null,missionTypes:r.missiontypes?.split(/\s+/).filter(Boolean).map(e=>Q[e.toLowerCase()]??e)??[],missionBriefing:s("MISSION BRIEFING"),briefingWav:r.briefingwav??null,bitmap:r.bitmap??null,planetName:r.planetname??null,missionBlurb:s("MISSION BLURB"),missionQuote:s("MISSION QUOTE"),missionString:s("MISSION STRING"),execScriptPaths:t.execScriptPaths,hasDynamicExec:t.hasDynamicExec,ast:t}}function Y(e,t){if(e)return e[t.toLowerCase()]}function ee(e){let[t,r,n]=(e.position??"0 0 0").split(" ").map(e=>parseFloat(e));return[r||0,n||0,t||0]}function et(e){let[t,r,n]=(e.scale??"1 1 1").split(" ").map(e=>parseFloat(e));return[r||0,n||0,t||0]}e.s(["getPosition",()=>ee,"getProperty",()=>Y,"getScale",()=>et,"parseMissionScript",()=>X],62395);let er="/t2-mapper",en=`${er}/base/`,es=`${er}/magenta.png`;function ei(e,t){let r;try{r=o(e)}catch(r){if(t)return console.warn(`Resource "${e}" not found - rendering fallback.`),t;throw r}let[n,s]=i(r);return n?`${en}@vl2/${n}/${s}`:`${en}${s}`}function eo(e){return ei(`interiors/${e}`).replace(/\.dif$/i,".glb")}function ea(e){return ei(`shapes/${e}`).replace(/\.dts$/i,".glb")}function el(e){return e=e.replace(/^terrain\./,""),ei(u(`textures/terrain/${e}`),es)}function eu(e,r){let n=t(r).split("/"),s=n.length>1?n.slice(0,-1).join("/")+"/":"";return ei(u(`${s}${e}`),es)}function ec(e){return ei(u(`textures/${e}`),es)}function ep(e){return ei(`audio/${e}`).replace(/\.wav$/i,".ogg")}async function ef(e){let t=ei(`textures/${e}`),r=await fetch(t);return(await r.text()).split(/(?:\r\n|\r|\n)/).map(e=>{if(!(e=e.trim()).startsWith(";"))return e}).filter(Boolean)}async function eh(e){let t,r=c(e),n=await fetch(ei(r.resourcePath)),s=await n.arrayBuffer();try{t=new TextDecoder("utf-8",{fatal:!0}).decode(s)}catch{t=new TextDecoder("windows-1252").decode(s)}return X(t=t.replaceAll("�","'"))}async function ed(e){let t=await fetch(ei(`terrains/${e}`));return function(e){let t=new DataView(e),r=0,n=t.getUint8(r++),s=new Uint16Array(65536),i=[],o=e=>{let n="";for(let s=0;s0&&i.push(s)}let a=[];for(let e of i){let e=new Uint8Array(65536);for(let n=0;n<65536;n++){let s=t.getUint8(r++);e[n]=s}a.push(e)}return{version:n,textureNames:i,heightMap:s,alphaMaps:a}}(await t.arrayBuffer())}async function eg(e){let t=ei(e),r=await fetch(t);return(await r.text()).split(/(?:\r\n|\r|\n)/g).map(e=>e.trim()).filter(Boolean).filter(e=>!e.startsWith(";")).map(e=>{let t=e.match(/^(.+)\s(\d+)$/);if(!t)return{name:e,frameCount:1};{let e=parseInt(t[2],10);return{name:t[1],frameCount:e}}})}e.s(["FALLBACK_TEXTURE_URL",0,es,"RESOURCE_ROOT_URL",0,en,"audioToUrl",()=>ep,"getUrlForPath",()=>ei,"iflTextureToUrl",()=>eu,"interiorToUrl",()=>eo,"loadDetailMapList",()=>ef,"loadImageFrameList",()=>eg,"loadMission",()=>eh,"loadTerrain",()=>ed,"shapeToUrl",()=>ea,"terrainTextureToUrl",()=>el,"textureToUrl",()=>ec],12979)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/e5617268e3c7a140.js b/docs/_next/static/chunks/e5617268e3c7a140.js new file mode 100644 index 00000000..e6d1ad19 --- /dev/null +++ b/docs/_next/static/chunks/e5617268e3c7a140.js @@ -0,0 +1 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,64972,e=>{"use strict";var r=e.i(43476),t=e.i(932),i=e.i(71645),s=e.i(71753),o=e.i(47071),n=e.i(90072),a=e.i(85557),c=e.i(12979);let l=new n.Vector3,u=new n.Vector3,d=new n.Vector3,f=new n.Vector3,b=new n.Vector3,x=new n.Vector3,y=new n.Vector3(0,1,0);function h(e){let i,s,a,l,u,d=(0,t.c)(14),{visual:f}=e;d[0]!==f.texture?(i=(0,c.textureToUrl)(f.texture),d[0]=f.texture,d[1]=i):i=d[1];let b=i,x=(0,o.useTexture)(b,p),y=Array.isArray(x)?x[0]:x;d[2]!==f.color.b||d[3]!==f.color.g||d[4]!==f.color.r?(s=new n.Color().setRGB(f.color.r,f.color.g,f.color.b,n.SRGBColorSpace),d[2]=f.color.b,d[3]=f.color.g,d[4]=f.color.r,d[5]=s):s=d[5];let h=s;return d[6]!==f.size?(a=[f.size,f.size,1],d[6]=f.size,d[7]=a):a=d[7],d[8]!==h||d[9]!==y?(l=(0,r.jsx)("spriteMaterial",{map:y,color:h,transparent:!0,blending:n.AdditiveBlending,depthWrite:!1,toneMapped:!1}),d[8]=h,d[9]=y,d[10]=l):l=d[10],d[11]!==a||d[12]!==l?(u=(0,r.jsx)("sprite",{scale:a,children:l}),d[11]=a,d[12]=l,d[13]=u):u=d[13],u}function p(e){let r=Array.isArray(e)?e[0]:e;(0,a.setupEffectTexture)(r)}function m(e){let h,p,m,g,S,w,j,z,T,V,v,C,B=(0,t.c)(28),{entity:R,visual:U}=e,_=(0,i.useRef)(null),F=(0,i.useRef)(null),q=(0,i.useRef)(null);B[0]===Symbol.for("react.memo_cache_sentinel")?(h=new n.Quaternion,B[0]=h):h=B[0];let M=(0,i.useRef)(h);B[1]!==U.texture?(p=(0,c.textureToUrl)(U.texture),B[1]=U.texture,B[2]=p):p=B[2];let W=U.crossTexture??U.texture;B[3]!==W?(m=(0,c.textureToUrl)(W),B[3]=W,B[4]=m):m=B[4],B[5]!==p||B[6]!==m?(g=[p,m],B[5]=p,B[6]=m,B[7]=g):g=B[7];let G=g,P=(0,o.useTexture)(G,A);B[8]!==P?(S=Array.isArray(P)?P:[P,P],B[8]=P,B[9]=S):S=B[9];let[D,L]=S;return B[10]!==R||B[11]!==U.crossSize||B[12]!==U.crossViewAng||B[13]!==U.renderCross||B[14]!==U.tracerLength||B[15]!==U.tracerWidth?(w=e=>{let{camera:r}=e,t=_.current,i=F.current;if(!t||!i)return;let s=R.keyframes?.[0],o=s?.position,n=R.direction??s?.velocity;if(!o||!n||((0,a.torqueVecToThree)(n,l),1e-8>l.lengthSq())){t.visible=!1,q.current&&(q.current.visible=!1);return}l.normalize(),t.visible=!0,(0,a.torqueVecToThree)(o,x),u.copy(x).sub(r.position),d.crossVectors(u,l),1e-8>d.lengthSq()&&(d.crossVectors(y,l),1e-8>d.lengthSq()&&d.set(1,0,0)),d.normalize().multiplyScalar(U.tracerWidth);let c=.5*U.tracerLength;f.copy(l).multiplyScalar(-c),b.copy(l).multiplyScalar(c);let h=i.array;h[0]=f.x+d.x,h[1]=f.y+d.y,h[2]=f.z+d.z,h[3]=f.x-d.x,h[4]=f.y-d.y,h[5]=f.z-d.z,h[6]=b.x-d.x,h[7]=b.y-d.y,h[8]=b.z-d.z,h[9]=b.x+d.x,h[10]=b.y+d.y,h[11]=b.z+d.z,i.needsUpdate=!0;let p=q.current;if(!p)return;if(!U.renderCross){p.visible=!1;return}u.normalize();let m=l.dot(u);if(m>-U.crossViewAng&&mh,"TracerProjectile",()=>m])}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/ee88398bb27ad4a1.js b/docs/_next/static/chunks/ee88398bb27ad4a1.js new file mode 100644 index 00000000..b1a28faa --- /dev/null +++ b/docs/_next/static/chunks/ee88398bb27ad4a1.js @@ -0,0 +1,521 @@ +(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,29418,e=>{e.v({Bottom:"PlayerNameplate-module__zYDm0a__Bottom PlayerNameplate-module__zYDm0a__Root",HealthBar:"PlayerNameplate-module__zYDm0a__HealthBar",HealthFill:"PlayerNameplate-module__zYDm0a__HealthFill",IffArrow:"PlayerNameplate-module__zYDm0a__IffArrow",Name:"PlayerNameplate-module__zYDm0a__Name",Root:"PlayerNameplate-module__zYDm0a__Root",Top:"PlayerNameplate-module__zYDm0a__Top PlayerNameplate-module__zYDm0a__Root"})},78779,e=>{e.v({Distance:"FlagMarker-module__INpLba__Distance",Icon:"FlagMarker-module__INpLba__Icon",Root:"FlagMarker-module__INpLba__Root"})},87297,38437,e=>{"use strict";var t=e.i(43476),r=e.i(932),a=e.i(71645),i=e.i(90072),o=e.i(71753);e.i(13876);var l=e.i(92224),n=e.i(77964),s=e.i(93784),u=e.i(91907),c=e.i(25947),f=e.i(89887),d=e.i(79123),m=e.i(68294);function g(e){let t,o,l,n,s=(0,r.c)(12),{entity:u}=e,{registerCamera:c,unregisterCamera:f}=(0,m.useCameras)(),d=(0,a.useId)(),g=u.cameraDataBlock;s[0]!==u.position?(t=u.position?new i.Vector3(...u.position):new i.Vector3,s[0]=u.position,s[1]=t):t=s[1];let h=t;s[2]!==u.rotation?(o=u.rotation?new i.Quaternion(...u.rotation):new i.Quaternion,s[2]=u.rotation,s[3]=o):o=s[3];let p=o;return s[4]!==g||s[5]!==d||s[6]!==h||s[7]!==c||s[8]!==p||s[9]!==f?(l=()=>{if("Observer"===g){let e={id:d,position:h,rotation:p};return c(e),()=>{f(e)}}},n=[d,g,c,f,h,p],s[4]=g,s[5]=d,s[6]=h,s[7]=c,s[8]=p,s[9]=f,s[10]=l,s[11]=n):(l=s[10],n=s[11]),(0,a.useEffect)(l,n),null}function h(e){let a,i=(0,r.c)(3),{entity:o}=e;return i[0]!==o.label||i[1]!==o.position?(a=o.label?(0,t.jsx)(f.FloatingLabel,{position:o.position,opacity:.6,children:o.label}):null,i[0]=o.label,i[1]=o.position,i[2]=a):a=i[2],a}var p=e.i(15080),v=e.i(66027),x=e.i(63318),b=e.i(12979),y=e.i(75567),S=e.i(47071);let F={sunLightPointsDown:{value:!0}};function w(e){F.sunLightPointsDown.value=e}e.s(["globalSunUniforms",0,F,"updateGlobalSunUniforms",()=>w],38437);let T=` +vec3 terrainLinearToSRGB(vec3 linear) { + vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055; + vec3 lower = linear * 12.92; + return mix(lower, higher, step(vec3(0.0031308), linear)); +} + +vec3 terrainSRGBToLinear(vec3 srgb) { + vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4)); + vec3 lower = srgb / 12.92; + return mix(lower, higher, step(vec3(0.04045), srgb)); +} + +// Debug grid overlay using screen-space derivatives for sharp, anti-aliased lines +// Returns 1.0 on grid lines, 0.0 elsewhere +float terrainDebugGrid(vec2 uv, float gridSize, float lineWidth) { + vec2 scaledUV = uv * gridSize; + vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); + float line = min(grid.x, grid.y); + return 1.0 - min(line / lineWidth, 1.0); +} +`;var M=e.i(47021),D=e.i(48066);let C={0:32,1:32,2:32,3:32,4:32,5:32},j=(0,a.memo)(function({displacementMap:e,visibilityMask:r,textureNames:o,alphaTextures:l,detailTextureName:n,lightmap:s}){let{debugMode:u}=(0,d.useDebug)(),c=(0,S.useTexture)(o.map(e=>(0,b.terrainTextureToUrl)(e)),e=>{e.forEach(e=>(0,y.setupTexture)(e))}),f=n?(0,b.textureToUrl)(n):null,m=(0,S.useTexture)(f??b.FALLBACK_TEXTURE_URL,e=>{(0,y.setupTexture)(e)}),g=(0,a.useCallback)(e=>{!function({shader:e,baseTextures:t,alphaTextures:r,visibilityMask:a,tiling:i,detailTexture:o=null,lightmap:l=null}){e.uniforms.sunLightPointsDown=F.sunLightPointsDown;let n=t.length;if(t.forEach((t,r)=>{e.uniforms[`albedo${r}`]={value:t}}),r.forEach((t,r)=>{e.uniforms[`mask${r}`]={value:t}}),a&&(e.uniforms.visibilityMask={value:a}),t.forEach((t,r)=>{e.uniforms[`tiling${r}`]={value:i[r]??32}}),l&&(e.uniforms.terrainLightmap={value:l}),o&&(e.uniforms.detailTexture={value:o},e.uniforms.detailTiling={value:64},e.uniforms.detailFadeDistance={value:150},e.vertexShader=e.vertexShader.replace("#include ",`#include +varying vec3 vTerrainWorldPos;`),e.vertexShader=e.vertexShader.replace("#include ",`#include +vTerrainWorldPos = (modelMatrix * vec4(transformed, 1.0)).xyz;`)),e.fragmentShader=` +uniform sampler2D albedo0; +uniform sampler2D albedo1; +uniform sampler2D albedo2; +uniform sampler2D albedo3; +uniform sampler2D albedo4; +uniform sampler2D albedo5; +uniform sampler2D mask0; +uniform sampler2D mask1; +uniform sampler2D mask2; +uniform sampler2D mask3; +uniform sampler2D mask4; +uniform sampler2D mask5; +uniform float tiling0; +uniform float tiling1; +uniform float tiling2; +uniform float tiling3; +uniform float tiling4; +uniform float tiling5; +${a?"uniform sampler2D visibilityMask;":""} +${l?"uniform sampler2D terrainLightmap;":""} +uniform bool sunLightPointsDown; +${o?`uniform sampler2D detailTexture; +uniform float detailTiling; +uniform float detailFadeDistance; +varying vec3 vTerrainWorldPos;`:""} + +${T} + +// Global variable to store shadow factor from RE_Direct for use in output calculation +float terrainShadowFactor = 1.0; +`+e.fragmentShader,a){let t="#include ";e.fragmentShader=e.fragmentShader.replace(t,`${t} + // Early discard for invisible areas (before fog/lighting) + float visibility = texture2D(visibilityMask, vMapUv).r; + if (visibility < 0.5) { + discard; + } + `)}e.fragmentShader=e.fragmentShader.replace("#include ",` + // Sample base albedo layers (sRGB textures auto-decoded to linear by Three.js) + vec2 baseUv = vMapUv; + vec3 c0 = texture2D(albedo0, baseUv * vec2(tiling0)).rgb; + ${n>1?"vec3 c1 = texture2D(albedo1, baseUv * vec2(tiling1)).rgb;":""} + ${n>2?"vec3 c2 = texture2D(albedo2, baseUv * vec2(tiling2)).rgb;":""} + ${n>3?"vec3 c3 = texture2D(albedo3, baseUv * vec2(tiling3)).rgb;":""} + ${n>4?"vec3 c4 = texture2D(albedo4, baseUv * vec2(tiling4)).rgb;":""} + ${n>5?"vec3 c5 = texture2D(albedo5, baseUv * vec2(tiling5)).rgb;":""} + + // Sample alpha masks for all layers (use R channel) + // Add +0.5 texel offset: Torque samples alpha at grid corners (integer indices), + // but GPU linear filtering samples at texel centers. This offset aligns them. + vec2 alphaUv = baseUv + vec2(0.5 / 256.0); + float a0 = texture2D(mask0, alphaUv).r; + ${n>1?"float a1 = texture2D(mask1, alphaUv).r;":""} + ${n>2?"float a2 = texture2D(mask2, alphaUv).r;":""} + ${n>3?"float a3 = texture2D(mask3, alphaUv).r;":""} + ${n>4?"float a4 = texture2D(mask4, alphaUv).r;":""} + ${n>5?"float a5 = texture2D(mask5, alphaUv).r;":""} + + // Torque-style additive weighted blending (blender.cc): + // result = tex0 * alpha0 + tex1 * alpha1 + tex2 * alpha2 + ... + // Each layer's alpha map defines its contribution weight. + vec3 blended = c0 * a0; + ${n>1?"blended += c1 * a1;":""} + ${n>2?"blended += c2 * a2;":""} + ${n>3?"blended += c3 * a3;":""} + ${n>4?"blended += c4 * a4;":""} + ${n>5?"blended += c5 * a5;":""} + + // Assign to diffuseColor before lighting + vec3 textureColor = blended; + + ${o?`// Detail texture blending (Torque-style multiplicative blend) + // Sample detail texture at high frequency tiling + vec3 detailColor = texture2D(detailTexture, baseUv * detailTiling).rgb; + + // Calculate distance-based fade factor using world positions + // Torque: distFactor = (zeroDetailDistance - distance) / zeroDetailDistance + float distToCamera = distance(vTerrainWorldPos, cameraPosition); + float detailFade = clamp(1.0 - distToCamera / detailFadeDistance, 0.0, 1.0); + + // Torque blending: dst * lerp(1.0, detailTexel, fadeFactor) + // Detail textures are authored with bright values (~0.8 mean), not 0.5 gray + // Direct multiplication adds subtle darkening for surface detail + textureColor *= mix(vec3(1.0), detailColor, detailFade);`:""} + + // Store blended texture in diffuseColor (still in linear space here) + // We'll convert to sRGB in the output calculation + diffuseColor.rgb = textureColor; +`),l&&(e.fragmentShader=e.fragmentShader.replace("#include ",`#include + +// Override RE_Direct to extract shadow factor for Torque-style gamma-space lighting +#undef RE_Direct +void RE_Direct_TerrainShadow( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + // Torque lighting (terrLighting.cc): if light points up, terrain gets only ambient + // This prevents shadow acne from light hitting terrain backfaces + if (!sunLightPointsDown) { + terrainShadowFactor = 0.0; + return; + } + // directLight.color = sunColor * shadowFactor (shadow already applied by Three.js) + // Extract shadow factor by comparing to original sun color + #if ( NUM_DIR_LIGHTS > 0 ) + vec3 originalSunColor = directionalLights[0].color; + float sunMax = max(max(originalSunColor.r, originalSunColor.g), originalSunColor.b); + float shadowedMax = max(max(directLight.color.r, directLight.color.g), directLight.color.b); + terrainShadowFactor = clamp(shadowedMax / max(sunMax, 0.001), 0.0, 1.0); + #endif + // Don't add to reflectedLight - we'll compute lighting in gamma space at output +} +#define RE_Direct RE_Direct_TerrainShadow + +`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include +// Clear indirect diffuse - we'll compute ambient in gamma space +#if defined( RE_IndirectDiffuse ) + irradiance = vec3(0.0); +#endif +`),e.fragmentShader=e.fragmentShader.replace("#include ",`#include + // Clear Three.js lighting - we compute everything in gamma space + reflectedLight.directDiffuse = vec3(0.0); + reflectedLight.indirectDiffuse = vec3(0.0); +`)),e.fragmentShader=e.fragmentShader.replace("#include ",`// Torque-style terrain lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space +{ + // Get texture in sRGB space (undo Three.js linear decode) + vec3 textureSRGB = terrainLinearToSRGB(diffuseColor.rgb); + + ${l?` + // Sample terrain lightmap for smooth NdotL + vec2 lightmapUv = vMapUv + vec2(0.5 / 512.0); + float lightmapNdotL = texture2D(terrainLightmap, lightmapUv).r; + + // Get sun and ambient colors from Three.js lights (these ARE sRGB values from mission file) + // Three.js interprets them as linear, but the numerical values are preserved + #if ( NUM_DIR_LIGHTS > 0 ) + vec3 sunColorSRGB = directionalLights[0].color; + #else + vec3 sunColorSRGB = vec3(0.7); + #endif + vec3 ambientColorSRGB = ambientLightColor; + + // Torque formula (terrLighting.cc:471-483): + // lighting = ambient + NdotL * shadowFactor * sunColor + // Clamp lighting to [0,1] before multiplying by texture + vec3 lightingSRGB = clamp(ambientColorSRGB + lightmapNdotL * terrainShadowFactor * sunColorSRGB, 0.0, 1.0); + `:` + // No lightmap - use simple ambient lighting + vec3 lightingSRGB = ambientLightColor; + `} + + // Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space + vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0); + + // Convert back to linear for Three.js output pipeline + outgoingLight = terrainSRGBToLinear(resultSRGB) + totalEmissiveRadiance; +} +#include `),e.fragmentShader=e.fragmentShader.replace("#include ",`#if DEBUG_MODE + // Debug mode: overlay green grid matching terrain grid squares (256x256) + float gridIntensity = terrainDebugGrid(vMapUv, 256.0, 1.5); + vec3 gridColor = vec3(0.0, 0.8, 0.4); // Green + gl_FragColor.rgb = mix(gl_FragColor.rgb, gridColor, gridIntensity * 0.1); +#endif + +#include `)}({shader:e,baseTextures:c,alphaTextures:l,visibilityMask:r,tiling:C,detailTexture:f?m:null,lightmap:s}),(0,M.injectCustomFog)(e,D.globalFogUniforms)},[c,l,r,m,f,s]),h=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=h.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!u,e.needsUpdate=!0)},[u]);let p=`${f?"detail":"nodetail"}-${s?"lightmap":"nolightmap"}`;return(0,t.jsx)("meshLambertMaterial",{ref:h,map:e,depthWrite:!0,side:i.FrontSide,defines:{DEBUG_MODE:+!!u},onBeforeCompile:g},p)}),_=(0,a.memo)(function(e){let i,o,l=(0,r.c)(8),{displacementMap:n,visibilityMask:s,textureNames:u,alphaTextures:c,detailTextureName:f,lightmap:d}=e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("meshLambertMaterial",{color:"rgb(0, 109, 56)",wireframe:!0}),l[0]=i):i=l[0],l[1]!==c||l[2]!==f||l[3]!==n||l[4]!==d||l[5]!==u||l[6]!==s?(o=(0,t.jsx)(a.Suspense,{fallback:i,children:(0,t.jsx)(j,{displacementMap:n,visibilityMask:s,textureNames:u,alphaTextures:c,detailTextureName:f,lightmap:d})}),l[1]=c,l[2]=f,l[3]=n,l[4]=d,l[5]=u,l[6]=s,l[7]=o):o=l[7],o}),k=(0,a.memo)(function(e){let a,i,o,l=(0,r.c)(15),{tileX:n,tileZ:s,blockSize:u,basePosition:c,textureNames:f,geometry:d,displacementMap:m,visibilityMask:g,alphaTextures:h,detailTextureName:p,lightmap:v,visible:x}=e,b=void 0===x||x,y=u/2,S=c.x+n*u+y,F=c.z+s*u+y;l[0]!==S||l[1]!==F?(a=[S,0,F],l[0]=S,l[1]=F,l[2]=a):a=l[2];let w=a;return l[3]!==h||l[4]!==p||l[5]!==m||l[6]!==v||l[7]!==f||l[8]!==g?(i=(0,t.jsx)(_,{displacementMap:m,visibilityMask:g,textureNames:f,alphaTextures:h,detailTextureName:p,lightmap:v}),l[3]=h,l[4]=p,l[5]=m,l[6]=v,l[7]=f,l[8]=g,l[9]=i):i=l[9],l[10]!==d||l[11]!==w||l[12]!==i||l[13]!==b?(o=(0,t.jsx)("mesh",{position:w,geometry:d,castShadow:!0,receiveShadow:!0,visible:b,children:i}),l[10]=d,l[11]=w,l[12]=i,l[13]=b,l[14]=o):o=l[14],o});var R=e.i(8328);function B(e){let t=new Uint8Array(65536);for(let r of(t.fill(255),e)){let e=255&r,a=r>>8&255,i=r>>16,o=256*a;for(let r=0;r0?_.visibleDistance:600,W=(0,p.useThree)(G),O=-(128*H);A[0]!==O?(n={x:O,z:O},A[0]=O,A[1]=n):n=A[1];let Y=n;A[2]!==E.emptySquareRuns?(s=E.emptySquareRuns??[],A[2]=E.emptySquareRuns,A[3]=s):s=A[3];let K=s,{data:Q}=((I=(0,r.c)(2))[0]!==P?(L={queryKey:["terrain",P],queryFn:()=>(0,b.loadTerrain)(P)},I[0]=P,I[1]=L):L=I[1],(0,v.useQuery)(L));e:{let e;if(!Q){u=null;break e}let t=256*H;A[4]!==t||A[5]!==H||A[6]!==Q.heightMap?(!function(e,t,r){let a=e.attributes.position,i=e.attributes.uv,o=e.attributes.normal,l=a.array,n=i.array,s=o.array,u=a.count,c=(e,r)=>(e=Math.max(0,Math.min(255,e)),t[256*(r=Math.max(0,Math.min(255,r)))+e]/65535*2048),f=(e,r)=>{let a=Math.floor(e=Math.max(0,Math.min(255,e))),i=Math.floor(r=Math.max(0,Math.min(255,r))),o=Math.min(a+1,255),l=Math.min(i+1,255),n=e-a,s=r-i;return(t[256*i+a]/65535*2048*(1-n)+t[256*i+o]/65535*2048*n)*(1-s)+(t[256*l+a]/65535*2048*(1-n)+t[256*l+o]/65535*2048*n)*s};for(let e=0;e0?(g/=v,h/=v,p/=v):(g=0,h=1,p=0),s[3*e]=g,s[3*e+1]=h,s[3*e+2]=p}a.needsUpdate=!0,o.needsUpdate=!0}(e=function(e,t){let r=new i.BufferGeometry,a=new Float32Array(198147),o=new Float32Array(198147),l=new Float32Array(132098),n=new Uint32Array(393216),s=0,u=e/256;for(let t=0;t<=256;t++)for(let r=0;r<=256;r++){let i=257*t+r;a[3*i]=r*u-e/2,a[3*i+1]=e/2-t*u,a[3*i+2]=0,o[3*i]=0,o[3*i+1]=0,o[3*i+2]=1,l[2*i]=r/256,l[2*i+1]=1-t/256}for(let e=0;e<256;e++)for(let t=0;t<256;t++){let r=257*e+t,a=r+1,i=(e+1)*257+t,o=i+1;((t^e)&1)==0?(n[s++]=r,n[s++]=i,n[s++]=o,n[s++]=r,n[s++]=o,n[s++]=a):(n[s++]=r,n[s++]=i,n[s++]=a,n[s++]=a,n[s++]=i,n[s++]=o)}return r.setIndex(new i.BufferAttribute(n,1)),r.setAttribute("position",new i.Float32BufferAttribute(a,3)),r.setAttribute("normal",new i.Float32BufferAttribute(o,3)),r.setAttribute("uv",new i.Float32BufferAttribute(l,2)),r.rotateX(-Math.PI/2),r.rotateY(-Math.PI/2),r}(t,0),Q.heightMap,H),A[4]=t,A[5]=H,A[6]=Q.heightMap,A[7]=e):e=A[7],u=e}let X=u;A[8]!==H||A[9]!==Q?(c=()=>{if(Q)return(0,R.setTerrainHeightSampler)((0,R.createTerrainHeightSampler)(Q.heightMap,H)),z},f=[Q,H],A[8]=H,A[9]=Q,A[10]=c,A[11]=f):(c=A[10],f=A[11]),(0,a.useEffect)(c,f);let Z=(0,l.useSceneSun)();t:{let e,t;if(!Z){let e;A[12]===Symbol.for("react.memo_cache_sentinel")?(e=new i.Vector3(.57735,-.57735,.57735),A[12]=e):e=A[12],d=e;break t}A[13]!==Z.direction?(e=(0,x.torqueToThree)(Z.direction),A[13]=Z.direction,A[14]=e):e=A[14];let[r,a,o]=e,l=Math.sqrt(r*r+a*a+o*o),n=r/l,s=a/l,u=o/l;A[15]!==u||A[16]!==n||A[17]!==s?(t=new i.Vector3(n,s,u),A[15]=u,A[16]=n,A[17]=s,A[18]=t):t=A[18],d=t}let J=d;r:{let e;if(!Q){m=null;break r}A[19]!==H||A[20]!==J||A[21]!==Q.heightMap?(e=function(e,t,r){let a=(t,r)=>{let a=Math.max(0,Math.min(255,t)),i=Math.max(0,Math.min(255,r)),o=Math.floor(a),l=Math.floor(i),n=Math.min(o+1,255),s=Math.min(l+1,255),u=a-o,c=i-l;return((e[256*l+o]/65535*(1-u)+e[256*l+n]/65535*u)*(1-c)+(e[256*s+o]/65535*(1-u)+e[256*s+n]/65535*u)*c)*2048},o=new i.Vector3(-t.x,-t.y,-t.z).normalize(),l=new Uint8Array(262144);for(let e=0;e<512;e++)for(let t=0;t<512;t++){let i=t/2+.25,n=e/2+.25,s=a(i,n),u=a(i-.5,n),c=a(i+.5,n),f=a(i,n-.5),d=-((a(i,n+.5)-f)/1),m=-((c-u)/1),g=Math.sqrt(d*d+r*r+m*m),h=Math.max(0,d/g*o.x+r/g*o.y+m/g*o.z),p=1;h>0&&(p=function(e,t,r,a,i,o){let l=a.z/i,n=a.x/i,s=a.y,u=Math.sqrt(l*l+n*n);if(u<1e-4)return 1;let c=.5/u,f=l*c,d=n*c,m=s*c,g=e,h=t,p=r+.1;for(let e=0;e<768&&(g+=f,h+=d,p+=m,!(g<0)&&!(g>=256)&&!(h<0)&&!(h>=256)&&!(p>2048));e++)if(pArray(el).fill(null),A[32]=el,A[33]=w):w=A[33];let[es,eu]=(0,a.useState)(w);A[34]===Symbol.for("react.memo_cache_sentinel")?(T={xStart:0,xEnd:0,zStart:0,zEnd:0},A[34]=T):T=A[34];let ec=(0,a.useRef)(T);return(A[35]!==Y.x||A[36]!==Y.z||A[37]!==q||A[38]!==W.position.x||A[39]!==W.position.z||A[40]!==el||A[41]!==$?(M=()=>{let e=W.position.x-Y.x,t=W.position.z-Y.z,r=Math.floor((e-$)/q),a=Math.ceil((e+$)/q),i=Math.floor((t-$)/q),o=Math.ceil((t+$)/q),l=ec.current;if(r===l.xStart&&a===l.xEnd&&i===l.zStart&&o===l.zEnd)return;l.xStart=r,l.xEnd=a,l.zStart=i,l.zEnd=o;let n=[];for(let e=r;e{let r=es[e];return(0,t.jsx)(k,{tileX:r?.tileX??0,tileZ:r?.tileZ??0,blockSize:q,basePosition:Y,textureNames:Q.textureNames,geometry:X,displacementMap:et,visibilityMask:ea,alphaTextures:ei,detailTextureName:V,lightmap:ee,visible:null!==r},e)}),A[53]=Y,A[54]=q,A[55]=V,A[56]=en,A[57]=ei,A[58]=et,A[59]=X,A[60]=Q.textureNames,A[61]=ee,A[62]=es,A[63]=C):C=A[63],A[64]!==D||A[65]!==C?(j=(0,t.jsxs)(t.Fragment,{children:[D,C]}),A[64]=D,A[65]=C,A[66]=j):j=A[66],j):null});function G(e){return e.camera}function z(){return(0,R.setTerrainHeightSampler)(null)}function U(e){return(0,y.setupMask)(e)}function N(e,t){return t}var I=e.i(8597),A=e.i(78140);let E=` +vec3 interiorLinearToSRGB(vec3 linear) { + vec3 higher = pow(linear, vec3(1.0/2.4)) * 1.055 - 0.055; + vec3 lower = linear * 12.92; + return mix(lower, higher, step(vec3(0.0031308), linear)); +} + +vec3 interiorSRGBToLinear(vec3 srgb) { + vec3 higher = pow((srgb + 0.055) / 1.055, vec3(2.4)); + vec3 lower = srgb / 12.92; + return mix(lower, higher, step(vec3(0.04045), srgb)); +} + +// Debug grid overlay function using screen-space derivatives for sharp, anti-aliased lines +// Returns 1.0 on grid lines, 0.0 elsewhere +float debugGrid(vec2 uv, float gridSize, float lineWidth) { + vec2 scaledUV = uv * gridSize; + vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); + float line = min(grid.x, grid.y); + return 1.0 - min(line / lineWidth, 1.0); +} +`;function P({materialName:e,material:r,lightMap:o}){let l=(0,d.useDebug)(),n=l?.debugMode??!1,s=(0,b.textureToUrl)(e),u=(0,S.useTexture)(s,e=>(0,y.setupTexture)(e)),c=new Set(r?.userData?.flag_names??[]).has("SelfIlluminating"),f=new Set(r?.userData?.surface_flag_names??[]).has("SurfaceOutsideVisible"),m=(0,a.useCallback)(e=>{let t;(0,M.injectCustomFog)(e,D.globalFogUniforms),t=f??!1,e.uniforms.useSceneLighting={value:t},e.uniforms.interiorDebugColor={value:t?new i.Vector3(0,.4,1):new i.Vector3(1,.2,0)},e.fragmentShader=e.fragmentShader.replace("#include ",`#include +${E} +uniform bool useSceneLighting; +uniform vec3 interiorDebugColor; +`),e.fragmentShader=e.fragmentShader.replace("#include ",`// Lightmap handled in custom output calculation +#ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); +#endif`),e.fragmentShader=e.fragmentShader.replace("#include ",`// Torque-style lighting: output = clamp(lighting \xd7 texture, 0, 1) in sRGB space +// Get texture in sRGB space (undo Three.js linear decode) +vec3 textureSRGB = interiorLinearToSRGB(diffuseColor.rgb); + +// Compute lighting in sRGB space +vec3 lightingSRGB = vec3(0.0); + +if (useSceneLighting) { + // Three.js computed: reflectedLight = lighting \xd7 texture_linear / PI + // Extract pure lighting: lighting = reflectedLight \xd7 PI / texture_linear + vec3 totalLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 safeTexLinear = max(diffuseColor.rgb, vec3(0.001)); + vec3 extractedLighting = totalLight * PI / safeTexLinear; + // NOTE: extractedLighting is ALREADY sRGB values because mission sun/ambient colors + // are sRGB values (Torque used them directly in gamma space). Three.js treats them + // as linear but the numerical values are the same. DO NOT convert to sRGB here! + // IMPORTANT: Torque clamps scene lighting to [0,1] BEFORE adding to lightmap + // (sceneLighting.cc line 1785: tmp.clamp()) + lightingSRGB = clamp(extractedLighting, 0.0, 1.0); +} + +// Add lightmap contribution (for BOTH outside and inside surfaces) +// In Torque, scene lighting is ADDED to lightmaps for outside surfaces at mission load +// (stored in .ml files). Inside surfaces only have base lightmap. Both need lightmap here. +#ifdef USE_LIGHTMAP + // Lightmap is stored as linear in Three.js (decoded from sRGB texture), convert back + lightingSRGB += interiorLinearToSRGB(lightMapTexel.rgb); +#endif +// Torque clamps the sum to [0,1] per channel (sceneLighting.cc lines 1817-1827) +lightingSRGB = clamp(lightingSRGB, 0.0, 1.0); + +// Torque formula: output = clamp(lighting \xd7 texture, 0, 1) in sRGB/gamma space +vec3 resultSRGB = clamp(lightingSRGB * textureSRGB, 0.0, 1.0); + +// Convert back to linear for Three.js output pipeline +vec3 resultLinear = interiorSRGBToLinear(resultSRGB); + +// Reassign outgoingLight before opaque_fragment consumes it +outgoingLight = resultLinear + totalEmissiveRadiance; + +#include `),e.fragmentShader=e.fragmentShader.replace("#include ",`// Debug mode: overlay colored grid on top of normal rendering +// Blue grid = SurfaceOutsideVisible (receives scene ambient light) +// Red grid = inside surface (no scene ambient light) +#if DEBUG_MODE && defined(USE_MAP) + // gridSize=4 creates 4x4 grid per UV tile, lineWidth=1.5 is ~1.5 pixels wide + float gridIntensity = debugGrid(vMapUv, 4.0, 1.5); + gl_FragColor.rgb = mix(gl_FragColor.rgb, interiorDebugColor, gridIntensity * 0.1); +#endif + +#include `)},[f]),g=(0,a.useRef)(null),h=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=g.current??h.current;e&&(e.defines??={},e.defines.DEBUG_MODE=+!!n,e.needsUpdate=!0)},[n]);let p={DEBUG_MODE:+!!n},v=`${f}`;return c?(0,t.jsx)("meshBasicMaterial",{ref:g,map:u,toneMapped:!1,defines:p,onBeforeCompile:m},v):(0,t.jsx)("meshLambertMaterial",{ref:h,map:u,lightMap:o,toneMapped:!1,defines:p,onBeforeCompile:m},v)}function H(e){if(!e)return null;let t=e.emissiveMap;return t&&(t.colorSpace=i.SRGBColorSpace),t??null}function V(e){let i,o,l,n=(0,r.c)(13),{node:s}=e;e:{let e,t;if(!s.material){let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],n[0]=e):e=n[0],i=e;break e}if(Array.isArray(s.material)){let e;n[1]!==s.material?(e=s.material.map(q),n[1]=s.material,n[2]=e):e=n[2],i=e;break e}n[3]!==s.material?(e=H(s.material),n[3]=s.material,n[4]=e):e=n[4],n[5]!==e?(t=[e],n[5]=e,n[6]=t):t=n[6],i=t}let u=i;return n[7]!==u||n[8]!==s.material?(o=s.material?(0,t.jsx)(a.Suspense,{fallback:(0,t.jsx)("meshStandardMaterial",{color:"yellow",wireframe:!0}),children:Array.isArray(s.material)?s.material.map((e,r)=>(0,t.jsx)(P,{materialName:e.userData.resource_path,material:e,lightMap:u[r]},r)):(0,t.jsx)(P,{materialName:s.material.userData.resource_path,material:s.material,lightMap:u[0]})}):null,n[7]=u,n[8]=s.material,n[9]=o):o=n[9],n[10]!==s.geometry||n[11]!==o?(l=(0,t.jsx)("mesh",{geometry:s.geometry,castShadow:!0,receiveShadow:!0,children:o}),n[10]=s.geometry,n[11]=o,n[12]=l):l=n[12],l}function q(e){return H(e)}let $=(0,a.memo)(function(e){let a,i,o,l,n,s,u,c=(0,r.c)(10),{interiorFile:m,ghostIndex:g}=e,{nodes:h}=((s=(0,r.c)(2))[0]!==m?(n=(0,b.interiorToUrl)(m),s[0]=m,s[1]=n):n=s[1],u=n,(0,A.useGLTF)(u)),p=(0,d.useDebug)(),v=p?.debugMode??!1;return c[0]===Symbol.for("react.memo_cache_sentinel")?(a=[0,-Math.PI/2,0],c[0]=a):a=c[0],c[1]!==h?(i=Object.entries(h).filter(K).map(Q),c[1]=h,c[2]=i):i=c[2],c[3]!==v||c[4]!==g||c[5]!==m?(o=v?(0,t.jsxs)(f.FloatingLabel,{children:[g,": ",m]}):null,c[3]=v,c[4]=g,c[5]=m,c[6]=o):o=c[6],c[7]!==i||c[8]!==o?(l=(0,t.jsxs)("group",{rotation:a,children:[i,o]}),c[7]=i,c[8]=o,c[9]=l):l=c[9],l});function W(e){let a,i,o,l,n=(0,r.c)(9),{color:s,label:u}=e;return n[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("boxGeometry",{args:[10,10,10]}),n[0]=a):a=n[0],n[1]!==s?(i=(0,t.jsx)("meshStandardMaterial",{color:s,wireframe:!0}),n[1]=s,n[2]=i):i=n[2],n[3]!==s||n[4]!==u?(o=u?(0,t.jsx)(f.FloatingLabel,{color:s,children:u}):null,n[3]=s,n[4]=u,n[5]=o):o=n[5],n[6]!==i||n[7]!==o?(l=(0,t.jsxs)("mesh",{children:[a,i,o]}),n[6]=i,n[7]=o,n[8]=l):l=n[8],l}function O(e){let a,i=(0,r.c)(3),{label:o}=e,l=(0,d.useDebug)(),n=l?.debugMode??!1;return i[0]!==n||i[1]!==o?(a=n?(0,t.jsx)(W,{color:"red",label:o}):null,i[0]=n,i[1]=o,i[2]=a):a=i[2],a}let Y=(0,a.memo)(function(e){let i,o,l,n,s,u,c,f,d,m=(0,r.c)(23),{scene:g}=e;m[0]!==g.transform.position?(i=(0,x.torqueToThree)(g.transform.position),m[0]=g.transform.position,m[1]=i):i=m[1];let h=i;m[2]!==g.transform?(o=(0,x.matrixFToQuaternion)(g.transform),m[2]=g.transform,m[3]=o):o=m[3];let p=o;m[4]!==g.scale?(l=(0,x.torqueScaleToThree)(g.scale),m[4]=g.scale,m[5]=l):l=m[5];let v=l,b=`${g.ghostIndex}: ${g.interiorFile}`;return m[6]!==b?(n=(0,t.jsx)(O,{label:b}),m[6]=b,m[7]=n):n=m[7],m[8]!==g.interiorFile?(s=e=>{console.warn(`[interior] Failed to load ${g.interiorFile}:`,e.message)},m[8]=g.interiorFile,m[9]=s):s=m[9],m[10]===Symbol.for("react.memo_cache_sentinel")?(u=(0,t.jsx)(W,{color:"orange"}),m[10]=u):u=m[10],m[11]!==g.ghostIndex||m[12]!==g.interiorFile?(c=(0,t.jsx)(a.Suspense,{fallback:u,children:(0,t.jsx)($,{interiorFile:g.interiorFile,ghostIndex:g.ghostIndex})}),m[11]=g.ghostIndex,m[12]=g.interiorFile,m[13]=c):c=m[13],m[14]!==n||m[15]!==s||m[16]!==c?(f=(0,t.jsx)(I.ErrorBoundary,{fallback:n,onError:s,children:c}),m[14]=n,m[15]=s,m[16]=c,m[17]=f):f=m[17],m[18]!==h||m[19]!==p||m[20]!==v||m[21]!==f?(d=(0,t.jsx)("group",{position:h,quaternion:p,scale:v,children:f}),m[18]=h,m[19]=p,m[20]=v,m[21]=f,m[22]=d):d=m[22],d});function K(e){let[,t]=e;return t.isMesh}function Q(e){let[r,a]=e;return(0,t.jsx)(V,{node:a},r)}var X=e.i(99143);function Z(e,{path:t}){let[r]=(0,X.useLoader)(i.CubeTextureLoader,[e],e=>e.setPath(t));return r}Z.preload=(e,{path:t})=>X.useLoader.preload(i.CubeTextureLoader,[e],e=>e.setPath(t));let J=()=>{};function ee(e){return e.wrapS=i.RepeatWrapping,e.wrapT=i.RepeatWrapping,e.minFilter=i.LinearFilter,e.magFilter=i.LinearFilter,e.colorSpace=i.NoColorSpace,e.needsUpdate=!0,e}let et=` + attribute float alpha; + + uniform vec2 uvOffset; + + varying vec2 vUv; + varying float vAlpha; + + void main() { + // Apply UV offset for scrolling + vUv = uv + uvOffset; + vAlpha = alpha; + + vec4 pos = projectionMatrix * modelViewMatrix * vec4(position, 1.0); + // Set depth to far plane so clouds are always visible and behind other geometry + gl_Position = pos.xyww; + } +`,er=` + uniform sampler2D cloudTexture; + uniform float debugMode; + uniform int layerIndex; + + varying vec2 vUv; + varying float vAlpha; + + // Debug grid using screen-space derivatives for sharp, anti-aliased lines + float debugGrid(vec2 uv, float gridSize, float lineWidth) { + vec2 scaledUV = uv * gridSize; + vec2 grid = abs(fract(scaledUV - 0.5) - 0.5) / fwidth(scaledUV); + float line = min(grid.x, grid.y); + return 1.0 - min(line / lineWidth, 1.0); + } + + void main() { + vec4 texColor = texture2D(cloudTexture, vUv); + + // Tribes 2 uses GL_MODULATE: final = texture \xd7 vertex color + // Vertex color is white with varying alpha, so: + // Final RGB = Texture RGB \xd7 1.0 = Texture RGB + // Final Alpha = Texture Alpha \xd7 Vertex Alpha + float finalAlpha = texColor.a * vAlpha; + vec3 color = texColor.rgb; + + // Debug mode: overlay R/G/B grid for layers 0/1/2 + if (debugMode > 0.5) { + float gridIntensity = debugGrid(vUv, 4.0, 1.5); + vec3 gridColor; + if (layerIndex == 0) { + gridColor = vec3(1.0, 0.0, 0.0); // Red + } else if (layerIndex == 1) { + gridColor = vec3(0.0, 1.0, 0.0); // Green + } else { + gridColor = vec3(0.0, 0.0, 1.0); // Blue + } + color = mix(color, gridColor, gridIntensity * 0.5); + } + + // Output clouds with texture color and combined alpha + gl_FragColor = vec4(color, finalAlpha); + } +`;function ea({textureUrl:e,radius:r,heightPercent:l,speed:n,windDirection:s,layerIndex:u}){let{debugMode:c}=(0,d.useDebug)(),{animationEnabled:f}=(0,d.useSettings)(),m=(0,a.useRef)(null),g=(0,S.useTexture)(e,ee),h=(0,a.useMemo)(()=>{let e=l-.05;return function(e,t,r,a){var o;let l,n,s,u,c,f,d,m,g,h,p,v,x,b,y,S,F,w=new i.BufferGeometry,T=new Float32Array(75),M=new Float32Array(50),D=[.05,.05,.05,.05,.05,.05,r,r,r,.05,.05,r,t,r,.05,.05,r,r,r,.05,.05,.05,.05,.05,.05],C=2*e/4;for(let t=0;t<5;t++)for(let r=0;r<5;r++){let a=5*t+r,i=-e+r*C,o=e-t*C,l=e*D[a];T[3*a]=i,T[3*a+1]=l,T[3*a+2]=o,M[2*a]=r,M[2*a+1]=t}o=T,l=e=>({x:o[3*e],y:o[3*e+1],z:o[3*e+2]}),n=(e,t,r,a)=>{o[3*e]=t,o[3*e+1]=r,o[3*e+2]=a},s=l(1),u=l(3),c=l(5),f=l(6),d=l(8),m=l(9),g=l(15),h=l(16),p=l(18),v=l(19),x=l(21),b=l(23),y=c.x+(s.x-c.x)*.5,S=c.y+(s.y-c.y)*.5,F=c.z+(s.z-c.z)*.5,n(0,f.x+(y-f.x)*2,f.y+(S-f.y)*2,f.z+(F-f.z)*2),y=m.x+(u.x-m.x)*.5,S=m.y+(u.y-m.y)*.5,F=m.z+(u.z-m.z)*.5,n(4,d.x+(y-d.x)*2,d.y+(S-d.y)*2,d.z+(F-d.z)*2),y=x.x+(g.x-x.x)*.5,S=x.y+(g.y-x.y)*.5,F=x.z+(g.z-x.z)*.5,n(20,h.x+(y-h.x)*2,h.y+(S-h.y)*2,h.z+(F-h.z)*2),y=b.x+(v.x-b.x)*.5,S=b.y+(v.y-b.y)*.5,F=b.z+(v.z-b.z)*.5,n(24,p.x+(y-p.x)*2,p.y+(S-p.y)*2,p.z+(F-p.z)*2);let j=function(e,t){let r=new Float32Array(25);for(let a=0;a<25;a++){let i=e[3*a],o=e[3*a+2],l=1.3-Math.sqrt(i*i+o*o)/t;l<.4?l=0:l>.8&&(l=1),r[a]=l}return r}(T,e),_=[];for(let e=0;e<4;e++)for(let t=0;t<4;t++){let r=5*e+t,a=r+1,i=r+5,o=i+1;_.push(r,i,o),_.push(r,o,a)}return w.setIndex(_),w.setAttribute("position",new i.Float32BufferAttribute(T,3)),w.setAttribute("uv",new i.Float32BufferAttribute(M,2)),w.setAttribute("alpha",new i.Float32BufferAttribute(j,1)),w.computeBoundingSphere(),w}(r,l,e,0)},[r,l]);(0,a.useEffect)(()=>()=>{h.dispose()},[h]);let p=(0,a.useMemo)(()=>new i.ShaderMaterial({uniforms:{cloudTexture:{value:g},uvOffset:{value:new i.Vector2(0,0)},debugMode:{value:+!!c},layerIndex:{value:u}},vertexShader:et,fragmentShader:er,transparent:!0,depthWrite:!1,side:i.DoubleSide}),[g,c,u]);return(0,a.useEffect)(()=>()=>{p.dispose()},[p]),(0,o.useFrame)(f?(e,t)=>{let r=1e3*t/32;m.current??=new i.Vector2(0,0),m.current.x+=s.x*n*r,m.current.y+=s.y*n*r,m.current.x-=Math.floor(m.current.x),m.current.y-=Math.floor(m.current.y),p.uniforms.uvOffset.value.copy(m.current)}:J),(0,t.jsx)("mesh",{geometry:h,frustumCulled:!1,renderOrder:10,children:(0,t.jsx)("primitive",{object:p,attach:"material"})})}function ei(e){var l;let n,s,u,c,f,d,m,g,h,p,x,y=(0,r.c)(18),{scene:S}=e,{data:F}=(l=S.materialList||void 0,(p=(0,r.c)(7))[0]!==l?(m=["detailMapList",l],g=()=>(0,b.loadDetailMapList)(l),p[0]=l,p[1]=m,p[2]=g):(m=p[1],g=p[2]),x=!!l,p[3]!==m||p[4]!==g||p[5]!==x?(h={queryKey:m,queryFn:g,enabled:x},p[3]=m,p[4]=g,p[5]=x,p[6]=h):h=p[6],(0,v.useQuery)(h)),w=.95*(S.visibleDistance>0?S.visibleDistance:500);y[0]!==S.cloudLayers?(n=S.cloudLayers.map(el),y[0]=S.cloudLayers,y[1]=n):n=y[1];let T=n;y[2]!==S.cloudLayers?(s=S.cloudLayers.map(eo),y[2]=S.cloudLayers,y[3]=s):s=y[3];let M=s;e:{let e,{x:t,y:r}=S.windVelocity;if(0!==t||0!==r){let e;y[4]!==t||y[5]!==r?(e=new i.Vector2(r,-t).normalize(),y[4]=t,y[5]=r,y[6]=e):e=y[6],u=e;break e}y[7]===Symbol.for("react.memo_cache_sentinel")?(e=new i.Vector2(1,0),y[7]=e):e=y[7],u=e}let D=u;t:{let e;if(!F){let e;y[8]===Symbol.for("react.memo_cache_sentinel")?(e=[],y[8]=e):e=y[8],c=e;break t}if(y[9]!==M||y[10]!==T||y[11]!==F){e=[];for(let t=0;t<3;t++){let r=F[7+t];r&&e.push({texture:r,height:M[t],speed:T[t]})}y[9]=M,y[10]=T,y[11]=F,y[12]=e}else e=y[12];c=e}let C=c,j=(0,a.useRef)(null);return(y[13]===Symbol.for("react.memo_cache_sentinel")?(f=e=>{let{camera:t}=e;j.current&&j.current.position.copy(t.position)},y[13]=f):f=y[13],(0,o.useFrame)(f),C&&0!==C.length)?(y[14]!==C||y[15]!==w||y[16]!==D?(d=(0,t.jsx)("group",{ref:j,children:C.map((e,r)=>{let i=(0,b.textureToUrl)(e.texture);return(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ea,{textureUrl:i,radius:w,heightPercent:e.height,speed:e.speed,windDirection:D,layerIndex:r})},r)})}),y[14]=C,y[15]=w,y[16]=D,y[17]=d):d=y[17],d):null}function eo(e,t){return e.heightPercent||[.35,.25,.2][t]}function el(e,t){return e.speed||[1e-4,2e-4,3e-4][t]}e.i(62395);let en=!1;function es(e){return[new i.Color().setRGB(e.r,e.g,e.b),new i.Color().setRGB(e.r,e.g,e.b).convertSRGBToLinear()]}function eu({skyBoxFiles:e,fogColor:r,fogState:o}){let{camera:l}=(0,p.useThree)(),n=Z(e,{path:""}),s=!!r,u=(0,a.useMemo)(()=>l.projectionMatrixInverse,[l]),c=(0,a.useMemo)(()=>o?(0,D.packFogVolumeData)(o.fogVolumes):new Float32Array(12),[o]),f=(0,a.useRef)({skybox:{value:n},fogColor:{value:r??new i.Color(0,0,0)},enableFog:{value:s},inverseProjectionMatrix:{value:u},cameraMatrixWorld:{value:l.matrixWorld},cameraHeight:D.globalFogUniforms.cameraHeight,fogVolumeData:{value:c},horizonFogHeight:{value:.18}}),d=(0,a.useMemo)(()=>{if(!o)return .18;let e=.95*o.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[o]);return(0,a.useEffect)(()=>{f.current.skybox.value=n,f.current.fogColor.value=r??new i.Color(0,0,0),f.current.enableFog.value=s,f.current.fogVolumeData.value=c,f.current.horizonFogHeight.value=d},[n,r,s,c,d]),(0,t.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,t.jsxs)("bufferGeometry",{children:[(0,t.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,t.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,t.jsx)("shaderMaterial",{uniforms:f.current,vertexShader:` + varying vec2 vUv; + + void main() { + vUv = uv; + gl_Position = vec4(position.xy, 0.9999, 1.0); + } + `,fragmentShader:` + uniform samplerCube skybox; + uniform vec3 fogColor; + uniform bool enableFog; + uniform mat4 inverseProjectionMatrix; + uniform mat4 cameraMatrixWorld; + uniform float cameraHeight; + uniform float fogVolumeData[12]; + uniform float horizonFogHeight; + + varying vec2 vUv; + + // Convert linear to sRGB for display + // shaderMaterial does NOT get automatic linear->sRGB output conversion + // Use proper sRGB transfer function (not simplified gamma 2.2) to match Three.js + vec3 linearToSRGB(vec3 linear) { + vec3 low = linear * 12.92; + vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055; + return mix(low, high, step(vec3(0.0031308), linear)); + } + + void main() { + vec2 ndc = vUv * 2.0 - 1.0; + vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0); + viewPos.xyz /= viewPos.w; + vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz); + direction = vec3(direction.z, direction.y, -direction.x); + // Sample skybox - Three.js CubeTexture with SRGBColorSpace auto-converts to linear + vec4 skyColor = textureCube(skybox, direction); + vec3 finalColor; + + if (enableFog) { + vec3 effectiveFogColor = fogColor; + + // Calculate how much fog volume the ray passes through + // For skybox at "infinite" distance, the relevant height is how much + // of the volume is above/below camera depending on view direction + float volumeFogInfluence = 0.0; + + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + if (volVisDist <= 0.0) continue; + + // Check if camera is inside this volume + if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { + // Camera is inside the fog volume + // Looking horizontally or up at shallow angles means ray travels + // through more fog before exiting the volume + float heightAboveCamera = volMaxH - cameraHeight; + float heightBelowCamera = cameraHeight - volMinH; + float volumeHeight = volMaxH - volMinH; + + // For horizontal rays (direction.y ≈ 0), maximum fog influence + // For rays going up steeply, less fog (exits volume quickly) + // For rays going down, more fog (travels through volume below) + float rayInfluence; + if (direction.y >= 0.0) { + // Looking up: influence based on how steep we're looking + // Shallow angles = long path through fog = high influence + rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y); + } else { + // Looking down: always high fog (into the volume) + rayInfluence = 1.0; + } + + // Scale by percentage and volume depth factor + volumeFogInfluence += rayInfluence * volPct; + } + } + + // Base fog factor from view direction (for haze at horizon) + // In Torque, the fog "bans" (bands) are rendered as geometry from + // height 0 (HORIZON) to height 60 (OFFSET_HEIGHT) on the skybox. + // The skybox corner is at mSkyBoxPt.x = mRadius / sqrt(3). + // + // horizonFogHeight is the direction.y value where the fog band ends: + // horizonFogHeight = 60 / sqrt(skyBoxPt.x^2 + 60^2) + // + // For Firestorm (visDist=600): mRadius=570, skyBoxPt.x=329, horizonFogHeight≈0.18 + // + // Torque renders the fog bands as geometry with linear vertex alpha + // interpolation. We use a squared curve (t^2) to create a gentler + // falloff at the top of the gradient, matching Tribes 2's appearance. + float baseFogFactor; + if (direction.y <= 0.0) { + // Looking at or below horizon: full fog + baseFogFactor = 1.0; + } else if (direction.y >= horizonFogHeight) { + // Above fog band: no fog + baseFogFactor = 0.0; + } else { + // Within fog band: squared curve for gentler falloff at top + float t = direction.y / horizonFogHeight; + baseFogFactor = (1.0 - t) * (1.0 - t); + } + + // Combine base fog with volume fog influence + // When inside a volume, increase fog intensity + float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5); + + finalColor = mix(skyColor.rgb, effectiveFogColor, finalFogFactor); + } else { + finalColor = skyColor.rgb; + } + // Convert linear result to sRGB for display + gl_FragColor = vec4(linearToSRGB(finalColor), 1.0); + } + `,depthWrite:!1,depthTest:!1})]})}function ec(e){let a,i,o,l,n=(0,r.c)(6),{materialList:s,fogColor:u,fogState:c}=e,{data:f}=((l=(0,r.c)(2))[0]!==s?(o={queryKey:["detailMapList",s],queryFn:()=>(0,b.loadDetailMapList)(s)},l[0]=s,l[1]=o):o=l[1],(0,v.useQuery)(o));n[0]!==f?(a=f?[(0,b.textureToUrl)(f[1]),(0,b.textureToUrl)(f[3]),(0,b.textureToUrl)(f[4]),(0,b.textureToUrl)(f[5]),(0,b.textureToUrl)(f[0]),(0,b.textureToUrl)(f[2])]:null,n[0]=f,n[1]=a):a=n[1];let d=a;return d?(n[2]!==u||n[3]!==c||n[4]!==d?(i=(0,t.jsx)(eu,{skyBoxFiles:d,fogColor:u,fogState:c}),n[2]=u,n[3]=c,n[4]=d,n[5]=i):i=n[5],i):null}function ef({skyColor:e,fogColor:r,fogState:o}){let{camera:l}=(0,p.useThree)(),n=!!r,s=(0,a.useMemo)(()=>l.projectionMatrixInverse,[l]),u=(0,a.useMemo)(()=>o?(0,D.packFogVolumeData)(o.fogVolumes):new Float32Array(12),[o]),c=(0,a.useMemo)(()=>{if(!o)return .18;let e=.95*o.visibleDistance/Math.sqrt(3);return 60/Math.sqrt(e*e+3600)},[o]),f=(0,a.useRef)({skyColor:{value:e},fogColor:{value:r??new i.Color(0,0,0)},enableFog:{value:n},inverseProjectionMatrix:{value:s},cameraMatrixWorld:{value:l.matrixWorld},cameraHeight:D.globalFogUniforms.cameraHeight,fogVolumeData:{value:u},horizonFogHeight:{value:c}});return(0,a.useEffect)(()=>{f.current.skyColor.value=e,f.current.fogColor.value=r??new i.Color(0,0,0),f.current.enableFog.value=n,f.current.fogVolumeData.value=u,f.current.horizonFogHeight.value=c},[e,r,n,u,c]),(0,t.jsxs)("mesh",{renderOrder:-1e3,frustumCulled:!1,children:[(0,t.jsxs)("bufferGeometry",{children:[(0,t.jsx)("bufferAttribute",{attach:"attributes-position",array:new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),count:3,itemSize:3}),(0,t.jsx)("bufferAttribute",{attach:"attributes-uv",array:new Float32Array([0,0,2,0,0,2]),count:3,itemSize:2})]}),(0,t.jsx)("shaderMaterial",{uniforms:f.current,vertexShader:` + varying vec2 vUv; + + void main() { + vUv = uv; + gl_Position = vec4(position.xy, 0.9999, 1.0); + } + `,fragmentShader:` + uniform vec3 skyColor; + uniform vec3 fogColor; + uniform bool enableFog; + uniform mat4 inverseProjectionMatrix; + uniform mat4 cameraMatrixWorld; + uniform float cameraHeight; + uniform float fogVolumeData[12]; + uniform float horizonFogHeight; + + varying vec2 vUv; + + // Convert linear to sRGB for display + vec3 linearToSRGB(vec3 linear) { + vec3 low = linear * 12.92; + vec3 high = 1.055 * pow(linear, vec3(1.0 / 2.4)) - 0.055; + return mix(low, high, step(vec3(0.0031308), linear)); + } + + void main() { + vec2 ndc = vUv * 2.0 - 1.0; + vec4 viewPos = inverseProjectionMatrix * vec4(ndc, 1.0, 1.0); + viewPos.xyz /= viewPos.w; + vec3 direction = normalize((cameraMatrixWorld * vec4(viewPos.xyz, 0.0)).xyz); + direction = vec3(direction.z, direction.y, -direction.x); + + vec3 finalColor; + + if (enableFog) { + // Calculate volume fog influence (same logic as SkyBoxTexture) + float volumeFogInfluence = 0.0; + + for (int i = 0; i < 3; i++) { + int offset = i * 4; + float volVisDist = fogVolumeData[offset + 0]; + float volMinH = fogVolumeData[offset + 1]; + float volMaxH = fogVolumeData[offset + 2]; + float volPct = fogVolumeData[offset + 3]; + + if (volVisDist <= 0.0) continue; + + if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { + float rayInfluence; + if (direction.y >= 0.0) { + rayInfluence = 1.0 - smoothstep(0.0, 0.3, direction.y); + } else { + rayInfluence = 1.0; + } + volumeFogInfluence += rayInfluence * volPct; + } + } + + // Base fog factor from view direction + float baseFogFactor; + if (direction.y <= 0.0) { + baseFogFactor = 1.0; + } else if (direction.y >= horizonFogHeight) { + baseFogFactor = 0.0; + } else { + float t = direction.y / horizonFogHeight; + baseFogFactor = (1.0 - t) * (1.0 - t); + } + + // Combine base fog with volume fog influence + float finalFogFactor = min(1.0, baseFogFactor + volumeFogInfluence * 0.5); + + finalColor = mix(skyColor, fogColor, finalFogFactor); + } else { + finalColor = skyColor; + } + + gl_FragColor = vec4(linearToSRGB(finalColor), 1.0); + } + `,depthWrite:!1,depthTest:!1})]})}function ed(e,t){let{fogDistance:r,visibleDistance:a}=e;return[r,a]}function em({fogState:e,enabled:t}){let{scene:r,camera:l}=(0,p.useThree)(),n=(0,a.useRef)(null),s=(0,a.useMemo)(()=>(0,D.packFogVolumeData)(e.fogVolumes),[e.fogVolumes]);return(0,a.useEffect)(()=>{en||((0,M.installCustomFogShader)(),en=!0)},[]),(0,a.useEffect)(()=>{(0,D.resetGlobalFogUniforms)();let[t,a]=ed(e,l.position.y),o=new i.Fog(e.fogColor,t,a);return r.fog=o,n.current=o,(0,D.updateGlobalFogUniforms)(l.position.y,s),()=>{r.fog=null,n.current=null,(0,D.resetGlobalFogUniforms)()}},[r,l,e,s]),(0,a.useEffect)(()=>{let r=n.current;if(r)if(t){let[t,a]=ed(e,l.position.y);r.near=t,r.far=a}else r.near=1e10,r.far=1e10},[t,e,l.position.y]),(0,o.useFrame)(()=>{let r=n.current;if(!r)return;let a=l.position.y;if((0,D.updateGlobalFogUniforms)(a,s,t),t){let[t,i]=ed(e,a);r.near=t,r.far=i,r.color.copy(e.fogColor)}}),null}function eg({scene:e}){let{fogEnabled:r}=(0,d.useSettings)(),o=e.materialList||void 0,l=(0,a.useMemo)(()=>es(e.skySolidColor),[e.skySolidColor]),n=e.useSkyTextures,s=(0,a.useMemo)(()=>(function(e){let t=e.fogDistance,r=e.visibleDistance>0?e.visibleDistance:1e3,{r:a,g:o,b:l}=e.fogColor,n=new i.Color().setRGB(a,o,l).convertSRGBToLinear(),s=[];for(let t of e.fogVolumes)t.visibleDistance<=0||t.maxHeight<=t.minHeight||s.push({visibleDistance:t.visibleDistance,minHeight:t.minHeight,maxHeight:t.maxHeight,percentage:1});let u=s.reduce((e,t)=>Math.max(e,t.maxHeight),0);return{fogDistance:t,visibleDistance:r,fogColor:n,fogVolumes:s,fogLine:u,enabled:r>t}})(e),[e]),u=(0,a.useMemo)(()=>es(e.fogColor),[e.fogColor]),c=l||u,f=s.enabled&&r,m=s.fogColor,{scene:g,gl:h}=(0,p.useThree)();(0,a.useEffect)(()=>{if(f){let e=m.clone();g.background=e,h.setClearColor(e)}else if(c){let e=c[0].clone();g.background=e,h.setClearColor(e)}else g.background=null;return()=>{g.background=null}},[g,h,f,m,c]);let v=l?.[1];return(0,t.jsxs)(t.Fragment,{children:[o&&n&&o.length>0?(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ec,{materialList:o,fogColor:f?m:void 0,fogState:f?s:void 0},o)}):v?(0,t.jsx)(ef,{skyColor:v,fogColor:f?m:void 0,fogState:f?s:void 0}):null,(0,t.jsx)(a.Suspense,{children:(0,t.jsx)(ei,{scene:e})}),s.enabled?(0,t.jsx)(em,{fogState:s,enabled:r}):null]})}let eh=(0,a.lazy)(()=>e.A(30814).then(e=>({default:e.PlayerModel}))),ep=(0,a.lazy)(()=>e.A(44325).then(e=>({default:e.ExplosionShape}))),ev=(0,a.lazy)(()=>e.A(62125).then(e=>({default:e.TracerProjectile}))),ex=(0,a.lazy)(()=>e.A(62125).then(e=>({default:e.SpriteProjectile}))),eb=(0,a.lazy)(()=>e.A(25147).then(e=>({default:e.ForceFieldBare}))),ey=(0,a.lazy)(()=>e.A(61921).then(e=>({default:e.AudioEmitter}))),eS=(0,a.lazy)(()=>e.A(18599).then(e=>({default:e.WaterBlock}))),eF={1:"Storm",2:"Inferno"},ew=(0,a.memo)(function(e){let i=(0,r.c)(26),{entity:o}=e;switch(o.renderType){case"Shape":{let e;return i[0]!==o?(e=(0,t.jsx)(eT,{entity:o}),i[0]=o,i[1]=e):e=i[1],e}case"ForceFieldBare":{let e;return i[2]!==o?(e=(0,t.jsx)(eM,{entity:o}),i[2]=o,i[3]=e):e=i[3],e}case"Player":{let e;return i[4]!==o?(e=(0,t.jsx)(eD,{entity:o}),i[4]=o,i[5]=e):e=i[5],e}case"Explosion":{let e;return i[6]!==o?(e=(0,t.jsx)(eC,{entity:o}),i[6]=o,i[7]=e):e=i[7],e}case"Tracer":{let e;return i[8]!==o?(e=(0,t.jsx)(ej,{entity:o}),i[8]=o,i[9]=e):e=i[9],e}case"Sprite":{let e;return i[10]!==o?(e=(0,t.jsx)(e_,{entity:o}),i[10]=o,i[11]=e):e=i[11],e}case"AudioEmitter":{let e;return i[12]!==o?(e=(0,t.jsx)(ek,{entity:o}),i[12]=o,i[13]=e):e=i[13],e}case"Camera":{let e;return i[14]!==o?(e=(0,t.jsx)(g,{entity:o}),i[14]=o,i[15]=e):e=i[15],e}case"WayPoint":{let e;return i[16]!==o?(e=(0,t.jsx)(h,{entity:o}),i[16]=o,i[17]=e):e=i[17],e}case"TerrainBlock":{let e;return i[18]!==o.terrainData?(e=(0,t.jsx)(L,{scene:o.terrainData}),i[18]=o.terrainData,i[19]=e):e=i[19],e}case"InteriorInstance":{let e;return i[20]!==o.interiorData?(e=(0,t.jsx)(Y,{scene:o.interiorData}),i[20]=o.interiorData,i[21]=e):e=i[21],e}case"Sky":{let e;return i[22]!==o.skyData?(e=(0,t.jsx)(eg,{scene:o.skyData}),i[22]=o.skyData,i[23]=e):e=i[23],e}case"Sun":case"MissionArea":case"None":return null;case"WaterBlock":{let e;return i[24]!==o.waterData?(e=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eS,{scene:o.waterData})}),i[24]=o.waterData,i[25]=e):e=i[25],e}}});function eT(e){let i,l,n,s,m,g,h=(0,r.c)(21),{entity:p}=e,{animationEnabled:v}=(0,d.useSettings)(),x=(0,a.useRef)(null);if(h[0]!==v||h[1]!==p.rotate?(i=()=>{if(!x.current||!p.rotate||!v)return;let e=performance.now()/1e3;x.current.rotation.y=e/3*Math.PI*2},h[0]=v,h[1]=p.rotate,h[2]=i):i=h[2],(0,o.useFrame)(i),!p.shapeName)return null;let b=p.runtimeObject,y=p.shapeType??"StaticShape",S=p.dataBlock?.toLowerCase()==="flag",F=p.teamId&&p.teamId>0?eF[p.teamId]:null,w=S&&F?`${F} Flag`:null,T="Item"===p.shapeType?"pink":p.threads?"#00ff88":"yellow",M=p.rotate?x:void 0,D=b?void 0:p;return h[3]!==w?(l=w?(0,t.jsx)(f.FloatingLabel,{opacity:.6,children:w}):null,h[3]=w,h[4]=l):l=h[4],h[5]!==T||h[6]!==D||h[7]!==l?(n=(0,t.jsx)(u.ShapeRenderer,{loadingColor:T,streamEntity:D,children:l}),h[5]=T,h[6]=D,h[7]=l,h[8]=n):n=h[8],h[9]!==p.barrelShapeName||h[10]!==b?(s=p.barrelShapeName&&(0,t.jsx)(c.ShapeInfoProvider,{object:b,shapeName:p.barrelShapeName,type:"Turret",children:(0,t.jsx)("group",{position:[0,1.5,0],children:(0,t.jsx)(u.ShapeRenderer,{})})}),h[9]=p.barrelShapeName,h[10]=b,h[11]=s):s=h[11],h[12]!==M||h[13]!==n||h[14]!==s?(m=(0,t.jsxs)("group",{ref:M,children:[n,s]}),h[12]=M,h[13]=n,h[14]=s,h[15]=m):m=h[15],h[16]!==p.shapeName||h[17]!==y||h[18]!==m||h[19]!==b?(g=(0,t.jsx)(c.ShapeInfoProvider,{object:b,shapeName:p.shapeName,type:y,children:m}),h[16]=p.shapeName,h[17]=y,h[18]=m,h[19]=b,h[20]=g):g=h[20],g}function eM(e){let i,o=(0,r.c)(2),{entity:l}=e;return l.forceFieldData?(o[0]!==l.forceFieldData?(i=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eb,{data:l.forceFieldData,scale:l.forceFieldData.dimensions})}),o[0]=l.forceFieldData,o[1]=i):i=o[1],i):null}function eD(e){let i,o=(0,r.c)(2),{entity:l}=e;return l.shapeName?(o[0]!==l?(i=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eh,{entity:l})}),o[0]=l,o[1]=i):i=o[1],i):null}function eC(e){let i,o,l,n=(0,r.c)(10),{entity:u}=e;n[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.streamPlaybackStore.getState(),n[0]=i):i=n[0];let c=i.playback;n[1]!==u.explosionDataBlockId||n[2]!==u.faceViewer||n[3]!==u.id||n[4]!==u.position||n[5]!==u.rotation||n[6]!==u.shapeName?(o={id:u.id,type:"Explosion",dataBlock:u.shapeName,position:u.position,rotation:u.rotation,faceViewer:u.faceViewer,explosionDataBlockId:u.explosionDataBlockId},n[1]=u.explosionDataBlockId,n[2]=u.faceViewer,n[3]=u.id,n[4]=u.position,n[5]=u.rotation,n[6]=u.shapeName,n[7]=o):o=n[7];let f=o;return u.shapeName&&c?(n[8]!==f?(l=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ep,{entity:f,playback:c})}),n[8]=f,n[9]=l):l=n[9],l):null}function ej(e){let i,o=(0,r.c)(2),{entity:l}=e;return o[0]!==l?(i=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ev,{entity:l,visual:l.visual})}),o[0]=l,o[1]=i):i=o[1],i}function e_(e){let i,o=(0,r.c)(2),{entity:l}=e;return o[0]!==l.visual?(i=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ex,{visual:l.visual})}),o[0]=l.visual,o[1]=i):i=o[1],i}function ek(e){let i,o=(0,r.c)(2),{entity:l}=e,{audioEnabled:n}=(0,d.useSettings)();return l.audioFileName&&n?(o[0]!==l?(i=(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(ey,{entity:l})}),o[0]=l,o[1]=i):i=o[1],i):null}var eR=e.i(60099),eB=e.i(85557),eL=e.i(29418);let eG=(0,b.textureToUrl)("gui/hud_alliedtriangle"),ez=(0,b.textureToUrl)("gui/hud_enemytriangle"),eU=new i.Vector3;function eN(e){let l,n,c,f,d,m,g,h=(0,r.c)(23),{entity:v}=e,x=(0,u.useStaticShape)(v.shapeName??v.dataBlock),{camera:b}=(0,p.useThree)(),y=(0,a.useRef)(null),S=(0,a.useRef)(null),F=(0,a.useRef)(null),w=(0,a.useRef)(null),T=(0,a.useRef)(null),[M,D]=(0,a.useState)(!0);e:{if(v.playerName){l=v.playerName;break e}if("string"==typeof v.id){let e;if(h[0]!==v.id){let t;h[2]===Symbol.for("react.memo_cache_sentinel")?(t=/\d+/,h[2]=t):t=h[2],e=v.id.match(t),h[0]=v.id,h[1]=e}else e=h[1];let t=e;if(t){l=``;break e}l=v.id;break e}l=""}let C=l;h[3]!==x.scene?(n=new i.Box3().setFromObject(x.scene),h[3]=x.scene,h[4]=n):n=h[4];let j=n.max.y+.1;h[5]!==v.keyframes?(c=v.keyframes??[],h[5]=v.keyframes,h[6]=c):c=h[6];let _=c;h[7]!==_?(f=_.some(eI),h[7]=_,h[8]=f):f=h[8];let k=f;h[9]!==b||h[10]!==v.iffColor||h[11]!==k||h[12]!==M||h[13]!==_?(d=()=>{let e=y.current;if(!e)return;e.getWorldPosition(eU);let t=b.position.distanceTo(eU),r=b.matrixWorld.elements,a=!(-((eU.x-r[12])*r[8])+-((eU.y-r[13])*r[9])+-((eU.z-r[14])*r[10])<0)&&t<150;if(M!==a&&D(a),!a)return;let i=(0,eB.getKeyframeAtTime)(_,s.streamPlaybackStore.getState().time),o=i?.health??1;if(i?.damageState!=null&&i.damageState>=1){S.current&&(S.current.style.opacity="0"),F.current&&(F.current.style.opacity="0");return}let l=Math.max(0,Math.min(1,1-t/150)).toString();if(S.current&&(S.current.style.opacity=l),F.current&&(F.current.style.opacity=l),T.current&&v.iffColor){let e=v.iffColor.r>v.iffColor.g?ez:eG;T.current.getAttribute("src")!==e&&(T.current.src=e)}w.current&&k&&(w.current.style.width=`${Math.max(0,Math.min(100,100*o))}%`,w.current.style.background=v.iffColor?`rgb(${v.iffColor.r}, ${v.iffColor.g}, ${v.iffColor.b})`:"")},h[9]=b,h[10]=v.iffColor,h[11]=k,h[12]=M,h[13]=_,h[14]=d):d=h[14],(0,o.useFrame)(d);let R=v.iffColor&&v.iffColor.r>v.iffColor.g?ez:eG;return h[15]!==C||h[16]!==k||h[17]!==j||h[18]!==R||h[19]!==M?(m=M&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eR.Html,{position:[0,j,0],center:!0,children:(0,t.jsx)("div",{ref:S,className:eL.default.Top,children:(0,t.jsx)("img",{ref:T,className:eL.default.IffArrow,src:R,alt:""})})}),(0,t.jsx)(eR.Html,{position:[0,-.2,0],center:!0,children:(0,t.jsxs)("div",{ref:F,className:eL.default.Bottom,children:[(0,t.jsx)("div",{className:eL.default.Name,children:C}),k&&(0,t.jsx)("div",{className:eL.default.HealthBar,children:(0,t.jsx)("div",{ref:w,className:eL.default.HealthFill})})]})})]}),h[15]=C,h[16]=k,h[17]=j,h[18]=R,h[19]=M,h[20]=m):m=h[20],h[21]!==m?(g=(0,t.jsx)("group",{ref:y,children:m}),h[21]=m,h[22]=g):g=h[22],g}function eI(e){return null!=e.health}var eA=e.i(78779);let eE=(0,b.textureToUrl)("commander/MiniIcons/com_flag_grey"),eP=new i.Vector3;function eH(e){let i,l,n,s,u,c=(0,r.c)(9),{entity:f}=e,d=(0,a.useRef)(null),m=(0,a.useRef)(null),g=(0,a.useRef)(null),{camera:h}=(0,p.useThree)();c[0]!==h||c[1]!==f.iffColor?(i=()=>{if(m.current&&f.iffColor){let{r:e,g:t,b:r}=f.iffColor;m.current.style.backgroundColor=`rgb(${e},${t},${r})`}if(g.current&&d.current){d.current.getWorldPosition(eP);let e=h.position.distanceTo(eP);g.current.textContent=e.toFixed(1)}},c[0]=h,c[1]=f.iffColor,c[2]=i):i=c[2],(0,o.useFrame)(i);let v=f.iffColor?`rgb(${f.iffColor.r},${f.iffColor.g},${f.iffColor.b})`:"rgb(200,200,200)";c[3]===Symbol.for("react.memo_cache_sentinel")?(l=[0,1.5,0],c[3]=l):l=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("span",{ref:g,className:eA.default.Distance}),c[4]=n):n=c[4],c[5]!==v?(s={backgroundColor:v,"--flag-icon-url":`url(${eE})`},c[5]=v,c[6]=s):s=c[6];let x=s;return c[7]!==x?(u=(0,t.jsx)("group",{ref:d,children:(0,t.jsx)(eR.Html,{position:l,center:!0,children:(0,t.jsxs)("div",{className:eA.default.Root,children:[n,(0,t.jsx)("div",{ref:m,className:eA.default.Icon,style:x})]})})}),c[7]=x,c[8]=u):u=c[8],u}var eV=e.i(58647);let eq=(0,a.lazy)(()=>e.A(44325).then(e=>({default:e.WeaponModel})));function e$(e){let a,i=(0,r.c)(3),{missionType:o}=e,l=(0,d.useDebug)(),n=l?.debugMode??!1;return i[0]!==n||i[1]!==o?(a=(0,t.jsx)("group",{ref:eW,children:(0,t.jsx)(eO,{missionType:o,debugMode:n})}),i[0]=n,i[1]=o,i[2]=a):a=i[2],a}function eW(e){s.streamPlaybackStore.setState({root:e})}let eO=(0,a.memo)(function({missionType:e,debugMode:r}){let i=(0,l.useAllGameEntities)(),o=(0,a.useRef)(new Map).current,n=new Set;for(let e of i)n.add(e.id),o.set(e.id,e);for(let e of o.keys())n.has(e)||o.delete(e);let s=(0,a.useMemo)(()=>{let t=[],r=e?.toLowerCase();for(let e of o.values()){if(r&&e.missionTypesList){let t=new Set(e.missionTypesList.toLowerCase().split(/\s+/).filter(Boolean));if(t.size>0&&!t.has(r))continue}t.push(e)}return t},[i,e]);return(0,t.jsx)(t.Fragment,{children:s.map(e=>(0,t.jsx)(eY,{entity:e,debugMode:r},e.id))})}),eY=(0,a.memo)(function(e){let a,i=(0,r.c)(8),{entity:o,debugMode:l}=e;if((0,n.isSceneEntity)(o)){let e,r;return i[0]!==o?(e=(0,t.jsx)(ew,{entity:o}),i[0]=o,i[1]=e):e=i[1],i[2]!==o.id||i[3]!==e?(r=(0,t.jsx)("group",{name:o.id,children:e}),i[2]=o.id,i[3]=e,i[4]=r):r=i[4],r}return"None"===o.renderType?null:(i[5]!==l||i[6]!==o?(a=(0,t.jsx)(eZ,{entity:o,debugMode:l}),i[5]=l,i[6]=o,i[7]=a):a=i[7],a)});function eK(e){let a,i=(0,r.c)(2),{entity:o}=e,l=(0,eV.useEngineSelector)(eQ);return o.id===l?null:(i[0]!==o?(a=(0,t.jsx)(eN,{entity:o}),i[0]=o,i[1]=a):a=i[1],a)}function eQ(e){return e.playback.streamSnapshot?.controlPlayerGhostId}function eX({entity:e}){let r=(0,a.useRef)(!1),[i,l]=(0,a.useState)(()=>((("targetRenderFlags"in e?e.targetRenderFlags:void 0)??0)&2)!=0);return(r.current=i,(0,o.useFrame)(()=>{let t=((("targetRenderFlags"in e?e.targetRenderFlags:void 0)??0)&2)!=0;t!==r.current&&(r.current=t,l(t))}),i)?(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eH,{entity:e})}):null}function eZ(e){let o,l,n,s,u,c,f,d,m,g,h,p=(0,r.c)(56),{entity:v,debugMode:x}=e,b=v.position,y=v.scale;e:{let e;if(!v.rotation){o=void 0;break e}p[0]!==v.rotation?(e=new i.Quaternion(...v.rotation),p[0]=v.rotation,p[1]=e):e=p[1],o=e}let S=o,F="Player"===v.renderType;if("Shape"===v.renderType&&!v.shapeName){let e,r,a,i,o,l,n=v.id;return p[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("sphereGeometry",{args:[.3,6,4]}),p[2]=e):e=p[2],p[3]!==v.className?(r=(0,eB.entityTypeColor)(v.className),p[3]=v.className,p[4]=r):r=p[4],p[5]!==r?(a=(0,t.jsxs)("mesh",{children:[e,(0,t.jsx)("meshBasicMaterial",{color:r,wireframe:!0})]}),p[5]=r,p[6]=a):a=p[6],p[7]!==x||p[8]!==v?(i=x&&(0,t.jsx)(eJ,{entity:v}),p[7]=x,p[8]=v,p[9]=i):i=p[9],p[10]!==v?(o=(0,t.jsx)(eX,{entity:v}),p[10]=v,p[11]=o):o=p[11],p[12]!==v.id||p[13]!==b||p[14]!==S||p[15]!==y||p[16]!==a||p[17]!==i||p[18]!==o?(l=(0,t.jsxs)("group",{name:n,position:b,quaternion:S,scale:y,children:[a,i,o]}),p[12]=v.id,p[13]=b,p[14]=S,p[15]=y,p[16]=a,p[17]=i,p[18]=o,p[19]=l):l=p[19],l}p[20]!==v.className||p[21]!==v.renderType?(l="Explosion"===v.renderType?null:(0,t.jsxs)("mesh",{children:[(0,t.jsx)("sphereGeometry",{args:[.5,8,6]}),(0,t.jsx)("meshBasicMaterial",{color:(0,eB.entityTypeColor)(v.className),wireframe:!0})]}),p[20]=v.className,p[21]=v.renderType,p[22]=l):l=p[22];let w=l,T="shapeName"in v?v.shapeName:void 0,M="weaponShape"in v?v.weaponShape:void 0;return p[23]!==v?(n=(0,t.jsx)(ew,{entity:v}),p[23]=v,p[24]=n):n=p[24],p[25]!==w||p[26]!==n?(s=(0,t.jsx)(a.Suspense,{fallback:w,children:n}),p[25]=w,p[26]=n,p[27]=s):s=p[27],p[28]!==w||p[29]!==s?(u=(0,t.jsx)(e0,{fallback:w,children:s}),p[28]=w,p[29]=s,p[30]=u):u=p[30],p[31]!==v||p[32]!==F?(c=F&&(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eK,{entity:v})}),p[31]=v,p[32]=F,p[33]=c):c=p[33],p[34]!==v?(f=(0,t.jsx)(eX,{entity:v}),p[34]=v,p[35]=f):f=p[35],p[36]!==x||p[37]!==v||p[38]!==T?(d=x&&!T&&"Shape"!==v.renderType&&(0,t.jsx)(eJ,{entity:v}),p[36]=x,p[37]=v,p[38]=T,p[39]=d):d=p[39],p[40]!==u||p[41]!==c||p[42]!==f||p[43]!==d?(m=(0,t.jsxs)("group",{name:"model",children:[u,c,f,d]}),p[40]=u,p[41]=c,p[42]=f,p[43]=d,p[44]=m):m=p[44],p[45]!==F||p[46]!==T||p[47]!==M?(g=M&&T&&!F&&(0,t.jsx)("group",{name:"weapon",children:(0,t.jsx)(e0,{fallback:null,children:(0,t.jsx)(a.Suspense,{fallback:null,children:(0,t.jsx)(eq,{shapeName:M,playerShapeName:T})})})}),p[45]=F,p[46]=T,p[47]=M,p[48]=g):g=p[48],p[49]!==v.id||p[50]!==b||p[51]!==S||p[52]!==y||p[53]!==g||p[54]!==m?(h=(0,t.jsxs)("group",{name:v.id,position:b,quaternion:S,scale:y,children:[m,g]}),p[49]=v.id,p[50]=b,p[51]=S,p[52]=y,p[53]=g,p[54]=m,p[55]=h):h=p[55],h}function eJ(e){let a,i,o=(0,r.c)(8),{entity:l}=e;o[0]!==l.className||o[1]!==l.dataBlockId||o[2]!==l.ghostIndex||o[3]!==l.id||o[4]!==l.shapeHint?((a=[]).push(`${l.id} (${l.className})`),"number"==typeof l.ghostIndex&&a.push(`ghost ${l.ghostIndex}`),"number"==typeof l.dataBlockId&&a.push(`db ${l.dataBlockId}`),a.push(l.shapeHint?`shapeHint ${l.shapeHint}`:"shapeHint "),o[0]=l.className,o[1]=l.dataBlockId,o[2]=l.ghostIndex,o[3]=l.id,o[4]=l.shapeHint,o[5]=a):a=o[5];let n=a.join(" | ");return o[6]!==n?(i=(0,t.jsx)(f.FloatingLabel,{color:"#ff6688",children:n}),o[6]=n,o[7]=i):i=o[7],i}class e0 extends a.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.warn("[entity] Shape load failed:",e.message,t.componentStack)}render(){return this.state.hasError?this.props.fallback:this.props.children}}e.s(["EntityScene",()=>e$,"ShapeErrorBoundary",()=>e0],87297)}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/fe8d2153bfb8c263.js b/docs/_next/static/chunks/fe8d2153bfb8c263.js deleted file mode 100644 index ce802b29..00000000 --- a/docs/_next/static/chunks/fe8d2153bfb8c263.js +++ /dev/null @@ -1,8 +0,0 @@ -(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75056,e=>{"use strict";var t=e.i(40859),r=e.i(71645),n=e.i(8560),i=e.i(90072);e.s(["ACESFilmicToneMapping",()=>i.ACESFilmicToneMapping,"AddEquation",()=>i.AddEquation,"AddOperation",()=>i.AddOperation,"AdditiveAnimationBlendMode",()=>i.AdditiveAnimationBlendMode,"AdditiveBlending",()=>i.AdditiveBlending,"AgXToneMapping",()=>i.AgXToneMapping,"AlphaFormat",()=>i.AlphaFormat,"AlwaysCompare",()=>i.AlwaysCompare,"AlwaysDepth",()=>i.AlwaysDepth,"AlwaysStencilFunc",()=>i.AlwaysStencilFunc,"AmbientLight",()=>i.AmbientLight,"AnimationAction",()=>i.AnimationAction,"AnimationClip",()=>i.AnimationClip,"AnimationLoader",()=>i.AnimationLoader,"AnimationMixer",()=>i.AnimationMixer,"AnimationObjectGroup",()=>i.AnimationObjectGroup,"AnimationUtils",()=>i.AnimationUtils,"ArcCurve",()=>i.ArcCurve,"ArrayCamera",()=>i.ArrayCamera,"ArrowHelper",()=>i.ArrowHelper,"AttachedBindMode",()=>i.AttachedBindMode,"Audio",()=>i.Audio,"AudioAnalyser",()=>i.AudioAnalyser,"AudioContext",()=>i.AudioContext,"AudioListener",()=>i.AudioListener,"AudioLoader",()=>i.AudioLoader,"AxesHelper",()=>i.AxesHelper,"BackSide",()=>i.BackSide,"BasicDepthPacking",()=>i.BasicDepthPacking,"BasicShadowMap",()=>i.BasicShadowMap,"BatchedMesh",()=>i.BatchedMesh,"Bone",()=>i.Bone,"BooleanKeyframeTrack",()=>i.BooleanKeyframeTrack,"Box2",()=>i.Box2,"Box3",()=>i.Box3,"Box3Helper",()=>i.Box3Helper,"BoxGeometry",()=>i.BoxGeometry,"BoxHelper",()=>i.BoxHelper,"BufferAttribute",()=>i.BufferAttribute,"BufferGeometry",()=>i.BufferGeometry,"BufferGeometryLoader",()=>i.BufferGeometryLoader,"ByteType",()=>i.ByteType,"Cache",()=>i.Cache,"Camera",()=>i.Camera,"CameraHelper",()=>i.CameraHelper,"CanvasTexture",()=>i.CanvasTexture,"CapsuleGeometry",()=>i.CapsuleGeometry,"CatmullRomCurve3",()=>i.CatmullRomCurve3,"CineonToneMapping",()=>i.CineonToneMapping,"CircleGeometry",()=>i.CircleGeometry,"ClampToEdgeWrapping",()=>i.ClampToEdgeWrapping,"Clock",()=>i.Clock,"Color",()=>i.Color,"ColorKeyframeTrack",()=>i.ColorKeyframeTrack,"ColorManagement",()=>i.ColorManagement,"CompressedArrayTexture",()=>i.CompressedArrayTexture,"CompressedCubeTexture",()=>i.CompressedCubeTexture,"CompressedTexture",()=>i.CompressedTexture,"CompressedTextureLoader",()=>i.CompressedTextureLoader,"ConeGeometry",()=>i.ConeGeometry,"ConstantAlphaFactor",()=>i.ConstantAlphaFactor,"ConstantColorFactor",()=>i.ConstantColorFactor,"Controls",()=>i.Controls,"CubeCamera",()=>i.CubeCamera,"CubeDepthTexture",()=>i.CubeDepthTexture,"CubeReflectionMapping",()=>i.CubeReflectionMapping,"CubeRefractionMapping",()=>i.CubeRefractionMapping,"CubeTexture",()=>i.CubeTexture,"CubeTextureLoader",()=>i.CubeTextureLoader,"CubeUVReflectionMapping",()=>i.CubeUVReflectionMapping,"CubicBezierCurve",()=>i.CubicBezierCurve,"CubicBezierCurve3",()=>i.CubicBezierCurve3,"CubicInterpolant",()=>i.CubicInterpolant,"CullFaceBack",()=>i.CullFaceBack,"CullFaceFront",()=>i.CullFaceFront,"CullFaceFrontBack",()=>i.CullFaceFrontBack,"CullFaceNone",()=>i.CullFaceNone,"Curve",()=>i.Curve,"CurvePath",()=>i.CurvePath,"CustomBlending",()=>i.CustomBlending,"CustomToneMapping",()=>i.CustomToneMapping,"CylinderGeometry",()=>i.CylinderGeometry,"Cylindrical",()=>i.Cylindrical,"Data3DTexture",()=>i.Data3DTexture,"DataArrayTexture",()=>i.DataArrayTexture,"DataTexture",()=>i.DataTexture,"DataTextureLoader",()=>i.DataTextureLoader,"DataUtils",()=>i.DataUtils,"DecrementStencilOp",()=>i.DecrementStencilOp,"DecrementWrapStencilOp",()=>i.DecrementWrapStencilOp,"DefaultLoadingManager",()=>i.DefaultLoadingManager,"DepthFormat",()=>i.DepthFormat,"DepthStencilFormat",()=>i.DepthStencilFormat,"DepthTexture",()=>i.DepthTexture,"DetachedBindMode",()=>i.DetachedBindMode,"DirectionalLight",()=>i.DirectionalLight,"DirectionalLightHelper",()=>i.DirectionalLightHelper,"DiscreteInterpolant",()=>i.DiscreteInterpolant,"DodecahedronGeometry",()=>i.DodecahedronGeometry,"DoubleSide",()=>i.DoubleSide,"DstAlphaFactor",()=>i.DstAlphaFactor,"DstColorFactor",()=>i.DstColorFactor,"DynamicCopyUsage",()=>i.DynamicCopyUsage,"DynamicDrawUsage",()=>i.DynamicDrawUsage,"DynamicReadUsage",()=>i.DynamicReadUsage,"EdgesGeometry",()=>i.EdgesGeometry,"EllipseCurve",()=>i.EllipseCurve,"EqualCompare",()=>i.EqualCompare,"EqualDepth",()=>i.EqualDepth,"EqualStencilFunc",()=>i.EqualStencilFunc,"EquirectangularReflectionMapping",()=>i.EquirectangularReflectionMapping,"EquirectangularRefractionMapping",()=>i.EquirectangularRefractionMapping,"Euler",()=>i.Euler,"EventDispatcher",()=>i.EventDispatcher,"ExternalTexture",()=>i.ExternalTexture,"ExtrudeGeometry",()=>i.ExtrudeGeometry,"FileLoader",()=>i.FileLoader,"Float16BufferAttribute",()=>i.Float16BufferAttribute,"Float32BufferAttribute",()=>i.Float32BufferAttribute,"FloatType",()=>i.FloatType,"Fog",()=>i.Fog,"FogExp2",()=>i.FogExp2,"FramebufferTexture",()=>i.FramebufferTexture,"FrontSide",()=>i.FrontSide,"Frustum",()=>i.Frustum,"FrustumArray",()=>i.FrustumArray,"GLBufferAttribute",()=>i.GLBufferAttribute,"GLSL1",()=>i.GLSL1,"GLSL3",()=>i.GLSL3,"GreaterCompare",()=>i.GreaterCompare,"GreaterDepth",()=>i.GreaterDepth,"GreaterEqualCompare",()=>i.GreaterEqualCompare,"GreaterEqualDepth",()=>i.GreaterEqualDepth,"GreaterEqualStencilFunc",()=>i.GreaterEqualStencilFunc,"GreaterStencilFunc",()=>i.GreaterStencilFunc,"GridHelper",()=>i.GridHelper,"Group",()=>i.Group,"HalfFloatType",()=>i.HalfFloatType,"HemisphereLight",()=>i.HemisphereLight,"HemisphereLightHelper",()=>i.HemisphereLightHelper,"IcosahedronGeometry",()=>i.IcosahedronGeometry,"ImageBitmapLoader",()=>i.ImageBitmapLoader,"ImageLoader",()=>i.ImageLoader,"ImageUtils",()=>i.ImageUtils,"IncrementStencilOp",()=>i.IncrementStencilOp,"IncrementWrapStencilOp",()=>i.IncrementWrapStencilOp,"InstancedBufferAttribute",()=>i.InstancedBufferAttribute,"InstancedBufferGeometry",()=>i.InstancedBufferGeometry,"InstancedInterleavedBuffer",()=>i.InstancedInterleavedBuffer,"InstancedMesh",()=>i.InstancedMesh,"Int16BufferAttribute",()=>i.Int16BufferAttribute,"Int32BufferAttribute",()=>i.Int32BufferAttribute,"Int8BufferAttribute",()=>i.Int8BufferAttribute,"IntType",()=>i.IntType,"InterleavedBuffer",()=>i.InterleavedBuffer,"InterleavedBufferAttribute",()=>i.InterleavedBufferAttribute,"Interpolant",()=>i.Interpolant,"InterpolateDiscrete",()=>i.InterpolateDiscrete,"InterpolateLinear",()=>i.InterpolateLinear,"InterpolateSmooth",()=>i.InterpolateSmooth,"InterpolationSamplingMode",()=>i.InterpolationSamplingMode,"InterpolationSamplingType",()=>i.InterpolationSamplingType,"InvertStencilOp",()=>i.InvertStencilOp,"KeepStencilOp",()=>i.KeepStencilOp,"KeyframeTrack",()=>i.KeyframeTrack,"LOD",()=>i.LOD,"LatheGeometry",()=>i.LatheGeometry,"Layers",()=>i.Layers,"LessCompare",()=>i.LessCompare,"LessDepth",()=>i.LessDepth,"LessEqualCompare",()=>i.LessEqualCompare,"LessEqualDepth",()=>i.LessEqualDepth,"LessEqualStencilFunc",()=>i.LessEqualStencilFunc,"LessStencilFunc",()=>i.LessStencilFunc,"Light",()=>i.Light,"LightProbe",()=>i.LightProbe,"Line",()=>i.Line,"Line3",()=>i.Line3,"LineBasicMaterial",()=>i.LineBasicMaterial,"LineCurve",()=>i.LineCurve,"LineCurve3",()=>i.LineCurve3,"LineDashedMaterial",()=>i.LineDashedMaterial,"LineLoop",()=>i.LineLoop,"LineSegments",()=>i.LineSegments,"LinearFilter",()=>i.LinearFilter,"LinearInterpolant",()=>i.LinearInterpolant,"LinearMipMapLinearFilter",()=>i.LinearMipMapLinearFilter,"LinearMipMapNearestFilter",()=>i.LinearMipMapNearestFilter,"LinearMipmapLinearFilter",()=>i.LinearMipmapLinearFilter,"LinearMipmapNearestFilter",()=>i.LinearMipmapNearestFilter,"LinearSRGBColorSpace",()=>i.LinearSRGBColorSpace,"LinearToneMapping",()=>i.LinearToneMapping,"LinearTransfer",()=>i.LinearTransfer,"Loader",()=>i.Loader,"LoaderUtils",()=>i.LoaderUtils,"LoadingManager",()=>i.LoadingManager,"LoopOnce",()=>i.LoopOnce,"LoopPingPong",()=>i.LoopPingPong,"LoopRepeat",()=>i.LoopRepeat,"MOUSE",()=>i.MOUSE,"Material",()=>i.Material,"MaterialLoader",()=>i.MaterialLoader,"MathUtils",()=>i.MathUtils,"Matrix2",()=>i.Matrix2,"Matrix3",()=>i.Matrix3,"Matrix4",()=>i.Matrix4,"MaxEquation",()=>i.MaxEquation,"Mesh",()=>i.Mesh,"MeshBasicMaterial",()=>i.MeshBasicMaterial,"MeshDepthMaterial",()=>i.MeshDepthMaterial,"MeshDistanceMaterial",()=>i.MeshDistanceMaterial,"MeshLambertMaterial",()=>i.MeshLambertMaterial,"MeshMatcapMaterial",()=>i.MeshMatcapMaterial,"MeshNormalMaterial",()=>i.MeshNormalMaterial,"MeshPhongMaterial",()=>i.MeshPhongMaterial,"MeshPhysicalMaterial",()=>i.MeshPhysicalMaterial,"MeshStandardMaterial",()=>i.MeshStandardMaterial,"MeshToonMaterial",()=>i.MeshToonMaterial,"MinEquation",()=>i.MinEquation,"MirroredRepeatWrapping",()=>i.MirroredRepeatWrapping,"MixOperation",()=>i.MixOperation,"MultiplyBlending",()=>i.MultiplyBlending,"MultiplyOperation",()=>i.MultiplyOperation,"NearestFilter",()=>i.NearestFilter,"NearestMipMapLinearFilter",()=>i.NearestMipMapLinearFilter,"NearestMipMapNearestFilter",()=>i.NearestMipMapNearestFilter,"NearestMipmapLinearFilter",()=>i.NearestMipmapLinearFilter,"NearestMipmapNearestFilter",()=>i.NearestMipmapNearestFilter,"NeutralToneMapping",()=>i.NeutralToneMapping,"NeverCompare",()=>i.NeverCompare,"NeverDepth",()=>i.NeverDepth,"NeverStencilFunc",()=>i.NeverStencilFunc,"NoBlending",()=>i.NoBlending,"NoColorSpace",()=>i.NoColorSpace,"NoNormalPacking",()=>i.NoNormalPacking,"NoToneMapping",()=>i.NoToneMapping,"NormalAnimationBlendMode",()=>i.NormalAnimationBlendMode,"NormalBlending",()=>i.NormalBlending,"NormalGAPacking",()=>i.NormalGAPacking,"NormalRGPacking",()=>i.NormalRGPacking,"NotEqualCompare",()=>i.NotEqualCompare,"NotEqualDepth",()=>i.NotEqualDepth,"NotEqualStencilFunc",()=>i.NotEqualStencilFunc,"NumberKeyframeTrack",()=>i.NumberKeyframeTrack,"Object3D",()=>i.Object3D,"ObjectLoader",()=>i.ObjectLoader,"ObjectSpaceNormalMap",()=>i.ObjectSpaceNormalMap,"OctahedronGeometry",()=>i.OctahedronGeometry,"OneFactor",()=>i.OneFactor,"OneMinusConstantAlphaFactor",()=>i.OneMinusConstantAlphaFactor,"OneMinusConstantColorFactor",()=>i.OneMinusConstantColorFactor,"OneMinusDstAlphaFactor",()=>i.OneMinusDstAlphaFactor,"OneMinusDstColorFactor",()=>i.OneMinusDstColorFactor,"OneMinusSrcAlphaFactor",()=>i.OneMinusSrcAlphaFactor,"OneMinusSrcColorFactor",()=>i.OneMinusSrcColorFactor,"OrthographicCamera",()=>i.OrthographicCamera,"PCFShadowMap",()=>i.PCFShadowMap,"PCFSoftShadowMap",()=>i.PCFSoftShadowMap,"PMREMGenerator",()=>n.PMREMGenerator,"Path",()=>i.Path,"PerspectiveCamera",()=>i.PerspectiveCamera,"Plane",()=>i.Plane,"PlaneGeometry",()=>i.PlaneGeometry,"PlaneHelper",()=>i.PlaneHelper,"PointLight",()=>i.PointLight,"PointLightHelper",()=>i.PointLightHelper,"Points",()=>i.Points,"PointsMaterial",()=>i.PointsMaterial,"PolarGridHelper",()=>i.PolarGridHelper,"PolyhedronGeometry",()=>i.PolyhedronGeometry,"PositionalAudio",()=>i.PositionalAudio,"PropertyBinding",()=>i.PropertyBinding,"PropertyMixer",()=>i.PropertyMixer,"QuadraticBezierCurve",()=>i.QuadraticBezierCurve,"QuadraticBezierCurve3",()=>i.QuadraticBezierCurve3,"Quaternion",()=>i.Quaternion,"QuaternionKeyframeTrack",()=>i.QuaternionKeyframeTrack,"QuaternionLinearInterpolant",()=>i.QuaternionLinearInterpolant,"R11_EAC_Format",()=>i.R11_EAC_Format,"RED_GREEN_RGTC2_Format",()=>i.RED_GREEN_RGTC2_Format,"RED_RGTC1_Format",()=>i.RED_RGTC1_Format,"REVISION",()=>i.REVISION,"RG11_EAC_Format",()=>i.RG11_EAC_Format,"RGBADepthPacking",()=>i.RGBADepthPacking,"RGBAFormat",()=>i.RGBAFormat,"RGBAIntegerFormat",()=>i.RGBAIntegerFormat,"RGBA_ASTC_10x10_Format",()=>i.RGBA_ASTC_10x10_Format,"RGBA_ASTC_10x5_Format",()=>i.RGBA_ASTC_10x5_Format,"RGBA_ASTC_10x6_Format",()=>i.RGBA_ASTC_10x6_Format,"RGBA_ASTC_10x8_Format",()=>i.RGBA_ASTC_10x8_Format,"RGBA_ASTC_12x10_Format",()=>i.RGBA_ASTC_12x10_Format,"RGBA_ASTC_12x12_Format",()=>i.RGBA_ASTC_12x12_Format,"RGBA_ASTC_4x4_Format",()=>i.RGBA_ASTC_4x4_Format,"RGBA_ASTC_5x4_Format",()=>i.RGBA_ASTC_5x4_Format,"RGBA_ASTC_5x5_Format",()=>i.RGBA_ASTC_5x5_Format,"RGBA_ASTC_6x5_Format",()=>i.RGBA_ASTC_6x5_Format,"RGBA_ASTC_6x6_Format",()=>i.RGBA_ASTC_6x6_Format,"RGBA_ASTC_8x5_Format",()=>i.RGBA_ASTC_8x5_Format,"RGBA_ASTC_8x6_Format",()=>i.RGBA_ASTC_8x6_Format,"RGBA_ASTC_8x8_Format",()=>i.RGBA_ASTC_8x8_Format,"RGBA_BPTC_Format",()=>i.RGBA_BPTC_Format,"RGBA_ETC2_EAC_Format",()=>i.RGBA_ETC2_EAC_Format,"RGBA_PVRTC_2BPPV1_Format",()=>i.RGBA_PVRTC_2BPPV1_Format,"RGBA_PVRTC_4BPPV1_Format",()=>i.RGBA_PVRTC_4BPPV1_Format,"RGBA_S3TC_DXT1_Format",()=>i.RGBA_S3TC_DXT1_Format,"RGBA_S3TC_DXT3_Format",()=>i.RGBA_S3TC_DXT3_Format,"RGBA_S3TC_DXT5_Format",()=>i.RGBA_S3TC_DXT5_Format,"RGBDepthPacking",()=>i.RGBDepthPacking,"RGBFormat",()=>i.RGBFormat,"RGBIntegerFormat",()=>i.RGBIntegerFormat,"RGB_BPTC_SIGNED_Format",()=>i.RGB_BPTC_SIGNED_Format,"RGB_BPTC_UNSIGNED_Format",()=>i.RGB_BPTC_UNSIGNED_Format,"RGB_ETC1_Format",()=>i.RGB_ETC1_Format,"RGB_ETC2_Format",()=>i.RGB_ETC2_Format,"RGB_PVRTC_2BPPV1_Format",()=>i.RGB_PVRTC_2BPPV1_Format,"RGB_PVRTC_4BPPV1_Format",()=>i.RGB_PVRTC_4BPPV1_Format,"RGB_S3TC_DXT1_Format",()=>i.RGB_S3TC_DXT1_Format,"RGDepthPacking",()=>i.RGDepthPacking,"RGFormat",()=>i.RGFormat,"RGIntegerFormat",()=>i.RGIntegerFormat,"RawShaderMaterial",()=>i.RawShaderMaterial,"Ray",()=>i.Ray,"Raycaster",()=>i.Raycaster,"RectAreaLight",()=>i.RectAreaLight,"RedFormat",()=>i.RedFormat,"RedIntegerFormat",()=>i.RedIntegerFormat,"ReinhardToneMapping",()=>i.ReinhardToneMapping,"RenderTarget",()=>i.RenderTarget,"RenderTarget3D",()=>i.RenderTarget3D,"RepeatWrapping",()=>i.RepeatWrapping,"ReplaceStencilOp",()=>i.ReplaceStencilOp,"ReverseSubtractEquation",()=>i.ReverseSubtractEquation,"RingGeometry",()=>i.RingGeometry,"SIGNED_R11_EAC_Format",()=>i.SIGNED_R11_EAC_Format,"SIGNED_RED_GREEN_RGTC2_Format",()=>i.SIGNED_RED_GREEN_RGTC2_Format,"SIGNED_RED_RGTC1_Format",()=>i.SIGNED_RED_RGTC1_Format,"SIGNED_RG11_EAC_Format",()=>i.SIGNED_RG11_EAC_Format,"SRGBColorSpace",()=>i.SRGBColorSpace,"SRGBTransfer",()=>i.SRGBTransfer,"Scene",()=>i.Scene,"ShaderChunk",()=>n.ShaderChunk,"ShaderLib",()=>n.ShaderLib,"ShaderMaterial",()=>i.ShaderMaterial,"ShadowMaterial",()=>i.ShadowMaterial,"Shape",()=>i.Shape,"ShapeGeometry",()=>i.ShapeGeometry,"ShapePath",()=>i.ShapePath,"ShapeUtils",()=>i.ShapeUtils,"ShortType",()=>i.ShortType,"Skeleton",()=>i.Skeleton,"SkeletonHelper",()=>i.SkeletonHelper,"SkinnedMesh",()=>i.SkinnedMesh,"Source",()=>i.Source,"Sphere",()=>i.Sphere,"SphereGeometry",()=>i.SphereGeometry,"Spherical",()=>i.Spherical,"SphericalHarmonics3",()=>i.SphericalHarmonics3,"SplineCurve",()=>i.SplineCurve,"SpotLight",()=>i.SpotLight,"SpotLightHelper",()=>i.SpotLightHelper,"Sprite",()=>i.Sprite,"SpriteMaterial",()=>i.SpriteMaterial,"SrcAlphaFactor",()=>i.SrcAlphaFactor,"SrcAlphaSaturateFactor",()=>i.SrcAlphaSaturateFactor,"SrcColorFactor",()=>i.SrcColorFactor,"StaticCopyUsage",()=>i.StaticCopyUsage,"StaticDrawUsage",()=>i.StaticDrawUsage,"StaticReadUsage",()=>i.StaticReadUsage,"StereoCamera",()=>i.StereoCamera,"StreamCopyUsage",()=>i.StreamCopyUsage,"StreamDrawUsage",()=>i.StreamDrawUsage,"StreamReadUsage",()=>i.StreamReadUsage,"StringKeyframeTrack",()=>i.StringKeyframeTrack,"SubtractEquation",()=>i.SubtractEquation,"SubtractiveBlending",()=>i.SubtractiveBlending,"TOUCH",()=>i.TOUCH,"TangentSpaceNormalMap",()=>i.TangentSpaceNormalMap,"TetrahedronGeometry",()=>i.TetrahedronGeometry,"Texture",()=>i.Texture,"TextureLoader",()=>i.TextureLoader,"TextureUtils",()=>i.TextureUtils,"Timer",()=>i.Timer,"TimestampQuery",()=>i.TimestampQuery,"TorusGeometry",()=>i.TorusGeometry,"TorusKnotGeometry",()=>i.TorusKnotGeometry,"Triangle",()=>i.Triangle,"TriangleFanDrawMode",()=>i.TriangleFanDrawMode,"TriangleStripDrawMode",()=>i.TriangleStripDrawMode,"TrianglesDrawMode",()=>i.TrianglesDrawMode,"TubeGeometry",()=>i.TubeGeometry,"UVMapping",()=>i.UVMapping,"Uint16BufferAttribute",()=>i.Uint16BufferAttribute,"Uint32BufferAttribute",()=>i.Uint32BufferAttribute,"Uint8BufferAttribute",()=>i.Uint8BufferAttribute,"Uint8ClampedBufferAttribute",()=>i.Uint8ClampedBufferAttribute,"Uniform",()=>i.Uniform,"UniformsGroup",()=>i.UniformsGroup,"UniformsLib",()=>n.UniformsLib,"UniformsUtils",()=>i.UniformsUtils,"UnsignedByteType",()=>i.UnsignedByteType,"UnsignedInt101111Type",()=>i.UnsignedInt101111Type,"UnsignedInt248Type",()=>i.UnsignedInt248Type,"UnsignedInt5999Type",()=>i.UnsignedInt5999Type,"UnsignedIntType",()=>i.UnsignedIntType,"UnsignedShort4444Type",()=>i.UnsignedShort4444Type,"UnsignedShort5551Type",()=>i.UnsignedShort5551Type,"UnsignedShortType",()=>i.UnsignedShortType,"VSMShadowMap",()=>i.VSMShadowMap,"Vector2",()=>i.Vector2,"Vector3",()=>i.Vector3,"Vector4",()=>i.Vector4,"VectorKeyframeTrack",()=>i.VectorKeyframeTrack,"VideoFrameTexture",()=>i.VideoFrameTexture,"VideoTexture",()=>i.VideoTexture,"WebGL3DRenderTarget",()=>i.WebGL3DRenderTarget,"WebGLArrayRenderTarget",()=>i.WebGLArrayRenderTarget,"WebGLCoordinateSystem",()=>i.WebGLCoordinateSystem,"WebGLCubeRenderTarget",()=>i.WebGLCubeRenderTarget,"WebGLRenderTarget",()=>i.WebGLRenderTarget,"WebGLRenderer",()=>n.WebGLRenderer,"WebGLUtils",()=>n.WebGLUtils,"WebGPUCoordinateSystem",()=>i.WebGPUCoordinateSystem,"WebXRController",()=>i.WebXRController,"WireframeGeometry",()=>i.WireframeGeometry,"WrapAroundEnding",()=>i.WrapAroundEnding,"ZeroCurvatureEnding",()=>i.ZeroCurvatureEnding,"ZeroFactor",()=>i.ZeroFactor,"ZeroSlopeEnding",()=>i.ZeroSlopeEnding,"ZeroStencilOp",()=>i.ZeroStencilOp,"createCanvasElement",()=>i.createCanvasElement,"error",()=>i.error,"getConsoleFunction",()=>i.getConsoleFunction,"log",()=>i.log,"setConsoleFunction",()=>i.setConsoleFunction,"warn",()=>i.warn,"warnOnce",()=>i.warnOnce],32009);var o=e.i(32009);function a(e,t){let r;return(...n)=>{window.clearTimeout(r),r=window.setTimeout(()=>e(...n),t)}}let s=["x","y","top","bottom","left","right","width","height"];var l=e.i(46791),u=e.i(43476);function c({ref:e,children:n,fallback:i,resize:l,style:c,gl:d,events:f=t.f,eventSource:A,eventPrefix:h,shadows:m,linear:p,flat:B,legacy:C,orthographic:g,frameloop:v,dpr:y,performance:b,raycaster:E,camera:M,scene:F,onPointerMissed:S,onCreated:R,...I}){r.useMemo(()=>(0,t.e)(o),[]);let T=(0,t.u)(),[x,G]=function({debounce:e,scroll:t,polyfill:n,offsetSize:i}={debounce:0,scroll:!1,offsetSize:!1}){var o,l,u;let c=n||("u"(p.current=!0,()=>void(p.current=!1)));let[B,C,g]=(0,r.useMemo)(()=>{let e=()=>{let e,t;if(!A.current.element)return;let{left:r,top:n,width:o,height:a,bottom:l,right:u,x:c,y:d}=A.current.element.getBoundingClientRect(),h={left:r,top:n,width:o,height:a,bottom:l,right:u,x:c,y:d};A.current.element instanceof HTMLElement&&i&&(h.height=A.current.element.offsetHeight,h.width=A.current.element.offsetWidth),Object.freeze(h),p.current&&(e=A.current.lastBounds,t=h,!s.every(r=>e[r]===t[r]))&&f(A.current.lastBounds=h)};return[e,m?a(e,m):e,h?a(e,h):e]},[f,i,h,m]);function v(){A.current.scrollContainers&&(A.current.scrollContainers.forEach(e=>e.removeEventListener("scroll",g,!0)),A.current.scrollContainers=null),A.current.resizeObserver&&(A.current.resizeObserver.disconnect(),A.current.resizeObserver=null),A.current.orientationHandler&&("orientation"in screen&&"removeEventListener"in screen.orientation?screen.orientation.removeEventListener("change",A.current.orientationHandler):"onorientationchange"in window&&window.removeEventListener("orientationchange",A.current.orientationHandler))}function y(){A.current.element&&(A.current.resizeObserver=new c(g),A.current.resizeObserver.observe(A.current.element),t&&A.current.scrollContainers&&A.current.scrollContainers.forEach(e=>e.addEventListener("scroll",g,{capture:!0,passive:!0})),A.current.orientationHandler=()=>{g()},"orientation"in screen&&"addEventListener"in screen.orientation?screen.orientation.addEventListener("change",A.current.orientationHandler):"onorientationchange"in window&&window.addEventListener("orientationchange",A.current.orientationHandler))}return o=g,l=!!t,(0,r.useEffect)(()=>{if(l)return window.addEventListener("scroll",o,{capture:!0,passive:!0}),()=>void window.removeEventListener("scroll",o,!0)},[o,l]),u=C,(0,r.useEffect)(()=>(window.addEventListener("resize",u),()=>void window.removeEventListener("resize",u)),[u]),(0,r.useEffect)(()=>{v(),y()},[t,g,C]),(0,r.useEffect)(()=>v,[]),[e=>{e&&e!==A.current.element&&(v(),A.current.element=e,A.current.scrollContainers=function e(t){let r=[];if(!t||t===document.body)return r;let{overflow:n,overflowX:i,overflowY:o}=window.getComputedStyle(t);return[n,i,o].some(e=>"auto"===e||"scroll"===e)&&r.push(t),[...r,...e(t.parentElement)]}(e),y())},d,B]}({scroll:!0,debounce:{scroll:50,resize:0},...l}),D=r.useRef(null),w=r.useRef(null);r.useImperativeHandle(e,()=>D.current);let L=(0,t.a)(S),[_,O]=r.useState(!1),[H,P]=r.useState(!1);if(_)throw _;if(H)throw H;let J=r.useRef(null);(0,t.b)(()=>{let e=D.current;G.width>0&&G.height>0&&e&&(J.current||(J.current=(0,t.c)(e)),async function(){await J.current.configure({gl:d,scene:F,events:f,shadows:m,linear:p,flat:B,legacy:C,orthographic:g,frameloop:v,dpr:y,performance:b,raycaster:E,camera:M,size:G,onPointerMissed:(...e)=>null==L.current?void 0:L.current(...e),onCreated:e=>{null==e.events.connect||e.events.connect(A?(0,t.i)(A)?A.current:A:w.current),h&&e.setEvents({compute:(e,t)=>{let r=e[h+"X"],n=e[h+"Y"];t.pointer.set(r/t.size.width*2-1,-(2*(n/t.size.height))+1),t.raycaster.setFromCamera(t.pointer,t.camera)}}),null==R||R(e)}}),J.current.render((0,u.jsx)(T,{children:(0,u.jsx)(t.E,{set:P,children:(0,u.jsx)(r.Suspense,{fallback:(0,u.jsx)(t.B,{set:O}),children:null!=n?n:null})})}))}())}),r.useEffect(()=>{let e=D.current;if(e)return()=>(0,t.d)(e)},[]);let U=A?"none":"auto";return(0,u.jsx)("div",{ref:w,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:U,...c},...I,children:(0,u.jsx)("div",{ref:x,style:{width:"100%",height:"100%"},children:(0,u.jsx)("canvas",{ref:D,style:{display:"block"},children:i})})})}function d(e){return(0,u.jsx)(l.FiberProvider,{children:(0,u.jsx)(c,{...e})})}e.i(89499),e.s(["Canvas",()=>d],75056)},17751,85413,e=>{"use strict";var t=e.i(19273),r=e.i(86491),n=e.i(40143),i=e.i(15823),o=class extends i.Subscribable{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,n,i){let o=n.queryKey,a=n.queryHash??(0,t.hashQueryKeyByOptions)(o,n),s=this.get(a);return s||(s=new r.Query({client:e,queryKey:o,queryHash:a,options:e.defaultQueryOptions(n),state:i,defaultOptions:e.getQueryDefaults(o)}),this.add(s)),s}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchQuery)(r,e))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(r=>(0,t.matchQuery)(e,r)):r}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},a=e.i(88587),s=e.i(36553),l=class extends a.Removable{#t;#r;#n;#i;constructor(e){super(),this.#t=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#r=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#r.includes(e)||(this.#r.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#r=this.#r.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#r.length||("pending"===this.state.status?this.scheduleGc():this.#n.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#o({type:"continue"})},r={client:this.#t,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=(0,s.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#o({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#o({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let n="pending"===this.state.status,i=!this.#i.canStart();try{if(n)t();else{this.#o({type:"pending",variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,r);let t=await this.options.onMutate?.(e,r);t!==this.state.context&&this.#o({type:"pending",context:t,variables:e,isPaused:i})}let o=await this.#i.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,r),await this.options.onSuccess?.(o,e,this.state.context,r),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(o,null,e,this.state.context,r),this.#o({type:"success",data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,r)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,r)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,r)}catch(e){Promise.reject(e)}throw this.#o({type:"error",error:t}),t}finally{this.#n.runNext(this)}}#o(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),n.notifyManager.batch(()=>{this.#r.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}},u=i,c=class extends u.Subscribable{constructor(e={}){super(),this.config=e,this.#a=new Set,this.#s=new Map,this.#l=0}#a;#s;#l;build(e,t,r){let n=new l({client:e,mutationCache:this,mutationId:++this.#l,options:e.defaultMutationOptions(t),state:r});return this.add(n),n}add(e){this.#a.add(e);let t=d(e);if("string"==typeof t){let r=this.#s.get(t);r?r.push(e):this.#s.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#a.delete(e)){let t=d(e);if("string"==typeof t){let r=this.#s.get(t);if(r)if(r.length>1){let t=r.indexOf(e);-1!==t&&r.splice(t,1)}else r[0]===e&&this.#s.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=d(e);if("string"!=typeof t)return!0;{let r=this.#s.get(t),n=r?.find(e=>"pending"===e.state.status);return!n||n===e}}runNext(e){let t=d(e);if("string"!=typeof t)return Promise.resolve();{let r=this.#s.get(t)?.find(t=>t!==e&&t.state.isPaused);return r?.continue()??Promise.resolve()}}clear(){n.notifyManager.batch(()=>{this.#a.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#a.clear(),this.#s.clear()})}getAll(){return Array.from(this.#a)}find(e){let r={exact:!0,...e};return this.getAll().find(e=>(0,t.matchMutation)(r,e))}findAll(e={}){return this.getAll().filter(r=>(0,t.matchMutation)(e,r))}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return n.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(t.noop))))}};function d(e){return e.options.scope?.id}var f=e.i(75555),A=e.i(14448);function h(e){return{onFetch:(r,n)=>{let i=r.options,o=r.fetchOptions?.meta?.fetchMore?.direction,a=r.state.data?.pages||[],s=r.state.data?.pageParams||[],l={pages:[],pageParams:[]},u=0,c=async()=>{let n=!1,c=(0,t.ensureQueryFn)(r.options,r.fetchOptions),d=async(e,i,o)=>{let a;if(n)return Promise.reject();if(null==i&&e.pages.length)return Promise.resolve(e);let s=(a={client:r.client,queryKey:r.queryKey,pageParam:i,direction:o?"backward":"forward",meta:r.options.meta},(0,t.addConsumeAwareSignal)(a,()=>r.signal,()=>n=!0),a),l=await c(s),{maxPages:u}=r.options,d=o?t.addToStart:t.addToEnd;return{pages:d(e.pages,l,u),pageParams:d(e.pageParams,i,u)}};if(o&&a.length){let e="backward"===o,t={pages:a,pageParams:s},r=(e?function(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}:m)(i,t);l=await d(t,r,e)}else{let t=e??a.length;do{let e=0===u?s[0]??i.initialPageParam:m(i,l);if(u>0&&null==e)break;l=await d(l,e),u++}while(ur.options.persister?.(c,{client:r.client,queryKey:r.queryKey,meta:r.options.meta,signal:r.signal},n):r.fetchFn=c}}}function m(e,{pages:t,pageParams:r}){let n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}var p=class{#u;#n;#c;#d;#f;#A;#h;#m;constructor(e={}){this.#u=e.queryCache||new o,this.#n=e.mutationCache||new c,this.#c=e.defaultOptions||{},this.#d=new Map,this.#f=new Map,this.#A=0}mount(){this.#A++,1===this.#A&&(this.#h=f.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onFocus())}),this.#m=A.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#u.onOnline())}))}unmount(){this.#A--,0===this.#A&&(this.#h?.(),this.#h=void 0,this.#m?.(),this.#m=void 0)}isFetching(e){return this.#u.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#n.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state.data}ensureQueryData(e){let r=this.defaultQueryOptions(e),n=this.#u.build(this,r),i=n.state.data;return void 0===i?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))&&this.prefetchQuery(r),Promise.resolve(i))}getQueriesData(e){return this.#u.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,r,n){let i=this.defaultQueryOptions({queryKey:e}),o=this.#u.get(i.queryHash),a=o?.state.data,s=(0,t.functionalUpdate)(r,a);if(void 0!==s)return this.#u.build(this,i).setData(s,{...n,manual:!0})}setQueriesData(e,t,r){return n.notifyManager.batch(()=>this.#u.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#u.get(t.queryHash)?.state}removeQueries(e){let t=this.#u;n.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let r=this.#u;return n.notifyManager.batch(()=>(r.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,r={}){let i={revert:!0,...r};return Promise.all(n.notifyManager.batch(()=>this.#u.findAll(e).map(e=>e.cancel(i)))).then(t.noop).catch(t.noop)}invalidateQueries(e,t={}){return n.notifyManager.batch(()=>(this.#u.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,r={}){let i={...r,cancelRefetch:r.cancelRefetch??!0};return Promise.all(n.notifyManager.batch(()=>this.#u.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let r=e.fetch(void 0,i);return i.throwOnError||(r=r.catch(t.noop)),"paused"===e.state.fetchStatus?Promise.resolve():r}))).then(t.noop)}fetchQuery(e){let r=this.defaultQueryOptions(e);void 0===r.retry&&(r.retry=!1);let n=this.#u.build(this,r);return n.isStaleByTime((0,t.resolveStaleTime)(r.staleTime,n))?n.fetch(r):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(t.noop).catch(t.noop)}fetchInfiniteQuery(e){return e.behavior=h(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(t.noop).catch(t.noop)}ensureInfiniteQueryData(e){return e.behavior=h(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return A.onlineManager.isOnline()?this.#n.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#u}getMutationCache(){return this.#n}getDefaultOptions(){return this.#c}setDefaultOptions(e){this.#c=e}setQueryDefaults(e,r){this.#d.set((0,t.hashKey)(e),{queryKey:e,defaultOptions:r})}getQueryDefaults(e){let r=[...this.#d.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,r){this.#f.set((0,t.hashKey)(e),{mutationKey:e,defaultOptions:r})}getMutationDefaults(e){let r=[...this.#f.values()],n={};return r.forEach(r=>{(0,t.partialMatchKey)(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let r={...this.#c.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return r.queryHash||(r.queryHash=(0,t.hashQueryKeyByOptions)(r.queryKey,r)),void 0===r.refetchOnReconnect&&(r.refetchOnReconnect="always"!==r.networkMode),void 0===r.throwOnError&&(r.throwOnError=!!r.suspense),!r.networkMode&&r.persister&&(r.networkMode="offlineFirst"),r.queryFn===t.skipToken&&(r.enabled=!1),r}defaultMutationOptions(e){return e?._defaulted?e:{...this.#c.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#u.clear(),this.#n.clear()}};e.s(["QueryClient",()=>p],17751);var B=Object.defineProperty;class C{constructor(){((e,t,r)=>{let n;return(n="symbol"!=typeof t?t+"":t)in e?B(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r})(this,"_listeners")}addEventListener(e,t){void 0===this._listeners&&(this._listeners={});let r=this._listeners;void 0===r[e]&&(r[e]=[]),-1===r[e].indexOf(t)&&r[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;let r=this._listeners;return void 0!==r[e]&&-1!==r[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;let r=this._listeners[e];if(void 0!==r){let e=r.indexOf(t);-1!==e&&r.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;let t=this._listeners[e.type];if(void 0!==t){e.target=this;let r=t.slice(0);for(let t=0,n=r.length;tC],85413)},91907,8597,78140,82816,25947,51475,71505,71832,e=>{"use strict";let t;e.s(["ShapeRenderer",()=>tc,"applyShapeShaderModifications",()=>tn,"createMaterialFromFlags",()=>ti,"useStaticShape",()=>to],91907);var r=e.i(43476),n=e.i(932),i=e.i(71645),o=i;let a=(0,o.createContext)(null),s={didCatch:!1,error:null};class l extends o.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=s}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){let{error:t}=this.state;null!==t&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(s))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){let{didCatch:r}=this.state,{resetKeys:n}=this.props;r&&null!==t.error&&function(e=[],t=[]){return e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))}(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(s))}render(){let{children:e,fallbackRender:t,FallbackComponent:r,fallback:n}=this.props,{didCatch:i,error:s}=this.state,l=e;if(i){let e={error:s,resetErrorBoundary:this.resetErrorBoundary};if("function"==typeof t)l=t(e);else if(r)l=(0,o.createElement)(r,e);else if(void 0!==n)l=n;else throw s}return(0,o.createElement)(a.Provider,{value:{didCatch:i,error:s,resetErrorBoundary:this.resetErrorBoundary}},l)}}e.s(["ErrorBoundary",()=>l],8597);var u=e.i(31067),c=e.i(90072);function d(e,t){if(t===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t!==c.TriangleFanDrawMode&&t!==c.TriangleStripDrawMode)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e;{let r=e.getIndex();if(null===r){let t=[],n=e.getAttribute("position");if(void 0===n)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;etypeof TextDecoder)return new TextDecoder().decode(e);let t="";for(let r=0,n=e.length;r=2.0 are supported."));return}let s=new ei(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});s.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}s.setExtensions(o),s.setPlugins(a),s.parse(r,n)}parseAsync(e,t){let r=this;return new Promise(function(n,i){r.parse(e,t,n,i)})}}function B(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let C={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class g{constructor(e){this.parser=e,this.name=C.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r=0))return null;else throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return t.loadTextureImage(e,i.source,o)}}class w{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],a=n.images[o.source],s=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then(function(i){if(i)return r.loadTextureImage(e,o.source,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class L{constructor(e){this.parser=e,this.name=C.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;let o=i.extensions[t],a=n.images[o.source],s=r.textureLoader;if(a.uri){let e=r.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then(function(i){if(i)return r.loadTextureImage(e,o.source,s);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class _{constructor(e){this.name=C.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(!r.extensions||!r.extensions[this.name])return null;{let e=r.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported)if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return n.then(function(t){let r=e.byteOffset||0,n=e.byteLength||0,o=e.count,a=e.byteStride,s=new Uint8Array(t,r,n);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(o,a,s,e.mode,e.filter).then(function(e){return e.buffer}):i.ready.then(function(){let t=new ArrayBuffer(o*a);return i.decodeGltfBuffer(new Uint8Array(t),o,a,s,e.mode,e.filter),t})})}}}class O{constructor(e){this.name=C.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;for(let e of t.meshes[r.mesh].primitives)if(e.mode!==Q.TRIANGLES&&e.mode!==Q.TRIANGLE_STRIP&&e.mode!==Q.TRIANGLE_FAN&&void 0!==e.mode)return null;let n=r.extensions[this.name].attributes,i=[],o={};for(let e in n)i.push(this.parser.getDependency("accessor",n[e]).then(t=>(o[e]=t,o[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{let t=e.pop(),r=t.isGroup?t.children:[t],n=e[0].count,i=[];for(let e of r){let t=new c.Matrix4,r=new c.Vector3,a=new c.Quaternion,s=new c.Vector3(1,1,1),l=new c.InstancedMesh(e.geometry,e.material,n);for(let e=0;e=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Z={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},z={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete};function $(e,t,r){for(let n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function ee(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function et(e){let t="",r=Object.keys(e).sort();for(let n=0,i=r.length;ntypeof navigator&&void 0!==navigator.userAgent&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=(n=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"u"{let r=this.associations.get(e);for(let[n,o]of(null!=r&&this.associations.set(t,r),e.children.entries()))i(o,t.children[n])};return i(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r=2&&o.setY(t,f[e*s+1]),s>=3&&o.setZ(t,f[e*s+2]),s>=4&&o.setW(t,f[e*s+3]),s>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return o})}loadTexture(e){let t=this.json,r=this.options,n=t.textures[e].source,i=t.images[n],o=this.textureLoader;if(i.uri){let e=r.manager.getHandler(i.uri);null!==e&&(o=e)}return this.loadTextureImage(e,n,o)}loadTextureImage(e,t,r){let n=this,i=this.json,o=i.textures[e],a=i.images[t],s=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[s])return this.textureCache[s];let l=this.loadImageSource(t,r).then(function(t){t.flipY=!1,t.name=o.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);let r=(i.samplers||{})[o.sampler]||{};return t.magFilter=V[r.magFilter]||c.LinearFilter,t.minFilter=V[r.minFilter]||c.LinearMipmapLinearFilter,t.wrapS=q[r.wrapS]||c.RepeatWrapping,t.wrapT=q[r.wrapT]||c.RepeatWrapping,n.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[s]=l,l}loadImageSource(e,t){let r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=r.images[e],o=self.URL||self.webkitURL,a=i.uri||"",s=!1;if(void 0!==i.bufferView)a=this.getDependency("bufferView",i.bufferView).then(function(e){s=!0;let t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let l=Promise.resolve(a).then(function(e){return new Promise(function(r,i){let o=r;!0===t.isImageBitmapLoader&&(o=function(e){let t=new c.Texture(e);t.needsUpdate=!0,r(t)}),t.load(c.LoaderUtils.resolveURL(e,n.path),o,void 0,i)})}).then(function(e){var t;return!0===s&&o.revokeObjectURL(a),ee(e,i),e.userData.mimeType=i.mimeType||((t=i.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=l,l}assignTexture(e,t,r,n){let i=this;return this.getDependency("texture",r.index).then(function(o){if(!o)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((o=o.clone()).channel=r.texCoord),i.extensions[C.KHR_TEXTURE_TRANSFORM]){let e=void 0!==r.extensions?r.extensions[C.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=i.associations.get(o);o=i.extensions[C.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return void 0!==n&&("number"==typeof n&&(n=3001===n?h:m),"colorSpace"in o?o.colorSpace=n:o.encoding=n===h?3001:3e3),e[t]=o,o})}assignFinalMaterial(e){let t=e.geometry,r=e.material,n=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new c.PointsMaterial,c.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){let e="LineBasicMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new c.LineBasicMaterial,c.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(n||i||o){let e="ClonedMaterial:"+r.uuid+":";n&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){let t,r=this,n=this.json,i=this.extensions,o=n.materials[e],a={},s=o.extensions||{},l=[];if(s[C.KHR_MATERIALS_UNLIT]){let e=i[C.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),l.push(e.extendParams(a,o,r))}else{let n=o.pbrMetallicRoughness||{};if(a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;a.color.setRGB(e[0],e[1],e[2],m),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(r.assignTexture(a,"map",n.baseColorTexture,h)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(r.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(r.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)})))}!0===o.doubleSided&&(a.side=c.DoubleSide);let u=o.alphaMode||"OPAQUE";if("BLEND"===u?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,"MASK"===u&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&t!==c.MeshBasicMaterial&&(l.push(r.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new c.Vector2(1,1),void 0!==o.normalTexture.scale)){let e=o.normalTexture.scale;a.normalScale.set(e,e)}if(void 0!==o.occlusionTexture&&t!==c.MeshBasicMaterial&&(l.push(r.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&t!==c.MeshBasicMaterial){let e=o.emissiveFactor;a.emissive=new c.Color().setRGB(e[0],e[1],e[2],m)}return void 0!==o.emissiveTexture&&t!==c.MeshBasicMaterial&&l.push(r.assignTexture(a,"emissiveMap",o.emissiveTexture,h)),Promise.all(l).then(function(){let n=new t(a);return o.name&&(n.name=o.name),ee(n,o),r.associations.set(n,{materials:e}),o.extensions&&$(i,n,o),n})}createUniqueName(e){let t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,n=this.primitiveCache,i=[];for(let o=0,a=e.length;o0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,n=t.weights.length;r1?new c.Group:1===t.length?t[0]:new c.Object3D)!==t[0])for(let e=0,r=t.length;e{let t=new Map;for(let[e,r]of n.associations)(e instanceof c.Material||e instanceof c.Texture)&&t.set(e,r);return e.traverse(e=>{let r=n.associations.get(e);null!=r&&t.set(e,r)}),t})(i),i})}_createAnimationTracks(e,t,r,n,i){let o,a=[],s=e.name?e.name:e.uuid,l=[];switch(Z[i.path]===Z.weights?e.traverse(function(e){e.morphTargetInfluences&&l.push(e.name?e.name:e.uuid)}):l.push(s),Z[i.path]){case Z.weights:o=c.NumberKeyframeTrack;break;case Z.rotation:o=c.QuaternionKeyframeTrack;break;case Z.position:case Z.scale:o=c.VectorKeyframeTrack;break;default:o=1===r.itemSize?c.NumberKeyframeTrack:c.VectorKeyframeTrack}let u=void 0!==n.interpolation?z[n.interpolation]:c.InterpolateLinear,d=this._getArrayFromAccessor(r);for(let e=0,r=l.length;e{let r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(n)},r,n)}decodeDracoFile(e,t,r,n){let i={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){let r;for(let e in t.attributeTypes){let r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}let n=JSON.stringify(t);if(es.has(e)){let t=es.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(i,o).then(n=>(r=n,new Promise((n,o)=>{r._callbacks[i]={resolve:n,reject:o},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return a.catch(()=>!0).then(()=>{r&&i&&this._releaseTask(r,i)}),es.set(e,{key:n,promise:a}),a}_createGeometry(e){let t=new ea.BufferGeometry;e.index&&t.setIndex(new ea.BufferAttribute(e.index.array,1));for(let r=0;r{r.load(e,t,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{let r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let n=eu.toString(),i=["/* draco decoder */",r,"\n/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.lengtht._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{let t=e.draco,r=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{let e=function(e,t,r,n){var i,o,a;let s,l,u,c,d,f,A=n.attributeIDs,h=n.attributeTypes,m=t.GetEncodedGeometryType(r);if(m===e.TRIANGULAR_MESH)d=new e.Mesh,f=t.DecodeBufferToMesh(r,d);else if(m===e.POINT_CLOUD)d=new e.PointCloud,f=t.DecodeBufferToPointCloud(r,d);else throw Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||0===d.ptr)throw Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());let p={index:null,attributes:[]};for(let r in A){let i,o,a=self[h[r]];if(n.useUniqueIDs)o=A[r],i=t.GetAttributeByUniqueId(d,o);else{if(-1===(o=t.GetAttributeId(d,e[A[r]])))continue;i=t.GetAttribute(d,o)}p.attributes.push(function(e,t,r,n,i,o){let a=o.num_components(),s=r.num_points()*a,l=s*i.BYTES_PER_ELEMENT,u=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),c=e._malloc(l);t.GetAttributeDataArrayForAllPoints(r,o,u,l,c);let d=new i(e.HEAPF32.buffer,c,s).slice();return e._free(c),{name:n,array:d,itemSize:a}}(e,t,d,r,a,i))}return m===e.TRIANGULAR_MESH&&(i=e,o=t,a=d,s=3*a.num_faces(),l=4*s,u=i._malloc(l),o.GetTrianglesUInt32Array(a,l,u),c=new Uint32Array(i.HEAPF32.buffer,u,s).slice(),i._free(u),p.index={array:c,itemSize:1}),e.destroy(d),p}(t,r,a,o),i=e.attributes.map(e=>e.array.buffer);e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(a),t.destroy(r)}})}}}var ec=e.i(99143);let ed=function(e){let t=new Map,r=new Map,n=e.clone();return function e(t,r,n){n(t,r);for(let i=0;i{let A={keys:l,deep:n,inject:s,castShadow:o,receiveShadow:a};if(Array.isArray(t=i.useMemo(()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse(t=>{t.isSkinnedMesh&&(e=!0)}),e)return ed(t)}return t},[t,e])))return i.createElement("group",(0,u.default)({},d,{ref:f}),t.map(e=>i.createElement(ef,(0,u.default)({key:e.uuid,object:e},A))),r);let{children:h,...m}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:n,castShadow:o,receiveShadow:a}){let s={};for(let r of t)s[r]=e[r];return r&&(s.geometry&&"materialsOnly"!==r&&(s.geometry=s.geometry.clone()),s.material&&"geometriesOnly"!==r&&(s.material=s.material.clone())),n&&(s="function"==typeof n?{...s,children:n(e)}:i.isValidElement(n)?{...s,children:n}:{...s,...n}),e instanceof c.Mesh&&(o&&(s.castShadow=!0),a&&(s.receiveShadow=!0)),s}(t,A),p=t.type[0].toLowerCase()+t.type.slice(1);return i.createElement(p,(0,u.default)({},m,d,{ref:f}),t.children.map(e=>"Bone"===e.type?i.createElement("primitive",(0,u.default)({key:e.uuid,object:e},A)):i.createElement(ef,(0,u.default)({key:e.uuid,object:e},A,{isChild:!0}))),r,h)}),eA=null,eh="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function em(e=!0,r=!0,n){return i=>{n&&n(i),e&&(eA||(eA=new el),eA.setDecoderPath("string"==typeof e?e:eh),i.setDRACOLoader(eA)),r&&i.setMeshoptDecoder((()=>{let e;if(t)return t;let r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let i="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB";WebAssembly.validate(r)&&(i="B9h9z9tFBBBFiI9gBB9gLaaaaaFa9gEaaaB9gFaFaEMcBBFBFFGGGEILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBOn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBNI9z9iqlBVc+N9IcIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMk8lLbaE97F9+FaL978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAeDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAeDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAeDeBJAiCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPAPDQBFGENVcMILKOSQfbHeD8dBh+BsxoxoUwN0AeD8dFhxoUwkwk+gUa0sHnhTkAnsHnhNkAnsHn7CgFZHiCEWCxkUUBJDBEBAiCx+YUUBJDBBBHeAeDQBBBBBBBBBBBBBBBBAnhAk7CgFZHiCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAeDeBJAiCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBReCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBH8ZCFD9tA8ZAPD9OD9hD9RH8ZDQBTFtGmEYIPLdKeOnHpAIAQJDBIBHyCFD9tAyAPD9OD9hD9RHyAIASJDBIBH8cCFD9tA8cAPD9OD9hD9RH8cDQBTFtGmEYIPLdKeOnH8dDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAeD9uHeDyBjGBAEAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeApA8dDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNiV8ZcpMyS8cQ8df8eb8fHdAyA8cDQNiV8ZcpMyS8cQ8df8eb8fH8ZDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJHIAeAdA8ZDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHeDyBjGBAIAGJHIAeAPAPDQILKOILKOILKOILKOD9uHeDyBjGBAIAGJHIAeAPAPDQNVcMNVcMNVcMNVcMD9uHeDyBjGBAIAGJHIAeAPAPDQSQfbSQfbSQfbSQfbD9uHeDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/dLEK97FaF97GXGXAGCI9HQBAF9FQFCBRGEXABABDBBBHECiD+rFCiD+sFD/6FHIAECND+rFCiD+sFD/6FAID/gFAECTD+rFCiD+sFD/6FHLD/gFD/kFD/lFHKCBDtD+2FHOAICUUUU94DtHND9OD9RD/kFHI9DBB/+hDYAIAID/mFAKAKD/mFALAOALAND9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHLD/mF9DBBX9LDYHOD/kFCgFDtD9OAECUUU94DtD9OD9QAIALD/mFAOD/kFCND+rFCU/+EDtD9OD9QAKALD/mFAOD/kFCTD+rFCUU/8ODtD9OD9QDMBBABCTJRBAGCIJHGAF9JQBSGMMAF9FQBCBRGEXABCTJHVAVDBBBHECBDtHOCUU98D8cFCUU98D8cEHND9OABDBBBHKAEDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAKAEDQBFGENVcMTtmYi8ZpyHECTD+sFD/6FHID/gFAECTD+rFCTD+sFD/6FHLD/gFD/kFD/lFHE9DB/+g6DYALAEAOD+2FHOALCUUUU94DtHcD9OD9RD/kFHLALD/mFAEAED/mFAIAOAIAcD9OD9RD/kFHEAED/mFD/kFD/kFD/jFD/nFHID/mF9DBBX9LDYHOD/kFCTD+rFALAID/mFAOD/kFCggEDtD9OD9QHLAEAID/mFAOD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHEDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAKAND9OALAEDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM/hEIGaF97FaL978jUUUUBCTlREGXAF9FQBCBRIEXAEABDBBBHLABCTJHKDBBBHODQILKOSQfbPden8c8d8e8fHNCTD+sFHVCID+rFDMIBAB9DBBU8/DY9D/zI818/DYAVCEDtD9QD/6FD/nFHVALAODQBFGENVcMTtmYi8ZpyHLCTD+rFCTD+sFD/6FD/mFHOAOD/mFAVALCTD+sFD/6FD/mFHcAcD/mFAVANCTD+rFCTD+sFD/6FD/mFHNAND/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHVD/mF9DBBX9LDYHLD/kFCggEDtHMD9OAcAVD/mFALD/kFCTD+rFD9QHcANAVD/mFALD/kFCTD+rFAOAVD/mFALD/kFAMD9OD9QHVDQBFTtGEmYILPdKOenHLD8dBAEDBIBDyB+t+J83EBABCNJALD8dFAEDBIBDyF+t+J83EBAKAcAVDQNVi8ZcMpySQ8c8dfb8e8fHVD8dBAEDBIBDyG+t+J83EBABCiJAVD8dFAEDBIBDyE+t+J83EBABCAJRBAICIJHIAF9JQBMMM9jFF97GXAGCGrAF9sHG9FQBCBRFEXABABDBBBHECND+rFCND+sFD/6FAECiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBABCTJRBAFCIJHFAG9JQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB");let o=WebAssembly.instantiate(function(e){let t=new Uint8Array(e.length);for(let r=0;r96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let i=0;i{(e=t.instance).exports.__wasm_call_ctors()});function a(t,r,n,i,o,a){let s=e.exports.sbrk,l=n+3&-4,u=s(l*i),c=s(o.length),d=new Uint8Array(e.exports.memory.buffer);d.set(o,c);let f=t(u,n,i,c,o.length);if(0===f&&a&&a(u,l,i),r.set(d.subarray(u,u+n*i)),s(u-s(0)),0!==f)throw Error(`Malformed buffer data: ${f}`)}let s={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},l={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return t={ready:o,supported:!0,decodeVertexBuffer(t,r,n,i,o){a(e.exports.meshopt_decodeVertexBuffer,t,r,n,i,e.exports[s[o]])},decodeIndexBuffer(t,r,n,i){a(e.exports.meshopt_decodeIndexBuffer,t,r,n,i)},decodeIndexSequence(t,r,n,i){a(e.exports.meshopt_decodeIndexSequence,t,r,n,i)},decodeGltfBuffer(t,r,n,i,o,u){a(e.exports[l[o]],t,r,n,i,e.exports[s[u]])}}})())}}let ep=(e,t,r,n)=>(0,ec.useLoader)(p,e,em(t,r,n));ep.preload=(e,t,r,n)=>ec.useLoader.preload(p,e,em(t,r,n)),ep.clear=e=>ec.useLoader.clear(p,e),ep.setDecoderPath=e=>{eh=e},e.s(["useGLTF",()=>ep],78140);var eB=e.i(47071),eC=e.i(71753),eg=e.i(12979);function ev(e){let t=new Map,r=new Map,n=e.clone();return function e(t,r,n){n(t,r);for(let i=0;iev],82816);var ey=e.i(75567),eb=e.i(79123);let eE=/borg|xorg|porg|dorg|plant|tree|bush|fern|vine|grass|leaf|flower|frond|palm|foliage/i;function eM(e){return eE.test(e)}let eF=(0,i.createContext)(null);function eS(){let e=(0,i.useContext)(eF);if(!e)throw Error("useShapeInfo must be used within ShapeInfoProvider");return e}function eR(e){let t,i,o,a=(0,n.c)(10),{children:s,object:l,shapeName:u,type:c}=e;a[0]!==u?(t=eM(u),a[0]=u,a[1]=t):t=a[1];let d=t;a[2]!==d||a[3]!==l||a[4]!==u||a[5]!==c?(i={object:l,shapeName:u,type:c,isOrganic:d},a[2]=d,a[3]=l,a[4]=u,a[5]=c,a[6]=i):i=a[6];let f=i;return a[7]!==s||a[8]!==f?(o=(0,r.jsx)(eF.Provider,{value:f,children:s}),a[7]=s,a[8]=f,a[9]=o):o=a[9],o}e.s(["ShapeInfoProvider",()=>eR,"isOrganicShape",()=>eM,"useShapeInfo",()=>eS],25947),e.i(13876);var eI=e.i(58647),eT=e.i(89887);e.i(47167);var ex=e.i(69230),eG=e.i(69637),eD=e.i(54440);let ew=(0,i.createContext)(null);function eL({children:e}){let t=(0,i.useRef)(void 0),n=(0,i.useRef)(0),o=(0,i.useRef)(0);(0,eC.useFrame)((e,r)=>{for(n.current+=r;n.current>=.03125;)if(n.current-=.03125,o.current++,t.current)for(let e of t.current)e(o.current)});let a=(0,i.useCallback)(e=>(t.current??=new Set,t.current.add(e),()=>{t.current.delete(e)}),[]),s=(0,i.useCallback)(()=>o.current,[]),l=(0,i.useMemo)(()=>({subscribe:a,getTick:s}),[a,s]);return(0,r.jsx)(ew.Provider,{value:l,children:e})}function e_(e){let t=(0,i.useContext)(ew);if(!t)throw Error("useTick must be used within a TickProvider");let r=(0,i.useRef)(e);r.current=e,(0,i.useEffect)(()=>t.subscribe(e=>r.current(e)),[t])}e.s(["TICK_RATE",0,32,"TickProvider",()=>eL,"useTick",()=>e_],51475);let eO=1/30,eH=new Map;function eP(e){let t=e[0].image,r=t.width,n=t.height,i=e.length,o=Math.ceil(Math.sqrt(i)),a=Math.ceil(i/o),s=document.createElement("canvas");s.width=r*o,s.height=n*a;let l=s.getContext("2d");e.forEach((e,t)=>{let i=Math.floor(t/o);l.drawImage(e.image,t%o*r,i*n)});let u=new c.CanvasTexture(s);return u.colorSpace=c.SRGBColorSpace,u.generateMipmaps=!1,u.minFilter=c.NearestFilter,u.magFilter=c.NearestFilter,u.wrapS=c.ClampToEdgeWrapping,u.wrapT=c.ClampToEdgeWrapping,u.repeat.set(1/o,1/a),{texture:u,columns:o,rows:a,frameCount:i,frameOffsetSeconds:[],totalDurationSeconds:0,lastFrame:-1}}function eJ(e,t){let r=0;e.frameOffsetSeconds=t.map(e=>r+=e.frameCount*eO),e.totalDurationSeconds=r}function eU(e,t){if(t===e.lastFrame)return;e.lastFrame=t;let r=t%e.columns,n=e.rows-1-Math.floor(t/e.columns);e.texture.offset.set(r/e.columns,n/e.rows)}function eN(e,t){let r=e.totalDurationSeconds;if(r<=0)return 0;let n=t;n>r&&(n-=r*Math.floor(n/r));for(let t=0;t(0,eg.iflTextureToUrl)(t.name,e)),i=eP(await Promise.all(n.map(ey.loadTextureAsync)));return eJ(i,r),eH.set(e,i),i}function eK(e){var t;let r,i,o,a,s=(0,n.c)(14),{animationEnabled:l}=(0,eb.useSettings)();s[0]!==e?(r={queryKey:["ifl",e],queryFn:()=>(0,eg.loadImageFrameList)(e)},s[0]=e,s[1]=r):r=s[1];let{data:u}=(t=r,(0,eG.useBaseQuery)({...t,enabled:!0,suspense:!0,throwOnError:eD.defaultThrowOnError,placeholderData:void 0},ex.QueryObserver,void 0));if(s[2]!==u||s[3]!==e){let t;s[5]!==e?(t=t=>(0,eg.iflTextureToUrl)(t.name,e),s[5]=e,s[6]=t):t=s[6],i=u.map(t),s[2]=u,s[3]=e,s[4]=i}else i=s[4];let c=i,d=(0,eB.useTexture)(c);s[7]!==u||s[8]!==e||s[9]!==d?((o=eH.get(e))||(o=eP(d),eH.set(e,o)),eJ(o,u),s[7]=u,s[8]=e,s[9]=d,s[10]=o):o=s[10];let f=o;return s[11]!==l||s[12]!==f?(a=e=>{let t=l?eN(f,e/32):0;eU(f,t)},s[11]=l,s[12]=f,s[13]=a):a=s[13],e_(a),f.texture}e.s(["getFrameIndexForTime",()=>eN,"loadIflAtlas",()=>ek,"updateAtlasFrame",()=>eU,"useIflTexture",()=>eK],71505);var ej=e.i(47021),eQ=e.i(48066);e.s(["ANIM_TRANSITION_TIME",()=>eV,"DEFAULT_EYE_HEIGHT",()=>eX,"STREAM_TICK_SEC",()=>eq,"_r90",()=>e$,"_r90inv",()=>e0,"buildStreamDemoEntity",()=>te,"entityTypeColor",()=>tt,"getKeyframeAtTime",()=>e3,"getPosedNodeTransform",()=>e6,"processShapeScene",()=>e5,"replaceWithShapeMaterial",()=>e4,"setQuaternionFromDir",()=>e2,"setupEffectTexture",()=>e9,"torqueHorizontalFovToThreeVerticalFov",()=>e1,"torqueVecToThree",()=>e8],71832);let eX=2.1,eV=.25,eq=.032,eW=new c.Vector3,eY=new c.Vector3,eZ=new c.Matrix4,ez=new c.Vector3(0,1,0),e$=new c.Quaternion().setFromAxisAngle(new c.Vector3(0,1,0),Math.PI/2),e0=e$.clone().invert();function e1(e,t){return 180*(2*Math.atan(Math.tan(Math.max(.01,Math.min(179.99,e))*Math.PI/180/2)/(Number.isFinite(t)&&t>1e-6?t:4/3)))/Math.PI}function e9(e){e.wrapS=c.ClampToEdgeWrapping,e.wrapT=c.ClampToEdgeWrapping,e.minFilter=c.LinearFilter,e.magFilter=c.LinearFilter,e.colorSpace=c.NoColorSpace,e.flipY=!1,e.needsUpdate=!0}function e8(e,t){return t.set(e[1],e[2],e[0])}function e2(e,t){eW.crossVectors(e,ez),1e-8>eW.lengthSq()&&eW.set(-1,0,0),eW.normalize(),eY.crossVectors(eW,e).normalize(),eZ.set(eW.x,e.x,eY.x,0,eW.y,e.y,eY.y,0,eW.z,e.z,eY.z,0,0,0,0,1),t.setFromRotationMatrix(eZ)}function e3(e,t){if(0===e.length)return null;if(t<=e[0].time)return e[0];if(t>=e[e.length-1].time)return e[e.length-1];let r=0,n=e.length-1;for(;n-r>1;){let i=r+n>>1;e[i].time<=t?r=i:n=i}return e[r]}function e6(e,t,r,n){let i=e.clone(!0),o=t.find(e=>"Root"===e.name);if(o){let e=new c.AnimationMixer(i);if(e.clipAction(o).play(),n)for(let r of n){let n=t.find(e=>e.name.toLowerCase()===r.toLowerCase());if(n){let t=e.clipAction(n);t.time=n.duration/2,t.setEffectiveTimeScale(0),t.play()}}e.setTime(0)}i.updateMatrixWorld(!0);let a=null,s=null;return(i.traverse(e=>{a||e.name!==r||(a=new c.Vector3,s=new c.Quaternion,e.getWorldPosition(a),e.getWorldQuaternion(s))}),a&&s)?{position:a,quaternion:s}:null}function e4(e,t){let r=e.userData?.resource_path,n=new Set(e.userData?.flag_names??[]);if(!r){let t=new c.MeshLambertMaterial({color:e.color,side:2,reflectivity:0});return tn(t),{material:t}}if(n.has("IflMaterial")){let i=ti(e,null,n,!1,t),o=Array.isArray(i)?i[1]:i;return{material:o,initialize:(e,t)=>e7(o,r,e,t)}}let i=(0,eg.textureToUrl)(r),o=(0,ey.loadTexture)(i);(0,ey.setupTexture)(o);let a=ti(e,o,n,!1,t);return{material:Array.isArray(a)?a[1]:a}}async function e7(e,t,r,n){let i=`textures/${t}.ifl`,o=await ek(i);e.map=o.texture,e.needsUpdate=!0;let a=!1,s=r.onBeforeRender;return r.onBeforeRender=function(...e){s?.apply(this,e),a||eU(o,eN(o,n()))},()=>{a=!0,r.onBeforeRender=s??(()=>{})}}function e5(e){var t;let r,n=[],i=null;e.traverse(e=>{!i&&e.skeleton&&(i=e.skeleton)});let o=i?(t=i,r=new Set,t.bones.forEach((e,t)=>{e.name.match(/^Hulk/i)&&r.add(t)}),r):new Set;return e.traverse(e=>{if(!e.isMesh)return;if(e.name.match(/^Hulk/i)||e.material?.name==="Unassigned"){e.visible=!1;return}let t=!!e.userData?.vis_sequence;if((e.userData?.vis??1)<.01&&(e.visible=!1),e.geometry){let t=function(e,t){if(0===t.size||!e.attributes.skinIndex)return e;let r=e.attributes.skinIndex,n=e.attributes.skinWeight,i=e.index,o=Array(r.count).fill(!1);for(let e=0;e.01&&t.has(a)){o[e]=!0;break}}if(i){let t=[],r=i.array;for(let e=0;e1){let t=0,r=0,n=0;for(let o of e)t+=i[3*o],r+=i[3*o+1],n+=i[3*o+2];let o=Math.sqrt(t*t+r*r+n*n);for(let a of(o>0&&(t/=o,r/=o,n/=o),e))i[3*a]=t,i[3*a+1]=r,i[3*a+2]=n}r.needsUpdate=!0}(t=t.clone()),e.geometry=t}let r=t?1:e.userData?.vis??1;if(Array.isArray(e.material))e.material=e.material.map(t=>{let i=e4(t,r);return i.initialize&&n.push({mesh:e,initialize:i.initialize}),i.material});else if(e.material){let t=e4(e.material,r);t.initialize&&n.push({mesh:e,initialize:t.initialize}),e.material=t.material}}),n}function te(e,t,r,n,i,o,a,s,l,u,c,d,f){return{id:e,type:t,dataBlock:r,visual:n,direction:i,weaponShape:o,playerName:a,className:s,ghostIndex:l,dataBlockId:u,shapeHint:c,explosionDataBlockId:d,faceViewer:f,keyframes:[{time:0,position:[0,0,0],rotation:[0,0,0,1]}]}}function tt(e){switch(e.toLowerCase()){case"player":return"#00ff88";case"vehicle":return"#ff8800";case"projectile":return"#ff0044";case"deployable":return"#ffcc00";default:return"#8888ff"}}function tr(){return"stopped"!==eI.engineStore.getState().playback.status?(0,eI.demoEffectNow)()/1e3:performance.now()/1e3}function tn(e){e.onBeforeCompile=t=>{(0,ej.injectCustomFog)(t,eQ.globalFogUniforms),e instanceof c.MeshLambertMaterial&&(t.uniforms.shapeDirectionalFactor={value:1},t.uniforms.shapeAmbientFactor={value:1.5},t.fragmentShader=t.fragmentShader.replace("#include ",`#include -uniform float shapeDirectionalFactor; -uniform float shapeAmbientFactor; -`),t.fragmentShader=t.fragmentShader.replace("#include ",`#include - // Apply shape-specific lighting multipliers - reflectedLight.directDiffuse *= shapeDirectionalFactor; - reflectedLight.indirectDiffuse *= shapeAmbientFactor; -`))}}function ti(e,t,r,n,i=1,o=!1){let a=r.has("Translucent"),s=r.has("Additive"),l=r.has("SelfIlluminating"),u=i<1||o;if(l||s){let e=s||a||u,r=new c.MeshBasicMaterial({map:t,side:2,transparent:e,depthWrite:!e,alphaTest:0,fog:!0,...u&&{opacity:i},...s&&{blending:c.AdditiveBlending}});return tn(r),r}if(n||a){let e={map:t,transparent:u,alphaTest:.5*!u,...u&&{opacity:i,depthWrite:!1},reflectivity:0},r=new c.MeshLambertMaterial({...e,side:1,polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),n=new c.MeshLambertMaterial({...e,side:0});return tn(r),tn(n),[r,n]}let d=new c.MeshLambertMaterial({map:t,side:2,reflectivity:0,...u&&{transparent:!0,opacity:i,depthWrite:!1}});return tn(d),d}function to(e){let t,r=(0,n.c)(2);return r[0]!==e?(t=(0,eg.shapeToUrl)(e),r[0]=e,r[1]=t):t=r[1],ep(t)}function ta(e){let t,i,o,a,s=(0,n.c)(9),{color:l,label:u}=e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,r.jsx)("boxGeometry",{args:[10,10,10]}),s[0]=t):t=s[0],s[1]!==l?(i=(0,r.jsx)("meshStandardMaterial",{color:l,wireframe:!0}),s[1]=l,s[2]=i):i=s[2],s[3]!==l||s[4]!==u?(o=u?(0,r.jsx)(eT.FloatingLabel,{color:l,children:u}):null,s[3]=l,s[4]=u,s[5]=o):o=s[5],s[6]!==i||s[7]!==o?(a=(0,r.jsxs)("mesh",{children:[t,i,o]}),s[6]=i,s[7]=o,s[8]=a):a=s[8],a}function ts(e){let t,i=(0,n.c)(4),{color:o,label:a}=e,{debugMode:s}=(0,eb.useDebug)();return i[0]!==o||i[1]!==s||i[2]!==a?(t=s?(0,r.jsx)(ta,{color:o,label:a}):null,i[0]=o,i[1]=s,i[2]=a,i[3]=t):t=i[3],t}let tl=new Set(["octahedron.dts"]);function tu(e){let t,i,o,a,s=(0,n.c)(6),{label:l}=e,{debugMode:u}=(0,eb.useDebug)();return u?(s[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,r.jsx)("icosahedronGeometry",{args:[1,1]}),i=(0,r.jsx)("meshBasicMaterial",{color:"cyan",wireframe:!0}),s[0]=t,s[1]=i):(t=s[0],i=s[1]),s[2]!==l?(o=l?(0,r.jsx)(eT.FloatingLabel,{color:"cyan",children:l}):null,s[2]=l,s[3]=o):o=s[3],s[4]!==o?(a=(0,r.jsxs)("mesh",{children:[t,i,o]}),s[4]=o,s[5]=a):a=s[5],a):null}function tc(e){let t,o,a,s,u,c=(0,n.c)(17),{loadingColor:d,demoThreads:f,children:A}=e,h=void 0===d?"yellow":d,{object:m,shapeName:p}=eS();if(!p){let e,t=`${m._id}: `;return c[0]!==t?(e=(0,r.jsx)(ts,{color:"orange",label:t}),c[0]=t,c[1]=e):e=c[1],e}if(tl.has(p.toLowerCase())){let e,t=`${m._id}: ${p}`;return c[2]!==t?(e=(0,r.jsx)(tu,{label:t}),c[2]=t,c[3]=e):e=c[3],e}let B=`${m._id}: ${p}`;return c[4]!==B?(t=(0,r.jsx)(ts,{color:"red",label:B}),c[4]=B,c[5]=t):t=c[5],c[6]!==h?(o=(0,r.jsx)(ta,{color:h}),c[6]=h,c[7]=o):o=c[7],c[8]!==f?(a=(0,r.jsx)(tf,{demoThreads:f}),c[8]=f,c[9]=a):a=c[9],c[10]!==A||c[11]!==o||c[12]!==a?(s=(0,r.jsxs)(i.Suspense,{fallback:o,children:[a,A]}),c[10]=A,c[11]=o,c[12]=a,c[13]=s):s=c[13],c[14]!==t||c[15]!==s?(u=(0,r.jsx)(l,{fallback:t,children:s}),c[14]=t,c[15]=s,c[16]=u):u=c[16],u}let td=(0,i.memo)(function({gltf:e,demoThreads:t}){let{object:n,shapeName:o}=eS(),{debugMode:a}=(0,eb.useDebug)(),{animationEnabled:s}=(0,eb.useSettings)(),l=(0,eI.useEngineSelector)(e=>e.runtime.runtime),{clonedScene:u,mixer:d,clipsByName:f,visNodesBySequence:A,iflMeshes:h}=(0,i.useMemo)(()=>{let t=ev(e.scene),r=[];for(let{mesh:e,hasVisSequence:n}of(t.traverse(e=>{if(!e.isMesh||!e.material)return;let t=Array.isArray(e.material)?e.material[0]:e.material;if(!t?.userData)return;let n=new Set(t.userData.flag_names??[]),i=t.userData.resource_path;if(n.has("IflMaterial")&&i){let t=e.userData,n=t?.ifl_sequence?String(t.ifl_sequence).toLowerCase():void 0,o=t?.ifl_duration?Number(t.ifl_duration):void 0,a=t?.ifl_sequence?!!t.ifl_cyclic:void 0,s=t?.ifl_tool_begin!=null?Number(t.ifl_tool_begin):void 0;r.push({mesh:e,iflPath:`textures/${i}.ifl`,hasVisSequence:!!t?.vis_sequence,iflSequence:n,iflDuration:o,iflCyclic:a,iflToolBegin:s})}}),e5(t),r))n||(e.visible=!0);let n=new Map;t.traverse(e=>{if(!e.isMesh)return;let t=e.userData;if(!t)return;let r=t.vis_keyframes,i=t.vis_duration,o=(t.vis_sequence??"").toLowerCase();if(!o||!Array.isArray(r)||r.length<=1||!i||i<=0)return;let a=n.get(o);a||(a=[],n.set(o,a)),a.push({mesh:e,keyframes:r,duration:i,cyclic:!!t.vis_cyclic})});let i=new Map;for(let t of e.animations)i.set(t.name.toLowerCase(),t);let o=i.size>0?new c.AnimationMixer(t):null;return{clonedScene:t,mixer:o,clipsByName:i,visNodesBySequence:n,iflMeshes:r}},[e]),m=(0,i.useRef)(new Map),p=(0,i.useRef)(new Map),B=(0,i.useRef)([]),C=(0,i.useRef)(0),g=(0,i.useRef)(s);g.current=s;let v=(0,i.useRef)(null),y=(0,i.useRef)(t);y.current=t;let b=(0,i.useRef)(null),E=(0,i.useRef)(null),M=(0,i.useRef)(void 0);(0,i.useEffect)(()=>{for(let e of(B.current=[],p.current.clear(),h))ek(e.iflPath).then(t=>{let r=Array.isArray(e.mesh.material)?e.mesh.material[0]:e.mesh.material;r&&(r.map=t.texture,r.needsUpdate=!0),B.current.push({atlas:t,sequenceName:e.iflSequence,sequenceDuration:e.iflDuration,cyclic:e.iflCyclic,toolBegin:e.iflToolBegin}),p.current.set(e.mesh,t)}).catch(()=>{})},[h]),(0,i.useEffect)(()=>{let e=m.current;function t(e){if(e.mesh.visible=!0,e.mesh.material?.isMeshStandardMaterial){let t=e4(e.mesh.material,e.mesh.userData?.vis??0);e.mesh.material=t.material}e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.transparent=!0,e.mesh.material.depthWrite=!1);let t=p.current.get(e.mesh);t&&e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.map=t.texture,e.mesh.material.needsUpdate=!0)}function r(r,n){let o=n.toLowerCase();i(r);let a=f.get(o),s=A.get(o),l={sequence:o,startTime:tr()};if(a&&d){let e=d.clipAction(a);"deploy"===o?(e.setLoop(c.LoopOnce,1),e.clampWhenFinished=!0):e.setLoop(c.LoopRepeat,1/0),e.reset().play(),l.action=e,!g.current&&"deploy"===o&&(e.time=a.duration,d.update(0),v.current&&queueMicrotask(()=>v.current?.(r)))}if(s){for(let e of s)t(e);l.visNodes=s}e.set(r,l)}function i(t){let r=e.get(t);if(r){if(r.action&&r.action.stop(),r.visNodes)for(let e of r.visNodes)e.mesh.visible=!1,e.mesh.material&&!Array.isArray(e.mesh.material)&&(e.mesh.material.opacity=e.keyframes[0]);e.delete(t)}}if(b.current=r,E.current=i,null!=y.current)return()=>{for(let t of(b.current=null,E.current=null,[...e.keys()]))i(t)};let o=f.has("deploy"),a=!!(l&&o&&n.datablock);function s(e){if(!l)return;let t=n.datablock;if(!t)return;let r=l.getObjectByName(String(t));r&&l.$.call(r,"onEndSequence",n,e)}function u(){for(let r of["ambient","power"]){let n=A.get(r);if(n){let i=tr();for(let e of n)t(e);let o=+("power"!==r);e.set(o,{sequence:r,visNodes:n,startTime:i})}let i=f.get(r);if(i&&d){let t=d.clipAction(i);t.setLoop(c.LoopRepeat,1/0),t.reset().play();let n=+("power"!==r),o=e.get(n);o?o.action=t:e.set(n,{sequence:r,action:t,startTime:tr()})}}}v.current=a?s:()=>u();let h=[],B=d?t=>{for(let[r,n]of e)if(n.action===t.action){a?s(r):u();break}}:null;return B&&d&&d.addEventListener("finished",B),l&&(h.push(l.$.onMethodCalled("ShapeBase","playThread",(e,t,i)=>{e._id===n._id&&r(Number(t),String(i))})),h.push(l.$.onMethodCalled("ShapeBase","stopThread",(e,t)=>{e._id===n._id&&i(Number(t))})),h.push(l.$.onMethodCalled("ShapeBase","pauseThread",(t,r)=>{if(t._id!==n._id)return;let i=e.get(Number(r));i?.action&&(i.action.paused=!0)}))),a?l.$.call(n,"deploy"):o?r(3,"deploy"):u(),()=>{for(let t of(B&&d&&d.removeEventListener("finished",B),h.forEach(e=>e()),v.current=null,b.current=null,E.current=null,[...e.keys()]))i(t)}},[d,f,A,n,l]);let F=(0,i.useMemo)(()=>{let t=e.scene.userData?.dts_sequence_names;if("string"==typeof t)try{return JSON.parse(t).map(e=>e.toLowerCase())}catch{}return e.animations.map(e=>e.name.toLowerCase())},[e]);return(0,eC.useFrame)((e,t)=>{let r=m.current,n=null!=y.current,i=eI.engineStore.getState().playback,o=n?"playing"===i.status?t*i.rate:0:t,a=y.current,l=M.current;if(a!==l){let e=b.current,t=E.current;if(e&&t){M.current=a;let n=[];if(a)for(let e of a)n[e.index]=e;let i=[];if(l)for(let e of l)i[e.index]=e;let o=Math.max(n.length,i.length);for(let a=0;a0)for(let e of(C.current+=o,u)){if(!s){eU(e.atlas,0);continue}if(e.sequenceName&&e.sequenceDuration){let t=0;for(let[,n]of r)if(n.sequence===e.sequenceName){let r=tr()-n.startTime,i=e.sequenceDuration;t=(e.cyclic?r/i%1:Math.min(r/i,1))*i+(e.toolBegin??0);break}eU(e.atlas,eN(e.atlas,t))}else eU(e.atlas,eN(e.atlas,C.current))}}),(0,r.jsxs)("group",{rotation:[0,Math.PI/2,0],children:[(0,r.jsx)("primitive",{object:u}),a?(0,r.jsxs)(eT.FloatingLabel,{children:[n._id,": ",o]}):null]})});function tf(e){let t,i=(0,n.c)(3),{demoThreads:o}=e,{shapeName:a}=eS(),s=to(a);return i[0]!==o||i[1]!==s?(t=(0,r.jsx)(td,{gltf:s,demoThreads:o}),i[0]=o,i[1]=s,i[2]=t):t=i[2],t}},81405,(e,t,r)=>{var n;e.e,(n=function(){function e(e){return i.appendChild(e.dom),e}function t(e){for(var t=0;ta+1e3&&(l.update(1e3*s/(e-a),100),a=e,s=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:i,setMode:t}}).Panel=function(e,t,r){var n=1/0,i=0,o=Math.round,a=o(window.devicePixelRatio||1),s=80*a,l=48*a,u=3*a,c=2*a,d=3*a,f=15*a,A=74*a,h=30*a,m=document.createElement("canvas");m.width=s,m.height=l,m.style.cssText="width:80px;height:48px";var p=m.getContext("2d");return p.font="bold "+9*a+"px Helvetica,Arial,sans-serif",p.textBaseline="top",p.fillStyle=r,p.fillRect(0,0,s,l),p.fillStyle=t,p.fillText(e,u,c),p.fillRect(d,f,A,h),p.fillStyle=r,p.globalAlpha=.9,p.fillRect(d,f,A,h),{dom:m,update:function(l,B){n=Math.min(n,l),i=Math.max(i,l),p.fillStyle=r,p.globalAlpha=1,p.fillRect(0,0,s,f),p.fillStyle=t,p.fillText(o(l)+" "+e+" ("+o(n)+"-"+o(i)+")",u,c),p.drawImage(m,d+a,f,A-a,h,d,f,A-a,h),p.fillRect(d+A-a,f,a,h),p.fillStyle=r,p.globalAlpha=.9,p.fillRect(d+A-a,f,a,o((1-l/B)*h))}}},t.exports=n},55141,e=>{e.v({AxisLabel:"DebugElements-module__Cmeo9W__AxisLabel",StatsPanel:"DebugElements-module__Cmeo9W__StatsPanel"})},86855,e=>{"use strict";var t=e.i(43476),r=e.i(932),n=e.i(71645),i=e.i(40859),i=i,o=i,a=e.i(81405);function s(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}function l({showPanel:e=0,className:t,parent:r}){let l=function(e,t=[],r){let[i,o]=n.useState();return n.useLayoutEffect(()=>{let t=e();return o(t),s(void 0,t),()=>s(void 0,null)},t),i}(()=>new a.default,[]);return n.useEffect(()=>{if(l){let n=r&&r.current||document.body;l.showPanel(e),null==n||n.appendChild(l.dom);let a=(null!=t?t:"").split(" ").filter(e=>e);a.length&&l.dom.classList.add(...a);let s=(0,i.j)(()=>l.begin()),u=(0,o.k)(()=>l.end());return()=>{a.length&&l.dom.classList.remove(...a),null==n||n.removeChild(l.dom),s(),u()}}},[r,l,t,e]),null}var u=e.i(60099),c=e.i(79123),d=e.i(55141);function f(){let e,i,o=(0,r.c)(3),{debugMode:a}=(0,c.useDebug)(),s=(0,n.useRef)(null);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=()=>{let e=s.current;e&&e.setColors("rgb(153, 255, 0)","rgb(0, 153, 255)","rgb(255, 153, 0)")},o[0]=e):e=o[0],(0,n.useEffect)(e),o[1]!==a?(i=a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(l,{className:d.default.StatsPanel}),(0,t.jsx)("axesHelper",{ref:s,args:[70],renderOrder:999,children:(0,t.jsx)("lineBasicMaterial",{depthTest:!1,depthWrite:!1,fog:!1,vertexColors:!0})}),(0,t.jsx)(u.Html,{position:[80,0,0],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"y",children:"Y"})}),(0,t.jsx)(u.Html,{position:[0,80,0],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"z",children:"Z"})}),(0,t.jsx)(u.Html,{position:[0,0,80],center:!0,children:(0,t.jsx)("span",{className:d.default.AxisLabel,"data-axis":"x",children:"X"})})]}):null,o[1]=a,o[2]=i):i=o[2],i}e.s(["DebugElements",()=>f],86855)},38360,(e,t,r)=>{var n={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"C",ċ:"c",Č:"C",č:"c",C̆:"C",c̆:"c",Ď:"D",ď:"d",Đ:"D",đ:"d",Ē:"E",ē:"e",Ĕ:"E",ĕ:"e",Ė:"E",ė:"e",Ę:"E",ę:"e",Ě:"E",ě:"e",Ĝ:"G",Ǵ:"G",ĝ:"g",ǵ:"g",Ğ:"G",ğ:"g",Ġ:"G",ġ:"g",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},i=Object.keys(n).join("|"),o=RegExp(i,"g"),a=RegExp(i,"");function s(e){return n[e]}var l=function(e){return e.replace(o,s)};t.exports=l,t.exports.has=function(e){return!!e.match(a)},t.exports.remove=l},11889,56373,86447,1559,18364,78440,59129,25998,70238,e=>{"use strict";e.i(47167);var t,r="u">typeof window&&!!(null==(t=window.document)?void 0:t.createElement);function n(e){return e?"self"in e?e.document:e.ownerDocument||document:document}function i(e){return e?"self"in e?e.self:n(e).defaultView||window:self}function o(e,t=!1){var r;let{activeElement:i}=n(e);if(!(null==i?void 0:i.nodeName))return null;if(s(i)&&(null==(r=i.contentDocument)?void 0:r.body))return o(i.contentDocument.body,t);if(t){let e=i.getAttribute("aria-activedescendant");if(e){let t=n(i).getElementById(e);if(t)return t}}return i}function a(e,t){return e===t||e.contains(t)}function s(e){return"IFRAME"===e.tagName}function l(e){let t=e.tagName.toLowerCase();return"button"===t||"input"===t&&!!e.type&&-1!==u.indexOf(e.type)}var u=["button","color","file","image","reset","submit"];function c(e){return"function"==typeof e.checkVisibility?e.checkVisibility():e.offsetWidth>0||e.offsetHeight>0||e.getClientRects().length>0}function d(e){try{let t=e instanceof HTMLInputElement&&null!==e.selectionStart,r="TEXTAREA"===e.tagName;return t||r||!1}catch(e){return!1}}function f(e){return e.isContentEditable||d(e)}function A(e){let t=0,r=0;if(d(e))t=e.selectionStart||0,r=e.selectionEnd||0;else if(e.isContentEditable){let i=n(e).getSelection();if((null==i?void 0:i.rangeCount)&&i.anchorNode&&a(e,i.anchorNode)&&i.focusNode&&a(e,i.focusNode)){let n=i.getRangeAt(0),o=n.cloneRange();o.selectNodeContents(e),o.setEnd(n.startContainer,n.startOffset),t=o.toString().length,o.setEnd(n.endContainer,n.endOffset),r=o.toString().length}}return{start:t,end:r}}function h(e,t){let r=null==e?void 0:e.getAttribute("role");return r&&-1!==["dialog","menu","listbox","tree","grid"].indexOf(r)?r:t}function m(e){if(!e)return null;let t=e=>"auto"===e||"scroll"===e;if(e.clientHeight&&e.scrollHeight>e.clientHeight){let{overflowY:r}=getComputedStyle(e);if(t(r))return e}else if(e.clientWidth&&e.scrollWidth>e.clientWidth){let{overflowX:r}=getComputedStyle(e);if(t(r))return e}return m(e.parentElement)||document.scrollingElement||document.body}function p(e,...t){/text|search|password|tel|url/i.test(e.type)&&e.setSelectionRange(...t)}function B(e,t){return t&&e.item(t)||null}var C=Symbol("FOCUS_SILENTLY");function g(e,t,r){if(!t||t===r)return!1;let n=e.item(t.id);return!!n&&(!r||n.element!==r)}function v(){}function y(e,t){return"function"==typeof Object.hasOwn?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t)}function b(...e){return(...t)=>{for(let r of e)"function"==typeof r&&r(...t)}}function E(e){return e}function M(e,t){if(!e){if("string"!=typeof t)throw Error("Invariant failed");throw Error(t)}}function F(e,...t){let r="function"==typeof e?e(...t):e;return null!=r&&!r}function S(e){return e.disabled||!0===e["aria-disabled"]||"true"===e["aria-disabled"]}function R(e){let t={};for(let r in e)void 0!==e[r]&&(t[r]=e[r]);return t}function I(...e){for(let t of e)if(void 0!==t)return t}var T=e.i(71645);function x(e,t){"function"==typeof e?e(t):e&&(e.current=t)}function G(){return r&&!!navigator.maxTouchPoints}function D(){return!!r&&/mac|iphone|ipad|ipod/i.test(navigator.platform)}function w(){return r&&D()&&/apple/i.test(navigator.vendor)}function L(e){return!!(e.currentTarget&&!a(e.currentTarget,e.target))}function _(e){return e.target===e.currentTarget}function O(e,t){let r=new FocusEvent("blur",t),n=e.dispatchEvent(r),i={...t,bubbles:!0};return e.dispatchEvent(new FocusEvent("focusout",i)),n}function H(e,t){let r=new MouseEvent("click",t);return e.dispatchEvent(r)}function P(e,t){let r=t||e.currentTarget,n=e.relatedTarget;return!n||!a(r,n)}function J(e,t,r,n){let i=(e=>{if(n){let t=setTimeout(e,n);return()=>clearTimeout(t)}let t=requestAnimationFrame(e);return()=>cancelAnimationFrame(t)})(()=>{e.removeEventListener(t,o,!0),r()}),o=()=>{i(),r()};return e.addEventListener(t,o,{once:!0,capture:!0}),i}function U(e,t,r,n=window){let i=[];try{for(let o of(n.document.addEventListener(e,t,r),Array.from(n.frames)))i.push(U(e,t,r,o))}catch(e){}return()=>{try{n.document.removeEventListener(e,t,r)}catch(e){}for(let e of i)e()}}var N={...T},k=N.useId;N.useDeferredValue;var K=N.useInsertionEffect,j=r?T.useLayoutEffect:T.useEffect;function Q(e){let t=(0,T.useRef)(()=>{throw Error("Cannot call an event handler while rendering.")});return K?K(()=>{t.current=e}):t.current=e,(0,T.useCallback)((...e)=>{var r;return null==(r=t.current)?void 0:r.call(t,...e)},[])}function X(...e){return(0,T.useMemo)(()=>{if(e.some(Boolean))return t=>{for(let r of e)x(r,t)}},e)}function V(e){if(k){let t=k();return e||t}let[t,r]=(0,T.useState)(e);return j(()=>{if(e||t)return;let n=Math.random().toString(36).slice(2,8);r(`id-${n}`)},[e,t]),e||t}function q(e,t){let r=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(r.current)return e();r.current=!0},t),(0,T.useEffect)(()=>()=>{r.current=!1},[])}function W(){return(0,T.useReducer)(()=>[],[])}function Y(e){return Q("function"==typeof e?e:()=>e)}function Z(e,t,r=[]){let n=(0,T.useCallback)(r=>(e.wrapElement&&(r=e.wrapElement(r)),t(r)),[...r,e.wrapElement]);return{...e,wrapElement:n}}function z(e=!1,t){let[r,n]=(0,T.useState)(null);return{portalRef:X(n,t),portalNode:r,domReady:!e||r}}var $=!1,ee=!1,et=0,er=0;function en(e){let t,r;t=e.movementX||e.screenX-et,r=e.movementY||e.screenY-er,et=e.screenX,er=e.screenY,(t||r||0)&&(ee=!0)}function ei(){ee=!1}var eo=e.i(43476);function ea(e){let t=T.forwardRef((t,r)=>e({...t,ref:r}));return t.displayName=e.displayName||e.name,t}function es(e,t){return T.memo(e,t)}function el(e,t){let r,{wrapElement:n,render:i,...o}=t,a=X(t.ref,i&&(0,T.isValidElement)(i)&&("ref"in i.props||"ref"in i)?({...i.props}).ref||i.ref:null);if(T.isValidElement(i)){let e={...i.props,ref:a};r=T.cloneElement(i,function(e,t){let r={...e};for(let n in t){if(!y(t,n))continue;if("className"===n){let n="className";r[n]=e[n]?`${e[n]} ${t[n]}`:t[n];continue}if("style"===n){let n="style";r[n]=e[n]?{...e[n],...t[n]}:t[n];continue}let i=t[n];if("function"==typeof i&&n.startsWith("on")){let t=e[n];if("function"==typeof t){r[n]=(...e)=>{i(...e),t(...e)};continue}}r[n]=i}return r}(o,e))}else r=i?i(o):(0,eo.jsx)(e,{...o});return n?n(r):r}function eu(e){let t=(t={})=>e(t);return t.displayName=e.name,t}function ec(e=[],t=[]){let r=T.createContext(void 0),n=T.createContext(void 0),i=()=>T.useContext(r),o=t=>e.reduceRight((e,r)=>(0,eo.jsx)(r,{...t,children:e}),(0,eo.jsx)(r.Provider,{...t}));return{context:r,scopedContext:n,useContext:i,useScopedContext:(e=!1)=>{let t=T.useContext(n),r=i();return e?t:t||r},useProviderContext:()=>{let e=T.useContext(n),t=i();if(!e||e!==t)return t},ContextProvider:o,ScopedContextProvider:e=>(0,eo.jsx)(o,{...e,children:t.reduceRight((t,r)=>(0,eo.jsx)(r,{...e,children:t}),(0,eo.jsx)(n.Provider,{...e}))})}}var ed=ec(),ef=ed.useContext;ed.useScopedContext,ed.useProviderContext;var eA=ec([ed.ContextProvider],[ed.ScopedContextProvider]),eh=eA.useContext;eA.useScopedContext;var em=eA.useProviderContext,ep=eA.ContextProvider,eB=eA.ScopedContextProvider,eC=(0,T.createContext)(void 0),eg=(0,T.createContext)(void 0),ev=(0,T.createContext)(!0),ey="input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";function eb(e){return!(!e.matches(ey)||!c(e)||e.closest("[inert]"))}function eE(e){if(!eb(e)||0>Number.parseInt(e.getAttribute("tabindex")||"0",10))return!1;if(!("form"in e)||!e.form||e.checked||"radio"!==e.type)return!0;let t=e.form.elements.namedItem(e.name);if(!t||!("length"in t))return!0;let r=o(e);return!r||r===e||!("form"in r)||r.form!==e.form||r.name!==e.name}function eM(e,t){let r=Array.from(e.querySelectorAll(ey));t&&r.unshift(e);let n=r.filter(eb);return n.forEach((e,t)=>{var r;if(!s(e))return;let i=null==(r=e.contentDocument)?void 0:r.body;i&&n.splice(t,1,...eM(i))}),n}function eF(e,t,r){let n=Array.from(e.querySelectorAll(ey)),i=n.filter(eE);return(t&&eE(e)&&i.unshift(e),i.forEach((e,t)=>{var n;if(!s(e))return;let o=null==(n=e.contentDocument)?void 0:n.body;if(!o)return;let a=eF(o,!1,r);i.splice(t,1,...a)}),!i.length&&r)?n:i}function eS(e,t){var r;let n,i,a,s;return r=document.body,n=o(r),a=(i=eM(r,!1)).indexOf(n),(s=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?s[0]:null)||null}function eR(e,t){var r;let n,i,a,s;return r=document.body,n=o(r),a=(i=eM(r,!1).reverse()).indexOf(n),(s=i.slice(a+1)).find(eE)||(e?i.find(eE):null)||(t?s[0]:null)||null}function eI(e){let t=o(e);if(!t)return!1;if(t===e)return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&r===e.id}function eT(e){let t=o(e);if(!t)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");return!!r&&"id"in e&&(r===e.id||!!e.querySelector(`#${CSS.escape(r)}`))}function ex(e){!eT(e)&&eb(e)&&e.focus()}var eG=w(),eD=["text","search","url","tel","email","password","number","date","month","week","time","datetime","datetime-local"],ew=Symbol("safariFocusAncestor");function eL(e){return"input"===e.tagName.toLowerCase()&&!!e.type&&("radio"===e.type||"checkbox"===e.type)}function e_(e,t){return Q(r=>{null==e||e(r),!r.defaultPrevented&&t&&(r.stopPropagation(),r.preventDefault())})}var eO=!1,eH=!0;function eP(e){let t=e.target;t&&"hasAttribute"in t&&!t.hasAttribute("data-focus-visible")&&(eH=!1)}function eJ(e){e.metaKey||e.ctrlKey||e.altKey||(eH=!0)}var eU=eu(function({focusable:e=!0,accessibleWhenDisabled:t,autoFocus:r,onFocusVisible:n,...i}){var o,a,s,u,c;let d=(0,T.useRef)(null);(0,T.useEffect)(()=>{!e||eO||(U("mousedown",eP,!0),U("keydown",eJ,!0),eO=!0)},[e]),eG&&(0,T.useEffect)(()=>{if(!e)return;let t=d.current;if(!t||!eL(t))return;let r="labels"in t?t.labels:null;if(!r)return;let n=()=>queueMicrotask(()=>t.focus());for(let e of r)e.addEventListener("mouseup",n);return()=>{for(let e of r)e.removeEventListener("mouseup",n)}},[e]);let f=e&&S(i),A=!!f&&!t,[h,m]=(0,T.useState)(!1);(0,T.useEffect)(()=>{e&&A&&h&&m(!1)},[e,A,h]),(0,T.useEffect)(()=>{if(!e||!h)return;let t=d.current;if(!t||"u"{eb(t)||m(!1)});return r.observe(t),()=>r.disconnect()},[e,h]);let p=e_(i.onKeyPressCapture,f),B=e_(i.onMouseDownCapture,f),C=e_(i.onClickCapture,f),g=i.onMouseDown,v=Q(t=>{if(null==g||g(t),t.defaultPrevented||!e)return;let r=t.currentTarget;if(!eG||L(t)||!l(r)&&!eL(r))return;let n=!1,i=()=>{n=!0};r.addEventListener("focusin",i,{capture:!0,once:!0});let o=function(e){for(;e&&!eb(e);)e=e.closest(ey);return e||null}(r.parentElement);o&&(o[ew]=!0),J(r,"mouseup",()=>{r.removeEventListener("focusin",i,!0),o&&(o[ew]=!1),n||ex(r)})}),y=(t,r)=>{if(r&&(t.currentTarget=r),!e)return;let i=t.currentTarget;i&&eI(i)&&(null==n||n(t),t.defaultPrevented||(i.dataset.focusVisible="true",m(!0)))},b=i.onKeyDownCapture,E=Q(t=>{if(null==b||b(t),t.defaultPrevented||!e||h||t.metaKey||t.altKey||t.ctrlKey||!_(t))return;let r=t.currentTarget;J(r,"focusout",()=>y(t,r))}),M=i.onFocusCapture,F=Q(t=>{if(null==M||M(t),t.defaultPrevented||!e)return;if(!_(t))return void m(!1);let r=t.currentTarget;eH||function(e){let{tagName:t,readOnly:r,type:n}=e;return"TEXTAREA"===t&&!r||"SELECT"===t&&!r||("INPUT"!==t||r?!!e.isContentEditable||"combobox"===e.getAttribute("role")&&!!e.dataset.name:eD.includes(n))}(t.target)?J(t.target,"focusout",()=>y(t,r)):m(!1)}),I=i.onBlur,x=Q(t=>{null==I||I(t),!e||P(t)&&(t.currentTarget.removeAttribute("data-focus-visible"),m(!1))}),G=(0,T.useContext)(ev),D=Q(t=>{e&&r&&t&&G&&queueMicrotask(()=>{eI(t)||eb(t)&&t.focus()})}),w=function(e,t){let r=e=>{if("string"==typeof e)return e},[n,i]=(0,T.useState)(()=>r(void 0));return j(()=>{let t=e&&"current"in e?e.current:e;i((null==t?void 0:t.tagName.toLowerCase())||r(void 0))},[e,void 0]),n}(d),O=e&&(!w||"button"===w||"summary"===w||"input"===w||"select"===w||"textarea"===w||"a"===w),H=e&&(!w||"button"===w||"input"===w||"select"===w||"textarea"===w),N=i.style,k=(0,T.useMemo)(()=>A?{pointerEvents:"none",...N}:N,[A,N]);return i={"data-focus-visible":e&&h||void 0,"data-autofocus":r||void 0,"aria-disabled":f||void 0,...i,ref:X(d,D,i.ref),style:k,tabIndex:(o=e,a=A,s=O,u=H,c=i.tabIndex,o?a?s&&!u?-1:void 0:s?c:c||0:c),disabled:!!H&&!!A||void 0,contentEditable:f?void 0:i.contentEditable,onKeyPressCapture:p,onClickCapture:C,onMouseDownCapture:B,onMouseDown:v,onKeyDownCapture:E,onFocusCapture:F,onBlur:x},R(i)});function eN(e){let t=[];for(let r of e)t.push(...r);return t}function ek(e){return e.slice().reverse()}function eK(e,t,r){return Q(n=>{var i;let o,a;if(null==t||t(n),n.defaultPrevented||n.isPropagationStopped()||!_(n)||"Shift"===n.key||"Control"===n.key||"Alt"===n.key||"Meta"===n.key||(!(o=n.target)||d(o))&&1===n.key.length&&!n.ctrlKey&&!n.metaKey)return;let s=e.getState(),l=null==(i=B(e,s.activeId))?void 0:i.element;if(!l)return;let{view:u,...c}=n;l!==(null==r?void 0:r.current)&&l.focus(),a=new KeyboardEvent(n.type,c),l.dispatchEvent(a)||n.preventDefault(),n.currentTarget.contains(l)&&n.stopPropagation()})}ea(function(e){return el("div",eU(e))});var ej=eu(function({store:e,composite:t=!0,focusOnMove:r=t,moveOnKeyPress:n=!0,...i}){let a=em();M(e=e||a,!1);let s=(0,T.useRef)(null),l=(0,T.useRef)(null),u=function(e){let[t,r]=(0,T.useState)(!1),n=(0,T.useCallback)(()=>r(!0),[]),i=e.useState(t=>B(e,t.activeId));return(0,T.useEffect)(()=>{let e=null==i?void 0:i.element;!t||e&&(r(!1),e.focus({preventScroll:!0}))},[i,t]),n}(e),c=e.useState("moves"),[,f]=function(e){let[t,r]=(0,T.useState)(null);return j(()=>{if(null==t||!e)return;let r=null;return e(e=>(r=e,t)),()=>{e(r)}},[t,e]),[t,r]}(t?e.setBaseElement:null);(0,T.useEffect)(()=>{var n;if(!e||!c||!t||!r)return;let{activeId:i}=e.getState(),o=null==(n=B(e,i))?void 0:n.element;o&&("scrollIntoView"in o?(o.focus({preventScroll:!0}),o.scrollIntoView({block:"nearest",inline:"nearest",...void 0})):o.focus())},[e,c,t,r]),j(()=>{if(!e||!c||!t)return;let{baseElement:r,activeId:n}=e.getState();if(null!==n||!r)return;let i=l.current;l.current=null,i&&O(i,{relatedTarget:r}),eI(r)||r.focus()},[e,c,t]);let A=e.useState("activeId"),h=e.useState("virtualFocus");j(()=>{var r;if(!e||!t||!h)return;let n=l.current;if(l.current=null,!n)return;let i=(null==(r=B(e,A))?void 0:r.element)||o(n);i!==n&&O(n,{relatedTarget:i})},[e,A,h,t]);let m=eK(e,i.onKeyDownCapture,l),p=eK(e,i.onKeyUpCapture,l),v=i.onFocusCapture,y=Q(t=>{var r;let n;if(null==v||v(t),t.defaultPrevented||!e)return;let{virtualFocus:i}=e.getState();if(!i)return;let o=t.relatedTarget,a=(n=(r=t.currentTarget)[C],delete r[C],n);_(t)&&a&&(t.stopPropagation(),l.current=o)}),b=i.onFocus,E=Q(r=>{if(null==b||b(r),r.defaultPrevented||!t||!e)return;let{relatedTarget:n}=r,{virtualFocus:i}=e.getState();i?_(r)&&!g(e,n)&&queueMicrotask(u):_(r)&&e.setActiveId(null)}),F=i.onBlurCapture,S=Q(t=>{var r;if(null==F||F(t),t.defaultPrevented||!e)return;let{virtualFocus:n,activeId:i}=e.getState();if(!n)return;let o=null==(r=B(e,i))?void 0:r.element,a=t.relatedTarget,s=g(e,a),u=l.current;l.current=null,_(t)&&s?(a===o?u&&u!==a&&O(u,t):o?O(o,t):u&&O(u,t),t.stopPropagation()):!g(e,t.target)&&o&&O(o,t)}),R=i.onKeyDown,I=Y(n),x=Q(t=>{var r;if(null==R||R(t),t.nativeEvent.isComposing||t.defaultPrevented||!e||!_(t))return;let{orientation:n,renderedItems:i,activeId:o}=e.getState(),a=B(e,o);if(null==(r=null==a?void 0:a.element)?void 0:r.isConnected)return;let s="horizontal"!==n,l="vertical"!==n,u=i.some(e=>!!e.rowId);if(("ArrowLeft"===t.key||"ArrowRight"===t.key||"Home"===t.key||"End"===t.key)&&d(t.currentTarget))return;let c={ArrowUp:(u||s)&&(()=>{if(u){let e=eN(ek(function(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}(i))).find(e=>!e.disabled);return null==e?void 0:e.id}return null==e?void 0:e.last()}),ArrowRight:(u||l)&&e.first,ArrowDown:(u||s)&&e.first,ArrowLeft:(u||l)&&e.last,Home:e.first,End:e.last,PageUp:e.first,PageDown:e.last}[t.key];if(c){let r=c();if(void 0!==r){if(!I(t))return;t.preventDefault(),e.move(r)}}});return i=Z(i,t=>(0,eo.jsx)(ep,{value:e,children:t}),[e]),i={"aria-activedescendant":e.useState(r=>{var n;if(e&&t&&r.virtualFocus)return null==(n=B(e,r.activeId))?void 0:n.id}),...i,ref:X(s,f,i.ref),onKeyDownCapture:m,onKeyUpCapture:p,onFocusCapture:y,onFocus:E,onBlurCapture:S,onKeyDown:x},i=eU({focusable:e.useState(e=>t&&(e.virtualFocus||null===e.activeId)),...i})});ea(function(e){return el("div",ej(e))});var eQ=ec();eQ.useContext,eQ.useScopedContext;var eX=eQ.useProviderContext,eV=ec([eQ.ContextProvider],[eQ.ScopedContextProvider]);eV.useContext,eV.useScopedContext;var eq=eV.useProviderContext,eW=eV.ContextProvider,eY=eV.ScopedContextProvider,eZ=(0,T.createContext)(void 0),ez=(0,T.createContext)(void 0),e$=ec([eW],[eY]);e$.useContext,e$.useScopedContext;var e0=e$.useProviderContext,e1=e$.ContextProvider,e9=e$.ScopedContextProvider,e8=eu(function({store:e,...t}){let r=e0();return e=e||r,t={...t,ref:X(null==e?void 0:e.setAnchorElement,t.ref)}});ea(function(e){return el("div",e8(e))});var e2=(0,T.createContext)(void 0),e3=ec([e1,ep],[e9,eB]),e6=e3.useContext,e4=e3.useScopedContext,e7=e3.useProviderContext,e5=e3.ContextProvider,te=e3.ScopedContextProvider,tt=(0,T.createContext)(void 0),tr=(0,T.createContext)(!1);function tn(e,t){let r=e.__unstableInternals;return M(r,"Invalid store"),r[t]}function ti(e,...t){let r=e,n=r,i=Symbol(),o=v,a=new Set,s=new Set,l=new Set,u=new Set,c=new Set,d=new WeakMap,f=new WeakMap,A=(e,t,r=u)=>(r.add(t),f.set(t,e),()=>{var e;null==(e=d.get(t))||e(),d.delete(t),f.delete(t),r.delete(t)}),h=(e,o,a=!1)=>{var l,A;if(!y(r,e))return;let h=(A=r[e],"function"==typeof o?o("function"==typeof A?A():A):o);if(h===r[e])return;if(!a)for(let r of t)null==(l=null==r?void 0:r.setState)||l.call(r,e,h);let m=r;r={...r,[e]:h};let p=Symbol();i=p,s.add(e);let B=(t,n,i)=>{var o;let a=f.get(t);(!a||a.some(t=>i?i.has(t):t===e))&&(null==(o=d.get(t))||o(),d.set(t,t(r,n)))};for(let e of u)B(e,m);queueMicrotask(()=>{if(i!==p)return;let e=r;for(let e of c)B(e,n,s);n=e,s.clear()})},m={getState:()=>r,setState:h,__unstableInternals:{setup:e=>(l.add(e),()=>l.delete(e)),init:()=>{let e=a.size,n=Symbol();a.add(n);let i=()=>{a.delete(n),a.size||o()};if(e)return i;let s=Object.keys(r).map(e=>b(...t.map(t=>{var r;let n=null==(r=null==t?void 0:t.getState)?void 0:r.call(t);if(n&&y(n,e))return tl(t,[e],t=>{h(e,t[e],!0)})}))),u=[];for(let e of l)u.push(e());return o=b(...s,...u,...t.map(ta)),i},subscribe:(e,t)=>A(e,t),sync:(e,t)=>(d.set(t,t(r,r)),A(e,t)),batch:(e,t)=>(d.set(t,t(r,n)),A(e,t,c)),pick:e=>ti(function(e,t){let r={};for(let n of t)y(e,n)&&(r[n]=e[n]);return r}(r,e),m),omit:e=>ti(function(e,t){let r={...e};for(let e of t)y(r,e)&&delete r[e];return r}(r,e),m)}};return m}function to(e,...t){if(e)return tn(e,"setup")(...t)}function ta(e,...t){if(e)return tn(e,"init")(...t)}function ts(e,...t){if(e)return tn(e,"subscribe")(...t)}function tl(e,...t){if(e)return tn(e,"sync")(...t)}function tu(e,...t){if(e)return tn(e,"batch")(...t)}function tc(e,...t){if(e)return tn(e,"omit")(...t)}function td(...e){var t;let r={};for(let n of e){let e=null==(t=null==n?void 0:n.getState)?void 0:t.call(n);e&&Object.assign(r,e)}let n=ti(r,...e);return Object.assign({},...e,n)}function tf(e,t){}function tA(e,t,r){if(!r)return!1;let n=e.find(e=>!e.disabled&&e.value);return(null==n?void 0:n.value)===t}function th(e,t){return!!t&&null!=e&&(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),t.length>e.length&&0===t.toLowerCase().indexOf(e.toLowerCase()))}var tm=eu(function({store:e,focusable:t=!0,autoSelect:r=!1,getAutoSelectId:n,setValueOnChange:i,showMinLength:o=0,showOnChange:a,showOnMouseDown:s,showOnClick:l=s,showOnKeyDown:u,showOnKeyPress:c=u,blurActiveItemOnClick:d,setValueOnClick:f=!0,moveOnKeyPress:B=!0,autoComplete:C="list",...g}){var y;let b,E=e7();M(e=e||E,!1);let S=(0,T.useRef)(null),[R,I]=W(),x=(0,T.useRef)(!1),G=(0,T.useRef)(!1),D=e.useState(e=>e.virtualFocus&&r),w="inline"===C||"both"===C,[L,_]=(0,T.useState)(w);y=[w],b=(0,T.useRef)(!1),j(()=>{if(b.current)return(()=>{w&&_(!0)})();b.current=!0},y),j(()=>()=>{b.current=!1},[]);let O=e.useState("value"),H=(0,T.useRef)(void 0);(0,T.useEffect)(()=>tl(e,["selectedValue","activeId"],(e,t)=>{H.current=t.selectedValue}),[]);let U=e.useState(e=>{var t;if(w&&L){if(e.activeValue&&Array.isArray(e.selectedValue)&&(e.selectedValue.includes(e.activeValue)||(null==(t=H.current)?void 0:t.includes(e.activeValue))))return;return e.activeValue}}),N=e.useState("renderedItems"),k=e.useState("open"),K=e.useState("contentElement"),Z=(0,T.useMemo)(()=>{if(!w||!L)return O;if(tA(N,U,D)){if(th(O,U)){let e=(null==U?void 0:U.slice(O.length))||"";return O+e}return O}return U||O},[w,L,N,U,D,O]);(0,T.useEffect)(()=>{let e=S.current;if(!e)return;let t=()=>_(!0);return e.addEventListener("combobox-item-move",t),()=>{e.removeEventListener("combobox-item-move",t)}},[]),(0,T.useEffect)(()=>{if(!w||!L||!U||!tA(N,U,D)||!th(O,U))return;let e=v;return queueMicrotask(()=>{let t=S.current;if(!t)return;let{start:r,end:n}=A(t),i=O.length,o=U.length;p(t,i,o),e=()=>{if(!eI(t))return;let{start:e,end:a}=A(t);e!==i||a===o&&p(t,r,n)}}),()=>e()},[R,w,L,U,N,D,O]);let z=(0,T.useRef)(null),$=Q(n),ee=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(!k||!K)return;let t=m(K);if(!t)return;z.current=t;let r=()=>{x.current=!1},n=()=>{if(!e||!x.current)return;let{activeId:t}=e.getState();null===t||t!==ee.current&&(x.current=!1)},i={passive:!0,capture:!0};return t.addEventListener("wheel",r,i),t.addEventListener("touchmove",r,i),t.addEventListener("scroll",n,i),()=>{t.removeEventListener("wheel",r,!0),t.removeEventListener("touchmove",r,!0),t.removeEventListener("scroll",n,!0)}},[k,K,e]),j(()=>{!O||G.current||(x.current=!0)},[O]),j(()=>{"always"!==D&&k||(x.current=k)},[D,k]);let et=e.useState("resetValueOnSelect");q(()=>{var t,r;let n=x.current;if(!e||!k||!n&&!et)return;let{baseElement:i,contentElement:o,activeId:a}=e.getState();if(!i||eI(i)){if(null==o?void 0:o.hasAttribute("data-placing")){let e=new MutationObserver(I);return e.observe(o,{attributeFilter:["data-placing"]}),()=>e.disconnect()}if(D&&n){let r,n=$(N),i=void 0!==n?n:null!=(t=null==(r=N.find(e=>{var t;return!e.disabled&&(null==(t=e.element)?void 0:t.getAttribute("role"))!=="tab"}))?void 0:r.id)?t:e.first();ee.current=i,e.move(null!=i?i:null)}else{let t=null==(r=e.item(a||e.first()))?void 0:r.element;t&&"scrollIntoView"in t&&t.scrollIntoView({block:"nearest",inline:"nearest"})}}},[e,k,R,O,D,et,$,N]),(0,T.useEffect)(()=>{if(!w)return;let t=S.current;if(!t)return;let r=[t,K].filter(e=>!!e),n=t=>{r.every(e=>P(t,e))&&(null==e||e.setValue(Z))};for(let e of r)e.addEventListener("focusout",n);return()=>{for(let e of r)e.removeEventListener("focusout",n)}},[w,K,e,Z]);let er=e=>e.currentTarget.value.length>=o,en=g.onChange,ei=Y(null!=a?a:er),eo=Y(null!=i?i:!e.tag),ea=Q(t=>{if(null==en||en(t),t.defaultPrevented||!e)return;let r=t.currentTarget,{value:n,selectionStart:i,selectionEnd:o}=r,a=t.nativeEvent;if(x.current=!0,"input"===a.type&&(a.isComposing&&(x.current=!1,G.current=!0),w)){let e="insertText"===a.inputType||"insertCompositionText"===a.inputType,t=i===n.length;_(e&&t)}if(eo(t)){let t=n===e.getState().value;e.setValue(n),queueMicrotask(()=>{p(r,i,o)}),w&&D&&t&&I()}ei(t)&&e.show(),D&&x.current||e.setActiveId(null)}),es=g.onCompositionEnd,el=Q(e=>{x.current=!0,G.current=!1,null==es||es(e),e.defaultPrevented||D&&I()}),eu=g.onMouseDown,ec=Y(null!=d?d:()=>!!(null==e?void 0:e.getState().includesBaseElement)),ed=Y(f),ef=Y(null!=l?l:er),eA=Q(t=>{null==eu||eu(t),t.defaultPrevented||t.button||t.ctrlKey||e&&(ec(t)&&e.setActiveId(null),ed(t)&&e.setValue(Z),ef(t)&&J(t.currentTarget,"mouseup",e.show))}),eh=g.onKeyDown,em=Y(null!=c?c:er),ep=Q(t=>{if(null==eh||eh(t),t.repeat||(x.current=!1),t.defaultPrevented||t.ctrlKey||t.altKey||t.shiftKey||t.metaKey||!e)return;let{open:r}=e.getState();!r&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&em(t)&&(t.preventDefault(),e.show())}),eB=g.onBlur,eC=Q(e=>{if(x.current=!1,null==eB||eB(e),e.defaultPrevented)return}),eg=V(g.id),ev=e.useState(e=>null===e.activeId);return g={id:eg,role:"combobox","aria-autocomplete":"inline"===C||"list"===C||"both"===C||"none"===C?C:void 0,"aria-haspopup":h(K,"listbox"),"aria-expanded":k,"aria-controls":null==K?void 0:K.id,"data-active-item":ev||void 0,value:Z,...g,ref:X(S,g.ref),onChange:ea,onCompositionEnd:el,onMouseDown:eA,onKeyDown:ep,onBlur:eC},g=ej({store:e,focusable:t,...g,moveOnKeyPress:e=>!F(B,e)&&(w&&_(!0),!0)}),{autoComplete:"off",...g=e8({store:e,...g})}}),tp=ea(function(e){return el("input",tm(e))});function tB(e){let t=e.relatedTarget;return(null==t?void 0:t.nodeType)===Node.ELEMENT_NODE?t:null}e.s(["Combobox",()=>tp],11889);var tC=Symbol("composite-hover"),tg=eu(function({store:e,focusOnHover:t=!0,blurOnHoverEnd:r=!!t,...n}){let i=eh();M(e=e||i,!1);let o=((0,T.useEffect)(()=>{$||(U("mousemove",en,!0),U("mousedown",ei,!0),U("mouseup",ei,!0),U("keydown",ei,!0),U("scroll",ei,!0),$=!0)},[]),Q(()=>ee)),s=n.onMouseMove,l=Y(t),u=Q(t=>{if((null==s||s(t),!t.defaultPrevented&&o())&&l(t)){if(!eT(t.currentTarget)){let t=null==e?void 0:e.getState().baseElement;t&&!eI(t)&&t.focus()}null==e||e.setActiveId(t.currentTarget.id)}}),c=n.onMouseLeave,d=Y(r),f=Q(t=>{var r;let n;null==c||c(t),!t.defaultPrevented&&o()&&((n=tB(t))&&a(t.currentTarget,n)||function(e){let t=tB(e);if(!t)return!1;do{if(y(t,tC)&&t[tC])return!0;t=t.parentElement}while(t)return!1}(t)||!l(t)||d(t)&&(null==e||e.setActiveId(null),null==(r=null==e?void 0:e.getState().baseElement)||r.focus()))}),A=(0,T.useCallback)(e=>{e&&(e[tC]=!0)},[]);return R(n={...n,ref:X(A,n.ref),onMouseMove:u,onMouseLeave:f})});es(ea(function(e){return el("div",tg(e))}));var tv=eu(function({store:e,shouldRegisterItem:t=!0,getItem:r=E,element:n,...i}){let o=ef();e=e||o;let a=V(i.id),s=(0,T.useRef)(n);return(0,T.useEffect)(()=>{let n=s.current;if(!a||!n||!t)return;let i=r({id:a,element:n});return null==e?void 0:e.renderItem(i)},[a,t,r,e]),R(i={...i,ref:X(s,i.ref)})});function ty(e){if(!e.isTrusted)return!1;let t=e.currentTarget;return"Enter"===e.key?l(t)||"SUMMARY"===t.tagName||"A"===t.tagName:" "===e.key&&(l(t)||"SUMMARY"===t.tagName||"INPUT"===t.tagName||"SELECT"===t.tagName)}ea(function(e){return el("div",tv(e))});var tb=Symbol("command"),tE=eu(function({clickOnEnter:e=!0,clickOnSpace:t=!0,...n}){let i,o,a=(0,T.useRef)(null),[s,u]=(0,T.useState)(!1);(0,T.useEffect)(()=>{a.current&&u(l(a.current))},[]);let[c,f]=(0,T.useState)(!1),A=(0,T.useRef)(!1),h=S(n),[m,p]=(i=n.onLoadedMetadataCapture,o=(0,T.useMemo)(()=>Object.assign(()=>{},{...i,[tb]:!0}),[i,tb,!0]),[null==i?void 0:i[tb],{onLoadedMetadataCapture:o}]),B=n.onKeyDown,C=Q(n=>{null==B||B(n);let i=n.currentTarget;if(n.defaultPrevented||m||h||!_(n)||d(i)||i.isContentEditable)return;let o=e&&"Enter"===n.key,a=t&&" "===n.key,s="Enter"===n.key&&!e,l=" "===n.key&&!t;if(s||l)return void n.preventDefault();if(o||a){let e=ty(n);if(o){if(!e){n.preventDefault();let{view:e,...t}=n,o=()=>H(i,t);r&&/firefox\//i.test(navigator.userAgent)?J(i,"keyup",o):queueMicrotask(o)}}else a&&(A.current=!0,e||(n.preventDefault(),f(!0)))}}),g=n.onKeyUp,v=Q(e=>{if(null==g||g(e),e.defaultPrevented||m||h||e.metaKey)return;let r=t&&" "===e.key;if(A.current&&r&&(A.current=!1,!ty(e))){e.preventDefault(),f(!1);let t=e.currentTarget,{view:r,...n}=e;queueMicrotask(()=>H(t,n))}});return eU(n={"data-active":c||void 0,type:s?"button":void 0,...p,...n,ref:X(a,n.ref),onKeyDown:C,onKeyUp:v})});ea(function(e){return el("button",tE(e))});var{useSyncExternalStore:tM}=e.i(2239).default,tF=()=>()=>{};function tS(e,t=E){let r=T.useCallback(t=>e?ts(e,null,t):tF(),[e]),n=()=>{let r="string"==typeof t?t:null,n="function"==typeof t?t:null,i=null==e?void 0:e.getState();return n?n(i):i&&r&&y(i,r)?i[r]:void 0};return tM(r,n,n)}function tR(e,t){let r=T.useRef({}),n=T.useCallback(t=>e?ts(e,null,t):tF(),[e]),i=()=>{let n=null==e?void 0:e.getState(),i=!1,o=r.current;for(let e in t){let r=t[e];if("function"==typeof r){let t=r(n);t!==o[e]&&(o[e]=t,i=!0)}if("string"==typeof r){if(!n||!y(n,r))continue;let t=n[r];t!==o[e]&&(o[e]=t,i=!0)}}return i&&(r.current={...o}),r.current};return tM(n,i,i)}function tI(e,t,r,n){var i;let o,a=y(t,r)?t[r]:void 0,s=(i={value:a,setValue:n?t[n]:void 0},o=(0,T.useRef)(i),j(()=>{o.current=i}),o);j(()=>tl(e,[r],(e,t)=>{let{value:n,setValue:i}=s.current;i&&e[r]!==t[r]&&e[r]!==n&&i(e[r])}),[e,r]),j(()=>{if(void 0!==a)return e.setState(r,a),tu(e,[r],()=>{void 0!==a&&e.setState(r,a)})})}function tT(e,t){let[r,n]=T.useState(()=>e(t));j(()=>ta(r),[r]);let i=T.useCallback(e=>tS(r,e),[r]);return[T.useMemo(()=>({...r,useState:i}),[r,i]),Q(()=>{n(r=>e({...t,...r.getState()}))})]}function tx(e,t,r,n=!1){var i;let o,a;if(!t||!r)return;let{renderedItems:s}=t.getState(),l=m(e);if(!l)return;let u=function(e,t=!1){let r=e.clientHeight,{top:n}=e.getBoundingClientRect(),i=1.5*Math.max(.875*r,r-40),o=t?r-i+n:i+n;return"HTML"===e.tagName?o+e.scrollTop:o}(l,n);for(let e=0;e=0){void 0!==a&&at||(e&&(null==B?void 0:B.baseElement)&&B.baseElement===e.baseElement?B.id:void 0),baseElement:e=>(null==e?void 0:e.baseElement)||void 0,isActiveItem:e=>!!e&&e.activeId===m,ariaSetSize:e=>null!=s?s:e&&(null==B?void 0:B.ariaSetSize)&&B.baseElement===e.baseElement?B.ariaSetSize:void 0,ariaPosInSet(e){if(null!=u)return u;if(!e||!(null==B?void 0:B.ariaPosInSet)||B.baseElement!==e.baseElement)return;let t=e.renderedItems.filter(e=>e.rowId===y);return B.ariaPosInSet+t.findIndex(e=>e.id===m)},isTabbable(t){if(!(null==t?void 0:t.renderedItems.length))return!0;if(t.virtualFocus)return!1;if(o)return!0;if(null===t.activeId)return!1;let r=null==e?void 0:e.item(t.activeId);return null!=r&&!!r.disabled||null==r||!r.element||t.activeId===m}}),x=(0,T.useCallback)(e=>{var t;let r={...e,id:m||e.id,rowId:y,disabled:!!v,children:null==(t=e.element)?void 0:t.textContent};return a?a(r):r},[m,y,v,a]),G=c.onFocus,D=(0,T.useRef)(!1),O=Q(t=>{var r,i;if(null==G||G(t),t.defaultPrevented||L(t)||!m||!e||(r=e,!_(t)&&g(r,t.target)))return;let{virtualFocus:o,baseElement:a}=e.getState();e.setActiveId(m),f(t.currentTarget)&&function(e,t=!1){if(d(e))e.setSelectionRange(t?e.value.length:0,e.value.length);else if(e.isContentEditable){let r=n(e).getSelection();null==r||r.selectAllChildren(e),t&&(null==r||r.collapseToEnd())}}(t.currentTarget),!o||!_(t)||!f(i=t.currentTarget)&&("INPUT"!==i.tagName||l(i))&&(null==a?void 0:a.isConnected)&&((w()&&t.currentTarget.hasAttribute("data-autofocus")&&t.currentTarget.scrollIntoView({block:"nearest",inline:"nearest"}),D.current=!0,t.relatedTarget===a||g(e,t.relatedTarget))?(a[C]=!0,a.focus({preventScroll:!0})):a.focus())}),H=c.onBlurCapture,P=Q(t=>{if(null==H||H(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState();(null==r?void 0:r.virtualFocus)&&D.current&&(D.current=!1,t.preventDefault(),t.stopPropagation())}),J=c.onKeyDown,U=Y(r),N=Y(i),k=Q(t=>{if(null==J||J(t),t.defaultPrevented||!_(t)||!e)return;let{currentTarget:r}=t,i=e.getState(),o=e.item(m),a=!!(null==o?void 0:o.rowId),s="horizontal"!==i.orientation,l="vertical"!==i.orientation,u=()=>!(!a&&!l&&i.baseElement&&d(i.baseElement)),c={ArrowUp:(a||s)&&e.up,ArrowRight:(a||l)&&e.next,ArrowDown:(a||s)&&e.down,ArrowLeft:(a||l)&&e.previous,Home:()=>{if(u())return!a||t.ctrlKey?null==e?void 0:e.first():null==e?void 0:e.previous(-1)},End:()=>{if(u())return!a||t.ctrlKey?null==e?void 0:e.last():null==e?void 0:e.next(-1)},PageUp:()=>tx(r,e,null==e?void 0:e.up,!0),PageDown:()=>tx(r,e,null==e?void 0:e.down)}[t.key];if(c){if(f(r)){let e=A(r),i=l&&"ArrowLeft"===t.key,o=l&&"ArrowRight"===t.key,a=s&&"ArrowUp"===t.key,u=s&&"ArrowDown"===t.key;if(o||u){let{length:t}=function(e){if(d(e))return e.value;if(e.isContentEditable){let t=n(e).createRange();return t.selectNodeContents(e),t.toString()}return""}(r);if(e.end!==t)return}else if((i||a)&&0!==e.start)return}let i=c();if(U(t)||void 0!==i){if(!N(t))return;t.preventDefault(),e.move(i)}}}),K=(0,T.useMemo)(()=>({id:m,baseElement:b}),[m,b]);return c={id:m,"data-active-item":E||void 0,...c=Z(c,e=>(0,eo.jsx)(eC.Provider,{value:K,children:e}),[K]),ref:X(p,c.ref),tabIndex:I?c.tabIndex:-1,onFocus:O,onBlurCapture:P,onKeyDown:k},c=tE(c),R({...c=tv({store:e,...c,getItem:x,shouldRegisterItem:!!m&&c.shouldRegisterItem}),"aria-setsize":M,"aria-posinset":F})});es(ea(function(e){return el("button",tG(e))}));var tD=eu(function({store:e,value:t,hideOnClick:r,setValueOnClick:n,selectValueOnClick:i=!0,resetValueOnSelect:o,focusOnHover:a=!1,moveOnKeyPress:s=!0,getItem:l,...u}){var c,f;let A=e4();M(e=e||A,!1);let{resetValueOnSelectState:h,multiSelectable:m,selected:p}=tR(e,{resetValueOnSelectState:"resetValueOnSelect",multiSelectable:e=>Array.isArray(e.selectedValue),selected:e=>(function(e,t){if(null!=t)return null!=e&&(Array.isArray(e)?e.includes(t):e===t)})(e.selectedValue,t)}),B=(0,T.useCallback)(e=>{let r={...e,value:t};return l?l(r):r},[t,l]);n=null!=n?n:!m,r=null!=r?r:null!=t&&!m;let C=u.onClick,g=Y(n),v=Y(i),y=Y(null!=(c=null!=o?o:h)?c:m),b=Y(r),E=Q(r=>{null==C||C(r),r.defaultPrevented||function(e){let t=e.currentTarget;if(!t)return!1;let r=t.tagName.toLowerCase();return!!e.altKey&&("a"===r||"button"===r&&"submit"===t.type||"input"===r&&"submit"===t.type)}(r)||!function(e){let t=e.currentTarget;if(!t)return!1;let r=D();if(r&&!e.metaKey||!r&&!e.ctrlKey)return!1;let n=t.tagName.toLowerCase();return"a"===n||"button"===n&&"submit"===t.type||"input"===n&&"submit"===t.type}(r)&&(null!=t&&(v(r)&&(y(r)&&(null==e||e.resetValue()),null==e||e.setSelectedValue(e=>Array.isArray(e)?e.includes(t)?e.filter(e=>e!==t):[...e,t]:t)),g(r)&&(null==e||e.setValue(t))),b(r)&&(null==e||e.hide()))}),F=u.onKeyDown,S=Q(t=>{if(null==F||F(t),t.defaultPrevented)return;let r=null==e?void 0:e.getState().baseElement;!r||eI(r)||(1===t.key.length||"Backspace"===t.key||"Delete"===t.key)&&(queueMicrotask(()=>r.focus()),d(r)&&(null==e||e.setValue(r.value)))});m&&null!=p&&(u={"aria-selected":p,...u}),u=Z(u,e=>(0,eo.jsx)(tt.Provider,{value:t,children:(0,eo.jsx)(tr.Provider,{value:null!=p&&p,children:e})}),[t,p]),u={role:null!=(f=({menu:"menuitem",listbox:"option",tree:"treeitem"})[(0,T.useContext)(e2)])?f:"option",children:t,...u,onClick:E,onKeyDown:S};let R=Y(s);return u=tG({store:e,...u,getItem:B,moveOnKeyPress:t=>{if(!R(t))return!1;let r=new Event("combobox-item-move"),n=null==e?void 0:e.getState().baseElement;return null==n||n.dispatchEvent(r),!0}}),u=tg({store:e,focusOnHover:a,...u})}),tw=es(ea(function(e){return el("div",tD(e))}));e.s(["ComboboxItem",()=>tw],56373);var tL=e.i(74080);function t_(e,t){let r=setTimeout(t,e);return()=>clearTimeout(r)}function tO(...e){return e.join(", ").split(", ").reduce((e,t)=>{let r=t.endsWith("ms")?1:1e3,n=Number.parseFloat(t||"0s")*r;return n>e?n:e},0)}function tH(e,t,r){return!r&&!1!==t&&(!e||!!t)}var tP=eu(function({store:e,alwaysVisible:t,...r}){let n=eX();M(e=e||n,!1);let i=(0,T.useRef)(null),o=V(r.id),[a,s]=(0,T.useState)(null),l=e.useState("open"),u=e.useState("mounted"),c=e.useState("animated"),d=e.useState("contentElement"),f=tS(e.disclosure,"contentElement");j(()=>{i.current&&(null==e||e.setContentElement(i.current))},[e]),j(()=>{let t;return null==e||e.setState("animated",e=>(t=e,!0)),()=>{void 0!==t&&(null==e||e.setState("animated",t))}},[e]),j(()=>{if(c){var e;let t;return(null==d?void 0:d.isConnected)?(e=()=>{s(l?"enter":u?"leave":null)},t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)}),()=>cancelAnimationFrame(t)):void s(null)}},[c,d,l,u]),j(()=>{if(!e||!c||!a||!d)return;let t=()=>null==e?void 0:e.setState("animating",!1),r=()=>(0,tL.flushSync)(t);if("leave"===a&&l||"enter"===a&&!l)return;if("number"==typeof c)return t_(c,r);let{transitionDuration:n,animationDuration:i,transitionDelay:o,animationDelay:s}=getComputedStyle(d),{transitionDuration:u="0",animationDuration:A="0",transitionDelay:h="0",animationDelay:m="0"}=f?getComputedStyle(f):{},p=tO(o,s,h,m)+tO(n,i,u,A);if(!p){"enter"===a&&e.setState("animated",!1),t();return}return t_(Math.max(p-1e3/60,0),r)},[e,c,d,f,l,a]);let A=tH(u,(r=Z(r,t=>(0,eo.jsx)(eY,{value:e,children:t}),[e])).hidden,t),h=r.style,m=(0,T.useMemo)(()=>A?{...h,display:"none"}:h,[A,h]);return R(r={id:o,"data-open":l||void 0,"data-enter":"enter"===a||void 0,"data-leave":"leave"===a||void 0,hidden:A,...r,ref:X(o?e.setContentElement:null,i,r.ref),style:m})}),tJ=ea(function(e){return el("div",tP(e))});ea(function({unmountOnHide:e,...t}){let r=eX();return!1===tS(t.store||r,t=>!e||(null==t?void 0:t.mounted))?null:(0,eo.jsx)(tJ,{...t})});var tU=eu(function({store:e,alwaysVisible:t,...r}){let n=e4(!0),i=e6(),o=!!(e=e||i)&&e===n;M(e,!1);let a=(0,T.useRef)(null),s=V(r.id),l=e.useState("mounted"),u=tH(l,r.hidden,t),c=u?{...r.style,display:"none"}:r.style,d=e.useState(e=>Array.isArray(e.selectedValue)),f=function(e,t,r){let n=function(e){let[t]=(0,T.useState)(e);return t}(r),[i,o]=(0,T.useState)(n);return(0,T.useEffect)(()=>{let r=e&&"current"in e?e.current:e;if(!r)return;let i=()=>{let e=r.getAttribute(t);o(null==e?n:e)},a=new MutationObserver(i);return a.observe(r,{attributeFilter:[t]}),i(),()=>a.disconnect()},[e,t,n]),i}(a,"role",r.role),A="listbox"===f||"tree"===f||"grid"===f,[h,m]=(0,T.useState)(!1),p=e.useState("contentElement");j(()=>{if(!l)return;let e=a.current;if(!e||p!==e)return;let t=()=>{m(!!e.querySelector("[role='listbox']"))},r=new MutationObserver(t);return r.observe(e,{subtree:!0,childList:!0,attributeFilter:["role"]}),t(),()=>r.disconnect()},[l,p]),h||(r={role:"listbox","aria-multiselectable":A&&d||void 0,...r}),r=Z(r,t=>(0,eo.jsx)(te,{value:e,children:(0,eo.jsx)(e2.Provider,{value:f,children:t})}),[e,f]);let B=!s||n&&o?null:e.setContentElement;return R(r={id:s,hidden:u,...r,ref:X(B,a,r.ref),style:c})}),tN=ea(function(e){return el("div",tU(e))});e.s(["ComboboxList",()=>tN,"useComboboxList",()=>tU],86447);var tk=(0,T.createContext)(null),tK=eu(function(e){return{...e,style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",whiteSpace:"nowrap",width:"1px",...e.style}}});ea(function(e){return el("span",tK(e))});var tj=eu(function(e){return tK(e={"data-focus-trap":"",tabIndex:0,"aria-hidden":!0,...e,style:{position:"fixed",top:0,left:0,...e.style}})}),tQ=ea(function(e){return el("span",tj(e))});function tX(e){queueMicrotask(()=>{null==e||e.focus()})}var tV=eu(function({preserveTabOrder:e,preserveTabOrderAnchor:t,portalElement:r,portalRef:i,portal:o=!0,...a}){let s=(0,T.useRef)(null),l=X(s,a.ref),u=(0,T.useContext)(tk),[c,d]=(0,T.useState)(null),[f,A]=(0,T.useState)(null),h=(0,T.useRef)(null),m=(0,T.useRef)(null),p=(0,T.useRef)(null),B=(0,T.useRef)(null);return j(()=>{let e=s.current;if(!e||!o)return void d(null);let t=r?"function"==typeof r?r(e):r:n(e).createElement("div");if(!t)return void d(null);let a=t.isConnected;if(a||(u||n(e).body).appendChild(t),t.id||(t.id=e.id?`portal/${e.id}`:function(e="id"){return`${e?`${e}-`:""}${Math.random().toString(36).slice(2,8)}`}()),d(t),x(i,t),!a)return()=>{t.remove(),x(i,null)}},[o,r,u,i]),j(()=>{if(!o||!e||!t)return;let r=n(t).createElement("span");return r.style.position="fixed",t.insertAdjacentElement("afterend",r),A(r),()=>{r.remove(),A(null)}},[o,e,t]),(0,T.useEffect)(()=>{if(!c||!e)return;let t=0,r=e=>{if(!P(e))return;let r="focusin"===e.type;if(cancelAnimationFrame(t),r){let e=c.querySelectorAll("[data-tabindex]"),t=e=>{let t=e.getAttribute("data-tabindex");e.removeAttribute("data-tabindex"),t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")};for(let r of(c.hasAttribute("data-tabindex")&&t(c),e))t(r);return}t=requestAnimationFrame(()=>{for(let e of eF(c,!0))!function(e){var t;let r=null!=(t=e.getAttribute("tabindex"))?t:"";e.setAttribute("data-tabindex",r),e.setAttribute("tabindex","-1")}(e)})};return c.addEventListener("focusin",r,!0),c.addEventListener("focusout",r,!0),()=>{cancelAnimationFrame(t),c.removeEventListener("focusin",r,!0),c.removeEventListener("focusout",r,!0)}},[c,e]),a={...a=Z(a,t=>{if(t=(0,eo.jsx)(tk.Provider,{value:c||u,children:t}),!o)return t;if(!c)return(0,eo.jsx)("span",{ref:l,id:a.id,style:{position:"fixed"},hidden:!0});t=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tQ,{ref:m,"data-focus-trap":a.id,className:"__focus-trap-inner-before",onFocus:e=>{P(e,c)?tX(eS()):tX(h.current)}}),t,e&&c&&(0,eo.jsx)(tQ,{ref:p,"data-focus-trap":a.id,className:"__focus-trap-inner-after",onFocus:e=>{P(e,c)?tX(eR()):tX(B.current)}})]}),c&&(t=(0,tL.createPortal)(t,c));let r=(0,eo.jsxs)(eo.Fragment,{children:[e&&c&&(0,eo.jsx)(tQ,{ref:h,"data-focus-trap":a.id,className:"__focus-trap-outer-before",onFocus:e=>{e.relatedTarget!==B.current&&P(e,c)?tX(m.current):tX(eR())}}),e&&(0,eo.jsx)("span",{"aria-owns":null==c?void 0:c.id,style:{position:"fixed"}}),e&&c&&(0,eo.jsx)(tQ,{ref:B,"data-focus-trap":a.id,className:"__focus-trap-outer-after",onFocus:e=>{if(P(e,c))tX(p.current);else{let e=eS();if(e===m.current)return void requestAnimationFrame(()=>{var e;return null==(e=eS())?void 0:e.focus()});tX(e)}}})]});return f&&e&&(r=(0,tL.createPortal)(r,f)),(0,eo.jsxs)(eo.Fragment,{children:[r,t]})},[c,u,o,a.id,e,f]),ref:l}});ea(function(e){return el("div",tV(e))});var tq=(0,T.createContext)(0);function tW({level:e,children:t}){let r=(0,T.useContext)(tq),n=Math.max(Math.min(e||r+1,6),1);return(0,eo.jsx)(tq.Provider,{value:n,children:t})}var tY=eu(function({autoFocusOnShow:e=!0,...t}){return Z(t,t=>(0,eo.jsx)(ev.Provider,{value:e,children:t}),[e])});ea(function(e){return el("div",tY(e))});var tZ=new WeakMap;function tz(e,t,r){tZ.has(e)||tZ.set(e,new Map);let n=tZ.get(e),i=n.get(t);if(!i)return n.set(t,r()),()=>{var e;null==(e=n.get(t))||e(),n.delete(t)};let o=r(),a=()=>{o(),i(),n.delete(t)};return n.set(t,a),()=>{n.get(t)===a&&(o(),n.set(t,i))}}function t$(e,t,r){return tz(e,t,()=>{let n=e.getAttribute(t);return e.setAttribute(t,r),()=>{null==n?e.removeAttribute(t):e.setAttribute(t,n)}})}function t0(e,t,r){return tz(e,t,()=>{let n=t in e,i=e[t];return e[t]=r,()=>{n?e[t]=i:delete e[t]}})}function t1(e,t){return e?tz(e,"style",()=>{let r=e.style.cssText;return Object.assign(e.style,t),()=>{e.style.cssText=r}}):()=>{}}var t9=["SCRIPT","STYLE"];function t8(e){return`__ariakit-dialog-snapshot-${e}`}function t2(e,t,r,i){for(let o of t){if(!(null==o?void 0:o.isConnected))continue;let s=t.some(e=>!!e&&e!==o&&e.contains(o)),l=n(o),u=o;for(;o.parentElement&&o!==l.body;){if(null==i||i(o.parentElement,u),!s)for(let i of o.parentElement.children)(function(e,t,r){return!t9.includes(t.tagName)&&!!function(e,t){let r=n(t),i=t8(e);if(!r.body[i])return!0;for(;;){if(t===r.body)return!1;if(t[i])return!0;if(!t.parentElement)return!1;t=t.parentElement}}(e,t)&&!r.some(e=>e&&a(t,e))})(e,i,t)&&r(i,u);o=o.parentElement}}}function t3(e,...t){if(!e)return!1;let r=e.getAttribute("data-backdrop");return null!=r&&(""===r||"true"===r||!t.length||t.some(e=>r===e))}function t6(e="",t=!1){return`__ariakit-dialog-${t?"ancestor":"outside"}${e?`-${e}`:""}`}function t4(e,t=""){return b(t0(e,t6("",!0),!0),t0(e,t6(t,!0),!0))}function t7(e,t){if(e[t6(t,!0)])return!0;let r=t6(t);for(;;){if(e[r])return!0;if(!e.parentElement)return!1;e=e.parentElement}}function t5(e,t){let r=[],n=t.map(e=>null==e?void 0:e.id);return t2(e,t,t=>{t3(t,...n)||r.unshift(function(e,t=""){return b(t0(e,t6(),!0),t0(e,t6(t),!0))}(t,e))},(t,n)=>{n.hasAttribute("data-dialog")&&n.id!==e||r.unshift(t4(t,e))}),()=>{for(let e of r)e()}}function re({store:e,type:t,listener:r,capture:i,domReady:o}){let s=Q(r),l=tS(e,"open"),u=(0,T.useRef)(!1);j(()=>{if(!l||!o)return;let{contentElement:t}=e.getState();if(!t)return;let r=()=>{u.current=!0};return t.addEventListener("focusin",r,!0),()=>t.removeEventListener("focusin",r,!0)},[e,l,o]),(0,T.useEffect)(()=>{if(l)return U(t,t=>{let{contentElement:r,disclosureElement:i}=e.getState(),o=t.target;!r||!o||!(!("HTML"===o.tagName||a(n(o).body,o))||a(r,o)||function(e,t){if(!e)return!1;if(a(e,t))return!0;let r=t.getAttribute("aria-activedescendant");if(r){let t=n(e).getElementById(r);if(t)return a(e,t)}return!1}(i,o)||o.hasAttribute("data-focus-trap")||function(e,t){if(!("clientY"in e))return!1;let r=t.getBoundingClientRect();return 0!==r.width&&0!==r.height&&r.top<=e.clientY&&e.clientY<=r.top+r.height&&r.left<=e.clientX&&e.clientX<=r.left+r.width}(t,r))&&(!u.current||t7(o,r.id))&&(o&&o[ew]||s(t))},i)},[l,i])}function rt(e,t){return"function"==typeof e?e(t):!!e}var rr=(0,T.createContext)({});function rn(){return"inert"in HTMLElement.prototype}function ri(e,t){if(!("style"in e))return v;if(rn())return t0(e,"inert",!0);let r=eF(e,!0).map(e=>{if(null==t?void 0:t.some(t=>t&&a(t,e)))return v;let r=tz(e,"focus",()=>(e.focus=v,()=>{delete e.focus}));return b(t$(e,"tabindex","-1"),r)});return b(...r,t$(e,"aria-hidden","true"),t1(e,{pointerEvents:"none",userSelect:"none",cursor:"default"}))}function ro(e={}){let t=td(e.store,tc(e.disclosure,["contentElement","disclosureElement"]));tf(e,t);let r=null==t?void 0:t.getState(),n=I(e.open,null==r?void 0:r.open,e.defaultOpen,!1),i=I(e.animated,null==r?void 0:r.animated,!1),o=ti({open:n,animated:i,animating:!!i&&n,mounted:n,contentElement:I(null==r?void 0:r.contentElement,null),disclosureElement:I(null==r?void 0:r.disclosureElement,null)},t);return to(o,()=>tl(o,["animated","animating"],e=>{e.animated||o.setState("animating",!1)})),to(o,()=>ts(o,["open"],()=>{o.getState().animated&&o.setState("animating",!0)})),to(o,()=>tl(o,["open","animating"],e=>{o.setState("mounted",e.open||e.animating)})),{...o,disclosure:e.disclosure,setOpen:e=>o.setState("open",e),show:()=>o.setState("open",!0),hide:()=>o.setState("open",!1),toggle:()=>o.setState("open",e=>!e),stopAnimation:()=>o.setState("animating",!1),setContentElement:e=>o.setState("contentElement",e),setDisclosureElement:e=>o.setState("disclosureElement",e)}}function ra(e,t,r){return q(t,[r.store,r.disclosure]),tI(e,r,"open","setOpen"),tI(e,r,"mounted","setMounted"),tI(e,r,"animated"),Object.assign(e,{disclosure:r.disclosure})}eu(function(e){return e});var rs=ea(function(e){return el("div",e)});function rl({store:e,backdrop:t,alwaysVisible:r,hidden:n}){let i=(0,T.useRef)(null),o=function(e={}){let[t,r]=tT(ro,e);return ra(t,r,e)}({disclosure:e}),a=tS(e,"contentElement");(0,T.useEffect)(()=>{let e=i.current;!e||a&&(e.style.zIndex=getComputedStyle(a).zIndex)},[a]),j(()=>{let e=null==a?void 0:a.id;if(!e)return;let t=i.current;if(t)return t4(t,e)},[a]);let s=tP({ref:i,store:o,role:"presentation","data-backdrop":(null==a?void 0:a.id)||"",alwaysVisible:r,hidden:null!=n?n:void 0,style:{position:"fixed",top:0,right:0,bottom:0,left:0}});if(!t)return null;if((0,T.isValidElement)(t))return(0,eo.jsx)(rs,{...s,render:t});let l="boolean"!=typeof t?t:"div";return(0,eo.jsx)(rs,{...s,render:(0,eo.jsx)(l,{})})}function ru(e={}){return ro(e)}Object.assign(rs,["a","button","details","dialog","div","form","h1","h2","h3","h4","h5","h6","header","img","input","label","li","nav","ol","p","section","select","span","summary","textarea","ul","svg"].reduce((e,t)=>(e[t]=ea(function(e){return el(t,e)}),e),{}));var rc=w();function rd(e,t=!1){if(!e)return null;let r="current"in e?e.current:e;return r?t?eb(r)?r:null:r:null}var rf=eu(function({store:e,open:t,onClose:s,focusable:u=!0,modal:d=!0,portal:f=!!d,backdrop:A=!!d,hideOnEscape:h=!0,hideOnInteractOutside:m=!0,getPersistentElements:p,preventBodyScroll:B=!!d,autoFocusOnShow:C=!0,autoFocusOnHide:g=!0,initialFocus:v,finalFocus:y,unmountOnHide:E,unstable_treeSnapshotKey:M,...F}){var S;let R,I,x,w=eq(),L=(0,T.useRef)(null),_=function(e={}){let[t,r]=tT(ru,e);return ra(t,r,e)}({store:e||w,open:t,setOpen(e){if(e)return;let t=L.current;if(!t)return;let r=new Event("close",{bubbles:!1,cancelable:!0});s&&t.addEventListener("close",s,{once:!0}),t.dispatchEvent(r),r.defaultPrevented&&_.setOpen(!0)}}),{portalRef:O,domReady:H}=z(f,F.portalRef),P=F.preserveTabOrder,N=tS(_,e=>P&&!d&&e.mounted),k=V(F.id),K=tS(_,"open"),q=tS(_,"mounted"),$=tS(_,"contentElement"),ee=tH(q,F.hidden,F.alwaysVisible);R=function({attribute:e,contentId:t,contentElement:r,enabled:i}){let[o,a]=W(),s=(0,T.useCallback)(()=>{if(!i||!r)return!1;let{body:o}=n(r),a=o.getAttribute(e);return!a||a===t},[o,i,r,e,t]);return(0,T.useEffect)(()=>{if(!i||!t||!r)return;let{body:o}=n(r);if(s())return o.setAttribute(e,t),()=>o.removeAttribute(e);let l=new MutationObserver(()=>(0,tL.flushSync)(a));return l.observe(o,{attributeFilter:[e]}),()=>l.disconnect()},[o,i,t,r,s,e]),s}({attribute:"data-dialog-prevent-body-scroll",contentElement:$,contentId:k,enabled:B&&!ee}),(0,T.useEffect)(()=>{var e,t;if(!R()||!$)return;let o=n($),a=i($),{documentElement:s,body:l}=o,u=s.style.getPropertyValue("--scrollbar-width"),c=u?Number.parseInt(u,10):a.innerWidth-s.clientWidth,d=Math.round(s.getBoundingClientRect().left)+s.scrollLeft?"paddingLeft":"paddingRight",f=D()&&!(r&&navigator.platform.startsWith("Mac")&&!G());return b((e="--scrollbar-width",t=`${c}px`,s?tz(s,e,()=>{let r=s.style.getPropertyValue(e);return s.style.setProperty(e,t),()=>{r?s.style.setProperty(e,r):s.style.removeProperty(e)}}):()=>{}),f?(()=>{var e,t;let{scrollX:r,scrollY:n,visualViewport:i}=a,o=null!=(e=null==i?void 0:i.offsetLeft)?e:0,s=null!=(t=null==i?void 0:i.offsetTop)?t:0,u=t1(l,{position:"fixed",overflow:"hidden",top:`${-(n-Math.floor(s))}px`,left:`${-(r-Math.floor(o))}px`,right:"0",[d]:`${c}px`});return()=>{u(),a.scrollTo({left:r,top:n,behavior:"instant"})}})():t1(l,{overflow:"hidden",[d]:`${c}px`}))},[R,$]),S=tS(_,"open"),I=(0,T.useRef)(null),(0,T.useEffect)(()=>{if(!S){I.current=null;return}return U("mousedown",e=>{I.current=e.target},!0)},[S]),re({...x={store:_,domReady:H,capture:!0},type:"click",listener:e=>{let{contentElement:t}=_.getState(),r=I.current;r&&c(r)&&t7(r,null==t?void 0:t.id)&&rt(m,e)&&_.hide()}}),re({...x,type:"focusin",listener:e=>{let{contentElement:t}=_.getState();!t||e.target===n(t)||rt(m,e)&&_.hide()}}),re({...x,type:"contextmenu",listener:e=>{rt(m,e)&&_.hide()}});let{wrapElement:et,nestedDialogs:er}=function(e){let t=(0,T.useContext)(rr),[r,n]=(0,T.useState)([]),i=(0,T.useCallback)(e=>{var r;return n(t=>[...t,e]),b(null==(r=t.add)?void 0:r.call(t,e),()=>{n(t=>t.filter(t=>t!==e))})},[t]);j(()=>tl(e,["open","contentElement"],r=>{var n;if(r.open&&r.contentElement)return null==(n=t.add)?void 0:n.call(t,e)}),[e,t]);let o=(0,T.useMemo)(()=>({store:e,add:i}),[e,i]);return{wrapElement:(0,T.useCallback)(e=>(0,eo.jsx)(rr.Provider,{value:o,children:e}),[o]),nestedDialogs:r}}(_);F=Z(F,et,[et]),j(()=>{if(!K)return;let e=L.current,t=o(e,!0);!t||"BODY"===t.tagName||e&&a(e,t)||_.setDisclosureElement(t)},[_,K]),rc&&(0,T.useEffect)(()=>{if(!q)return;let{disclosureElement:e}=_.getState();if(!e||!l(e))return;let t=()=>{let t=!1,r=()=>{t=!0};e.addEventListener("focusin",r,{capture:!0,once:!0}),J(e,"mouseup",()=>{e.removeEventListener("focusin",r,!0),t||ex(e)})};return e.addEventListener("mousedown",t),()=>{e.removeEventListener("mousedown",t)}},[_,q]),(0,T.useEffect)(()=>{if(!q||!H)return;let e=L.current;if(!e)return;let t=i(e),r=t.visualViewport||t,n=()=>{var r,n;let i=null!=(n=null==(r=t.visualViewport)?void 0:r.height)?n:t.innerHeight;e.style.setProperty("--dialog-viewport-height",`${i}px`)};return n(),r.addEventListener("resize",n),()=>{r.removeEventListener("resize",n)}},[q,H]),(0,T.useEffect)(()=>{if(!d||!q||!H)return;let e=L.current;if(e&&!e.querySelector("[data-dialog-dismiss]")){var t;let r;return t=_.hide,(r=n(e).createElement("button")).type="button",r.tabIndex=-1,r.textContent="Dismiss popup",Object.assign(r.style,{border:"0px",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0px",position:"absolute",whiteSpace:"nowrap",width:"1px"}),r.addEventListener("click",t),e.prepend(r),()=>{r.removeEventListener("click",t),r.remove()}}},[_,d,q,H]),j(()=>{if(!rn()||K||!q||!H)return;let e=L.current;if(e)return ri(e)},[K,q,H]);let en=K&&H;j(()=>{if(k&&en)return function(e,t){let{body:r}=n(t[0]),i=[];return t2(e,t,t=>{i.push(t0(t,t8(e),!0))}),b(t0(r,t8(e),!0),()=>{for(let e of i)e()})}(k,[L.current])},[k,en,M]);let ei=Q(p);j(()=>{if(!k||!en)return;let{disclosureElement:e}=_.getState(),t=[L.current,...ei()||[],...er.map(e=>e.getState().contentElement)];if(d){let e,r;return b(t5(k,t),(e=[],r=t.map(e=>null==e?void 0:e.id),t2(k,t,n=>{t3(n,...r)||!function(e,...t){if(!e)return!1;let r=e.getAttribute("data-focus-trap");return null!=r&&(!t.length||""!==r&&t.some(e=>r===e))}(n,...r)&&e.unshift(ri(n,t))},r=>{!r.hasAttribute("role")||t.some(e=>e&&a(e,r))||e.unshift(t$(r,"role","none"))}),()=>{for(let t of e)t()}))}return t5(k,[e,...t])},[k,_,en,ei,er,d,M]);let ea=!!C,es=Y(C),[el,eu]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!K||!ea||!H||!(null==$?void 0:$.isConnected))return;let e=rd(v,!0)||$.querySelector("[data-autofocus=true],[autofocus]")||function(e,t,r){let[n]=eF(e,t,r);return n||null}($,!0,f&&N)||$,t=eb(e);es(t?e:null)&&(eu(!0),queueMicrotask(()=>{e.focus(),!rc||t&&e.scrollIntoView({block:"nearest",inline:"nearest"})}))},[K,ea,H,$,v,f,N,es]);let ec=!!g,ed=Y(g),[ef,eA]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(K)return eA(!0),()=>eA(!1)},[K]);let eh=(0,T.useCallback)((e,t=!0)=>{let r,{disclosureElement:i}=_.getState();if(!(!(r=o())||e&&a(e,r))&&eb(r))return;let s=rd(y)||i;if(null==s?void 0:s.id){let e=n(s),t=`[aria-activedescendant="${s.id}"]`,r=e.querySelector(t);r&&(s=r)}if(s&&!eb(s)){let e=s.closest("[data-dialog]");if(null==e?void 0:e.id){let t=n(e),r=`[aria-controls~="${e.id}"]`,i=t.querySelector(r);i&&(s=i)}}let l=s&&eb(s);!l&&t?requestAnimationFrame(()=>eh(e,!1)):!ed(l?s:null)||l&&(null==s||s.focus({preventScroll:!0}))},[_,y,ed]),em=(0,T.useRef)(!1);j(()=>{if(K||!ef||!ec)return;let e=L.current;em.current=!0,eh(e)},[K,ef,H,ec,eh]),(0,T.useEffect)(()=>{if(!ef||!ec)return;let e=L.current;return()=>{if(em.current){em.current=!1;return}eh(e)}},[ef,ec,eh]);let ep=Y(h);(0,T.useEffect)(()=>{if(H&&q)return U("keydown",e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=L.current;if(!t||t7(t))return;let r=e.target;if(!r)return;let{disclosureElement:n}=_.getState();!("BODY"===r.tagName||a(t,r)||!n||a(n,r))||ep(e)&&_.hide()},!0)},[_,H,q,ep]);let eB=(F=Z(F,e=>(0,eo.jsx)(tW,{level:d?1:void 0,children:e}),[d])).hidden,eC=F.alwaysVisible;F=Z(F,e=>A?(0,eo.jsxs)(eo.Fragment,{children:[(0,eo.jsx)(rl,{store:_,backdrop:A,hidden:eB,alwaysVisible:eC}),e]}):e,[_,A,eB,eC]);let[eg,ev]=(0,T.useState)(),[ey,eE]=(0,T.useState)();return F=tY({...F={id:k,"data-dialog":"",role:"dialog",tabIndex:u?-1:void 0,"aria-labelledby":eg,"aria-describedby":ey,...F=Z(F,e=>(0,eo.jsx)(eY,{value:_,children:(0,eo.jsx)(eZ.Provider,{value:ev,children:(0,eo.jsx)(ez.Provider,{value:eE,children:e})})}),[_]),ref:X(L,F.ref)},autoFocusOnShow:el}),F=tV({portal:f,...F=eU({...F=tP({store:_,...F}),focusable:u}),portalRef:O,preserveTabOrder:N})});function rA(e,t=eq){return ea(function(r){let n=t();return tS(r.store||n,e=>!r.unmountOnHide||(null==e?void 0:e.mounted)||!!r.open)?(0,eo.jsx)(e,{...r}):null})}rA(ea(function(e){return el("div",rf(e))}),eq);let rh=Math.min,rm=Math.max,rp=Math.round,rB=Math.floor,rC=e=>({x:e,y:e}),rg={left:"right",right:"left",bottom:"top",top:"bottom"},rv={start:"end",end:"start"};function ry(e,t){return"function"==typeof e?e(t):e}function rb(e){return e.split("-")[0]}function rE(e){return e.split("-")[1]}function rM(e){return"x"===e?"y":"x"}function rF(e){return"y"===e?"height":"width"}let rS=new Set(["top","bottom"]);function rR(e){return rS.has(rb(e))?"y":"x"}function rI(e){return e.replace(/start|end/g,e=>rv[e])}let rT=["left","right"],rx=["right","left"],rG=["top","bottom"],rD=["bottom","top"];function rw(e){return e.replace(/left|right|bottom|top/g,e=>rg[e])}function rL(e){return"number"!=typeof e?{top:0,right:0,bottom:0,left:0,...e}:{top:e,right:e,bottom:e,left:e}}function r_(e){let{x:t,y:r,width:n,height:i}=e;return{width:n,height:i,top:r,left:t,right:t+n,bottom:r+i,x:t,y:r}}function rO(e,t,r){let n,{reference:i,floating:o}=e,a=rR(t),s=rM(rR(t)),l=rF(s),u=rb(t),c="y"===a,d=i.x+i.width/2-o.width/2,f=i.y+i.height/2-o.height/2,A=i[l]/2-o[l]/2;switch(u){case"top":n={x:d,y:i.y-o.height};break;case"bottom":n={x:d,y:i.y+i.height};break;case"right":n={x:i.x+i.width,y:f};break;case"left":n={x:i.x-o.width,y:f};break;default:n={x:i.x,y:i.y}}switch(rE(t)){case"start":n[s]-=A*(r&&c?-1:1);break;case"end":n[s]+=A*(r&&c?-1:1)}return n}async function rH(e,t){var r;void 0===t&&(t={});let{x:n,y:i,platform:o,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:A=0}=ry(t,e),h=rL(A),m=s[f?"floating"===d?"reference":"floating":d],p=r_(await o.getClippingRect({element:null==(r=await (null==o.isElement?void 0:o.isElement(m)))||r?m:m.contextElement||await (null==o.getDocumentElement?void 0:o.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),B="floating"===d?{x:n,y:i,width:a.floating.width,height:a.floating.height}:a.reference,C=await (null==o.getOffsetParent?void 0:o.getOffsetParent(s.floating)),g=await (null==o.isElement?void 0:o.isElement(C))&&await (null==o.getScale?void 0:o.getScale(C))||{x:1,y:1},v=r_(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:B,offsetParent:C,strategy:l}):B);return{top:(p.top-v.top+h.top)/g.y,bottom:(v.bottom-p.bottom+h.bottom)/g.y,left:(p.left-v.left+h.left)/g.x,right:(v.right-p.right+h.right)/g.x}}let rP=async(e,t,r)=>{let{placement:n="bottom",strategy:i="absolute",middleware:o=[],platform:a}=r,s=o.filter(Boolean),l=await (null==a.isRTL?void 0:a.isRTL(t)),u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:d}=rO(u,n,l),f=n,A={},h=0;for(let r=0;rtypeof window}function rk(e){return rQ(e)?(e.nodeName||"").toLowerCase():"#document"}function rK(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function rj(e){var t;return null==(t=(rQ(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function rQ(e){return!!rN()&&(e instanceof Node||e instanceof rK(e).Node)}function rX(e){return!!rN()&&(e instanceof Element||e instanceof rK(e).Element)}function rV(e){return!!rN()&&(e instanceof HTMLElement||e instanceof rK(e).HTMLElement)}function rq(e){return!(!rN()||"u"{try{return e.matches(t)}catch(e){return!1}})}let r0=["transform","translate","scale","rotate","perspective"],r1=["transform","translate","scale","rotate","perspective","filter"],r9=["paint","layout","strict","content"];function r8(e){let t=r2(),r=rX(e)?r4(e):e;return r0.some(e=>!!r[e]&&"none"!==r[e])||!!r.containerType&&"normal"!==r.containerType||!t&&!!r.backdropFilter&&"none"!==r.backdropFilter||!t&&!!r.filter&&"none"!==r.filter||r1.some(e=>(r.willChange||"").includes(e))||r9.some(e=>(r.contain||"").includes(e))}function r2(){return!("u"rX(e)&&"body"!==rk(e)),i=null,o="fixed"===r4(e).position,a=o?r5(e):e;for(;rX(a)&&!r6(a);){let t=r4(a),r=r8(a);r||"fixed"!==t.position||(i=null),(o?!r&&!i:!r&&"static"===t.position&&!!i&&nc.has(i.position)||rY(a)&&!r&&function e(t,r){let n=r5(t);return!(n===r||!rX(n)||r6(n))&&("fixed"===r4(n).position||e(n,r))}(e,a))?n=n.filter(e=>e!==a):i=t,a=r5(a)}return t.set(e,n),n}(t,this._c):[].concat(r),n],a=o[0],s=o.reduce((e,r)=>{let n=nd(t,r,i);return e.top=rm(n.top,e.top),e.right=rh(n.right,e.right),e.bottom=rh(n.bottom,e.bottom),e.left=rm(n.left,e.left),e},nd(t,a,i));return{width:s.right-s.left,height:s.bottom-s.top,x:s.left,y:s.top}},getOffsetParent:nh,getElementRects:nm,getClientRects:function(e){return Array.from(e.getClientRects())},getDimensions:function(e){let{width:t,height:r}=nr(e);return{width:t,height:r}},getScale:ni,isElement:rX,isRTL:function(e){return"rtl"===r4(e).direction}};function nB(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function nC(e=0,t=0,r=0,n=0){if("function"==typeof DOMRect)return new DOMRect(e,t,r,n);let i={x:e,y:t,width:r,height:n,top:t,right:e+r,bottom:t+n,left:e};return{...i,toJSON:()=>i}}function ng(e){return/^(?:top|bottom|left|right)(?:-(?:start|end))?$/.test(e)}function nv(e){let t=window.devicePixelRatio||1;return Math.round(e*t)/t}var ny=eu(function({store:e,modal:t=!1,portal:r=!!t,preserveTabOrder:n=!0,autoFocusOnShow:i=!0,wrapperProps:o,fixed:a=!1,flip:s=!0,shift:l=0,slide:u=!0,overlap:c=!1,sameWidth:d=!1,fitViewport:f=!1,gutter:A,arrowPadding:h=4,overflowPadding:m=8,getAnchorRect:p,updatePosition:B,...C}){let g=e0();M(e=e||g,!1);let v=e.useState("arrowElement"),y=e.useState("anchorElement"),b=e.useState("disclosureElement"),E=e.useState("popoverElement"),F=e.useState("contentElement"),S=e.useState("placement"),R=e.useState("mounted"),I=e.useState("rendered"),x=(0,T.useRef)(null),[G,D]=(0,T.useState)(!1),{portalRef:w,domReady:L}=z(r,C.portalRef),_=Q(p),O=Q(B),H=!!B;j(()=>{if(!(null==E?void 0:E.isConnected))return;E.style.setProperty("--popover-overflow-padding",`${m}px`);let t={contextElement:y||void 0,getBoundingClientRect:()=>{let e=null==_?void 0:_(y);return e||!y?function(e){if(!e)return nC();let{x:t,y:r,width:n,height:i}=e;return nC(t,r,n,i)}(e):y.getBoundingClientRect()}},r=async()=>{var r,n,i,o,p;let B,C,g;if(!R)return;v||(x.current=x.current||document.createElement("div"));let y=v||x.current,b=[(r={gutter:A,shift:l},void 0===(n=({placement:e})=>{var t;let n=((null==y?void 0:y.clientHeight)||0)/2,i="number"==typeof r.gutter?r.gutter+n:null!=(t=r.gutter)?t:n;return{crossAxis:e.split("-")[1]?void 0:r.shift,mainAxis:i,alignmentAxis:r.shift}})&&(n=0),{name:"offset",options:n,async fn(e){var t,r;let{x:i,y:o,placement:a,middlewareData:s}=e,l=await rU(e,n);return a===(null==(t=s.offset)?void 0:t.placement)&&null!=(r=s.arrow)&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:a}}}}),function(e){var t;if(!1===e.flip)return;let r="string"==typeof e.flip?e.flip.split(" "):void 0;return M(!r||r.every(ng),!1),{name:"flip",options:t={padding:e.overflowPadding,fallbackPlacements:r},async fn(e){var r,n,i,o,a,s,l,u;let c,d,f,{placement:A,middlewareData:h,rects:m,initialPlacement:p,platform:B,elements:C}=e,{mainAxis:g=!0,crossAxis:v=!0,fallbackPlacements:y,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:E="none",flipAlignment:M=!0,...F}=ry(t,e);if(null!=(r=h.arrow)&&r.alignmentOffset)return{};let S=rb(A),R=rR(p),I=rb(p)===p,T=await (null==B.isRTL?void 0:B.isRTL(C.floating)),x=y||(I||!M?[rw(p)]:(c=rw(p),[rI(p),c,rI(c)])),G="none"!==E;!y&&G&&x.push(...(d=rE(p),f=function(e,t,r){switch(e){case"top":case"bottom":if(r)return t?rx:rT;return t?rT:rx;case"left":case"right":return t?rG:rD;default:return[]}}(rb(p),"start"===E,T),d&&(f=f.map(e=>e+"-"+d),M&&(f=f.concat(f.map(rI)))),f));let D=[p,...x],w=await B.detectOverflow(e,F),L=[],_=(null==(n=h.flip)?void 0:n.overflows)||[];if(g&&L.push(w[S]),v){let e,t,r,n,i=(s=A,l=m,void 0===(u=T)&&(u=!1),e=rE(s),r=rF(t=rM(rR(s))),n="x"===t?e===(u?"end":"start")?"right":"left":"start"===e?"bottom":"top",l.reference[r]>l.floating[r]&&(n=rw(n)),[n,rw(n)]);L.push(w[i[0]],w[i[1]])}if(_=[..._,{placement:A,overflows:L}],!L.every(e=>e<=0)){let e=((null==(i=h.flip)?void 0:i.index)||0)+1,t=D[e];if(t&&("alignment"!==v||R===rR(t)||_.every(e=>rR(e.placement)!==R||e.overflows[0]>0)))return{data:{index:e,overflows:_},reset:{placement:t}};let r=null==(o=_.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0])?void 0:o.placement;if(!r)switch(b){case"bestFit":{let e=null==(a=_.filter(e=>{if(G){let t=rR(e.placement);return t===R||"y"===t}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0])?void 0:a[0];e&&(r=e);break}case"initialPlacement":r=p}if(A!==r)return{reset:{placement:r}}}return{}}}}({flip:s,overflowPadding:m}),function(e){if(e.slide||e.overlap){var t,r;return{name:"shift",options:r={mainAxis:e.slide,crossAxis:e.overlap,padding:e.overflowPadding,limiter:(void 0===t&&(t={}),{options:t,fn(e){let{x:r,y:n,placement:i,rects:o,middlewareData:a}=e,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=ry(t,e),c={x:r,y:n},d=rR(i),f=rM(d),A=c[f],h=c[d],m=ry(s,e),p="number"==typeof m?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){let e="y"===f?"height":"width",t=o.reference[f]-o.floating[e]+p.mainAxis,r=o.reference[f]+o.reference[e]-p.mainAxis;Ar&&(A=r)}if(u){var B,C;let e="y"===f?"width":"height",t=rJ.has(rb(i)),r=o.reference[d]-o.floating[e]+(t&&(null==(B=a.offset)?void 0:B[d])||0)+(t?0:p.crossAxis),n=o.reference[d]+o.reference[e]+(t?0:(null==(C=a.offset)?void 0:C[d])||0)-(t?p.crossAxis:0);hn&&(h=n)}return{[f]:A,[d]:h}}})},async fn(e){let{x:t,y:n,placement:i,platform:o}=e,{mainAxis:a=!0,crossAxis:s=!1,limiter:l={fn:e=>{let{x:t,y:r}=e;return{x:t,y:r}}},...u}=ry(r,e),c={x:t,y:n},d=await o.detectOverflow(e,u),f=rR(rb(i)),A=rM(f),h=c[A],m=c[f];if(a){let e="y"===A?"top":"left",t="y"===A?"bottom":"right",r=h+d[e],n=h-d[t];h=rm(r,rh(h,n))}if(s){let e="y"===f?"top":"left",t="y"===f?"bottom":"right",r=m+d[e],n=m-d[t];m=rm(r,rh(m,n))}let p=l.fn({...e,[A]:h,[f]:m});return{...p,data:{x:p.x-t,y:p.y-n,enabled:{[A]:a,[f]:s}}}}}}}({slide:u,shift:l,overlap:c,overflowPadding:m}),function(e,t){if(e){let r;return{name:"arrow",options:r={element:e,padding:t.arrowPadding},async fn(e){let{x:t,y:n,placement:i,rects:o,platform:a,elements:s,middlewareData:l}=e,{element:u,padding:c=0}=ry(r,e)||{};if(null==u)return{};let d=rL(c),f={x:t,y:n},A=rM(rR(i)),h=rF(A),m=await a.getDimensions(u),p="y"===A,B=p?"clientHeight":"clientWidth",C=o.reference[h]+o.reference[A]-f[A]-o.floating[h],g=f[A]-o.reference[A],v=await (null==a.getOffsetParent?void 0:a.getOffsetParent(u)),y=v?v[B]:0;y&&await (null==a.isElement?void 0:a.isElement(v))||(y=s.floating[B]||o.floating[h]);let b=y/2-m[h]/2-1,E=rh(d[p?"top":"left"],b),M=rh(d[p?"bottom":"right"],b),F=y-m[h]-M,S=y/2-m[h]/2+(C/2-g/2),R=rm(E,rh(S,F)),I=!l.arrow&&null!=rE(i)&&S!==R&&o.reference[h]/2-(S{},...d}=ry(o,e),f=await l.detectOverflow(e,d),A=rb(a),h=rE(a),m="y"===rR(a),{width:p,height:B}=s.floating;"top"===A||"bottom"===A?(n=A,i=h===(await (null==l.isRTL?void 0:l.isRTL(u.floating))?"start":"end")?"left":"right"):(i=A,n="end"===h?"top":"bottom");let C=B-f.top-f.bottom,g=p-f.left-f.right,v=rh(B-f[n],C),y=rh(p-f[i],g),b=!e.middlewareData.shift,E=v,M=y;if(null!=(t=e.middlewareData.shift)&&t.enabled.x&&(M=g),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(E=C),b&&!h){let e=rm(f.left,0),t=rm(f.right,0),r=rm(f.top,0),n=rm(f.bottom,0);m?M=p-2*(0!==e||0!==t?e+t:rm(f.left,f.right)):E=B-2*(0!==r||0!==n?r+n:rm(f.top,f.bottom))}await c({...e,availableWidth:M,availableHeight:E});let F=await l.getDimensions(u.floating);return p!==F.width||B!==F.height?{reset:{rects:!0}}:{}}}],F=await (p={placement:S,strategy:a?"fixed":"absolute",middleware:b},B=new Map,g={...(C={platform:np,...p}).platform,_c:B},rP(t,E,{...C,platform:g}));null==e||e.setState("currentPlacement",F.placement),D(!0);let I=nv(F.x),T=nv(F.y);if(Object.assign(E.style,{top:"0",left:"0",transform:`translate3d(${I}px,${T}px,0)`}),y&&F.middlewareData.arrow){let{x:e,y:t}=F.middlewareData.arrow,r=F.placement.split("-")[0],n=y.clientWidth/2,i=y.clientHeight/2,o=null!=e?e+n:-n,a=null!=t?t+i:-i;E.style.setProperty("--popover-transform-origin",{top:`${o}px calc(100% + ${i}px)`,bottom:`${o}px ${-i}px`,left:`calc(100% + ${n}px) ${a}px`,right:`${-n}px ${a}px`}[r]),Object.assign(y.style,{left:null!=e?`${e}px`:"",top:null!=t?`${t}px`:"",[r]:"100%"})}},n=function(e,t,r,n){let i;void 0===n&&(n={});let{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:s="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:u=!1}=n,c=nn(e),d=o||a?[...c?ne(c):[],...ne(t)]:[];d.forEach(e=>{o&&e.addEventListener("scroll",r,{passive:!0}),a&&e.addEventListener("resize",r)});let f=c&&l?function(e,t){let r,n=null,i=rj(e);function o(){var e;clearTimeout(r),null==(e=n)||e.disconnect(),n=null}return!function a(s,l){void 0===s&&(s=!1),void 0===l&&(l=1),o();let u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:A}=u;if(s||t(),!f||!A)return;let h={rootMargin:-rB(d)+"px "+-rB(i.clientWidth-(c+f))+"px "+-rB(i.clientHeight-(d+A))+"px "+-rB(c)+"px",threshold:rm(0,rh(1,l))||1},m=!0;function p(t){let n=t[0].intersectionRatio;if(n!==l){if(!m)return a();n?a(!1,n):r=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==n||nB(u,e.getBoundingClientRect())||a(),m=!1}try{n=new IntersectionObserver(p,{...h,root:i.ownerDocument})}catch(e){n=new IntersectionObserver(p,h)}n.observe(e)}(!0),o}(c,r):null,A=-1,h=null;s&&(h=new ResizeObserver(e=>{let[n]=e;n&&n.target===c&&h&&(h.unobserve(t),cancelAnimationFrame(A),A=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),r()}),c&&!u&&h.observe(c),h.observe(t));let m=u?ns(e):null;return u&&function t(){let n=ns(e);m&&!nB(m,n)&&r(),m=n,i=requestAnimationFrame(t)}(),r(),()=>{var e;d.forEach(e=>{o&&e.removeEventListener("scroll",r),a&&e.removeEventListener("resize",r)}),null==f||f(),null==(e=h)||e.disconnect(),h=null,u&&cancelAnimationFrame(i)}}(t,E,async()=>{H?(await O({updatePosition:r}),D(!0)):await r()},{elementResize:"function"==typeof ResizeObserver});return()=>{D(!1),n()}},[e,I,E,v,y,E,S,R,L,a,s,l,u,c,d,f,A,h,m,_,H,O]),j(()=>{if(!R||!L||!(null==E?void 0:E.isConnected)||!(null==F?void 0:F.isConnected))return;let e=()=>{E.style.zIndex=getComputedStyle(F).zIndex};e();let t=requestAnimationFrame(()=>{t=requestAnimationFrame(e)});return()=>cancelAnimationFrame(t)},[R,L,E,F]);let P=a?"fixed":"absolute";return C=Z(C,t=>(0,eo.jsx)("div",{...o,style:{position:P,top:0,left:0,width:"max-content",...null==o?void 0:o.style},ref:null==e?void 0:e.setPopoverElement,children:t}),[e,P,o]),C={"data-placing":!G||void 0,...C=Z(C,t=>(0,eo.jsx)(e9,{value:e,children:t}),[e]),style:{position:"relative",...C.style}},C=rf({store:e,modal:t,portal:r,preserveTabOrder:n,preserveTabOrderAnchor:b||y,autoFocusOnShow:G&&i,...C,portalRef:w})});rA(ea(function(e){return el("div",ny(e))}),e0);var nb=eu(function({store:e,modal:t,tabIndex:r,alwaysVisible:i,autoFocusOnHide:o=!0,hideOnInteractOutside:a=!0,...s}){let l=e7();M(e=e||l,!1);let u=e.useState("baseElement"),c=(0,T.useRef)(!1),d=tS(e.tag,e=>null==e?void 0:e.renderedItems.length);return s=tU({store:e,alwaysVisible:i,...s}),s=ny({store:e,modal:t,alwaysVisible:i,backdrop:!1,autoFocusOnShow:!1,finalFocus:u,preserveTabOrderAnchor:null,unstable_treeSnapshotKey:d,...s,getPersistentElements(){var r;let i=(null==(r=s.getPersistentElements)?void 0:r.call(s))||[];if(!t||!e)return i;let{contentElement:o,baseElement:a}=e.getState();if(!a)return i;let l=n(a),u=[];if((null==o?void 0:o.id)&&u.push(`[aria-controls~="${o.id}"]`),(null==a?void 0:a.id)&&u.push(`[aria-controls~="${a.id}"]`),!u.length)return[...i,a];let c=u.join(",");return[...i,...l.querySelectorAll(c)]},autoFocusOnHide:e=>!F(o,e)&&(!c.current||(c.current=!1,!1)),hideOnInteractOutside(t){var r,n;let i=null==e?void 0:e.getState(),o=null==(r=null==i?void 0:i.contentElement)?void 0:r.id,s=null==(n=null==i?void 0:i.baseElement)?void 0:n.id;if(function(e,...t){if(!e)return!1;if("id"in e){let r=t.filter(Boolean).map(e=>`[aria-controls~="${e}"]`).join(", ");return!!r&&e.matches(r)}return!1}(t.target,o,s))return!1;let l="function"==typeof a?a(t):a;return l&&(c.current="click"===t.type),l}})}),nE=rA(ea(function(e){return el("div",nb(e))}),e7);e.s(["ComboboxPopover",()=>nE],1559),(0,T.createContext)(null),(0,T.createContext)(null);var nM=ec([ep],[eB]),nF=nM.useContext;nM.useScopedContext,nM.useProviderContext,nM.ContextProvider,nM.ScopedContextProvider;var nS={id:null};function nR(e,t){return e.find(e=>t?!e.disabled&&e.id!==t:!e.disabled)}function nI(e,t){return e.filter(e=>e.rowId===t)}function nT(e){let t=[];for(let r of e){let e=t.find(e=>{var t;return(null==(t=e[0])?void 0:t.rowId)===r.rowId});e?e.push(r):t.push([r])}return t}function nx(e){let t=0;for(let{length:r}of e)r>t&&(t=r);return t}var nG=w()&&G();function nD({tag:e,...t}={}){let r=td(t.store,function(e,...t){if(e)return tn(e,"pick")(...t)}(e,["value","rtl"]));tf(t,r);let i=null==e?void 0:e.getState(),o=null==r?void 0:r.getState(),a=I(t.activeId,null==o?void 0:o.activeId,t.defaultActiveId,null),s=function(e={}){var t;let r=null==(t=e.store)?void 0:t.getState(),i=function(e={}){var t,r;tf(e,e.store);let i=null==(t=e.store)?void 0:t.getState(),o=I(e.items,null==i?void 0:i.items,e.defaultItems,[]),a=new Map(o.map(e=>[e.id,e])),s={items:o,renderedItems:I(null==i?void 0:i.renderedItems,[])},l=null==(r=e.store)?void 0:r.__unstablePrivateStore,u=ti({items:o,renderedItems:s.renderedItems},l),c=ti(s,e.store),d=e=>{var t;let r,n,i=(t=e=>e.element,r=e.map((e,t)=>[t,e]),n=!1,(r.sort(([e,r],[i,o])=>{var a;let s=t(r),l=t(o);return s!==l&&s&&l?(a=s,l.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_PRECEDING)?(e>i&&(n=!0),-1):(et):e);u.setState("renderedItems",i),c.setState("renderedItems",i)};to(c,()=>ta(u)),to(u,()=>tu(u,["items"],e=>{c.setState("items",e.items)})),to(u,()=>tu(u,["renderedItems"],e=>{let t=!0,r=requestAnimationFrame(()=>{let{renderedItems:t}=c.getState();e.renderedItems!==t&&d(e.renderedItems)});if("function"!=typeof IntersectionObserver)return()=>cancelAnimationFrame(r);let i=new IntersectionObserver(()=>{if(t){t=!1;return}cancelAnimationFrame(r),r=requestAnimationFrame(()=>d(e.renderedItems))},{root:function(e){var t;let r=e.find(e=>!!e.element),i=[...e].reverse().find(e=>!!e.element),o=null==(t=null==r?void 0:r.element)?void 0:t.parentElement;for(;o&&(null==i?void 0:i.element);){let e=o;if(i&&e.contains(i.element))return o;o=o.parentElement}return n(o).body}(e.renderedItems)});for(let t of e.renderedItems)t.element&&i.observe(t.element);return()=>{cancelAnimationFrame(r),i.disconnect()}}));let f=(e,t,r=!1)=>{let n;return t(t=>{let r=t.findIndex(({id:t})=>t===e.id),i=t.slice();if(-1!==r){let o={...n=t[r],...e};i[r]=o,a.set(e.id,o)}else i.push(e),a.set(e.id,e);return i}),()=>{t(t=>{if(!n)return r&&a.delete(e.id),t.filter(({id:t})=>t!==e.id);let i=t.findIndex(({id:t})=>t===e.id);if(-1===i)return t;let o=t.slice();return o[i]=n,a.set(e.id,n),o})}},A=e=>f(e,e=>u.setState("items",e),!0);return{...c,registerItem:A,renderItem:e=>b(A(e),f(e,e=>u.setState("renderedItems",e))),item:e=>{if(!e)return null;let t=a.get(e);if(!t){let{items:r}=u.getState();(t=r.find(t=>t.id===e))&&a.set(e,t)}return t||null},__unstablePrivateStore:u}}(e),o=I(e.activeId,null==r?void 0:r.activeId,e.defaultActiveId),a=ti({...i.getState(),id:I(e.id,null==r?void 0:r.id,`id-${Math.random().toString(36).slice(2,8)}`),activeId:o,baseElement:I(null==r?void 0:r.baseElement,null),includesBaseElement:I(e.includesBaseElement,null==r?void 0:r.includesBaseElement,null===o),moves:I(null==r?void 0:r.moves,0),orientation:I(e.orientation,null==r?void 0:r.orientation,"both"),rtl:I(e.rtl,null==r?void 0:r.rtl,!1),virtualFocus:I(e.virtualFocus,null==r?void 0:r.virtualFocus,!1),focusLoop:I(e.focusLoop,null==r?void 0:r.focusLoop,!1),focusWrap:I(e.focusWrap,null==r?void 0:r.focusWrap,!1),focusShift:I(e.focusShift,null==r?void 0:r.focusShift,!1)},i,e.store);to(a,()=>tl(a,["renderedItems","activeId"],e=>{a.setState("activeId",t=>{var r;return void 0!==t?t:null==(r=nR(e.renderedItems))?void 0:r.id})}));let s=(e="next",t={})=>{var r,n;let i=a.getState(),{skip:o=0,activeId:s=i.activeId,focusShift:l=i.focusShift,focusLoop:u=i.focusLoop,focusWrap:c=i.focusWrap,includesBaseElement:d=i.includesBaseElement,renderedItems:f=i.renderedItems,rtl:A=i.rtl}=t,h="up"===e||"down"===e,m="next"===e||"down"===e,p=h?eN(function(e,t,r){let n=nx(e);for(let i of e)for(let e=0;ee.id===s);if(!B)return null==(n=nR(p))?void 0:n.id;let C=p.some(e=>e.rowId),g=p.indexOf(B),v=p.slice(g+1),y=nI(v,B.rowId);if(o){let e=y.filter(e=>s?!e.disabled&&e.id!==s:!e.disabled),t=e.slice(o)[0]||e[e.length-1];return null==t?void 0:t.id}let b=u&&(h?"horizontal"!==u:"vertical"!==u),E=C&&c&&(h?"horizontal"!==c:"vertical"!==c),M=m?(!C||h)&&b&&d:!!h&&d;if(b){let e=nR(function(e,t,r=!1){let n=e.findIndex(e=>e.id===t);return[...e.slice(n+1),...r?[nS]:[],...e.slice(0,n)]}(E&&!M?p:nI(p,B.rowId),s,M),s);return null==e?void 0:e.id}if(E){let e=nR(M?y:v,s);return M?(null==e?void 0:e.id)||null:null==e?void 0:e.id}let F=nR(y,s);return!F&&M?null:null==F?void 0:F.id};return{...i,...a,setBaseElement:e=>a.setState("baseElement",e),setActiveId:e=>a.setState("activeId",e),move:e=>{void 0!==e&&(a.setState("activeId",e),a.setState("moves",e=>e+1))},first:()=>{var e;return null==(e=nR(a.getState().renderedItems))?void 0:e.id},last:()=>{var e;return null==(e=nR(ek(a.getState().renderedItems)))?void 0:e.id},next:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("next",e)),previous:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("previous",e)),down:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("down",e)),up:e=>(void 0!==e&&"number"==typeof e&&(e={skip:e}),s("up",e))}}({...t,activeId:a,includesBaseElement:I(t.includesBaseElement,null==o?void 0:o.includesBaseElement,!0),orientation:I(t.orientation,null==o?void 0:o.orientation,"vertical"),focusLoop:I(t.focusLoop,null==o?void 0:o.focusLoop,!0),focusWrap:I(t.focusWrap,null==o?void 0:o.focusWrap,!0),virtualFocus:I(t.virtualFocus,null==o?void 0:o.virtualFocus,!0)}),l=function({popover:e,...t}={}){let r=td(t.store,tc(e,["arrowElement","anchorElement","contentElement","popoverElement","disclosureElement"]));tf(t,r);let n=null==r?void 0:r.getState(),i=ru({...t,store:r}),o=I(t.placement,null==n?void 0:n.placement,"bottom"),a=ti({...i.getState(),placement:o,currentPlacement:o,anchorElement:I(null==n?void 0:n.anchorElement,null),popoverElement:I(null==n?void 0:n.popoverElement,null),arrowElement:I(null==n?void 0:n.arrowElement,null),rendered:Symbol("rendered")},i,r);return{...i,...a,setAnchorElement:e=>a.setState("anchorElement",e),setPopoverElement:e=>a.setState("popoverElement",e),setArrowElement:e=>a.setState("arrowElement",e),render:()=>a.setState("rendered",Symbol("rendered"))}}({...t,placement:I(t.placement,null==o?void 0:o.placement,"bottom-start")}),u=I(t.value,null==o?void 0:o.value,t.defaultValue,""),c=I(t.selectedValue,null==o?void 0:o.selectedValue,null==i?void 0:i.values,t.defaultSelectedValue,""),d=Array.isArray(c),f={...s.getState(),...l.getState(),value:u,selectedValue:c,resetValueOnSelect:I(t.resetValueOnSelect,null==o?void 0:o.resetValueOnSelect,d),resetValueOnHide:I(t.resetValueOnHide,null==o?void 0:o.resetValueOnHide,d&&!e),activeValue:null==o?void 0:o.activeValue},A=ti(f,s,l,r);return nG&&to(A,()=>tl(A,["virtualFocus"],()=>{A.setState("virtualFocus",!1)})),to(A,()=>{if(e)return b(tl(A,["selectedValue"],t=>{Array.isArray(t.selectedValue)&&e.setValues(t.selectedValue)}),tl(e,["values"],e=>{A.setState("selectedValue",e.values)}))}),to(A,()=>tl(A,["resetValueOnHide","mounted"],e=>{!e.resetValueOnHide||e.mounted||A.setState("value",u)})),to(A,()=>tl(A,["open"],e=>{e.open||(A.setState("activeId",a),A.setState("moves",0))})),to(A,()=>tl(A,["moves","activeId"],(e,t)=>{e.moves===t.moves&&A.setState("activeValue",void 0)})),to(A,()=>tu(A,["moves","renderedItems"],(e,t)=>{if(e.moves===t.moves)return;let{activeId:r}=A.getState(),n=s.item(r);A.setState("activeValue",null==n?void 0:n.value)})),{...l,...s,...A,tag:e,setValue:e=>A.setState("value",e),resetValue:()=>A.setState("value",f.value),setSelectedValue:e=>A.setState("selectedValue",e)}}function nw(e={}){var t,r,n,i,o,a,s,l;let u;t=e,u=nF();let[c,d]=tT(nD,e={id:V((r=t={...t,tag:void 0!==t.tag?t.tag:u}).id),...r});return q(d,[(n=e).tag]),tI(c,n,"value","setValue"),tI(c,n,"selectedValue","setSelectedValue"),tI(c,n,"resetValueOnHide"),tI(c,n,"resetValueOnSelect"),Object.assign((a=c,q(s=d,[(l=n).popover]),tI(a,l,"placement"),i=ra(a,s,l),o=i,q(d,[n.store]),tI(o,n,"items","setItems"),tI(i=o,n,"activeId","setActiveId"),tI(i,n,"includesBaseElement"),tI(i,n,"virtualFocus"),tI(i,n,"orientation"),tI(i,n,"rtl"),tI(i,n,"focusLoop"),tI(i,n,"focusWrap"),tI(i,n,"focusShift"),i),{tag:n.tag})}function nL(e={}){let t=nw(e);return(0,eo.jsx)(e5,{value:t,children:e.children})}e.s(["useComboboxStore",()=>nw],18364),e.s(["ComboboxProvider",()=>nL],78440);var n_=(0,T.createContext)(void 0),nO=eu(function(e){let[t,r]=(0,T.useState)();return R(e={role:"group","aria-labelledby":t,...e=Z(e,e=>(0,eo.jsx)(n_.Provider,{value:r,children:e}),[])})});ea(function(e){return el("div",nO(e))});var nH=eu(function({store:e,...t}){return nO(t)});ea(function(e){return el("div",nH(e))});var nP=eu(function({store:e,...t}){let r=e4();return M(e=e||r,!1),"grid"===h(e.useState("contentElement"))&&(t={role:"rowgroup",...t}),t=nH({store:e,...t})}),nJ=ea(function(e){return el("div",nP(e))});e.s(["ComboboxGroup",()=>nJ],59129);var nU=eu(function(e){let t=(0,T.useContext)(n_),r=V(e.id);return j(()=>(null==t||t(r),()=>null==t?void 0:t(void 0)),[t,r]),R(e={id:r,"aria-hidden":!0,...e})});ea(function(e){return el("div",nU(e))});var nN=eu(function({store:e,...t}){return nU(t)});ea(function(e){return el("div",nN(e))});var nk=eu(function(e){return nN(e)}),nK=ea(function(e){return el("div",nk(e))});e.s(["ComboboxGroupLabel",()=>nK],25998);var nj=e.i(38360);let nQ={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},nX=(e,t)=>String(e.rankedValue).localeCompare(String(t.rankedValue));function nV(e,t,r={}){let{keys:n,threshold:i=nQ.MATCHES,baseSort:o=nX,sorter:a=e=>e.sort((e,t)=>(function(e,t,r){let{rank:n,keyIndex:i}=e,{rank:o,keyIndex:a}=t;return n!==o?n>o?-1:1:i===a?r(e,t):i{let s=nq(i,u,c),l=t,{minRanking:d,maxRanking:f,threshold:A}=o;return s=nQ.MATCHES?s=d:s>f&&(s=f),s>e&&(e=s,r=a,n=A,l=i),{rankedValue:l,rank:e,keyIndex:r,keyThreshold:n}},{rankedValue:s,rank:nQ.NO_MATCH,keyIndex:-1,keyThreshold:c.threshold}):{rankedValue:s,rank:nq(s,u,c),keyIndex:-1,keyThreshold:c.threshold}),{rank:f,keyThreshold:A=i}=d;return f>=A&&e.push({...d,item:o,index:a}),e},[])).map(({item:e})=>e)}function nq(e,t,r){if(e=nW(e,r),(t=nW(t,r)).length>e.length)return nQ.NO_MATCH;if(e===t)return nQ.CASE_SENSITIVE_EQUAL;let n=function*(e,t){let r=-1;for(;(r=e.indexOf(t,r+1))>-1;)yield r;return -1}(e=e.toLowerCase(),t=t.toLowerCase()),i=n.next(),o=i.value;if(e.length===t.length&&0===o)return nQ.EQUAL;if(0===o)return nQ.STARTS_WITH;let a=i;for(;!a.done;){if(a.value>0&&" "===e[a.value-1])return nQ.WORD_STARTS_WITH;a=n.next()}return o>0?nQ.CONTAINS:1===t.length?nQ.NO_MATCH:(function(e){let t="",r=" ";for(let n=0;n-1))return nQ.NO_MATCH;return r=o-s,n=i/t.length,nQ.MATCHES+1/r*n}(e,t)}function nW(e,{keepDiacritics:t}){return e=`${e}`,t||(e=(0,nj.default)(e)),e}nV.rankings=nQ;let nY={maxRanking:1/0,minRanking:-1/0};e.s(["matchSorter",()=>nV],70238)},29402,(e,t,r)=>{var n,i,o,a,s="__lodash_hash_undefined__",l=1/0,u="[object Arguments]",c="[object Array]",d="[object Boolean]",f="[object Date]",A="[object Error]",h="[object Function]",m="[object Map]",p="[object Number]",B="[object Object]",C="[object Promise]",g="[object RegExp]",v="[object Set]",y="[object String]",b="[object Symbol]",E="[object WeakMap]",M="[object ArrayBuffer]",F="[object DataView]",S=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,R=/^\w*$/,I=/^\./,T=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,x=/\\(\\)?/g,G=/^\[object .+?Constructor\]$/,D=/^(?:0|[1-9]\d*)$/,w={};w["[object Float32Array]"]=w["[object Float64Array]"]=w["[object Int8Array]"]=w["[object Int16Array]"]=w["[object Int32Array]"]=w["[object Uint8Array]"]=w["[object Uint8ClampedArray]"]=w["[object Uint16Array]"]=w["[object Uint32Array]"]=!0,w[u]=w[c]=w[M]=w[d]=w[F]=w[f]=w[A]=w[h]=w[m]=w[p]=w[B]=w[g]=w[v]=w[y]=w[E]=!1;var L=e.g&&e.g.Object===Object&&e.g,_="object"==typeof self&&self&&self.Object===Object&&self,O=L||_||Function("return this")(),H=r&&!r.nodeType&&r,P=H&&t&&!t.nodeType&&t,J=P&&P.exports===H&&L.process,U=function(){try{return J&&J.binding("util")}catch(e){}}(),N=U&&U.isTypedArray;function k(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1},eb.prototype.set=function(e,t){var r=this.__data__,n=eS(r,e);return n<0?r.push([e,t]):r[n][1]=t,this},eE.prototype.clear=function(){this.__data__={hash:new ey,map:new(el||eb),string:new ey}},eE.prototype.delete=function(e){return eL(this,e).delete(e)},eE.prototype.get=function(e){return eL(this,e).get(e)},eE.prototype.has=function(e){return eL(this,e).has(e)},eE.prototype.set=function(e,t){return eL(this,e).set(e,t),this},eM.prototype.add=eM.prototype.push=function(e){return this.__data__.set(e,s),this},eM.prototype.has=function(e){return this.__data__.has(e)},eF.prototype.clear=function(){this.__data__=new eb},eF.prototype.delete=function(e){return this.__data__.delete(e)},eF.prototype.get=function(e){return this.__data__.get(e)},eF.prototype.has=function(e){return this.__data__.has(e)},eF.prototype.set=function(e,t){var r=this.__data__;if(r instanceof eb){var n=r.__data__;if(!el||n.length<199)return n.push([e,t]),this;r=this.__data__=new eE(n)}return r.set(e,t),this};var eR=(n=function(e,t){return e&&eI(e,t,e0)},function(e,t){if(null==e)return e;if(!eV(e))return n(e,t);for(var r=e.length,i=-1,o=Object(e);++is))return!1;var u=o.get(e);if(u&&o.get(t))return u==t;var c=-1,d=!0,f=1&i?new eM:void 0;for(o.set(e,t),o.set(t,e);++c-1&&e%1==0&&e-1&&e%1==0&&e<=0x1fffffffffffff}function eY(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function eZ(e){return!!e&&"object"==typeof e}function ez(e){return"symbol"==typeof e||eZ(e)&&ee.call(e)==b}var e$=N?K(N):function(e){return eZ(e)&&eW(e.length)&&!!w[ee.call(e)]};function e0(e){return eV(e)?function(e,t){var r=eX(e)||eQ(e)?function(e,t){for(var r=-1,n=Array(e);++rt||o&&a&&l&&!s&&!u||n&&a&&l||!r&&l||!i)return 1;if(!n&&!o&&!u&&e=s)return l;return l*("desc"==r[n]?-1:1)}}return e.index-t.index}(e,t,r)});l--;)s[l]=s[l].value;return s}(e,t,r))}},97442,e=>{e.v({Group:"MissionSelect-module__N_AIjG__Group",GroupLabel:"MissionSelect-module__N_AIjG__GroupLabel",Input:"MissionSelect-module__N_AIjG__Input",InputWrapper:"MissionSelect-module__N_AIjG__InputWrapper",Item:"MissionSelect-module__N_AIjG__Item",ItemHeader:"MissionSelect-module__N_AIjG__ItemHeader",ItemMissionName:"MissionSelect-module__N_AIjG__ItemMissionName",ItemName:"MissionSelect-module__N_AIjG__ItemName",ItemType:"MissionSelect-module__N_AIjG__ItemType",ItemTypes:"MissionSelect-module__N_AIjG__ItemTypes",List:"MissionSelect-module__N_AIjG__List",NoResults:"MissionSelect-module__N_AIjG__NoResults",Popover:"MissionSelect-module__N_AIjG__Popover",SelectedName:"MissionSelect-module__N_AIjG__SelectedName",SelectedValue:"MissionSelect-module__N_AIjG__SelectedValue",Shortcut:"MissionSelect-module__N_AIjG__Shortcut"})},38847,e=>{"use strict";var t=e.i(80902),r=e.i(22289),n=e.i(71645);function i(e,t,n){try{return e(t)}catch(e){return(0,r.l)("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":""),t,e,n),null}}function o(e){function t(t){if(void 0===t)return null;let r="";if(Array.isArray(t)){if(void 0===t[0])return null;r=t[0]}return"string"==typeof t&&(r=t),i(e.parse,r)}return{type:"single",eq:(e,t)=>e===t,...e,parseServerSide:t,withDefault(e){return{...this,defaultValue:e,parseServerSide:r=>t(r)??e}},withOptions(e){return{...this,...e}}}}o({parse:e=>e,serialize:String}),o({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),o({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),o({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(1&t.length?"0":"")+t}}),o({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String});let a=o({parse:e=>"true"===e.toLowerCase(),serialize:String});function s(e,t){return e.valueOf()===t.valueOf()}o({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:s}),o({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:s}),o({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:s});let l=(0,t.r)(),u={};function c(e,r,n,o,a,s){let l=!1,u=Object.entries(e).reduce((e,[u,c])=>{var d;let f=r?.[u]??u,A=o[f],h="multi"===c.type?[]:null,m=void 0===A?("multi"===c.type?n?.getAll(f):n?.get(f))??h:A;return a&&s&&((d=a[f]??h)===m||null!==d&&null!==m&&"string"!=typeof d&&"string"!=typeof m&&d.length===m.length&&d.every((e,t)=>e===m[t]))?e[u]=s[u]??null:(l=!0,e[u]=((0,t.i)(m)?null:i(c.parse,m,f))??null,a&&(a[f]=m)),e},{});if(!l){let t=Object.keys(e),r=Object.keys(s??{});l=t.length!==r.length||t.some(e=>!r.includes(e))}return{state:u,hasChanged:l}}function d(e,t){return Object.fromEntries(Object.keys(e).map(r=>[r,e[r]??t[r]??null]))}function f(e,i={}){let{parse:o,type:a,serialize:s,eq:A,defaultValue:h,...m}=i,[{[e]:p},B]=function(e,i={}){let o=(0,n.useId)(),a=(0,r.i)(),s=(0,r.a)(),{history:f="replace",scroll:A=a?.scroll??!1,shallow:h=a?.shallow??!0,throttleMs:m=t.s.timeMs,limitUrlUpdates:p=a?.limitUrlUpdates,clearOnDefault:B=a?.clearOnDefault??!0,startTransition:C,urlKeys:g=u}=i,v=Object.keys(e).join(","),y=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(e=>[e,g[e]??e])),[v,JSON.stringify(g)]),b=(0,r.r)(Object.values(y)),E=b.searchParams,M=(0,n.useRef)({}),F=(0,n.useMemo)(()=>Object.fromEntries(Object.keys(e).map(t=>[t,e[t].defaultValue??null])),[Object.values(e).map(({defaultValue:e})=>e).join(",")]),S=t.t.useQueuedQueries(Object.values(y)),[R,I]=(0,n.useState)(()=>c(e,g,E??new URLSearchParams,S).state),T=(0,n.useRef)(R);if((0,r.c)("[nuq+ %s `%s`] render - state: %O, iSP: %s",o,v,R,E),Object.keys(M.current).join("&")!==Object.values(y).join("&")){let{state:t,hasChanged:n}=c(e,g,E,S,M.current,T.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,v,{state:t,initialSearchParams:E,queuedQueries:S,queryRef:M.current,stateRef:T.current}),T.current=t,I(t)),M.current=Object.fromEntries(Object.entries(y).map(([t,r])=>[r,e[t]?.type==="multi"?E?.getAll(r):E?.get(r)??null]))}(0,n.useEffect)(()=>{let{state:t,hasChanged:n}=c(e,g,E,S,M.current,T.current);n&&((0,r.c)("[nuq+ %s `%s`] State changed: %O",o,v,{state:t,initialSearchParams:E,queuedQueries:S,queryRef:M.current,stateRef:T.current}),T.current=t,I(t))},[Object.values(y).map(e=>`${e}=${E?.getAll(e)}`).join("&"),JSON.stringify(S)]),(0,n.useEffect)(()=>{let t=Object.keys(e).reduce((t,n)=>(t[n]=({state:t,query:i})=>{I(a=>{let{defaultValue:s}=e[n],l=y[n],u=t??s??null;return Object.is(a[n]??s??null,u)?((0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",o,v,l,t,s,T.current),a):(T.current={...T.current,[n]:u},M.current[l]=i,(0,r.c)("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",o,v,l,t,s,T.current),T.current)})},t),{});for(let n of Object.keys(e)){let e=y[n];(0,r.c)("[nuq+ %s `%s`] Subscribing to sync for `%s`",o,e,v),l.on(e,t[n])}return()=>{for(let n of Object.keys(e)){let e=y[n];(0,r.c)("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",o,e,v),l.off(e,t[n])}}},[v,y]);let x=(0,n.useCallback)((n,i={})=>{let a,u=Object.fromEntries(Object.keys(e).map(e=>[e,null])),c="function"==typeof n?n(d(T.current,F))??u:n??u;(0,r.c)("[nuq+ %s `%s`] setState: %O",o,v,c);let g=0,E=!1,M=[];for(let[n,o]of Object.entries(c)){let u=e[n],c=y[n];if(!u||void 0===o)continue;(i.clearOnDefault??u.clearOnDefault??B)&&null!==o&&void 0!==u.defaultValue&&(u.eq??((e,t)=>e===t))(o,u.defaultValue)&&(o=null);let d=null===o?null:(u.serialize??String)(o);l.emit(c,{state:o,query:d});let v={key:c,query:d,options:{history:i.history??u.history??f,shallow:i.shallow??u.shallow??h,scroll:i.scroll??u.scroll??A,startTransition:i.startTransition??u.startTransition??C}};if(i?.limitUrlUpdates?.method==="debounce"||p?.method==="debounce"||u.limitUrlUpdates?.method==="debounce"){!0===v.options.shallow&&console.warn((0,r.s)(422));let e=i?.limitUrlUpdates?.timeMs??p?.timeMs??u.limitUrlUpdates?.timeMs??t.s.timeMs,n=t.t.push(v,e,b,s);gt(e),E?t.n.flush(b,s):t.n.getPendingPromise(b));return a??S},[v,f,h,A,m,p?.method,p?.timeMs,C,y,b.updateUrl,b.getSearchParamsSnapshot,b.rateLimitFactor,s,F]);return[(0,n.useMemo)(()=>d(R,F),[R,F]),x]}({[e]:{parse:o??(e=>e),type:a,serialize:s,eq:A,defaultValue:h}},m);return[p,(0,n.useCallback)((t,r={})=>B(r=>({[e]:"function"==typeof t?t(r[e]):t}),r),[e,B])]}e.s(["createParser",()=>o,"parseAsBoolean",()=>a,"useQueryState",()=>f],38847)},32424,e=>{"use strict";var t=e.i(12979);function r(){return async e=>{let r;try{r=(0,t.getUrlForPath)(e)}catch(t){return console.warn(`Script not in manifest: ${e} (${t})`),null}try{let t=await fetch(r);if(!t.ok)return console.error(`Script fetch failed: ${e} (${t.status})`),null;return await t.text()}catch(t){return console.error(`Script fetch error: ${e}`),console.error(t),null}}}e.s(["createScriptLoader",()=>r])},7368,e=>{"use strict";e.s(["ignoreScripts",0,["scripts/admin.cs","scripts/ai.cs","scripts/aiBotProfiles.cs","scripts/aiBountyGame.cs","scripts/aiChat.cs","scripts/aiCnH.cs","scripts/aiCTF.cs","scripts/aiDeathMatch.cs","scripts/aiDebug.cs","scripts/aiDefaultTasks.cs","scripts/aiDnD.cs","scripts/aiHumanTasks.cs","scripts/aiHunters.cs","scripts/aiInventory.cs","scripts/aiObjectiveBuilder.cs","scripts/aiObjectives.cs","scripts/aiRabbit.cs","scripts/aiSiege.cs","scripts/aiTDM.cs","scripts/aiTeamHunters.cs","scripts/deathMessages.cs","scripts/graphBuild.cs","scripts/navGraph.cs","scripts/serverTasks.cs","scripts/spdialog.cs"]])}]); \ No newline at end of file diff --git a/docs/_not-found/__next._full.txt b/docs/_not-found/__next._full.txt index dd66f8ee..dd873a75 100644 --- a/docs/_not-found/__next._full.txt +++ b/docs/_not-found/__next._full.txt @@ -8,7 +8,7 @@ a:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] c:I[68027,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["","_not-found",""],"q":"","i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L5",null,{"children":["$","$6",null,{"name":"Next.MetadataOutlet","children":"$@7"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L8",null,{"children":"$L9"}],["$","div",null,{"hidden":true,"children":["$","$La",null,{"children":["$","$6",null,{"name":"Next.Metadata","children":"$Lb"}]}]}],null]}],false]],"m":"$undefined","G":["$c","$undefined"],"S":true} +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["","_not-found",""],"q":"","i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L5",null,{"children":["$","$6",null,{"name":"Next.MetadataOutlet","children":"$@7"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L8",null,{"children":"$L9"}],["$","div",null,{"hidden":true,"children":["$","$La",null,{"children":["$","$6",null,{"name":"Next.Metadata","children":"$Lb"}]}]}],null]}],false]],"m":"$undefined","G":["$c","$undefined"],"S":true} 9:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] d:I[27201,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"IconMark"] 7:null diff --git a/docs/_not-found/__next._head.txt b/docs/_not-found/__next._head.txt index ffbf2151..41d6f513 100644 --- a/docs/_not-found/__next._head.txt +++ b/docs/_not-found/__next._head.txt @@ -3,4 +3,4 @@ 3:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 4:"$Sreact.suspense" 5:I[27201,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"IconMark"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} diff --git a/docs/_not-found/__next._index.txt b/docs/_not-found/__next._index.txt index f8230d2e..42eb3c22 100644 --- a/docs/_not-found/__next._index.txt +++ b/docs/_not-found/__next._index.txt @@ -3,4 +3,4 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} diff --git a/docs/_not-found/__next._not-found.__PAGE__.txt b/docs/_not-found/__next._not-found.__PAGE__.txt index 680c3341..a2bc0faf 100644 --- a/docs/_not-found/__next._not-found.__PAGE__.txt +++ b/docs/_not-found/__next._not-found.__PAGE__.txt @@ -1,5 +1,5 @@ 1:"$Sreact.fragment" 2:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] 3:"$Sreact.suspense" -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],null,["$","$L2",null,{"children":["$","$3",null,{"name":"Next.MetadataOutlet","children":"$@4"}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],null,["$","$L2",null,{"children":["$","$3",null,{"name":"Next.MetadataOutlet","children":"$@4"}]}]]}],"loading":null,"isPartial":false} 4:null diff --git a/docs/_not-found/__next._not-found.txt b/docs/_not-found/__next._not-found.txt index 0b76f1d5..30a01e63 100644 --- a/docs/_not-found/__next._not-found.txt +++ b/docs/_not-found/__next._not-found.txt @@ -1,4 +1,4 @@ 1:"$Sreact.fragment" 2:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 3:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}]}]]}],"loading":null,"isPartial":false} diff --git a/docs/_not-found/__next._tree.txt b/docs/_not-found/__next._tree.txt index 7b3d425a..ee8dcad0 100644 --- a/docs/_not-found/__next._tree.txt +++ b/docs/_not-found/__next._tree.txt @@ -1,2 +1,2 @@ :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"/_not-found","paramType":null,"paramKey":"/_not-found","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":false}},"isRootLayout":true},"staleTime":300} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"/_not-found","paramType":null,"paramKey":"/_not-found","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":false}},"isRootLayout":true},"staleTime":300} diff --git a/docs/_not-found/index.html b/docs/_not-found/index.html index b69d086f..cfbe476a 100644 --- a/docs/_not-found/index.html +++ b/docs/_not-found/index.html @@ -1 +1 @@ -404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file +404: This page could not be found.MapGenius – Explore maps for Tribes 2

404

This page could not be found.

\ No newline at end of file diff --git a/docs/_not-found/index.txt b/docs/_not-found/index.txt index dd66f8ee..dd873a75 100644 --- a/docs/_not-found/index.txt +++ b/docs/_not-found/index.txt @@ -8,7 +8,7 @@ a:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] c:I[68027,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["","_not-found",""],"q":"","i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L5",null,{"children":["$","$6",null,{"name":"Next.MetadataOutlet","children":"$@7"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L8",null,{"children":"$L9"}],["$","div",null,{"hidden":true,"children":["$","$La",null,{"children":["$","$6",null,{"name":"Next.Metadata","children":"$Lb"}]}]}],null]}],false]],"m":"$undefined","G":["$c","$undefined"],"S":true} +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["","_not-found",""],"q":"","i":false,"f":[[["",{"children":["/_not-found",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:style","children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:1:props:style","children":404}],["$","div",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:style","children":["$","h2",null,{"style":"$0:f:0:1:0:props:children:1:props:children:props:children:props:children:props:notFound:0:1:props:children:props:children:2:props:children:props:style","children":"This page could not be found."}]}]]}]}]],null,["$","$L5",null,{"children":["$","$6",null,{"name":"Next.MetadataOutlet","children":"$@7"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[["$","meta",null,{"name":"robots","content":"noindex"}],["$","$L8",null,{"children":"$L9"}],["$","div",null,{"hidden":true,"children":["$","$La",null,{"children":["$","$6",null,{"name":"Next.Metadata","children":"$Lb"}]}]}],null]}],false]],"m":"$undefined","G":["$c","$undefined"],"S":true} 9:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] d:I[27201,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"IconMark"] 7:null diff --git a/docs/base/@vl2/Classic_maps_v1.vl2/shapes/borg11.glb b/docs/base/@vl2/Classic_maps_v1.vl2/shapes/borg11.glb index 1da7a4dbd5017a936179374e83ce498ac24539d0..c5ae46406eb8576a1957d635f7952a741e50fac7 100644 GIT binary patch delta 57 zcmZoMT4KbTo)hB6#K6FyBFVsDGm-a)oQ_gTNpXB}YGG+=UUF)Da%FN(X0no%Qgm8k MPI2mHW=2K{0NZ8}5dZ)H delta 26 hcmZ2t)MCV&o)hB6#K6G7BFVrYGm-blW>v=j;s93%2FCyZ diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/authconnect.cs b/docs/base/@vl2/T2csri.vl2/t2csri/authconnect.cs index e512308d..ee254307 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/authconnect.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/authconnect.cs @@ -1,70 +1,87 @@ -// Tribes 2 Unofficial Authentication System -// http://www.tribesnext.com/ -// Written by Electricutioner/Thyth -// Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative - -// Authentication Server Connector Version 1.0: 11/06/2008 - -function authConnect_findAuthServer() -{ - if ($AuthServer::Address !$= "") - return; - - echo("Looking up Authentication Server..."); - - if (isObject(AuthConnection)) - { - AuthConnection.disconnect(); - AuthConnection.delete(); - } - - new HTTPObject(AuthConnection); - AuthConnection.setHeader("Accept", "text/plain"); - AuthConnection.get("www.tribesnext.com", "auth"); -} - -function AuthConnection::onLine(%this, %line) -{ - if (getFieldCount(%line) != 2) - return; - - %address = getField(%line, 0); - %signature = getField(%line, 1); - - %sha1sum = sha1sum(%address); - %verifSum = t2csri_verify_auth_signature(%signature); - while (strlen(%verifSum) < 40) - %verifSum = "0" @ %verifSum; - - if (%sha1sum !$= %verifSum) - { - error("Authentication server lookup returned an address with an invalid signature."); - error("Unable to contact the authentication server."); - $AuthServer::Address = ""; - } - else - { - echo("Authentication server found at " @ %address @ ". Ready to authenticate."); - $AuthServer::Address = %address; - } -} - -function AuthConnection::onDisconnect(%this) -{ - if ($AuthServer::Address $= "") - { - error("Authentication server lookup failed."); - } - - %this.delete(); -} - -function AuthConnection::onConnectFailed(%this) -{ - %this.delete(); -} - -function AuthConnection::onDNSFailed(%this) -{ - %this.delete(); -} \ No newline at end of file +// Tribes 2 Unofficial Authentication System +// http://www.tribesnext.com/ +// Written by Electricutioner/Thyth +// Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative + +// Authentication Server Connector Version 1.0: 11/06/2008 + +function authConnect_findAuthServer() +{ + if ($AuthServer::Address !$= "") + return; + echo("Looking up Authentication Server..."); + if (isObject(AuthConnection)) + { + AuthConnection.disconnect(); + AuthConnection.delete(); + } + new TCPObject(AuthConnection); + + %data = "GET /auth HTTP/1.1\r\nHost: www.tribesnext.com\r\nUser-Agent: Tribes 2\r\nConnection: close\r\n\r\n"; + AuthConnection.data = %data; + AuthConnection.connect("www.tribesnext.com:80"); + $AuthServer::Primed = 0; +} + +function AuthConnection::onLine(%this, %line) +{ + if (%line == 411) + return; + if (trim(%line) $= "") + { + $AuthServer::Primed = 1; + return; + } + + if ($AuthServer::Primed) + { + $AuthServer::Address = %line; + %this.disconnect(); + authConnect_verifyLookup(); + } +} + +function AuthConnection::onConnected(%this) +{ + %this.send(%this.data); +} + +function authConnect_verifyLookup() +{ + + if (getFieldCount($AuthServer::Address) != 2) + { + $AuthServer::Address = ""; + error("Authentication server lookup failed."); + return; + } + %address = getField($AuthServer::Address, 0); + %signature = getField($AuthServer::Address, 1); + + %sha1sum = sha1sum(%address); + %verifSum = t2csri_verify_auth_signature(%signature); + while (strlen(%verifSum) < 40) + %verifSum = "0" @ %verifSum; + if (%sha1sum !$= %verifSum) + { + // signature verification failed... someone has subverted the auth server lookup + error("Authentication server lookup returned an address with an invalid signature."); + error("Unable to contact the authentication server."); + $AuthServer::Address = ""; + return; + } + else + { + echo("Authentication server found at " @ %address @ ". Ready to authenticate."); + $AuthServer::Address = %address; + $AuthServer::Primed = ""; + } +} + +// perform signature verification to prove that the auth server has designated the +// provided address +function t2csri_verify_auth_signature(%sig) +{ + rubyEval("tsEval '$temp=\"' + t2csri_verify_auth_signature('" @ %sig @ "').to_s(16) + '\";'"); + return $temp; +} diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/authinterface.cs b/docs/base/@vl2/T2csri.vl2/t2csri/authinterface.cs index 3ba595b5..8d456a06 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/authinterface.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/authinterface.cs @@ -14,9 +14,9 @@ $Authentication::Settings::Timeout = 30000; function AuthenticationInterface::onLine(%this, %line) { + //warn(%line); if (isEventPending($Authentication::TransactionCompletionSchedule)) cancel($Authentication::TransactionCompletionSchedule); - $Authentication::TransactionCompletionSchedule = schedule(700, 0, Authentication_transactionComplete); if ($Authentication::Status::ActiveMode != 0) @@ -102,8 +102,12 @@ function Authentication_transactionComplete() } else if (getWord(%buffer, 0) $= "CERT:") { - $Authentication::Status::LastCert = getRecord(%buffer, 0); - $Authentication::Status::LastExp = getRecord(%buffer, 1); + %cert = getSubStr(%buffer, 0, strstr(%buffer, "\n")); + %buffer = getSubStr(%buffer, strstr(%buffer, "\n") + 1, strlen(%buffer)); + %exp = getSubStr(%buffer, 0, (strstr(%buffer, "\n") == -1 ? strlen(%buffer) : strstr(%buffer, "\n"))); + + $Authentication::Status::LastCert = %cert; + $Authentication::Status::LastExp = %exp; echo("Authentication: Successfully downloaded certificate and encrypted key."); } else @@ -163,7 +167,6 @@ function Authentication_checkAvail() if (isObject(AuthenticationInterface)) AuthenticationInterface.delete(); - new TCPObject(AuthenticationInterface); AuthenticationInterface.data = "AVAIL\n"; @@ -185,7 +188,6 @@ function Authentication_checkName(%name) if (isObject(AuthenticationInterface)) AuthenticationInterface.delete(); - new TCPObject(AuthenticationInterface); AuthenticationInterface.data = "NAME\t" @ %name @ "\n"; @@ -207,7 +209,6 @@ function Authentication_recoverAccount(%payload) if (isObject(AuthenticationInterface)) AuthenticationInterface.delete(); - new TCPObject(AuthenticationInterface); AuthenticationInterface.data = "RECOVER\t" @ %payload @ "\n"; @@ -229,11 +230,9 @@ function Authentication_registerAccount(%payload) if (isObject(AuthenticationInterface)) AuthenticationInterface.delete(); - new TCPObject(AuthenticationInterface); AuthenticationInterface.data = "SIGN\t" @ %payload @ "\n"; - AuthenticationInterface.connect($AuthServer::Address); $Authentication::TransactionCompletionSchedule = schedule($Authentication::Settings::Timeout, 0, Authentication_transactionComplete); } \ No newline at end of file diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/autoupdate.cs b/docs/base/@vl2/T2csri.vl2/t2csri/autoupdate.cs new file mode 100644 index 00000000..fac7bd01 --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/autoupdate.cs @@ -0,0 +1,111 @@ +// Tribes 2 Unofficial Authentication System +// http://www.tribesnext.com/ +// Written by Electricutioner/Thyth +// Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative + +// Bare Bones Auto Update System Version 1.0: 11/06/2008 + +function authConnect_findAutoUpdater() +{ + if ($AutoUpdater::Address !$= "") + return; + + if (isObject(AutoUpdateConnection)) + { + AutoUpdateConnection.disconnect(); + AutoUpdateConnection.delete(); + } + new TCPObject(AutoUpdateConnection); + + %data = "GET /update HTTP/1.1\r\nHost: www.tribesnext.com\r\nUser-Agent: Tribes 2\r\nConnection: close\r\n\r\n"; + AutoUpdateConnection.connect("www.tribesnext.com:80"); + AutoUpdateConnection.schedule(1000, send, %data); +} + +function AutoUpdateConnection::onLine(%this, %line) +{ + if (!$AutoUpdater::UpdateFound) + { + $AutoUpdater::Address = %line; + %this.disconnect(); + autoUpdate_verifyLookup(); + } + else + { + if (isEventPending($AutoUpdate::LastLineSch)) + cancel($AutoUpdate::LastLineSch); + $AutoUpdate::LastLineSch = autoUpdate_applyUpdate(); + if ($AutoUpdate::UpdateStarted) + $AutoUpdate::Buffer = $AutoUpdate::Buffer @ "\n" @ %line; + else if (strlen(%line) == 0) + $AutoUpdate::UpdateStarted = 1; + } +} + +function autoUpdate_verifyLookup() +{ + if (getFieldCount($AutoUpdate::Address) != 2) + { + $AutoUpdater::Address = ""; + error("No valid update address found."); + return; + } + %address = getField($AutoUpdater::Address, 0); + %signature = getField($AutoUpdater::Address, 1); + + %sha1sum = sha1sum(%address); + if (%sha1sum !$= t2csri_verify_update_signature(%signature)) + { + // signature verification failed... someone has subverted the auth server lookup + error("Auto update lookup returned an address with an invalid signature."); + error("Unable to download update without a correct signature."); + $AutoUpdater::Address = ""; + return; + } + else + { + echo("New update found at " @ %address @ ". Ready to download."); + $AutoUpdater::Address = %address; + $AutoUpdater::UpdateFound = 1; + } +} + +// perform signature verification to prove that the update server has designated the +// provided URL for a download, we don't want people injecting arbitrary code into +// user installations +function t2csri_verify_update_signature(%sig) +{ + rubyEval("tsEval '$temp=\"' + t2csri_verify_update_signature('" @ %sig @ "') + '\";'"); + return $temp; +} + +function autoUpdate_performUpdate() +{ + if ($AutoUpdater::Address $= "") + return; + + if (isObject(AutoUpdateConnection)) + { + AutoUpdateConnection.disconnect(); + AutoUpdateConnection.delete(); + } + new TCPObject(AutoUpdateConnection); + + %host = getSubStr($AutoUpdater::Address, 0, strstr("/")); + %uri = getSubStr($AutoUpdater::Address, strlen(%host), strlen($AutoUpdater::Address)); + + %data = "GET " @ %uri @ " HTTP/1.1\nHost: " @ %host @ "\nUser-Agent: Tribes 2\nConnection: close\n\n"; + AutoUpdateConnection.connect(%host); + AutoUpdateConnection.schedule(1000, send, %data); +} + +function autoUpdate_applyUpdate() +{ + new FileObject(AutoUpdateFile); + AutoUpdateFile.openForWrite("autoUpdate.rb"); + AutoUpdateFile.writeline($AutoUpdate::Buffer); + AutoUpdateFile.close(); + AutoUpdateFile.delete(); + + rubyExec("autoUpdate.rb"); +} diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/bans.cs b/docs/base/@vl2/T2csri.vl2/t2csri/bans.cs new file mode 100644 index 00000000..f2184169 --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/bans.cs @@ -0,0 +1,93 @@ +// Tribes 2 Unofficial Authentication System +// http://www.tribesnext.com/ +// Written by Electricutioner/Thyth +// Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative + +// IP and GUID ban list handling. +// These seem to be completely broken in engine, so... here is a script implementation. + +// Still works the same way as before... so scripts will function unmodified. +// BanList::add( %guid, %ipAddress, %seconds); +// If both GUID and IP address are specified, both types of entries are made on the banlist. + +// gets the current Unix Epoch time from Ruby -- in seconds +function currentEpochTime() +{ + rubyEval("tsEval '$temp=' + Time.now.to_i.to_s + ';'"); + return $temp; +} + +// compute the addition in Ruby, due to the Torque script precision problems for >1e6 values +function getEpochOffset(%seconds) +{ + rubyEval("tsEval '$temp=' + (Time.now.to_i + " @ %seconds @ ").to_s + ';'"); + return $temp; +} + +// bans are added to the $BanList::GUID and $BanList::IP hash maps as the Unix epoch time +// when the ban will expire +function BanList::add(%guid, %ipAddress, %seconds) +{ + if (%guid != 0) + { + // add GUID ban + $BanList::GUID[%guid] = getEpochOffset(%seconds); + } + if (getSubStr(%ipAddress, 0, 3) $= "IP:") + { + // add IP ban + %bareIP = getSubStr(%ipAddress, 3, strLen(%ipAddress)); + %bareIP = getSubStr(%bareIP, 0, strstr(%bareIP, ":")); + %bareIP = strReplace(%bareIP, ".", "_"); // variable access bug workaround + + $BanList::IP[%bareIP] = getEpochOffset(%seconds); + } + + // write out the updated bans to the file + export("$BanList*", "prefs/banlist.cs"); +} + +// returns boolean on whether the given client is IP banned or not +// true if banned, false if not banned +function banList_checkIP(%client) +{ + %ip = %client.getAddress(); + %ip = getSubStr(%ip, 3, strLen(%ip)); + %ip = getSubStr(%ip, 0, strstr(%ip, ":")); + %ip = strReplace(%ip, ".", "_"); + + %time = $BanList::IP[%ip]; + if (%time !$= "") + { + //%delta = %time - currentEpochTime(); + // T2 arithmetic fail again... doing subtraction in Ruby + rubyEval("tsEval '$temp=' + (" @ %time @ " - Time.now.to_i).to_s + ';'"); + %delta = $temp; + + if (%delta > 0) + return 1; + else + deleteVariables("$BanList::IP" @ %ip); + } + return 0; +} + +// returns boolean on whether the given GUID is banned or not +// true if banned, false if not banned +function banList_checkGUID(%guid) +{ + %time = $BanList::GUID[%guid]; + if (%time !$= "") + { + //%delta = %time - currentEpochTime(); + // T2 arithmetic fail again... doing subtraction in Ruby + rubyEval("tsEval '$temp=' + (" @ %time @ " - Time.now.to_i).to_s + ';'"); + %delta = $temp; + + if (%delta > 0) + return 1; + else + deleteVariables("$BanList::GUID" @ %guid); + } + return 0; +} \ No newline at end of file diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/base64.cs b/docs/base/@vl2/T2csri.vl2/t2csri/base64.cs new file mode 100644 index 00000000..d4f86b70 --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/base64.cs @@ -0,0 +1,164 @@ +// Torque Script Base64 Utilities +// Written by Electricutioner +// 10:43 PM 7/13/2005 + +// Used under license by the Tribes 2 Community System Re-engineering Intitiative. +// License Granted: 10/31/2008 + +// necessary for the transfer of arbitrary binary data over ASCII connections +function Base64_Encode(%string) +{ + %encoded = ""; + for (%i = 0; %i < strLen(%string); %i += 3) + { + %binBlock = ""; + for (%j = 0; %j < 3; %j++) + { + %bin = DecToBin(strCmp(getSubStr(%string, %i + %j, 1), "")); + while (strLen(%bin) < 8 && strLen(%bin) != 0) + %bin = "0" @ %bin; + %binBlock = %binBlock @ %bin; + } + for (%j = 0; %j < 4; %j++) + { + %bin = getSubStr(%binBlock, 6 * %j, 6); + if (%bin !$= "") + { + while(strLen(%bin) < 6) + %bin = %bin @ "0"; + %encoded = %encoded @ $Base64Utils::Base64Chars[BinToDec(%bin)]; + } + else + %encoded = %encoded @ "="; + } + } + return %encoded; +} +function Base64_Decode(%string) +{ + %decoded = ""; + for (%i = 0; %i < strLen(%string); %i += 4) + { + %binBlock = ""; + for (%j = 0; %j < 4; %j++) + { + %bin = ""; + %val = Base64_ValToIndex(strCmp(getSubStr(%string, %i + %j, 1), "")); + if (%val != -1) + %bin = DecToBin(%val); + while (strLen(%bin) < 6 && %val != -1) + %bin = "0" @ %bin; + %binBlock = %binBlock @ %bin; + } + for (%j = 0; %j < 3; %j++) + { + %bin = getSubStr(%binBlock, 8 * %j, 8); + while(strLen(%bin) < 8 && strLen(%bin) != 0) + %bin = "0" @ %bin; + if (%bin !$= "") + %decoded = %decoded @ collapseEscape("\\x" @ DecToHex(BinToDec(%bin))); + } + } + + return %decoded; +} +// a few conditionals are better than a loop +function Base64_ValToIndex(%val) +{ + if (%val > 96 && %val < 123) + return %val - 71; + else if (%val > 64 && %val < 91) + return %val - 65; + else if (%val > 47 && %val < 58) + return %val + 4; + else if (%val == 43) + return 62; + else if (%val == 47) + return 63; + else if (%val == 61) + return -1; + else + return ""; +} + +//create the character array in a minimum of fuss +function Base64_CreateArray() +{ + for (%i = 0; %i < 26; %i++) + { + $Base64Utils::Base64Chars[%i] = collapseEscape("\\x" @ DecToHex(65 + %i)); + $Base64Utils::Base64Chars[%i + 26] = collapseEscape("\\x" @ DecToHex(97 + %i)); + + if (%i < 10) + $Base64Utils::Base64Chars[%i + 52] = %i; + } + $Base64Utils::Base64Chars[62] = "+"; + $Base64Utils::Base64Chars[63] = "/"; +} + +// these binary conversion functions are much better than older ones +// these can handle just about any size of input, unlike 8 bit like the previous ones +function DecToBin(%dec) +{ + %length = mCeil(mLog(%dec) / mLog(2)); + %bin = ""; + for (%i = 0; %i <= %length; %i++) + { + %test = mPow(2, %length - %i); + if (%dec >= %test) + { + %bin = %bin @ "1"; + %dec -= %test; + } + else if (%i > 0) + %bin = %bin @ "0"; + } + return %bin; +} +function BinToDec(%bin) +{ + %dec = 0; + for (%i = 0; %i < strLen(%bin); %i++) + %dec += getSubStr(%bin, %i, 1) * mPow(2, strLen(%bin) - %i - 1); + return %dec; +} + +//no length limit +function DecToHex(%dec) +{ + %bin = DecToBin(%dec); + while (strLen(%bin) % 4 != 0) + %bin = "0" @ %bin; + + for (%i = 0; %i < strLen(%bin); %i += 4) + { + %block = getSubStr(%bin, strLen(%bin) - %i - 4, 4); + %part = BinToDec(%block); + if (%part > 9) + { + switch (%part) + { + case 10: + %hex = "a" @ %hex; + case 11: + %hex = "b" @ %hex; + case 12: + %hex = "c" @ %hex; + case 13: + %hex = "d" @ %hex; + case 14: + %hex = "e" @ %hex; + case 15: + %hex = "f" @ %hex; + } + } + else + %hex = %part @ %hex; + } + if (strlen(%hex) == 0) + return "00"; + else + return %hex; +} + +Base64_CreateArray(); \ No newline at end of file diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/certstore.rb b/docs/base/@vl2/T2csri.vl2/t2csri/certstore.rb new file mode 100644 index 00000000..24a85732 --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/certstore.rb @@ -0,0 +1,43 @@ +# +# Tribes 2 Community System Reengineering Initiative +# Client Side Credential/Certificate Store +# Version 1.1 (2009/01/25) +# +# Written by Electricutioner/Thyth +# http://absolous.no-ip.com/ +# Copyright 2008 - 2009 +# +# Released under the terms of the GNU General Public License v3 or later. +# http://www.gnu.org/licenses/gpl.html +# Your use of this software is subject to the terms of that license. Use, modification, or distribution +# constitutes acceptance of these software terms. This license is the only manner by which you are permitted +# to use this software, thus rejection of the license terms prohibits your use of this software. +# +$accCerts = Hash.new +$accPrivateKeys = Hash.new + +def certstore_loadAccounts + IO.foreach('public.store') {|line| $accCerts[line.split("\t")[0].downcase] = line.rstrip.lstrip } + IO.foreach('private.store') {|line| $accPrivateKeys[line.split("\t")[0].downcase] = line.rstrip.lstrip } +end + +def certstore_addAccount(public, private) + $accCerts[public.split("\t")[0].downcase] = public + $accPrivateKeys[public.split("\t")[0].downcase] = private + + publicstore = File.new('public.store', 'a') + publicstore.seek(0, IO::SEEK_END) + publicstore.puts(public + "\r\n") + publicstore.close + + privatestore = File.new('private.store', 'a') + privatestore.seek(0, IO::SEEK_END) + privatestore.puts(private + "\r\n") + privatestore.close +end + +def certstore_listAccounts + list = String.new + $accCerts.each_key { |username| list = list.rstrip + "\t" + $accCerts[username].split("\t")[0].to_s } + return list.lstrip +end diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/clientSide.cs b/docs/base/@vl2/T2csri.vl2/t2csri/clientSide.cs index 7b79ba52..fe02cf8a 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/clientSide.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/clientSide.cs @@ -8,12 +8,201 @@ // load the clan support functions exec("t2csri/clientSideClans.cs"); +// initialize the SHA1 digester in Ruby +function t2csri_initDigester() +{ + $SHA1::Initialized = 1; + rubyEval("$sha1hasher = SHA1Pure.new"); +} + +// use Ruby to get the SHA1 hash of the string +function sha1sum(%string) +{ + if (!$SHA1::Initialized) + t2csri_initDigester(); + %string = strReplace(%string, "'", "\\'"); + rubyEval("$sha1hasher.prepare"); + rubyEval("$sha1hasher.append('" @ %string @ "')"); + rubyEval("tsEval '$temp=\"' + $sha1hasher.hexdigest + '\";'"); + %temp = $temp; + $temp = ""; + return %temp; +} + +// get the password encrypted private key for the following name +// assuming it is installed on the system +function t2csri_getEncryptedAccountKey(%name) +{ + return rubyGetValue("$accPrivateKeys['" @ strlwr(%name) @ "']"); +} + +// get the public certificate key for the following name +// assuming it is installed on the system +function t2csri_getAccountCertificate(%name) +{ + // check if the name exists + %found = 0; + for (%i = 0; %i < getFieldCount($accountList); %i++) + { + if (%name $= getField($accountList, %i)) + %found = 1; + } + + // this is a bit of a hack -- Ruby 1.9.0 has some problems getting the account on the first try + %value = ""; + if (%found) + { + while (strLen(%value) == 0) + { + %value = rubyGetValue("$accCerts['" @ strlwr(%name) @ "']"); + } + } + else + { + %value = rubyGetValue("$accCerts['" @ strlwr(%name) @ "']"); + } + return %value; +} + // prevents a warning generated when leaving a server, and allows the yellow // highlight selection on the warrior screen that indicates the active account function WONGetAuthInfo() { - $LoginCertificate = t2csri_getAccountCertificate(); - return getField($LoginCertificate, 0) @ "\t\t0\t" @ getField($LoginCertificate, 1) @ "\n"; + return getField($LoginCertificate, 0) @ "\t\t0\t" @ getField($LoginCertificate, 1) @ "\n"; +} + +// decrypt an RC4 encrypted account key +// also used for encryption on the plaintext when generating the account +function t2csri_decryptAccountKey(%account, %password, %nonce, %doingEncryption) +{ + %key = sha1sum(%password @ %nonce); + + // initiate RC4 stream state with key + %iterations = 256; + for (%i = 0; %i < %iterations; %i++) + { + %SArray[%i] = %i; + } + %j = 0; + for (%i = 0; %i < %iterations; %i++) + { + %j = (%j + %SArray[%i] + strCmp(getSubStr(%key, %i % strLen(%key), 1), "")) % %iterations; + + //swap(S[i],S[j]) + %temp = %SArray[%i]; + %SArray[%i] = %SArray[%j]; + %SArray[%j] = %temp; + } + + // discard 2048 bytes from the start of the stream to avoid the strongly biased first bytes + %seedI = 0; %seedJ = 0; + for (%i = 0; %i < 2048; %i++) + { + %seedI = (%seedI + 1) % 256; + %seedJ = (%seedJ + %SArray[%seedI]) % 256; + + %temp = %SArray[%seedI]; + %SArray[%seedI] = %SArray[%seedJ]; + %SArray[%seedJ] = %temp; + } + + // decrypt the account + %bytes = strlen(%account) / 2; + for (%i = 0; %i < %bytes; %i++) + { + %seedI = (%seedI + 1) % 256; + %seedJ = (%seedJ + %SArray[%seedI]) % 256; + + %temp = %SArray[%seedI]; + %SArray[%seedI] = %SArray[%seedJ]; + %SArray[%seedJ] = %temp; + + %schar = %SArray[(%SArray[%seedI] + %SArray[%seedJ]) % 256]; + %achar = strCmp(collapseEscape("\\x" @ getSubStr(%account, %i * 2, 2)), ""); + %byte = DecToHex(%schar ^ %achar); + if (strLen(%byte) < 2) + %byte = "0" @ %byte; + %out = %out @ %byte; + } + + // verify that the password is correct by checking with the nonce (SHA1 plaintext hash) + %hash = sha1sum(%out); + if (%hash $= %nonce || %doingEncryption) + return %out; + else + { + %out = getSubStr(%out, 0, strlen(%out) - 2); + // last 4-bit block was corrupted... try to fix it + for (%i = 0; %i < 16; %i++) + { + %chunk = getSubStr(DecToHex(%i), 1, 1); + %hash = sha1sum(%out @ %chunk); + if (%hash $= %nonce) + return %out @ %chunk; + } + // last 8-bit block was corrupted... try to fix it + for (%i = 0; %i < 256; %i++) + { + %chunk = DecToHex(%i); + %hash = sha1sum(%out @ %chunk); + if (%hash $= %nonce) + return %out @ %chunk; + } + + // looks like the password was still wrong + return ""; + } +} + +function t2csri_encryptAccountKey(%account, %password) +{ + %nonce = sha1sum(%account); + return %nonce @ ":" @ t2csri_decryptAccountKey(%account, %password, %nonce, 1); +} + +// this does the "login" process internally for accounts that exist +// it finds the cert, the private key, decrypts it, and sets up the +// RSA key data structures in the Ruby environment. +function t2csri_getAccount(%username, %password) +{ + $LoginUsername = %username; + $LoginCertificate = t2csri_getAccountCertificate(%username); + if ($LoginCertificate $= "") + { + return "NO_SUCH_ACCOUNT"; + } + + // split the certificate into its components + // username guid e n signature + %user = getField($LoginCertificate, 0); + %guid = getField($LoginCertificate, 1); + %e = getField($LoginCertificate, 2); + %n = getField($LoginCertificate, 3); + %sig = getField($LoginCertificate, 4); + + // nonce:encrypted + %encryptedKey = t2csri_getEncryptedAccountKey(%username); + %encryptedKey = getField(%encryptedKey, 1); // strip the username from the field + %nonce = getSubStr(%encryptedKey, 0, strstr(%encryptedKey, ":")); + %block = getSubStr(%encryptedKey, strLen(%nonce) + 1, strLen(%encryptedKey)); + %decryptedKey = t2csri_decryptAccountKey(%block, %password, %nonce); + if (%decryptedKey $= "") + { + return "INVALID_PASSWORD"; + } + + // we have the account, and the properly decrypted private key... interface with Ruby and + // insert the data... + rubyEval("$accountKey = RSAKey.new"); + rubyEval("$accountKey.e = '" @ %e @ "'.to_i(16)"); + rubyEval("$accountKey.n = '" @ %n @ "'.to_i(16)"); + rubyEval("$accountKey.d = '" @ %decryptedKey @ "'.to_i(16)"); + // protect the private exponent (d) from reading now. + // this will prevent scripts from stealing the private exponent, but still + // allows doing decryption using the player's account key + rubyEval("$accountKey.protect"); + + return "SUCCESS"; } // this sends a request to the authentication server to retrieve an account that is @@ -34,7 +223,10 @@ function t2csri_downloadAccount(%username, %password) //echo(%authStored); // get time in UTC, use it as a nonce to prevent replay attacks - %utc = time(); + rubyEval("tsEval '$temp=\"' + Time.new.getutc.to_s + '\";'"); + %utc = $temp; + $temp = ""; + //echo(%utc); // time/username nonce %timeNonce = sha1sum(%utc @ strlwr(%username)); @@ -70,13 +262,14 @@ function t2csri_processDownloadCompletion() %cert = getSubStr(%cert, 6, strlen(%cert)); %exp = getField(%cert, 0) @ "\t" @ getSubStr(%exp, 5, strlen(%exp)); // add it to the store - t2csri_storeAccount(%cert, %exp); + rubyEval("certstore_addAccount('" @ %cert @ "','" @ %exp @ "')"); // refresh the UI $LastLoginKey = $LoginName; LoginEditMenu.clear(); LoginEditMenu.populate(); LoginEditMenu.setActive(1); + LoginEditMenu.setSelected(0); LoginEditBox.clear(); } else @@ -93,7 +286,6 @@ function t2csri_processDownloadCompletion() function t2csri_gameServerHexAddress() { %ip = ServerConnection.getAddress(); - %ip = getSubStr(%ip, strstr(%ip, ":") + 1, strlen(%ip)); %ip = getSubStr(%ip, 0, strstr(%ip, ":")); %ip = strReplace(%ip, ".", " "); @@ -111,7 +303,7 @@ function t2csri_gameServerHexAddress() // client side interface to communicate with the game server function clientCmdt2csri_pokeClient(%version) { - echo("T2CSRI: Authenticating with connected game server. (" @ %version @ ")"); + echo("T2CSRI: Authenticating with connected game server."); // send the community certificate, assuming server is running later than 1.0 if (getWord(%version, 1) > 1.0) @@ -119,7 +311,6 @@ function clientCmdt2csri_pokeClient(%version) $encryptedchallenge = ""; - $LoginCertificate = t2csri_getAccountCertificate(); // send the certificate in 200 byte parts for (%i = 0; %i < strlen($LoginCertificate); %i += 200) { @@ -127,11 +318,10 @@ function clientCmdt2csri_pokeClient(%version) } // send a 64 bit challenge to the server to prevent replay attacks - $loginchallenge = rand_challenge(18446744073709551615); + rubyEval("tsEval '$loginchallenge=\"' + rand(18446744073709551615).to_s(16) + '\";'"); // append what the client thinks the server IP address is, for anti-replay purposes $loginchallenge = $loginchallenge @ t2csri_gameServerHexAddress(); - - schedule(0, 0, commandToServer, 't2csri_sendChallenge', $loginchallenge); + commandToServer('t2csri_sendChallenge', $loginchallenge); // at this point, server will validate the signature on the certificate then // proceed to verifying the client has the private part of the key if valid @@ -151,7 +341,8 @@ function clientCmdt2csri_decryptChallenge() %challenge = strlwr($encryptedchallenge); for (%i = 0; %i < strlen(%challenge); %i++) { - if (!isxdigit(getSubStr(%challenge, %i, 1))) + %char = strcmp(getSubStr(%challenge, %i, 1), ""); + if ((%char < 48 || %char > 102) || (%char > 57 && %char < 97)) { schedule(1000, 0, MessageBoxOK, "REJECTED","Invalid characters in server challenge."); disconnect(); @@ -159,11 +350,11 @@ function clientCmdt2csri_decryptChallenge() } } - %decryptedChallenge = t2csri_rsa_decrypt(%challenge); + rubyEval("tsEval '$decryptedChallenge=\"' + $accountKey.decrypt('" @ %challenge @ "'.to_i(16)).to_s(16) + '\";'"); // verify that the client challenge is intact, and extract the server challenge - %replayedClientChallenge = getSubStr(%decryptedChallenge, 0, strLen($loginchallenge)); - %serverChallenge = getSubStr(%decryptedChallenge, strlen(%replayedClientChallenge), strLen(%decryptedChallenge)); + %replayedClientChallenge = getSubStr($decryptedChallenge, 0, strLen($loginchallenge)); + %serverChallenge = getSubStr($decryptedChallenge, strlen(%replayedClientChallenge), strLen($decryptedChallenge)); if (%replayedClientChallenge !$= $loginchallenge) { schedule(1000, 0, MessageBoxOK, "REJECTED","Server sent back wrong client challenge."); @@ -186,7 +377,7 @@ function clientCmdt2csri_decryptChallenge() // private exponent -- different x requires different time for x^d, and d bits can be found // if you are really resourceful... adding this schedule kills time accuracy and makes such // a correlation attack very improbable - schedule(getRandom(64, 512), 0, commandToServer, 't2csri_challengeResponse', %serverChallenge); + schedule(getRandom(128, 512), 0, commandToServer, 't2csri_challengeResponse', %serverChallenge); // at this point, server will verify that the challenge is equivalent to the one it sent encrypted // to the client. the only way it can be equivalent is if the client has the private key they diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/clientSideClans.cs b/docs/base/@vl2/T2csri.vl2/t2csri/clientSideClans.cs index e0f9d440..26a90e9a 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/clientSideClans.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/clientSideClans.cs @@ -36,7 +36,6 @@ function clientCmdt2csri_requestUnknownDCECert(%dceNum) { commandToServer('t2csri_getDCEChunk', getSubStr(%cert, %i, 200)); } - commandToServer('t2csri_finishedDCE'); } @@ -51,6 +50,5 @@ function t2csri_sendCommunityCert() { commandToServer('t2csri_sendCommunityCertChunk', getSubStr(%cert, %i, 200)); } - commandToServer('t2csri_comCertSendDone'); } diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/crypto.rb b/docs/base/@vl2/T2csri.vl2/t2csri/crypto.rb new file mode 100644 index 00000000..4c5ed26a --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/crypto.rb @@ -0,0 +1,492 @@ +# +# Tribes 2 Community System Reengineering Initiative +# Assymetric Cryptography Identity Provisioning +# Version 1.0 +# +# Written by Electricutioner/Thyth +# http://absolous.no-ip.com/ +# Copyright 2008 +# +# Released under the terms of the GNU General Public License v3 or later. +# http://www.gnu.org/licenses/gpl.html +# Your use of this software is subject to the terms of that license. Use, modification, or distribution +# constitutes acceptance of these software terms. This license is the only manner by which you are permitted +# to use this software, thus rejection of the license terms prohibits your use of this software. +# + +# fast modular exponentiation -- the key to the RSA algorithm +# result = (b ^ e) % m +def rsa_mod_exp(b, e, m) + result = 1 + while (e > 0) + if ((e & 1) == 1) + result = (result * b) % m + end + e = e >> 1 + b = (b * b) % m + end + return result +end + +# RSA key class to keep things nice and organized +class RSAKey + # allow reading and writing the key values + attr_reader :e, :n, :twister, :strength + attr_writer :e, :d, :n, :twister + + # allow protecting the d value so it isn't stolen by evil scripts + # once a key is protected, it cannot be deprotected, but it can be used to decrypt + def protect + @protected = 1 + end + # attribute reader for d that returns nil if key protection is active + def d + if (@protected == 1) + return nil + else + return @d + end + end + + # encrypt a message with the public exponent (e) + # this could be construed as a misnomer, since this is used to verify authentication + # images from the authentication server, and to verify a client has both parts of the key they + # claim to have + def encrypt(message) + rsa_mod_exp(message, @e, @n) + end + + # decrypt a message with the private exponent (d), also usable for signing + # obviously, this will fail if the instance is only the public part of the key + def decrypt(message) + rsa_mod_exp(message, @d, @n) + end + + # generate a new random RSA key of the specified bitsize + # this generates keys that should be resistant to quick factorization techniques + def generate(bitsize) + p = 0 + q = 0 + @n = 100 + @strength = bitsize + + # test for some conditions that could produce insecure RSA keys + # p, q difference to see if Fermat factorization could be successful + # p - q must be greater than 2*(n ^ (1/4)) + while ((p - q).abs < (2 * Math.sqrt(Math.sqrt(@n)))) + p = createPrime(bitsize / 2, 150) + q = createPrime(bitsize / 2, 150) + @n = p * q + end + + totient = (p - 1) * (q - 1) + + # e must be coprime to the totient. we start at 3 and add 2 whenever coprime test fails + @e = 3 + coprimee = 0 + while (coprimee) + if (@e > 7) + # e over 7 has a large chance of not being coprime to the totient + generate(bitsize) + return + end + block = extendedEuclid(@e, totient, 0, 1, 1, 0) + if (block[0] > 1) + @e = @e + 2 + else + coprimee = nil + end + end + + # calculate the d value such that d * e = 1 mod totient + # this calculation is done in the coprime of e verification + @d = block[1] + while (@d < 0) + @d = @d + totient + end + + # verify that the generated key is a valid RSA key + 1.upto(10) do |i| + testVal = @twister.randomnumber(bitsize) % @n + if (decrypt(encrypt(testVal)) != testVal) + # key failed... generate a new one + generate(bitsize) + return + end + end + end + + # private methods that people shouldn't be poking without a good reason + private + # obtain gcd and return the "d" value that we want + def extendedEuclid(a, b, c, d, e, f) + if (b == 0) + block = Array.new(3, 0) + block[0] = a; # gcd(a, b) + block[1] = e; # coefficient of 'a' and the 'd' value we want + block[2] = f; # coefficient of 'b' + return block + else + return extendedEuclid(b, a % b, e - ((a / b) * c), f - ((a / b) * d), c, d); + end + end + + # create a prime number of the specified bitlength + # the number of tests specified will control how many miller-rabin primality tests are run + # this function will return a prime number with a high degree of confidence if sufficient + # tests are run + def createPrime(bitlen, tests) + # generate a random number of the specific bitlen + p = @twister.randomnumber(bitlen) + + # run the primality tests + testrun = 0 + while (testrun < tests) + if (prime?(p)) + testrun = testrun + 1 + else # not prime -- generate a new one + return createPrime(bitlen, tests) + end + end + return p + end + + # run a miller-rabin primality test on the given number + # returns true if the number is "probably" prime + def prime?(potential) + qandm = getqm(potential) + if (qandm[0] == -1) + return nil + end + + bval = @twister.randomnumber(@strength / 2) + mval = qandm[1] + + if (rsa_mod_exp(bval, mval, potential) == 1) + return 1 + end + j = 0 + while (j < qandm[0]) + if ((potential - 1) == rsa_mod_exp(bval, mval, potential)) + return 1 + end + mval = mval * 2 + j = j + 1 + end + return nil + end + + def getqm(p) + p = p - 1 + rt = Array.new(2, 0) + if (p & 1 != 0) + rt[0] = -1 + rt[1] = -1 + return rt + end + div = p / 2 + counter = 1 + while (div & 1 == 0) + counter = counter + 1 + div = div / 2 + end + rt[0] = counter + rt[1] = div + return rt + end +end + +# Mersenne Twister pseudo random number generator, modified for cryptographic security +# period length should be 20 * (2 ^ 19937 - 1) +class MersenneTwister + @index = 0 + + # build the internal storage array + def initialize + @mt = Array.new(624, 0) + end + + # initialize the generator from a seed, can be done repeatedly + def seedgen(seed) + @mt[0] = seed + 1.upto(623) do |i| + @mt[i] = 0xffffffff & (1812433243 * (@mt[i - 1] ^ (@mt[i - 1] >> 30)) + i) + end + generateNumbers + end + + # extract a number that does not give away the state of the generator, takes 37 elements from generator + # and applies SHA1 on it to get a 20 element number. this is repeated until the required length + # is reached, and truncated as necessary to bring it down to the requested bitlen + def randomnumber(bits) + bytes = bits / 8 + if (bits % 8 != 0) + bytes = bytes + 1 + end + + produced = 0 + output = 0 + stages = 0 + mask = 0 + + sha1hash = SHA1Pure.new + while (produced < bytes) + sha1hash.prepare + 1.upto(37) do |i| + sha1hash.append(extractNumber().to_s); + end + digest = sha1hash.hexdigest.to_i(16) + output = output | (digest << (160 * stages)) + produced = produced + 20 + stages = stages + 1 + end + + 0.upto(bits.to_i) do |i| + mask = (mask.to_i << 1) | 1 + end + return (output & mask) + end + + private + # extract a tempered pseudorandom number + def extractNumber() + if (@index == 0) + generateNumbers() + end + + y = @mt[@index.to_i] + y = y ^ (y >> 11) + y = y ^ ((y << 7) & 2636928640) + y = y ^ ((y << 15) & 4022730752) + y = y ^ (y >> 18) + y = y & 0xffffffff + + @index = (@index.to_i + 1) % 624 + return y + end + + # generate 624 untempered numbers for this generator's array + def generateNumbers() + 0.upto(623) do |i| + y = (@mt[i] & 0x80000000) + (@mt[(i + 1) % 624] & 0x7FFFFFFF) + @mt[i] = @mt[(i + 397) % 624] ^ (y >> 1) + if (y & 1 == 1) + @mt[i] = @mt[i] ^ 2567483615 + end + end + end +end + +# SHA1 in Pure Ruby +class SHA1Pure + + def initialize + prepare + end + + # prepare the hash digester for a new hash + def prepare + @state = Array.new(5, 0) + @block = Array.new(16, 0) + @blockIndex = 0 + @count = 0 + + @state[0] = 0x67452301 + @state[1] = 0xefcdab89 + @state[2] = 0x98badcfe + @state[3] = 0x10325476 + @state[4] = 0xc3d2e1f0 + end + + # append a string to the string being digested + def append(str) + str = str.to_s + str.each_byte {|c| update(c.to_i & 0xff)} + end + + # produce a hexidecimal digest string + def hexdigest + bits = Array.new(8, 0) + 0.upto(7) do |i| + bits[i] = (@count >> (((7 - i) * 8) & 0xff)) & 0xff + end + update(128) + while (@blockIndex != 56) + update(0) + end + 0.upto(7) do |i| + update(bits[i]) + end # this will accomplish a transform + + # output the digest + digest = "" + 0.upto(4) do |i| + chunk = @state[i].to_s(16) + while(chunk.length < 8) + chunk = "0" + chunk + end + digest = digest + chunk + end + prepare + return digest + end + + private + def rol(val, bits) + val = val.to_i + bits = bits.to_i + return (val << bits) | (val >> (32 - bits)) + end + + def blk0(i) + i = i.to_i + @block[i] = (rol(@block[i], 24) & 0xff00ff00) | (rol(@block[i], 8) & 0xff00ff) + @block[i] = @block[i] & 0xffffffff + return @block[i] + end + + def blk(i) + i = i.to_i + @block[i & 15] = rol(@block[(i + 13) & 15] ^ @block[(i + 8) & 15] ^ @block[(i + 2) & 15] ^ @block[i & 15], 1) + @block[i & 15] = @block[i & 15] & 0xffffffff + return @block[i & 15] + end + + def r0(data, v, w, x, y, z, i) + data[z] += ((data[w] & (data[x] ^ data[y])) ^ data[y]) + blk0(i) + 0x5a827999 + rol(data[v], 5) + data[z] = data[z] & 0xffffffff + data[w] = rol(data[w], 30) & 0xffffffff + end + + def r1(data, v, w, x, y, z, i) + data[z] += ((data[w] & (data[x] ^ data[y])) ^ data[y]) + blk(i) + 0x5a827999 + rol(data[v], 5) + data[z] = data[z] & 0xffffffff + data[w] = rol(data[w], 30) & 0xffffffff + end + + def r2(data, v, w, x, y, z, i) + data[z] += (data[w] ^ data[x] ^ data[y]) + blk(i) + 0x6ed9eba1 + rol(data[v], 5) + data[z] = data[z] & 0xffffffff + data[w] = rol(data[w], 30) & 0xffffffff + end + + def r3(data, v, w, x, y, z, i) + data[z] += (((data[w] | data[x]) & data[y]) | (data[w] & data[x])) + blk(i) + 0x8f1bbcdc + rol(data[v], 5) + data[z] = data[z] & 0xffffffff + data[w] = rol(data[w], 30) & 0xffffffff + end + + def r4(data, v, w, x, y, z, i) + data[z] += (data[w] ^ data[x] ^ data[y]) + blk(i) + 0xca62c1d6 + rol(data[v], 5) + data[z] = data[z] & 0xffffffff + data[w] = rol(data[w], 30) & 0xffffffff + end + + def transform + dd = Array.new(5, 0) + dd[0] = @state[0] + dd[1] = @state[1] + dd[2] = @state[2] + dd[3] = @state[3] + dd[4] = @state[4] + + r0(dd,0,1,2,3,4, 0) + r0(dd,4,0,1,2,3, 1) + r0(dd,3,4,0,1,2, 2) + r0(dd,2,3,4,0,1, 3) + r0(dd,1,2,3,4,0, 4) + r0(dd,0,1,2,3,4, 5) + r0(dd,4,0,1,2,3, 6) + r0(dd,3,4,0,1,2, 7) + r0(dd,2,3,4,0,1, 8) + r0(dd,1,2,3,4,0, 9) + r0(dd,0,1,2,3,4,10) + r0(dd,4,0,1,2,3,11) + r0(dd,3,4,0,1,2,12) + r0(dd,2,3,4,0,1,13) + r0(dd,1,2,3,4,0,14) + r0(dd,0,1,2,3,4,15) + r1(dd,4,0,1,2,3,16) + r1(dd,3,4,0,1,2,17) + r1(dd,2,3,4,0,1,18) + r1(dd,1,2,3,4,0,19) + r2(dd,0,1,2,3,4,20) + r2(dd,4,0,1,2,3,21) + r2(dd,3,4,0,1,2,22) + r2(dd,2,3,4,0,1,23) + r2(dd,1,2,3,4,0,24) + r2(dd,0,1,2,3,4,25) + r2(dd,4,0,1,2,3,26) + r2(dd,3,4,0,1,2,27) + r2(dd,2,3,4,0,1,28) + r2(dd,1,2,3,4,0,29) + r2(dd,0,1,2,3,4,30) + r2(dd,4,0,1,2,3,31) + r2(dd,3,4,0,1,2,32) + r2(dd,2,3,4,0,1,33) + r2(dd,1,2,3,4,0,34) + r2(dd,0,1,2,3,4,35) + r2(dd,4,0,1,2,3,36) + r2(dd,3,4,0,1,2,37) + r2(dd,2,3,4,0,1,38) + r2(dd,1,2,3,4,0,39) + r3(dd,0,1,2,3,4,40) + r3(dd,4,0,1,2,3,41) + r3(dd,3,4,0,1,2,42) + r3(dd,2,3,4,0,1,43) + r3(dd,1,2,3,4,0,44) + r3(dd,0,1,2,3,4,45) + r3(dd,4,0,1,2,3,46) + r3(dd,3,4,0,1,2,47) + r3(dd,2,3,4,0,1,48) + r3(dd,1,2,3,4,0,49) + r3(dd,0,1,2,3,4,50) + r3(dd,4,0,1,2,3,51) + r3(dd,3,4,0,1,2,52) + r3(dd,2,3,4,0,1,53) + r3(dd,1,2,3,4,0,54) + r3(dd,0,1,2,3,4,55) + r3(dd,4,0,1,2,3,56) + r3(dd,3,4,0,1,2,57) + r3(dd,2,3,4,0,1,58) + r3(dd,1,2,3,4,0,59) + r4(dd,0,1,2,3,4,60) + r4(dd,4,0,1,2,3,61) + r4(dd,3,4,0,1,2,62) + r4(dd,2,3,4,0,1,63) + r4(dd,1,2,3,4,0,64) + r4(dd,0,1,2,3,4,65) + r4(dd,4,0,1,2,3,66) + r4(dd,3,4,0,1,2,67) + r4(dd,2,3,4,0,1,68) + r4(dd,1,2,3,4,0,69) + r4(dd,0,1,2,3,4,70) + r4(dd,4,0,1,2,3,71) + r4(dd,3,4,0,1,2,72) + r4(dd,2,3,4,0,1,73) + r4(dd,1,2,3,4,0,74) + r4(dd,0,1,2,3,4,75) + r4(dd,4,0,1,2,3,76) + r4(dd,3,4,0,1,2,77) + r4(dd,2,3,4,0,1,78) + r4(dd,1,2,3,4,0,79) + + @state[0] = (@state[0] + dd[0]) & 0xffffffff + @state[1] = (@state[1] + dd[1]) & 0xffffffff + @state[2] = (@state[2] + dd[2]) & 0xffffffff + @state[3] = (@state[3] + dd[3]) & 0xffffffff + @state[4] = (@state[4] + dd[4]) & 0xffffffff + end + + def update(b) + mask = (8 * (@blockIndex & 3)) + @count = @count + 8 + @block[@blockIndex >> 2] = @block[@blockIndex >> 2] & ~(0xff << mask) + @block[@blockIndex >> 2] = @block[@blockIndex >> 2] | ((b & 0xff) << mask) + @blockIndex = @blockIndex + 1 + if (@blockIndex == 64) + transform + @blockIndex = 0 + end + end +end \ No newline at end of file diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/glue.cs b/docs/base/@vl2/T2csri.vl2/t2csri/glue.cs index f6a4a8d2..432c6211 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/glue.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/glue.cs @@ -11,8 +11,17 @@ // load the torque script components exec("t2csri/authconnect.cs"); exec("t2csri/authinterface.cs"); +exec("t2csri/base64.cs"); exec("t2csri/clientSide.cs"); exec("t2csri/ipv4.cs"); +exec("t2csri/rubyUtils.cs"); + +// load the Ruby components +rubyExec("t2csri/crypto.rb"); +rubyExec("t2csri/certstore.rb"); + +rubyEval("certstore_loadAccounts"); +rubyEval("tsEval '$RubyEnabled=1;'"); // connect to the auth server via signed lookup schedule(32, 0, authConnect_findAuthServer); diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/ipv4.cs b/docs/base/@vl2/T2csri.vl2/t2csri/ipv4.cs index f677892c..184c47fc 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/ipv4.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/ipv4.cs @@ -1,5 +1,6 @@ // Tribes 2 Unofficial Authentication System // http://www.tribesnext.com/ +// Written by Electricutioner/Thyth // Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative // IPv4 Utils Version 1.1 (03/26/2008) @@ -10,7 +11,7 @@ // when the game launches, so there shouldn't be more than a // couple of hundred hits per day from the entire T2 community. -$IPv4::AutomationURL = "/whatismyip"; +$IPv4::AutomationURL = "/whatismyip.php"; function ipv4_getInetAddress() { @@ -22,20 +23,20 @@ function ipv4_getInetAddress() IPv4Connection.disconnect(); IPv4Connection.delete(); } + new TCPObject(IPv4Connection); + IPV4Connection.data = "GET " @ $IPv4::AutomationURL @ " HTTP/1.1\r\nHost: www.tribesnext.com\r\nUser-Agent: Tribes 2\r\nConnection: close\r\n\r\n"; + IPv4Connection.connect("www.tribesnext.com:80"); +} - new HTTPObject(IPv4Connection) - { - enableIPv6 = false; - }; - - IPv4Connection.get("master.tribesnext.com", $IPv4::AutomationURL); +function IPv4Connection::onConnected(%this) +{ + %this.send(%this.data); } function IPv4Connection::onLine(%this, %line) { if (%line $= "" || %line == 0) return; - $IPv4::InetAddress = %line; %this.disconnect(); } @@ -93,12 +94,13 @@ function ipv4_reasonableConnection(%source, %destination) } } + // convert a (big endian) hex block into a numeric IP function ipv4_hexBlockToIP(%hex) { for (%i = 0; %i < 4; %i++) { - %ip = %ip @ "." @ ord(collapseEscape("\\x" @ getSubStr(%hex, %i * 2, 2))); + %ip = %ip @ "." @ strcmp(collapseEscape("\\x" @ getSubStr(%hex, %i * 2, 2)), ""); } return getSubStr(%ip, 1, strlen(%ip) - 1); } diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/rubyUtils.cs b/docs/base/@vl2/T2csri.vl2/t2csri/rubyUtils.cs new file mode 100644 index 00000000..60f9a483 --- /dev/null +++ b/docs/base/@vl2/T2csri.vl2/t2csri/rubyUtils.cs @@ -0,0 +1,31 @@ +// Tribes 2 Unofficial Authentication System +// http://www.tribesnext.com/ +// Written by Electricutioner/Thyth +// Copyright 2008-2009 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative + +// Ruby Interface Utilities Version 1.3 (01/27/2009) + +// loads a ruby script +function rubyExec(%script) +{ + echo("Loading Ruby script " @ %script @ "."); + new FileObject("RubyExecutor"); + RubyExecutor.openForRead(%script); + + while (!RubyExecutor.isEOF()) + { + %line = RubyExecutor.readLine(); + %buffer = %buffer @ "\n" @ %line; + } + rubyEval(%buffer); + RubyExecutor.close(); + RubyExecutor.delete(); +} + +// extracts a value from the Ruby interpreter environment +function rubyGetValue(%value) +{ + $temp = ""; + rubyEval("tsEval '$temp=\"' + " @ %value @ " + '\";'"); + return $temp; +} diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/serverSide.cs b/docs/base/@vl2/T2csri.vl2/t2csri/serverSide.cs index 6e9deebb..990b41ee 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/serverSide.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/serverSide.cs @@ -1,10 +1,41 @@ // Tribes 2 Unofficial Authentication System // http://www.tribesnext.com/ +// Written by Electricutioner/Thyth // Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative -// Version 1.3: 2009-04-23 +// Version 1.2: 2009-02-16 // Clan/Rename Certificate support is included in this version. +// initialize the SHA1 digester in Ruby +function t2csri_initDigester() +{ + $SHA1::Initialized = 1; + rubyEval("$sha1hasher = SHA1Pure.new"); +} + +// use Ruby to get the SHA1 hash of the string +function sha1sum(%string) +{ + if (!$SHA1::Initialized) + t2csri_initDigester(); + %string = strReplace(%string, "'", "\\'"); + rubyEval("$sha1hasher.prepare"); + rubyEval("$sha1hasher.append('" @ %string @ "')"); + rubyEval("tsEval '$temp=\"' + $sha1hasher.hexdigest + '\";'"); + %temp = $temp; + $temp = ""; + return %temp; +} + +// verify with the auth server's RSA public key... hard coded in the executable +function t2csri_verify_auth_signature(%sig) +{ + rubyEval("tsEval '$temp=\"' + t2csri_verify_auth_signature('" @ %sig @ "').to_s(16) + '\";'"); + while (strLen($temp) < 40) + $temp = "0" @ $temp; + return $temp; +} + // server sends the client a certificate in chunks, since they can be rather large function serverCmdt2csri_sendCertChunk(%client, %chunk) { @@ -16,7 +47,7 @@ function serverCmdt2csri_sendCertChunk(%client, %chunk) if (strlen(%client.t2csri_cert) > 20000) { %client.setDisconnectReason("Account certificate too long. Check your account key for corruption."); - %client.schedule(0, delete); + %client.delete(); } } @@ -46,43 +77,20 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) if (%client.doneAuthenticating) return; - if (%client.t2csri_retryChallenge) - { - if (isEventPending(%client.t2csri_retryChallenge)) - cancel(%client.t2csri_retryChallenge); - - %client.t2csri_retryChallenge = ""; - } - - if (!%client.t2csri_sentComCertDone && strLen(%client.t2csri_comCert) > 0) - { - %client.t2csri_retryChallenge = schedule(250, 0, serverCmdt2csri_sendChallenge, %client, %clientChallenge); - return; - } - - if (strlen(%client.t2csri_cert) < 1024) - { - %client.setDisconnectReason("Invalid authentication certificate."); - %client.schedule(0, delete); - - return; - } - - // echo("Client requesting challenge. CC: " @ %clientChallenge); - // echo("Client's certificate: " @ %client.t2csri_cert); + //echo("Client requesting challenge. CC: " @ %clientChallenge); + //echo("Client's certificate: " @ %client.t2csri_cert); // verify that the certificate the client sent is signed by the authentication server %user = strReplace(getField(%client.t2csri_cert, 0), "\x27", "\\\x27"); %guid = getField(%client.t2csri_cert, 1); - // sanitize GUID for (%i = 0; %i < strlen(%guid); %i++) { - %char = ord(getSubStr(%guid, %i, 1)); + %char = strcmp(getSubStr(%guid, %i, 1), ""); if (%char > 57 || %char < 48) { %client.setDisconnectReason("Invalid characters in client GUID."); - %client.schedule(0, delete); + %client.delete(); return; } } @@ -95,10 +103,11 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) %rsa_chunk = strlwr(%e @ %n @ %sig); for (%i = 0; %i < strlen(%rsa_chunk); %i++) { - if (!isxdigit(getSubStr(%rsa_chunk, %i, 1))) + %char = strcmp(getSubStr(%rsa_chunk, %i, 1), ""); + if ((%char < 48 || %char > 102) || (%char > 57 && %char < 97)) { %client.setDisconnectReason("Invalid characters in certificate RSA fields."); - %client.schedule(0, delete); + %client.delete(); return; } } @@ -106,16 +115,11 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) // get a SHA1 sum %sumStr = %user @ "\t" @ %guid @ "\t" @ %e @ "\t" @ %n; %certSum = sha1sum(%sumStr); - - while (strLen(%sig) < 1024) - %sig = "0" @ %sig; - %verifSum = t2csri_verify_auth_signature(%sig); while (strLen(%verifSum) < 40) %verifSum = "0" @ %verifSum; - - // echo("Calc'd SHA1: " @ %certSum); - // echo("Signed SHA1: " @ %verifSum); + //echo("Calc'd SHA1: " @ %certSum); + //echo("Signed SHA1: " @ %verifSum); // verify signature if (%verifSum !$= %certSum) @@ -123,7 +127,7 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) // client supplied a bogus certificate that was never signed by the auth server // abort their connection %client.setDisconnectReason("Invalid account certificate."); - %client.schedule(0, delete); + %client.delete(); return; } @@ -135,10 +139,11 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) %clientChallenge = strlwr(%clientChallenge); for (%i = 0; %i < strlen(%clientChallenge); %i++) { - if (!isxdigit(getSubStr(%clientChallenge, %i, 1))) + %char = strcmp(getSubStr(%clientChallenge, %i, 1), ""); + if ((%char < 48 || %char > 102) || (%char > 57 && %char < 97)) { %client.setDisconnectReason("Invalid characters in client challenge."); - %client.schedule(0, delete); + %client.delete(); return; } } @@ -150,25 +155,22 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) if (!ipv4_reasonableConnection(%sourceIP, %sanityIP)) { %client.setDisconnectReason("Potential man in the middle attack detected. Your client claims it connected to: " @ %sanityIP @ ", but the server does not consider this reasonable."); - %client.schedule(0, delete); + %client.delete(); return; } // calculate a random 64-bit server side challenge - %client.t2csri_serverChallenge = rand_challenge() @ t2csri_gameClientHexAddress(%client); + rubyEval("tsEval '$temp=\"' + rand(18446744073709551615).to_s(16) + '\";'"); + %client.t2csri_serverChallenge = $temp @ t2csri_gameClientHexAddress(%client); %fullChallenge = %client.t2csri_clientChallenge @ %client.t2csri_serverChallenge; - if (strlen(%fullChallenge) % 2) - %fullChallenge = "0" @ %fullChallenge; - - %temp = rsa_mod_exp(%fullChallenge, %e, %n); + rubyEval("tsEval '$temp=\"' + rsa_mod_exp('" @ %fullChallenge @ "'.to_i(16), '" @ %e @ "'.to_i(16), '" @ %n @ "'.to_i(16)).to_s(16) + '\";'"); // send the challenge in 200 byte chunks - for (%i = 0; %i < strlen(%temp); %i += 200) + for (%i = 0; %i < strlen($temp); %i += 200) { - commandToClient(%client, 't2csri_getChallengeChunk', getSubStr(%temp, %i, 200)); + commandToClient(%client, 't2csri_getChallengeChunk', getSubStr($temp, %i, 200)); } - // tell the client we're done sending commandToClient(%client, 't2csri_decryptChallenge'); @@ -189,7 +191,7 @@ function serverCmdt2csri_sendChallenge(%client, %clientChallenge) { // uh oh... someone's being naughty.. valid cert, but for a different player. kill them! %client.setDisconnectReason("Community supplemental certificate doesn't match account certificate."); - %client.schedule(0, delete); + %client.delete(); return; } } @@ -206,10 +208,10 @@ function serverCmdt2csri_challengeResponse(%client, %serverChallenge) if (%client.t2csri_serverChallenge $= %serverChallenge) { // check to see if the client is GUID banned, now that we verified their certificate - if (BanList::isBanned(getField(%client.t2csri_authInfo, 3), "*")) + if (banList_checkGUID(getField(%client.t2csri_authInfo, 3))) { %client.setDisconnectReason("You are not allowed to play on this server."); - %client.schedule(0, delete); + %client.delete(); return; } @@ -219,7 +221,7 @@ function serverCmdt2csri_challengeResponse(%client, %serverChallenge) else { %client.setDisconnectReason("Invalid server challenge. Check your account key for corruption."); - %client.schedule(0, delete); + %client.delete(); } } @@ -228,9 +230,8 @@ function t2csri_expireClient(%client) { if (!isObject(%client)) return; - - %client.setDisconnectReason("This is a TribesNEXT server. You must install the TribesNEXT client to play. See www.tribesnext.com for info."); - %client.schedule(0, delete); + %client.setDisconnectReason("This is a TribesNext server. You must install the TribesNext client to play. See www.tribesnext.com for info."); + %client.delete(); } package t2csri_server @@ -238,17 +239,17 @@ package t2csri_server // packaged to create the "pre-connection" authentication phase function GameConnection::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch) { - if (%client.getAddress() !$= "local" && %client.t2csri_serverChallenge $= "") + if (%client.t2csri_serverChallenge $= "" && !%client.isAIControlled() && %client.getAddress() !$= "Local") { // check to see if the client is IP banned - if (BanList::isBanned(0, %client.getAddress())) + if (banList_checkIP(%client)) { %client.setDisconnectReason("You are not allowed to play on this server."); - %client.schedule(0, delete); + %client.delete(); return; } - // echo("Client connected. Initializing pre-connection authentication phase..."); + //echo("Client connected. Initializing pre-connection authentication phase..."); // save these for later %client.tname = %name; %client.trgen = %raceGender; @@ -259,10 +260,10 @@ package t2csri_server // start the 15 second count down %client.tterm = schedule(15000, 0, t2csri_expireClient, %client); - commandToClient(%client, 't2csri_pokeClient', "T2CSRI 1.5 - 08/09/2012"); + commandToClient(%client, 't2csri_pokeClient', "T2CSRI 1.1 - 03/18/2009"); return; } - // echo("Client completed pre-authentication phase."); + //echo("Client completed pre-authentication phase."); // continue connection process if (isEventPending(%client.tterm)) @@ -270,7 +271,6 @@ package t2csri_server Parent::onConnect(%client, %name, %raceGender, %skin, %voice, %voicePitch); %client.doneAuthenticating = 1; - %client.t2csri_cert = ""; } // packaged to prevent game leaving messages for clients that are in the authentication phase @@ -278,7 +278,6 @@ package t2csri_server { if (!isObject(%client) || !%client.doneAuthenticating) return; - Parent::onDrop(%client, %reason); } @@ -292,33 +291,11 @@ package t2csri_server // clan support will be implemented via delegation to a community server function GameConnection::getAuthInfo(%client) { - if (%client.t2csri_authInfo $= "" && %client.getAddress() $= "local") + if (%client.getAddress() $= "Local" && %client.t2csri_authInfo $= "") %client.t2csri_authInfo = WONGetAuthInfo(); - return %client.t2csri_authInfo; } - - // deactivating old master list server protocol handlers in script - // sending a game type list to a dedicated server would result in a massive number - // of nuiscance calls to the following functions, and spam the console with pages of errors - // the errors were the main source of CPU utilization, so just setting stubs is adequate protection - function addGameType() - { - return; - } - function clearGameTypes() - { - return; - } - function clearMissionTypes() - { - return; - } - function sortGameAndMissionTypeLists() - { - return; - } }; -if ($PlayingOnline && !isActivePackage(t2csri_server)) - activatePackage(t2csri_server); \ No newline at end of file +if ($PlayingOnline) + activatePackage(t2csri_server); diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/serverSideClans.cs b/docs/base/@vl2/T2csri.vl2/t2csri/serverSideClans.cs index 0dbeb07e..5041cdac 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/serverSideClans.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/serverSideClans.cs @@ -1,5 +1,6 @@ // Tribes 2 Unofficial Authentication System // http://www.tribesnext.com/ +// Written by Electricutioner/Thyth // Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative // Version 1.0: 2009-02-13 @@ -24,6 +25,16 @@ // HexBlob format: // (Follows same format as contents returned by getAuthInfo, but is hex encoded.) +// verify with the delegation RSA public key... hard coded in the executable +function t2csri_verify_deleg_signature(%sig) +{ + %sig = strReplace(%sig, "\x27", "\\\x27"); + rubyEval("tsEval '$temp=\"' + t2csri_verify_deleg_signature('" @ %sig @ "').to_s(16) + '\";'"); + while (strLen($temp) < 40) + $temp = "0" @ $temp; + return $temp; +} + // allow the client to send in an unknown DCE certificate function serverCmdt2csri_getDCEChunk(%client, %chunk) { @@ -77,6 +88,8 @@ function serverCmdt2csri_finishedDCE(%client) if (%sigSha !$= %calcSha) { + echo(%sigSha); + warn(%calcSha); %client.setDisconnectReason("DCE is not signed by authoritative root."); %client.delete(); return; @@ -161,9 +174,10 @@ function serverCmdt2csri_comCertSendDone(%client) } // get the signature SHA1 - %sigSha = rsa_mod_exp(%sig, %e, %n); - while (strlen(%sigSha) < 40) - %sigSha = "0" @ %sigSha; + rubyEval("tsEval '$temp = \"' + rsa_mod_exp('" @ %sig @ "'.to_i(16), '" @ %e @ "'.to_i(16), '" @ %n @ "'.to_i(16)).to_s(16) + '\";'"); + while (strlen($temp) < 40) + $temp = "0" @ $temp; + %sigSha = $temp; if (%sigSha !$= %calcSha) { diff --git a/docs/base/@vl2/T2csri.vl2/t2csri/serverglue.cs b/docs/base/@vl2/T2csri.vl2/t2csri/serverglue.cs index 356f0d1f..5e7db087 100644 --- a/docs/base/@vl2/T2csri.vl2/t2csri/serverglue.cs +++ b/docs/base/@vl2/T2csri.vl2/t2csri/serverglue.cs @@ -1,16 +1,22 @@ // Tribes 2 Unofficial Authentication System // http://www.tribesnext.com/ +// Written by Electricutioner/Thyth // Copyright 2008 by Electricutioner/Thyth and the Tribes 2 Community System Reengineering Intitiative // Version 1.0 initialization and glue file (server side) if (isObject(ServerGroup)) { + // load the Ruby utils and cryptography module + exec("t2csri/rubyUtils.cs"); + rubyExec("t2csri/crypto.rb"); + // load the torque script components exec("t2csri/serverSide.cs"); exec("t2csri/serverSideClans.cs"); exec("t2csri/bans.cs"); exec("t2csri/ipv4.cs"); + exec("t2csri/base64.cs"); // get the global IP for sanity testing purposes schedule(32, 0, ipv4_getInetAddress); diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2flag.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2flag.glb index 88e039e3c6751b9e23ee4bfb6f9afd6eb4907cc2..48debb925e3e41aab2d4cabe280735c31582d271 100644 GIT binary patch delta 61 zcmexiGQ*TNJtxGCiGhJ(h7<$Cl!?4QWp$KNN{Zu)QwvK|^O95JlPi;RGLx08l%h+D RN>ewpFt+e+Zs+^R4FG5^6ukfd delta 31 ncmbPX`on}bJtxGCiGhKkLW+T*WFqg+&8mz|yqj0>ec%QFmdy#@ diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2heavy_male.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2heavy_male.glb index 33e71cf4732e50aaa552c7ba18eeda467187abdc..1886690da9ff20592d9c773780714ab9ec294d40 100644 GIT binary patch delta 336 zcmaE`LGR2aJ-+mu5H}_U1_qy*+zd808~G}j>UES-N{Zu)QwvK|^O95JlPi;RGLx08 zl%mrTbBa@S6rfZ|Q7M9hDn${m9&Q5>#^7-TL<*V2VqUCLt&UP&Vs0wXf5FMAd8tY| w&C{9Mr!z4EG1KR delta 82 zcmX@JN$wMuqkO8)hJ8 a0b*7lW&>h&Am#vKP9Wym9$>@$Ck6lrEf{?O diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2light_female.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2light_female.glb index 5b25187896f744b6d1dc0df78503e5ffe88a0ea1..deb0d0ec134ee4559fcd304da279526d773884b5 100644 GIT binary patch delta 332 zcmcceT>HRFZNBuJ5H}_U28IJ)xENZVY~-tAs@G9UDJhOGPAx1=%}Y*=Pp(YP$xK$V zQi@JX%qdRQQGikf1pu-ncoP5s delta 76 zcmX@`Qv1qtZNBuJ5H}_U28Ju2xfo_V-pE(Q)Lh2gUdGJ0y^NVj`CHoo+n5H}_U28NUkj0_L{ZRD$D-28zt=kMm||AiX?{*e!3 diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2medium_female.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2medium_female.glb index 6a563c0dca8b25a659d41379584847e560277396..ad11ddfa479b920fb53a0a3b89d8a2877bd48caf 100644 GIT binary patch delta 336 zcmca|Naw&29lrFO5H}_U1_lQuZiXk~8~Li3>UES-N{Zu)QwvK|^O95JlPi;RGLx08 zl%mrTbBa@S6rfZ|Q7M9hDn${m9&Q6xWAIoDkwPZ1nt&`At5mC_l$V&B3iMxaa%x_x yl1}qXruLakj6lq^eI^rgkw`m_I5QBl05K~NvjH(X5OV-AClGUO=Mm@j-~s^7ylM9U delta 82 zcmX?bMCZyO9lrFO5H}_U28IwtZiXLX8~Li3noF76OPLvgm}z?{Gjp>DqeA-+ab_T9 a0b*7lW&>h&Am#vKP9Wym{zIJGg9`vw^BblB diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2medium_male.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2medium_male.glb index 947766fb1c8f19a06b7a1b05775cf2c9602df9d6..0a7f70e2fea522d390555851a42b964d80023d0f 100644 GIT binary patch delta 330 zcmaFxP4~(VUB2|35H}_U28NItZiW>5jeKoP^*Tx^CB^Z@sfDGfdC95q$(6}DnaN64 zO3`VFImM|u3Q($~s1(6Lm7<7O54V8`WAHcvB88#=g@bH*tWvFxQeI+iD$twF^O)M_ jF);!$h-L<279eH?Vm2UV2VxE&<^*D{?emzp4^;pFcyMk% delta 74 zcmcceL-)ZqUB2|35H}_U28M)cZiWK8jeKoP%^l3`9n6eC%ml3jhEB delta 29 lcmX@Hg?Y{vX5RFi5H}_U1_qg13=C^F^71lnc4K6^2>^=>2$BE* diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_disc.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_disc.glb index f7e29d781442ec7530f56b0dfc28bf5d4af072ac..836a783a51c7bf5dbf5914c9a290141fe789f02e 100644 GIT binary patch delta 90 zcmZ3pjq%AgM&9(C5H}_U28NVq28IP2d9@kMb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL dqDzWOQ*{&|WLjcQF)C-X8KbM|<{GmNDgZNb9v%Py delta 34 qcmaE|jd9I3M&9(C5H}_U1_qsI28N7{yxNSL3mKhFH*YrEr~&}FB?@8y diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_grenade_launcher.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_grenade_launcher.glb index 73cb51ae9e5a13777bf8cfb8fa5f51e0f5344387..b7429dbbe3085414a81431df6c4382a6cce461d5 100644 GIT binary patch delta 72 zcmbR9g7L@;M&9(C5H}_U1_qZB28Ni8yo`*hI!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA Y(P@b}#i=?9U}`fDqmAokceks$06)zajQ{`u delta 34 qcmX@|f^p6ZM&9(C5H}_U1_qfD1_qOjyo`*SO&P6RHy5~F(FFjwNeTr3 diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_mortar.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_mortar.glb index e4b9d5e61ed57fef6dc91dc38ddfe23d14d7ee7e..5f4300aa28507c168ad50c6f02a7074cf0df8d84 100644 GIT binary patch delta 63 zcmX>xi}}SYX5RFi5H}_U28N8Y3=A$4dB4l*D5aDX#}}s-mZs(`j_3Y!1` diff --git a/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_shocklance.glb b/docs/base/@vl2/TR2final105-client.vl2/shapes/TR2weapon_shocklance.glb index 9453b67725491aff765991bc47440b9780365a17..f895dba82cb1e373976bb01e08031c84fca6953b 100644 GIT binary patch delta 72 zcmex!jA_MjCf@X%5H}_U28I=j85mqP^71ii=_sX?6vr2*7M7;wC8x$GS0?9VCM#Jf XMVAznrs^m_$h5?q;?&KOjLC}tVjmbS delta 29 lcmZ2+oaxUoCf@X%5H}_U28No&3=9$*dHEPOyE7&(0sxW@2($nI diff --git a/docs/base/@vl2/shapes.vl2/shapes/ammo_plasma.glb b/docs/base/@vl2/shapes.vl2/shapes/ammo_plasma.glb index 405e6cc268fcfde24163a82a922e509609bb6f07..4f858d4683e4f762a04e36b6d8cf5bd1a8dd7135 100644 GIT binary patch delta 61 zcmX>T|0bR{JtxGCiGhLPjXncI#6;d7vN}pBCB^Z@sfDGfdC95q$(6}DnaN64O3@`n RrKy{l89n7Udn+{Z0|1Kn6s7JtxGCiGhJ(j|>BY&P3iHvN}pBCB^Z@sfDGfdC95q$(6}DnaN64O3@`n RrKy{l8RbMbtBBRG0RT;<6B_^k delta 35 rcmdmExxkV)JtxGCiGhJ(feZtKz(n33n^hQPM41&76gE4E)vy5os2>QV diff --git a/docs/base/@vl2/shapes.vl2/shapes/bioderm_heavy.glb b/docs/base/@vl2/shapes.vl2/shapes/bioderm_heavy.glb index 7d39985f7a6b81e8d39fe6496ba0742a5af30a96..130502ff96dd4e38da49c2ce396a7db195a3d307 100644 GIT binary patch delta 379 zcmZ3n$mYlr8@}|M5H}_U1_l=)euga`8~H9W)$1swloZDorxuo`<|U`bCs!utWF{+F zDMhCx<`k#uC_t%_qEZA0Rf-~BJ=_K&jG?9@AZC@wf&GQk;O4tb?RS|Nffz(HZ@#7scUy!|gT%V`%T1%>t# j9xOo23dC$c%nrmHK+FlmTtLhX#5_REyZwX*U(HDXTsxGIn}0I3|72nWVi3)|{U;Mk rwJNiMf7=AFov3rfS6UHitI0(<~P4$YJbJV2*e%P4 delta 31 ncmX@2v_y$FJtxGCiGhJZMUa6ZVIuF3%_@xf?3<@>Y~TO@g)j)I diff --git a/docs/base/@vl2/shapes.vl2/shapes/borg13.glb b/docs/base/@vl2/shapes.vl2/shapes/borg13.glb index a5fee32d6fc782bf1e1dacebc21aa7d269606a8a..ccc1d4a86a94c87641e8bb90b3ab25f36de9fbb0 100644 GIT binary patch delta 57 zcmez3JjI1KJtxGCiGhJZM2Ugn!9?C4aym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF NImM})nHfJS000ui6Da@y delta 26 icmbQ@^2M1qJtxGCiGhLPiy{NVfr-37HmfqeR{#KYZ3y20 diff --git a/docs/base/@vl2/shapes.vl2/shapes/borg2.glb b/docs/base/@vl2/shapes.vl2/shapes/borg2.glb index ba952754c51bff915c869f3715258f487ece9039..b21a0bf4b9d472b810cbe21e28b6ef80a171b30d 100644 GIT binary patch delta 63 zcmdn7oax4LCf@X%5H}_U28J7x85lAq^8S$3QA#N(jxSCvEKSWzPK{5lOwP$nRqxh5?}7XZLi3pxM* diff --git a/docs/base/@vl2/shapes.vl2/shapes/borg3.glb b/docs/base/@vl2/shapes.vl2/shapes/borg3.glb index 7ff5e300808f8abc55857616d58aee7bde1ee845..6a08745987762736ef22940f4833a22e0dde4475 100644 GIT binary patch delta 63 zcmZqBSfIh1o)hB6#K6FyAi}_KWg_nnSskU6lH&N{)WXu#yyVpQvH%UvARqt$ delta 37 tcmcc6$2g&nkvBaj#Epr8fkD8XfgxfeuPNi^7Df#XCIyAfYc!Y00syJtxGCiGhK^MUH`C#YEnpvN}pBCB^Z@sfDGfdC95q$(6}DnaN64O3@`n TrKy`)7-xtvDr}x3-oXX{d(#wF delta 31 ncmX?Nv&4osJtxGCiGhJZMUH`?VeT5P^y$>9nBOQ0AS delta 37 tcmZqq$N1ncBX4?6h#M0F1H*$l28JUWd6^hDn=&4^U{X-n{Kt~R6#)0n3?Kji diff --git a/docs/base/@vl2/shapes.vl2/shapes/deploy_inventory.glb b/docs/base/@vl2/shapes.vl2/shapes/deploy_inventory.glb index eb1ffdf4c910c82d4f7f9d2bf5175f4a818729e7..e02088b0817e3fa31f02ac317df4f36ee4eb3085 100644 GIT binary patch delta 93 zcmeB}%5r2X3vYT(h#M0F1H%z6Mur<3d9@iWbd*v`isOq@3rkb;l2hZ8E0c3Fla;KL hqSF#{ic@tIN{UM1Bvc4YZ8l@9TFj`hdHs@`sQ`HpAOQdX delta 34 qcmX>ym8D}U3vYT(h#M0F149QFBg34HyxNSLix?{wZ+^4nMk)ZbEeq8E diff --git a/docs/base/@vl2/shapes.vl2/shapes/deploy_sensor_motion.glb b/docs/base/@vl2/shapes.vl2/shapes/deploy_sensor_motion.glb index 26b65e2dd3f87d5d3f629e311e7f0ebd6d30a780..5af58ba0039ef3ced0dd662d6a2eaf95d50b3ccc 100644 GIT binary patch delta 84 zcmZ27mGQ<@M&9(C5H}_U28J763=A$Cd8HW*b(B&{isOq@3rkb;l2hZ8E0c3Fla;KL dqSF#{ic@tIN{UM1Bv@#(8sk5M&B{iN5&&vu8@T`g delta 34 qcmcaHm2t^bM&9(C5H}_U28JbG3=9Grd8HXQM>GC0*c@ThAOQffi3$w> diff --git a/docs/base/@vl2/shapes.vl2/shapes/deploy_sensor_pulse.glb b/docs/base/@vl2/shapes.vl2/shapes/deploy_sensor_pulse.glb index e732face5cbb4a4cb8e832ca2500a664789b142c..7780dfb31602347b5615cb3294c71ea6a84ba863 100644 GIT binary patch delta 84 zcmeydmvO~DM&9(C5H}_U1_q6I28Ih8d8HW*b(B&{isOq@3rkb;l2hZ8E0c3Fla;KL dqSF#{ic@tIN{UM1Bv@#(8e_NJ<}LOv@&Jit93lV! delta 38 ucmZ3nkMYM|M&9(C5H}_U28JJT3=9i4@=7yqj%Mt%V^&a5*!;xaMIHe6G7H=Q diff --git a/docs/base/@vl2/shapes.vl2/shapes/disc.glb b/docs/base/@vl2/shapes.vl2/shapes/disc.glb index 7b254a1a7ce7b854b232175d3f5fbd0e317c7355..245957f97295f0fbcc4c633da4fdc74261d99c9a 100644 GIT binary patch delta 70 zcmdlJ{vw<=JtxGCiGhLPg*F32#ztNdMlBtsl#=53;?%;@)V$=>_~gpuoXlh;E2Zd? WqS90yg|x(+Vju1k#?8Krv$X(r%m<4A diff --git a/docs/base/@vl2/shapes.vl2/shapes/disc_explosion.glb b/docs/base/@vl2/shapes.vl2/shapes/disc_explosion.glb index edd08aa4b7421960b5df89b62957bbcf26e377e1..20ff0428019b1a165212c15f68f104842d928780 100644 GIT binary patch delta 59 zcmcc8#`vX;kvBaj#Epr8fuY2if#J+V-XC&0N+~79@x`fyrKx$zsqx8`$vK(HN>)nI OX^A<-shgP@1Dyaj%=JtxGCiGhK^M~Z<#Vj{YIKMJtxGCiGhLP4KD*j%tYQFaym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF NImM})nHf*=000;B6AJ(U delta 26 icmaDOeMXu$JtxGCiGhLP3@-zN%|zZGn^hT)^8f&A1P8(Z diff --git a/docs/base/@vl2/shapes.vl2/shapes/ext_flagstand.glb b/docs/base/@vl2/shapes.vl2/shapes/ext_flagstand.glb index 6b81d2a4aa387c5cd138b332d784e9afa20d4ca2..b94469954222efec3f6a159f97d9d1d9fa5e74eb 100644 GIT binary patch delta 73 zcmcb!fw5&HBX4?6h#M0F14By$14F?^UN%Nm9i^0#;`rj!!qU{deK)o)hB6#K6Fyp~S$jVB{wV9Xkx9nzi`A$&){LmIx delta 33 pcmdmyIU$oTJtxGCiGhJ(f(Zk|7rBjmjEtMj7=OxcHjwWS1puo?3C;ij diff --git a/docs/base/@vl2/shapes.vl2/shapes/grenade_flare.glb b/docs/base/@vl2/shapes.vl2/shapes/grenade_flare.glb index b34abf462567755c7d5219eca48fdccae6bceded..b1e899f5a741ae93a8bd9b85b09da1be2bfc21a3 100644 GIT binary patch delta 71 zcmbPpfbqZqM&9(C5H}_U1_p-&1_q0byiANLI!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA b(IrKtsX7X2i8;lon|T=}EjDXdeo+Ge1ojqh delta 37 tcmX?bfN{ev8Gv4H4R9Jk6n*#u*B^6o# delta 30 mcmeyPen*`*JtxGCiGhLPjxYnmiHW>FHmfjR=UV)Sn*#uz#0pyg diff --git a/docs/base/@vl2/shapes.vl2/shapes/heavy_male.glb b/docs/base/@vl2/shapes.vl2/shapes/heavy_male.glb index dde73574b5d37d30bc0982c5fe35c6f3148f45df..814c80b6b609224116dae03bee31504637cf6036 100644 GIT binary patch delta 371 zcmeyc(zs`hF<*L4h#M0F0|U=B9tIPkjeO^s>UES-N{Zu)QwvK|^O95JlPi;RGLx08 zl%mrTbBa@S6rfZ|Q7M9hDn${m9&Q5>#!%A{5VK0;!2ZH%aPw`Z_S;O1Kn$Xpx8G)B j@#kyT5o7^kRv=~rVs;?r0Afxc<^p2w?K*-yM-Br3KxTO+ delta 86 zcmeBKWBg&IF<*L4h#M0F1H*?aJPZa{@6J5OZ&L7ved37y!}!8fgFk diff --git a/docs/base/@vl2/shapes.vl2/shapes/light_female.glb b/docs/base/@vl2/shapes.vl2/shapes/light_female.glb index 6798e2732ceb75e5454a7589621a482452f85185..7c5d5a23643a521e815add8c263759a8dc55503e 100644 GIT binary patch delta 392 zcmX@`!Su@~Q@-?^5H}_U28NPKUWPp_8~J`R)$1swloZDorxuo`<|U`bCs!utWF{+F zDMhCx<`k#uC_t%_qEZA0Rf-~BJ=_MY#?Zi86eCNFk^O}th1ES^!Dd$Gc2;IaAZ7w$ o=IyM^EYlm>XE(C|F)I+W0Wmuea{w_X5OV=B_x9P%JWIa-0HAV)#Q*>R delta 84 zcmezJ$@IVnQ@-?^5H}_U1_p-;UWSh5jeI|unypyctyma=mv8H$2M delta 84 zcmZ2*-ss60Bfj*U5H}_U28NVnJPbOS8~Iq7n|)c@eOVZRmUES-N{Zu)QwvK|^O95JlPi;RGLx08 zl%mrTbBa@S6rfZ|Q7M9hDn${m9&Q6xV`yM4#7LOII$%%2c*s7+;-2PjOzq#87=ai> iGXpUT5VHa?8xXStF$WNH0x=g5a|1EY_HRtQdJzC=9)sKf delta 82 zcmcbx!*t0uQ@-?^5H}_U1_qUAUIvEdjeM_|npIfZRah8-mUES-N{Zu)QwvK|^O95JlPi;RGLx08 zl%mrTbBa@S6rfZ|Q7M9hDn${m9&Q6ZW3btdO$?tISmjEz!Tv%q3x$KMtC^9xospRl rh?#(xc{?LBi?e;Zvl9ytvjQ<25VHd@2M}`tF&7YXZ+CX$nL7~xuw8r? delta 84 zcmeBKW&B{dF<*L4h#M0F1H*&MJPZa-8~MI6HS4jo>#;BbF%u9oZ`WgCakOtQaApBw bRv=~rVs;?r0Afxc<^p2w?FG&}b0z`+H~|@o diff --git a/docs/base/@vl2/shapes.vl2/shapes/mine.glb b/docs/base/@vl2/shapes.vl2/shapes/mine.glb index d89d6d18e93dbe7f293efceb66d24c96861913ec..bf0e0832af11f429432b26d511cbda163ad5d6af 100644 GIT binary patch delta 72 zcmZp8&A8+>BX4?6h#M0F1H+P11_qOjysV6>I!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA Y(P@b}#i=?9U~01fqoCJj74H}=06eJ{*Z=?k delta 38 tcmZ4Tnz7+EBX4?6h#M0F14Bb81B1XuURK7rcJtxGCiGhJ3LzRJ{U?T4iIUS{xlH&N{)WXu#yyVpQO2MBQh diff --git a/docs/base/@vl2/shapes.vl2/shapes/nexus_effect.glb b/docs/base/@vl2/shapes.vl2/shapes/nexus_effect.glb index 0aca5353bb08ddb565c75b222c42c80f693911e5..bd641590dce69ac5237518022c27d17620f8eab6 100644 GIT binary patch delta 91 zcmdmy_acusJtxGCiGhJ3!<>O(!$w|VMr|FXl#=53;?%;@)V$=>_~gpuoXlh;E2Zd? oqS90yg|x(+Vi>hqjTh90529CVE_OC delta 44 zcmaEnw?#wOls~Xh!e>02hu6 AlK=n! diff --git a/docs/base/@vl2/shapes.vl2/shapes/nexusbase.glb b/docs/base/@vl2/shapes.vl2/shapes/nexusbase.glb index efc426c68499b718d54e21288b52b1ee8abc4996..726504d7fdb052201d0a0464063f18dae6c65470 100644 GIT binary patch delta 78 zcmca|l&Rqu6K{G>h#M0F5G-b3(Amf<%&4uSlu}Y0Uz}Q4nwpoK8lPO5oRgWXWTg~c aQdF9%qmY)EQw*av%Q1d!+bq&?Knei3P8tvZ delta 34 pcmZoT#&qQ<6K{G>h#M0F1H+X?Kw=}WFym%l#?Nh=?K=)i0RY3W3wHnj diff --git a/docs/base/@vl2/shapes.vl2/shapes/nexuscap.glb b/docs/base/@vl2/shapes.vl2/shapes/nexuscap.glb index a24dcccdf7dc01f16530921f38a419b3dcfcafec..99976938f638f9f1093ce4bb7722554fda20b9dc 100644 GIT binary patch delta 78 zcmca}mZ{?$6K{G>h#M0F0|Uo$28ItCd4(CZb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL cqDzWOQ*{*55_5`S)Mh!xon4!6bhAhU0P+AD)Bpeg delta 34 qcmeA;$8_f`6K{G>h#M0F1H+wV3=Bs$@(MF<_GR4OwVAnxRT==$B?~+N diff --git a/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_ammo.glb b/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_ammo.glb index 315e3b046fd4e28b9e4baf16ab35375420aaa005..c64d03ebfbde83756eecbbcb41e55286a35fa8cf 100644 GIT binary patch delta 57 zcmcZ-_$81xJtxGCiGhLPiv|Nj%|zZGaym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF NImM})nHevt0{}g{6YT&1 delta 26 icmewocqNcGJtxGCiGhLPiUtEi%tYQFn^hUls{;Ues|ch3 diff --git a/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_sensor_motion.glb b/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_sensor_motion.glb index 073e7098159c997bb20911d10276bc68f1202fa4..63871e9374360bb914160a796f1ce3fee7457791 100644 GIT binary patch delta 57 zcmcbR^&yKlJtxGCiGhKkz?6aE$wc1oaym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF MImM})nHc>{06|t0kN^Mx delta 26 hcmey6bs>v4JtxGCiGhJ3z?6aE$VA@nn^hQnOaOWy2uA<_ diff --git a/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_sensor_pulse.glb b/docs/base/@vl2/shapes.vl2/shapes/pack_deploy_sensor_pulse.glb index 7200663e823ac08c6163ff167fccd76a1936e267..8d308001e6abc556a84224213c2c780742b6bb15 100644 GIT binary patch delta 59 zcmeyffN{=3M&9(C5H}_U28KBSKs=H6yPS?vN=b2iacW^{YF=_`d~#)SPG+)_l~QzC NVoq`DW+uiee*jjp6deEn delta 28 icmbQUknzs~M&9(C5H}_U28NmdAfCwkeX|Ni8nnb#Epr8f#E?D1B1mx-XF3$N+~79@x`fyrKx$zsqx8`$vK(HN>)nI TB}JvFo0%E4k~SM8Pmu=zrGOQ9 delta 37 tcmaFR%5L{g@6vr2*7M7;wC8x$GS0?9VCM#Jf TMVAznrfy>V)nI SB}JvFn;1nbHVa$+lmP%+SQIn> delta 33 ncmZ3phOuW2BX4?6h#M0F0|QSOkeJB(b+aO)ki}*b%O5fTp0o*9 diff --git a/docs/base/@vl2/shapes.vl2/shapes/plasmabolt.glb b/docs/base/@vl2/shapes.vl2/shapes/plasmabolt.glb index aed10db96129ad58e3ec61f4141e91905250b80e..5bcdc2051c2cfb85a4da2ce08e78c5346d464b90 100644 GIT binary patch delta 61 zcmew%K0|^xJtxGCiGhJZf`@^jWFqemSskU6lH&N{)WXu#yyVpQBn^hQ-IX8E3O<)87lpzU2 diff --git a/docs/base/@vl2/shapes.vl2/shapes/repair_kit.glb b/docs/base/@vl2/shapes.vl2/shapes/repair_kit.glb index 236b95581f4fbf7a462741e6af677dc22e930854..67a7cea964849ba03e6002a8d316696539c29ff0 100644 GIT binary patch delta 65 zcmaFS%-GSw$eW%M;>N_lz`)_ez>qMJ_lK;GQc6j2d~s@FX=+|_YJ75Ka!zKll9f_) UNl|I)W@g4fRYrx)A!<{k0gvqzJpcdz delta 33 pcmeBZVSLfd$eW%M;>N_l!0^J6fx%%S?~lzYjQ*;dOVp-F0|2f$3OxV- diff --git a/docs/base/@vl2/shapes.vl2/shapes/repair_patch.glb b/docs/base/@vl2/shapes.vl2/shapes/repair_patch.glb index fb21190f15eef995ddf0ae89141b78cea7cd38ac..ecba2a2d417ac014355c6466ed446364bbe18be3 100644 GIT binary patch delta 61 zcmcZ;`XiJ#JtxGCiGhLPhZY0Fhl#vDWObBMN{Zu)QwvK|^O95JlPi;RGLx08l%h+D RN>ev8Gd_~p{6h8%4*;*w7VQ84 delta 46 zcmewndMA`OJtxGCiGhLPjur#Mm5IDRHmfi`kl|8LPG-&jF)FJD<~)|{xHiD06IMzZU6uP delta 34 qcmZ3mg89R8X1?^C5H}_U28Iup85r)&+Q=u!xY>vC;>^Vgvn>JG0t{{d diff --git a/docs/base/@vl2/shapes.vl2/shapes/station_inv_human.glb b/docs/base/@vl2/shapes.vl2/shapes/station_inv_human.glb index 5ed51914c6ae1494791aff53fb9730cdf1105baa..37648a1b622a47c3df2512d981c266725efcf54d 100644 GIT binary patch delta 92 zcmexzh-t%NCf@X%5H}_U28Im_85lln$!c2>Ad2 diff --git a/docs/base/@vl2/shapes.vl2/shapes/station_teleport.glb b/docs/base/@vl2/shapes.vl2/shapes/station_teleport.glb index 9fdddb7baef6acd1ebc8377b586897f183ac568f..33379a83765798e3930fbfed3a4478fd969f1b00 100644 GIT binary patch delta 78 zcmX?6@uz|}JtxGCiGhKk#)g5xW+SfxqmhnMN=b2iacW^{YF=_`d~#)SPG+)_l~QzC XVoq_YjzURMDUgJ6z|>}KMp0gZiyaE?G delta 33 pcmdn8m1)XWCf@X%5H}_U28JoK7#Mmc^8VPY!Z@xh%pJtxGCiGhLPgE9j{#YEm8n^hRw1vak{Oc4SAp`{7} diff --git a/docs/base/@vl2/shapes.vl2/shapes/teamlogo_inf.glb b/docs/base/@vl2/shapes.vl2/shapes/teamlogo_inf.glb index 7548785ee3967bbc29a87367099304a30f539098..db580345a0c285fbc21094a96b9433434ffe2c60 100644 GIT binary patch delta 63 zcmaD5&=AO*o)hB6#K6GNpuxbfW+LwoSskU6lH&N{)WXu#yyVpQ9%td3GjNpXB}YGG+=UUF)Da%FN(X0no%QglgC QY3gQX#zOJU#S&jx0bTzTb^rhX delta 31 ncmeCMePP3!o)hB6#K6FiA;-XwFp>AiW);SK@y$~tzOVuSl3WRx diff --git a/docs/base/@vl2/shapes.vl2/shapes/teamlogo_storm.glb b/docs/base/@vl2/shapes.vl2/shapes/teamlogo_storm.glb index 8bd646b8a874791f0a951f90db4f0a7aaecfa804..89b9e77aeb12b8638afce44fa0b923d8ab1ed3d0 100644 GIT binary patch delta 61 zcmX@(^2UWXJtxGCiGhJ3M~Q(!Vj)>JtxGCiGhK^M~Q)fV1ouR~@3J~dDJ8}6#i@m*sd>q%@yV6RIhn~yR!Y$& SMWv~mnHjmbHVbgi5CH&KP7@{o delta 36 scmX?Nzrvm`JtxGCiGhJ(g**epAFhdf-#4o;a&R##C@5^!;hrG^0Kwb|t^fc4 diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_aa_large.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_aa_large.glb index 94fbbf4ec39df42d65419c1504998b6c39fbca00..c40c34606c85a82bebbbc2e0a6f97f5fd4b48e37 100644 GIT binary patch delta 89 zcmcbyoN3AmCcgBX5H}_U1_qHS3=Aq>8~HRCt#p)9N{Zu)QwvK|^O95JlPi;RGLx08 Vl%mrTbBa@S6mV0UO&FI<0szoc9QptN delta 30 mcmbQTg6YO`CcgBX5H}_U28J7x85mx8ZsgNo++4)CXc7ROYzi9y diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_assaulttank_mortar.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_assaulttank_mortar.glb index 37a9092ac7ae5d6451c46e784d26e35bdf5fcd7d..f2293df9d8c266046d1babe0dc4f1b6721a2bb79 100644 GIT binary patch delta 114 zcmZ2+i}A-TM&9(C5H}_U28N1U28J~oc>@@Ib(B&{isOq@3rkb;l2hZ8E0c3Fla;KL hqSF#{ic@tIuu>&Or3fh`&gN)FQ4dCi%>|x2lmVtnCTaix delta 34 qcmexyi*dy*M&9(C5H}_U1_q5>28Ni8ya9}x*DwluY(C(*Lm2?a+zTZD diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_assaulttank_plasma.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_assaulttank_plasma.glb index d14631ab3288e90d6c5b4425f8cef8102550f638..28a7bfda288e05a931b4b2fb7c7ca4d4cf9d95b5 100644 GIT binary patch delta 88 zcmZoz%D87KBX4?6h#M0F1H+ym28JCQdDR%Lbd*v`isOq@3rkb;l2hZ8E0c3Fla;KL TqSF#{ic@tIa8sKN8T|tR=Q$kK delta 29 kcmdn9l(AtcBX4?6h#M0F14Ba)14GS5UNy$e`Ha4S0D))+`2YX_ diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_base_large.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_base_large.glb index 6c2e9717c6a7df4df5ebe062cad1b96e4114d7fb..e39d5c09cbc8692559c1bc369fcfc23ddef2055e 100644 GIT binary patch delta 101 zcmdmRk@?F-X5RFi5H}_U28J&$7#Msu@|rU`=qRO>6vr2*7M7;wC8x$GS0?9VCM#Jf gMW-d^6sPJapi(78rD$TCofvOTW>nZLJ#}g@0QkuxX#fBK delta 34 qcmexzk$J;KX5RFi5H}_U28InU7#KJ<@|rVlZezSLd2_6vr2*7M7;wC8x$GS0?9VCM#Jf eMW-d^6sPJapi(78rD$TC?HFAmH@8Ghu>b%|pCM@g delta 36 scmcbyjA_O)Cf@X%5H}_U1_p`A3=9Pud5sx2H!(UzGAe9795vMf0LQ5c*#H0l diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_belly_barrell.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_belly_barrell.glb index e261a06c383f412bdec8e08eef39df938bace1ac..d77ab2404f172d6c2b416002da39df6b9a5bbfba 100644 GIT binary patch delta 70 zcmaDMKS6;vJtxGCiGhJZK!AZ^%SK*CMpYf9l#=53;?%;@)V$=>_~gpuoXlh;E2ZeP W#GK+(9R)D8nTK%-=jQobo~!`KA{ABu delta 32 ocmbQB@Isz9JtxGCiGhLP1wR8r&qiKG#?7XTlQ=h@;PPMv0F*Zf%>V!Z diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_belly_barrelr.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_belly_barrelr.glb index 2a2bc81ea2997889544d08ed21fcb4ec744fe1c2..ca4ff23d06831ebe36407229536236b381145024 100644 GIT binary patch delta 72 zcmaDMKS6;vJtxGCiGhJZK!AZ^%SK*CMpYf9l#=53;?%;@)V$=>_~gpuoXlh;E2ZeP Y#GK+(9R)D8nTK%-C!@mV1zaAi0PsTV!Z diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_belly_base.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_belly_base.glb index ff3f08a09e306fdb5bf48c99fd834e2ca34a35af..083cc6a76d1d8cec7c896beda19ba91bb91a5ad9 100644 GIT binary patch delta 88 zcmbPHb)kwkJtxGCiGhJ3z?OlbVk55%qp^-sN=b2iacW^{YF=_`d~#)SPG+)_l~QzC aVoq_Yjsg~HvpS=$60?GW!sZa=Ba#5hwi}QD delta 32 ncmcamHKU3*JtxGCiGhJZ!j^%-VI!{$gXt?loZDorxuo`<|U`bCs!utWF{+F ZDMhCx<`k#uC?Hdt28~KD7H~TT(>tj^dtUV#O8UWiH3*i6& diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_fusion_large.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_fusion_large.glb index ee7299ca010a010ede51c9fe26e31b87dfcadc47..8fecbc66b6d43868f9323cc6b069dba53986673a 100644 GIT binary patch delta 86 zcmbR6hw;cCM&9(C5H}_U1_qZp28M);M1& diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_indoor_deployc.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_indoor_deployc.glb index 623a3d577672cad40bfe3ae8163f7e6c3d7bf960..2745a3e8e71606433d8d8b71789e0ce9483abc44 100644 GIT binary patch delta 106 zcmX@m#@x})%$uGQ;>N_lz|e7+fnmxN_lz~FG0fx%}ZuPx)|$&8}8j0&4qoynKwNr#Epr8fkEal14GD0URy?Y9i^0#;`rj!!qU{dDox$&!RS!Jte~Kyi|NNKCf@X%5H}_U28N1W28JUWd1V=mb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL ZqSF#{ic@tIuuz*d7^`hIFR@+V4*=2}9d7^t delta 34 qcmew{i|NQLCf@X%5H}_U1_qa228Ib6d1VsN6ybCP= diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_mortar_large.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_mortar_large.glb index ffa4a7e97d1f9ce8078d0aa6d260e410318b3300..17613a36267854c1b91cf33ac000bcfd80365583 100644 GIT binary patch delta 90 zcmcbyfn~x*7T)xn5H}_U28Ia|j0`U}^2#zA>nNp^6vr2*7M7;wC8x$GS0?9VCM#Jf dMW-d^6sPJaV4*f^FwR-Wte~K<`N;Yy82~IX9;pBT delta 34 qcmbQRk>$n)7T)xn5H}_U28IX;MurU=d1VH#716uMnfH?l#=53;?%;@)V$=>_~gpuoXlh;E2ZeP b#GK+(9fgvjQaA|~+N{M`r@VQ&%0nIiNGKbx delta 32 ocmdm!+>y+io)hB6#K6GNVaUKRWh1XVm*PJOG(42W0>N diff --git a/docs/base/@vl2/shapes.vl2/shapes/turret_tank_base.glb b/docs/base/@vl2/shapes.vl2/shapes/turret_tank_base.glb index ce70134c8dc98024d48e432f521d9a637c3b8e74..a303f00264e4e0730b04f491e9bd19e04d6fa967 100644 GIT binary patch delta 88 zcmeCMJz&e5o)hB6#K6FCK#qZ7!bV;hMq?eNl#=53;?%;@)V$=>_~gpuoXlh;E2ZeP a#GK+(9R)1ZW_3naL1qO7h0QraGCTmZiW;~8 delta 32 ncmX?L+hNO_o)hB6#K6GNA;-WFv5{AXadRA_v*6|>LNYu6jI{_4 diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_bomber.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_bomber.glb index c68c16d2802b9cb317766869db847210f15a5460..e44c7d7f37425e445390df7db4af4bacb7333235 100644 GIT binary patch delta 92 zcmZ4Rl=;C^X5RFi5H}_U28IWp7#NOh~-(@{z(DUL5rEi6sVOHPeXu1wC!Ojfc| ciY_TCP1R9=kZFlI#Xt@!1(Mnv%IN(O0P&b0%m4rY delta 29 lcmaFxlzG8ZX5RFi5H}_U28IQn7#LbM@_I3Dp3dm`5dfmb3UL4c diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_hapc.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_hapc.glb index 1095c5e250040a2039dc63b764cd44f2ac9867b3..e625ab29ab0dd5778c1c3e96ed3396823ca01207 100644 GIT binary patch delta 104 zcmZ26f#t&l7T)xn5H}_U28IF-MusmNc_SFzbd*v`isOq@3rkb;l2hZ8E0c3Fla;KL dqSF#{ic@tIP^prlQmkUl$&A~R85xhV0RZn!B2)kX delta 33 pcmew`fn~)67T)xn5H}_U1_lidMus&Tc_SE`*D`Kj%gA_`4FIS&36TH* diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_scout.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_air_scout.glb index ff26364c58341ed014f10fdfb1b11a546b7237a0..b7a7916485b4b2a6c46998f18efe777dd5ad066a 100644 GIT binary patch delta 99 zcmZqpz;xgP6JL5xh#M0F1B1g31_qPVjeK5=_Bu)_CB^Z@sfDGfdC95q$(6}DnaN64 iO3`VFImM|u3aC^`Q7KRiLV{&BhcRwU-prBuBM1OqCn78W delta 37 scmX@`fvMpG6JL5xh#M0F5bR)J_>!`b&x>*MOvd%ej0&4QQhx*i0Pxog<^TWy diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_grav_scout.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_grav_scout.glb index 122a34d2ccc08d8cdc30ce0bb273dbea3003ab06..e53bf73b968c493a174f6099d5d15e033e665b0c 100644 GIT binary patch delta 78 zcmZ4Ti0Q&3Cf@X%5H}_U28Mu*3=A7K@=7ym>nNp^6vr2*7M7;wC8x$GS0?9VCM#Jf dMW-d^6sPJaloXW$Nib)#8e?Jd<{2qHJ^%(h8xjBj delta 36 scmccch-t|qCf@X%5H}_U1_qUl3=AzBd8HXQhcf0TGb(I8lG5V?0NXnYn*aa+ diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_grav_tank.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_grav_tank.glb index 1a6046477df015df7aae187aed170a48d244f5b5..9acac95f5e363d2f02f0598b195563b78b331ebf 100644 GIT binary patch delta 80 zcmbR6kNL^0G3j>L{g@6vr2*7M7;wC8x$GS0?9VCM#Jf YMW-d^6sPJafT_&_jHxl3D`H)|0e&|awg3PC delta 38 ucmaEGk!jCGCf@X%5H}_U28KN=7#LDE^0G2+wq#6>VOCI3*gPlJ#Tx+iR11{= diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_land_assault.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_land_assault.glb index cd3716ee1292aedf5d8b88724aac7a1bb6104685..51cfefc1b5d29884b52947ad9f71ba082884d4ad 100644 GIT binary patch delta 72 zcmeDAz_{fDBX4?6h#M0F1A|Eg1H+V!ysV6>I!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA Y(P@b}#i=?9U~01fV}aG?dh1>r07j7)&Hw-a delta 34 qcmdn;fwAWUBX4?6h#M0F0|QS514GV6URK7^0G3j>L{g@6vr2*7M7;wC8x$GS0?9VCM#Jf YMW-d^6sPJafT_&_jHxl3D`H)|0e&|awg3PC delta 38 ucmaEGk!jCGCf@X%5H}_U28KN=7#LDE^0G2+wq#6>VOCI3*gPlJ#Tx+iR11{= diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_land_mpbase.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_land_mpbase.glb index 42d7a156a5921586397d8db7aedce97e379efb13..7a7e8f2431b47a04215a7cb5527671b3373d2bd8 100644 GIT binary patch delta 198 zcmbQSLUPGUN#69F5H}_U28JaeYz#{_@}6R>*HKC-DUL5rEi6sVOHPeXu1wC!Ojfc| ziY_TCP1RArPo^d26ay8JO92h%gWCZ%r1>i2_N$DHAsOvDS&Tr;1jNih%(7i4i}lS* E02;(Ywg3PC delta 59 zcmZ3oQgX%$N#69F5H}_U1_p@`HU^1}yr&qO)0noWF);>ZFe@l1wC~7b1Y#y2W(H!G L?K`qq-@F6>3V;*X diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_pad.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_pad.glb index 13e83b48a88b3defad75dd0d5fb0514d89654d2a..6c4d6d1ebfe112635969028d6609d6aa2541362c 100644 GIT binary patch delta 78 zcmeyejD5~>cHZ=y5H}_U28KD885u%0^0G3j=qRO>6vr2*7M7;wC8x$GS0?9VCM#Jf iMW-d^6sPJaloXYwHVZIr7hq&GP-j%wZm+>;x*7o4KNtT1 delta 39 vcmbQUoc+r(cHZ=y5H}_U28NQ$j0`#(d082oEf}|3Ff!_?Z_m(RG+7M*>2?aq diff --git a/docs/base/@vl2/shapes.vl2/shapes/vehicle_pad_station.glb b/docs/base/@vl2/shapes.vl2/shapes/vehicle_pad_station.glb index 7f4fc1b9d1d4e94196f2821cc26f251f459f7375..9325ad48fdd5f9dbead01d3e2784a51975e2d3a6 100644 GIT binary patch delta 80 zcmZ2;fce1zX5RFi5H}_U28M(O3=9Puc@-Fqbd*v`isOq@3rkb;l2hZ8E0c3Fla;KL aqSF#{ic@tIN{UK>B$NZDHfu97-Uk3J78=w5 delta 29 lcmaEGfO*XUX5RFi5H}_U1_qr63=B3Kc@-EpCo=xO2LO?t38(-7 diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_chaingun.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_chaingun.glb index 0cfabdd163b0313466e61ab00e1ba3c682e550b0..b60e19706d1f7320bf469863ea6c0239adb90fc1 100644 GIT binary patch delta 72 zcmbO+pXtbaCf@X%5H}_U28JX33=C^F^71lj=_sX?6vr2*7M7;wC8x$GS0?9VCM#Jf XMVAznrs^m_$h5?q;?&I&j17GNPi`0u delta 29 lcmX>ypJ~Q?Cf@X%5H}_U28J2^3=9n$d3hN(yD`@F0RV@R2$TQ- diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_disc.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_disc.glb index cac1468156e0bf739a8fb843078d3f323ba610cb..1d2c340c814e85ff72f317f4da0815548325fadd 100644 GIT binary patch delta 91 zcmeyen{mw^M!xi%5H}_U1_qrt1_lGmjeJ^+<~m9#CB^Z@sfDGfdC95q$(6}DnaN64 eO3@`nrKvg!X^A<-KnjDi*^Ke3`DPx=7b*ZIcOEMM delta 35 rcmZ3phw;m9M!xi%5H}_U28J)O3=BUkHu7mPZZ2fJY`)pq@}&v@;4chq diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_energy.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_energy.glb index 23e151a7861a9c5cc0b07c01d54c204a2c070042..12f660553f4822f7d84acc321502a8686d409423 100644 GIT binary patch delta 80 zcmcaIov~vEBX4?6h#M0F0|SQ-14GV6UO7f19i^0#;`rj!!qU{dy#UEg8E^mq delta 29 lcmeB}!FXjlBX4?6h#M0F1H%<>1_q0bymE}2;~7_a0RV##2t)t? diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_grenade_launcher.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_grenade_launcher.glb index 2defc5e2691af0827ffaa1c86fc0db6ec8e84458..334ed138328d60a75ee47e019d7daa16bbe851c5 100644 GIT binary patch delta 72 zcmeC##JFV>BVT$>h#M0F1A|E<1A~m&LOw=S9i^0#;`rj!!qU{dh#M0F0|QSa1H%{7g?x;gO&NcgY&I}sQ3e3AjS0B` diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_missile.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_missile.glb index ce44dd4b6d5313073d43b58284bbbd22adb76546..a5cc81312fbd592d4612f4ae79b0221c445a317d 100644 GIT binary patch delta 57 zcmaD*(oo8qo)hB6#K6GNV8y`jVIuE$IUS{xlH&N{)WXu#yyVpQ0s2r>Ww diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_mortar.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_mortar.glb index 03419a7cd530c173b43a23f97bd637c8ea659252..ef1135d2b9351b3368c1f6984129bc5680845645 100644 GIT binary patch delta 63 zcmX>zhxx@EX5RFi5H}_U28N7t3=A$4dB4l*D5aDX#}}s-mZs( delta 29 lcmZ2;is{EmCf@X%5H}_U28JI?7#LVK^2#x8j%Pf(7yz1Y3Ag|N diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_repair.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_repair.glb index 468b059a42a5b7cc78107f0b74a6a4381e21a390..b25960e8bd2045017c0d7895084b2e63a440330a 100644 GIT binary patch delta 74 zcmaEGjj7{06K{G>h#M0F14GAZ28NW4yv&R$I!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA e(P@b}#i=?9B}JvFoB0@>l9&_}HU}gNcmM!`G8d2l delta 34 qcmeCU&h+3K6K{G>h#M0F14F`U1_qmryv&T7%@`e$HdiDIcmM#s;tCM} diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_shocklance.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_shocklance.glb index 90877db38831a5d36b8b998aa264770897a4e943..cef5e65151a3aea4a257d5d81cf200c2ecf6c274 100644 GIT binary patch delta 72 zcmexyg=xuECf@X%5H}_U28Jc87#Mms^71ii=_sX?6vr2*7M7;wC8x$GS0?9VCM#Jf WMW-d^6sPJaloXXh$<30C@hbs#d>D@a delta 29 lcmZ2-mFdS7Cf@X%5H}_U28N1N3=9bydHEPOyEDeF1OS%`2^IhV diff --git a/docs/base/@vl2/shapes.vl2/shapes/weapon_sniper.glb b/docs/base/@vl2/shapes.vl2/shapes/weapon_sniper.glb index 1b6f958d2fe4460bff90ba95d9ac9347c4d3c95f..80e3f7fe2f0fd2a7a2ce315e7b80ba34b0bdbe98 100644 GIT binary patch delta 74 zcmdn7gYm%*M&9(C5H}_U28M(f28IyiAOnO&D9PH}A1oA`bw%^udugJtxGCiGhLPg8~CX#6;d7n^hRo1vd8xw(tW0oihor diff --git a/docs/base/@vl2/shapes.vl2/shapes/xorg4.glb b/docs/base/@vl2/shapes.vl2/shapes/xorg4.glb index e084c8f8628f15d84574f5f86b4325903906e265..918de19154250ce07c653ef5218404d6a774ea19 100644 GIT binary patch delta 63 zcmX@1{X&~JJtxGCiGhLPg(w5Viix~GWObBMN{Zu)QwvK|^O95JlPi;RGLx08l%h+D TN>ev8GtT5;RMv=j;s93%2FCyZ diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/buildStation.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/buildStation.glb index 0391ed2b7001c7e3f7d72b9230eaab06aebd89cf..eaffacc99d9358d4b1d93d8df7f3140296d2f064 100644 GIT binary patch delta 73 zcmdn+g6YN!Cf@X%5H}_U28M_&3=AO~d07}$bd*v`isOq@3rkb;l2hZ8E0c3Fla;KL dqSF#{ic@tIN{UKTH}f+ZCNnB*wom!!4*+t67)1a8 delta 34 qcmccdf@#AGCf@X%5H}_U1_pyI3=BFOd07}Yn=|SsZ_Y^h;12-APYUM% diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/cannonTip.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/cannonTip.glb index fc93d23a5277862b258898c71e0d583d07b66072..0fa6962ea54200c68cfccd63f1e69868ae2ff04e 100644 GIT binary patch delta 56 zcmZqhU*ON1o)hB6#K6F?K%If%%S7Iv delta 26 hcmZ4B-{8-io)hB6#K6GNpw7T>Wg_p_%}R`QY5-^o2g3jW diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/dsFlame.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/dsFlame.glb index a3820d4e796585b7501d545490cef253d5f05dfc..5c883246219525095f86388a367bbab5c0c078a0 100644 GIT binary patch delta 61 zcmdm>a6y4LJtxGCiGhJ3K!Aba&P3iHvN}pBCB^Z@sfDGfdC95q$(6}DnaN64O3@`n RrKy{l8P9TTKF^uR1^`(h6lwqf delta 31 ncmcbhut9-0JtxGCiGhK^K!AZ^&qUrIn^hQ3b8P;=nZO1BkhTeo diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/dsPlane.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/dsPlane.glb index b90e0e148a12ceae0c900b24f2bec00f0191e942..8a64817171eb2db376c9220c258e4f536f61cf75 100644 GIT binary patch delta 67 zcmeBq!nWcG8*h3}h#M0F1B1pUMusyJd4I_2D5aDX#}}s-mZs(Nzh#M0F1H*zjd<+6Q6ZyW&>L{g@6vr2*7M7;wC8x$GS0?9VCM#Jf zMVAznrfz0tWYlhE)@f(fVFY3(AZ7+)79eH?Vm2UV2VxE&<^*CcAm#>Q9w6r3&aA^% GTL1uEDj$ph delta 90 zcmZ3m)2d;o6<>Nzh#M0F14F|cK86q46ZyVxR$=_F)vTh^uA;*T#7scU48$xz%nHP8 cK+F!r96-zo#9Tnk4a7V^%)4Dhhp(mp0K%CVdH?_b diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/faceSphere.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/faceSphere.glb index 8f9e833487a8f362c8b1e4dbbc9daa390693039d..e08b6323b167c7c58d5c9cc9fc81c12dbc6c6742 100644 GIT binary patch delta 229 zcmWN=y9)tv0KoCzd7amJzuykGxH2;ul#+ z@$J_cogMw+=n`FY(?c(Pl<8-HL53Kn!U&^`G0p^&Ofk(2v&=Ei0*frM%nGZlu}+l@ MHraYRy4Jn_0V{b`y#N3J delta 191 zcmWN=y$ymu0Dw^rR6sq!Ule~h5NWtMoWKF-Y#72s6B>)Nu)-}Y?48Qe?PY15BYoNqAne!)Ya(5XhE9}JM6MYmmYogIpC0zBL)mP=7dwuIOl>9ms~OC Vnj3DpV?xE08TZV2_!wQ>pMT5$KJWkl diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/hellFireGun.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/hellFireGun.glb index ea401ebb33b2e4a7320ade9b3de761759f01e825..1149079d2e87f8c188c3f8a044b30c3469c03b31 100644 GIT binary patch delta 57 zcmeBCU8BmEo)hB6#K6F?Mu>rdg=Zq)7daiJl#=53;?%;@)V$=>_~gpuoXlh;E2ZeP M#GK;PO^iK)0Nd^n+5i9m delta 27 icmZ3Z+M~*so)hB6#K6GNBgDY)gnJ_2m(5CyU4j5-u?LX= diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/hellFireTurret.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/hellFireTurret.glb index 2a286650c1da6d0a7d356d342d2caf478ee3646b..ee2d1e2a167f5703200c5e590a98157ebd3b41b6 100644 GIT binary patch delta 86 zcmZ27kLkudCf@X%5H}_U28M`!28Iy~Cf@X%5H}_U1_qUW28NQ2yb6q)lNh6785K6~iJM~p0LGCD#sB~S diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1CMDStation.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1CMDStation.glb index 120a3c90b46d4164125f1dc5447e2413caa94beb..8402da31debdec3ac9c26f9c834a6788bd7e7620 100644 GIT binary patch delta 78 zcmcbzma$1_qmryaJ4yJsE!o0swsc2j&0( diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1GrenadeLauncher.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1GrenadeLauncher.glb index e3e371d53214803ab3e7155e2c1835929676f299..c4a8505d9882d8e468cfeaf6a1d34639972704ee 100644 GIT binary patch delta 56 zcmdmBb-{`^JtxGCiGhJ3K$d~w!$jV%aym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF LImM})7!70q1Sb-S delta 26 hcmca$wZV!vJtxGCiGhK^K$d~w!bIM$o0S;#WB_O+2SES; diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1LSensor.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1LSensor.glb index 8a5d12580f1e54e40a21f47086632a71bbde8055..f421f26d379afa2f64d9e89ad6171e3984ba9b2f 100644 GIT binary patch delta 73 zcmbO*ooUB(Cf@X%5H}_U28JEo3=DHN@^Ub$=qRO>6vr2*7M7;wC8x$GS0?9VCM#Jf dMVAznrs^o9CFT^TZWd-N)nHWE+^)%)1OQN07b^e& delta 34 qcmdlnooT{!Cf@X%5H}_U28IdU3=Ab3c{vz2TQe4GY~G;Bkpuv+HVMrD diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1MisTurret.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1MisTurret.glb index 825b24361da975980b5c88ef917e465a506e3117..d080bba0d0d0abef033d79b950f44be039d3eac8 100644 GIT binary patch delta 86 zcmZqKz_eon6K{G>h#M0F1B1m328KTyc@-Fqb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL ZqSF#{ic@tIuuz+|88`ZEzU!~<0RXuI9X9{~ delta 34 qcmdn7fvIH!6K{G>h#M0F0|Uzp28I(Gc@-EpCo!(~+bj^E;Q;`%eF^pe diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1PowerGen.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1PowerGen.glb index 4f36a5c8484c8714357e6f267c0eb7fc734acdf4..e38d708feaefe42de3592a5effbe1344ecb52d2a 100644 GIT binary patch delta 74 zcmcc7$k@=t$eW%M;>N@P1da?0FE;YBF{N_lz;MHXf#JYLUN*+fmW&5=HviFO5e5LWa|%QN diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RemoteTurret.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RemoteTurret.glb index 6dbb88fc469aa674f9118a038c8eb49a8a631f1a..393b563868fb4f4fdfaf5d0df14b8a4aa4ae0f02 100644 GIT binary patch delta 90 zcmexzo@vbmCf@X%5H}_U1_qrK3=9Pud1V-lb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL dqSF#{ic@tIuuz-T8CBDm6%-UU`=qaM001*F9XS91 delta 34 qcmZ2;f$7V6Cf@X%5H}_U28J)o85k@!^2#u7j$>3#+uV}A!T|u$8VipA diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RepairPack.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RepairPack.glb index f6f38305c0c4921cc15684ac80275d716c1b4a25..9e5ea37111c277d3e9e66c758b84104db4ed8b8d 100644 GIT binary patch delta 62 zcmcbU_a~1xJtxGCiGhKk#+-p+$3)(*vN}pBCB^Z@sfDGfdC95q$(6}DnaN64O3@`n SrKy`3*Jv{;Y+j?YfeQey?G^k0 delta 31 ncmey9cPEcGJtxGCiGhJ3#+-p+#zfw)n-v*XX>UHGvw;f$u$2n_ diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RepairPackGun.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1RepairPackGun.glb index caf2db2d5623fd628884187804298abe0fbdfae8..77ca69086d605bb5c1d8a3a80ca2cd8c86c939ea 100644 GIT binary patch delta 62 zcmZn&S`fsWo)hB6#K6Fypvk}xGLiSItd3GjNpXB}YGG+=UUF)Da%FN(X0no%QglgC RY3e3M4>?AK%^vbQH~~wM6Jr1X delta 31 lcmZ1w)DXm*o)hB6!~g`E3=Ad{dB1K}WOS3;oFTu1699u92xR~O diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1Sentry.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1Sentry.glb index a28a7aefd9a4e5c1e1e9fd9f413e4f649bab6faa..59f0e781f8c8aa8e0ef21069828a542dac1fd425 100644 GIT binary patch delta 86 zcmZ3ng7MA@M&9(C5H}_U28Ngr28IgcbG4b0RX6&9Bcpp delta 36 scmcb!f^o$PM&9(C5H}_U1_q4~28NQ2yb6q)lNh7S7!@|}F<&490K@?bO8@`> diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1Solar.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1Solar.glb index f4b0870a9c9bcea123772946091e695b590ce8aa..3be368f2591bdfba8e8a61d9bd658920dfaaf391 100644 GIT binary patch delta 71 zcmey;!#JatkvBaj#Epr8fnkOl14F|`UN%M*9i^0#;`rj!!qU{d3oZZv diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1VehStation.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1VehStation.glb index e133f6a79d753682fbf22e74dc4145b8c5268012..501afc4fc987243399da6eb5433dcc0ca97e33e6 100644 GIT binary patch delta 79 zcmX>zk?F@oCcgBX5H}_U28JIU3=9IX8~KD8wRMzIN{Zu)QwvK|^O95JlPi;RGLx08 el%mrTbBa@S6iSLpfh3r-S)TDm^yVKiSF`~KNE^)n delta 35 rcmew{k?G7tCcgBX5H}_U28J^o3=B_VHu4EGZuVom7QInNp^6vr2*7M7;wC8x$GS0?9VCM#Jf eMW-d^6sPJaloXW$Nib)#JmU`U%{P2*=l}paNE}lD delta 47 zcmccfnQ_BsM&9(C5H}_U28Iol3=Bs$@`^BS_G8@U&7p8Xhk?P#({J+p0H4j_zO6a{ DfS3=5 diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1blaster.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1blaster.glb index 8684cd720617598bd9fca01a4a6615931be52a71..9b613c622ab0823f1eec88e04fb197867d260ad9 100644 GIT binary patch delta 63 zcmcaHh4IG}M&9(C5H}_U28IeR28N!Aygy}ilu}BHlXEhYm8_Ja TONvTUH?uI-m~E~%zbOO&sqq!} delta 33 pcmew{h4ID|M&9(C5H}_U28IYP28Nu8ygxUqGFF*wUSNJh2mrdE3mE_a diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1disc.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1disc.glb index 78c08aa05da976fa3b0174c666ff1990c1bb4848..34a7055b6625c316d324f70b850e364f82e3de60 100644 GIT binary patch delta 90 zcmbPXbH#=?JtxGCiGhJ3M2>;s%SK);MoS%~l#=53;?%;@)V$=>_~gpuoXlh;E2ZeP d#GK+(9fgvjQXmQCAXA%78K(N9e)4- delta 32 ocmca&GsA{AJtxGCiGhJZLXLr9$3|W)#?3{HQ-wBji1=^;0FS*0DgXcg diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1elfTurret.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1elfTurret.glb index 9b0263c72102351ff97e9689b56943d2a822af8e..bad9328c7f5d389bf782f7e4cceed449c7c58150 100644 GIT binary patch delta 86 zcmdmUiSffFM&9(C5H}_U28M!628I_Kc@-Fqb(B&{isOq@3rkb;l2hZ8E0c3Fla;KL ZqSF#{ic@tIuuz+|8Rs}}KH*ZL0s!zK9mfCw delta 34 qcmexxiE+;*M&9(C5H}_U1_ql<28Jygc@-EpCo#@)-u&C8R0ROctqX+! diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1flyer.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1flyer.glb index f0015a7f354557778ecaa64738ff1253cd84a0c2..3cdc80bbdba91f7107b0a71c1e91c8aca4d3d68c 100644 GIT binary patch delta 57 zcmez1J;8@JJtxGCiGhJZK#hT+W+LxTIUS{xlH&N{)WXu#yyVpQ^TC@pJtxGCiGhLPgDL|<%tYRwo7EU!sQ>_Sp$LQk diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1flyer2.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1flyer2.glb index 06f54e5802a9bef19d06d41039daf382ea9365eb..3f0f4cb1b3b60c54074d02142eb9deabba64953b 100644 GIT binary patch delta 57 zcmez3J;jGNJtxGCiGhJZM2&%=VIuEOIUS{xlH&N{)WXu#yyVpQ_T$q1ML diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1hpc.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1hpc.glb index 9cca5505bedda95f0f7eb7aba9333f6e3659956f..bfda30a159fdc34c1acea985587ec916fa497a74 100644 GIT binary patch delta 57 zcmdl|bESqiJtxGCiGhJ3#EyaCz(n4kaym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF MImM})Sr`p$0W<^?Gynhq delta 26 hcmcaov!#YNJtxGCiGhK^#EyYs!9?Dlo7EWgYyowp2kQU; diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1inventorystation.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1inventorystation.glb index 1571da19446d061b3d53b47000f60d7f7dff5497..ee4331c53b6bc9cabbe244624995fa139e9e3be7 100644 GIT binary patch delta 82 zcmca|gt6r)BX4?6h#M0F14By^14G6}UJ*uZ9i^0#;`rj!!qU{d1B1mzUJ=I4evH~~n`_)Tqyezu2`vBs diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1lpc.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1lpc.glb index b6a1846054cf1c4f38bbf5063760b3c029dd7a53..abc7050aa0fbb3741d672c693d0990810962d281 100644 GIT binary patch delta 57 zcmaD6*AdT~o)hB6#K6GNq0hi@U?T5NIUS{xlH&N{)WXu#yyVpQa2jTz# diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1mSensor.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1mSensor.glb index 14e7c238280537ca068515c0bd28e1199cc696e4..c9425ebebf41e543c0ab1ada96bb886299a6742d 100644 GIT binary patch delta 71 zcmexzm~qAtM&9(C5H}_U1_p^F28N7{yc~=wI!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA b(IrKtsX7X2i8;lon}r#jWj9C2&2a_*7seK) delta 37 tcmbPngz?K^M&9(C5H}_U28J(*3=A$Cc{vz2TQfS!GASr*u92JL3;^9%3atPD diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1mortar.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1mortar.glb index b8658bc6a56066071d6a7b158d39753e327b371f..eda284aef8e50e156785077b12ff97492a44e395 100644 GIT binary patch delta 56 zcmca%_QQ-fJtxGCiGhKkLYjf$%|za>aym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF LImM})7$c+r8NCx3 delta 26 hcmexicEgM}JtxGCiGhJ3LYjf$%tYR=o0S;DqyTYF2hjik diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1pGen.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t1pGen.glb index 50fd943a0fa9914e52658a32f30ce5e02dd10930..6feb57e604a9e72ab503fdc900dcd8c21bb1e99b 100644 GIT binary patch delta 71 zcmdmSfbq@&M&9(C5H}_U28Ngf28NuCyljjrI!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA b(IrKtsX7X2i8;lon*|v?JvPU9-Vp-;C^8pY delta 37 tcmca}fN{qGM&9(C5H}_U1_p}+1_qCfyljk{Eg9WCm=qK?H+bF=0|3yt3Saym*WCB^Z@sfDGfdC95q$(6}DnaN64O3`VF LImM})7+qul52q5< delta 26 hcmaE2b;OD{JtxGCiGhK^MV5i#%tYR=o0S-yWB_dx2aNy# diff --git a/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t2DepAmmo.glb b/docs/base/@vl2/z_mappacks/z_DMP2-V0.6.vl2/shapes/t2DepAmmo.glb index 76bc5d4a4e9257fc41c666af0e3f8676a18cd1df..f97d4b3f69379b98238c4a53ffa5e764a0d49260 100644 GIT binary patch delta 72 zcmaE`m$_#jGjDoMh#M0F0|U=}28NW4yaJ3`I!Y-e#qq_dg{7%^$*J+lmB~4o$x2pA W(P@b}#i=?9B}JuBaMapGenius – Explore maps for Tribes 2 \ No newline at end of file +MapGenius – Explore maps for Tribes 2 \ No newline at end of file diff --git a/docs/index.txt b/docs/index.txt index f349044e..0f7d73dd 100644 --- a/docs/index.txt +++ b/docs/index.txt @@ -3,16 +3,16 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 5:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -6:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/94212136ebe55507.js"],"default"] +6:I[31713,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","/t2-mapper/_next/static/chunks/164bc8495505bc95.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","/t2-mapper/_next/static/chunks/629d98e413c0344a.js","/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js"],"default"] 9:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] a:"$Sreact.suspense" c:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ViewportBoundary"] e:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 10:I[68027,[],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -:HL["/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3a7943ba4f8effca.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/29cbf5720c3c6313.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/90c5f23d057a7dda.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/c0475cead0a67c33.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/07f1e4bb8e7d8066.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/d96f10e4606ed566.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/44bbdd420cb3ec27.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/94212136ebe55507.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +:HL["/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","style"] +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["",""],"q":"","i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","link","1",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/bd03a29a57c8ca45.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/2400be5b6a2e4806.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/164bc8495505bc95.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/ee88398bb27ad4a1.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/576b06837c0cb7a0.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/b07469fc6c6cd3bb.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/629d98e413c0344a.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/9eaea0ae086bad69.js","async":true,"nonce":"$undefined"}],["$","script","script-9",{"src":"/t2-mapper/_next/static/chunks/037fbc56cebf7caa.js","async":true,"nonce":"$undefined"}],["$","script","script-10",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true,"nonce":"$undefined"}],["$","script","script-11",{"src":"/t2-mapper/_next/static/chunks/49bf5eb2ca42014f.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} 7:{} 8:"$0:f:0:1:1:children:0:props:children:0:props:serverProvidedParams:params" d:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] diff --git a/docs/shapes/__next._full.txt b/docs/shapes/__next._full.txt index 970a188e..1506006f 100644 --- a/docs/shapes/__next._full.txt +++ b/docs/shapes/__next._full.txt @@ -3,15 +3,15 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 5:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -6:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js"],"default"] +6:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","/t2-mapper/_next/static/chunks/12261e943ff623d2.js","/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js"],"default"] 9:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] a:"$Sreact.suspense" c:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ViewportBoundary"] e:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 10:I[68027,[],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["","shapes",""],"q":"","i":false,"f":[[["",{"children":["shapes",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["","shapes",""],"q":"","i":false,"f":[[["",{"children":["shapes",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/12261e943ff623d2.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} 7:{} 8:"$0:f:0:1:1:children:1:children:0:props:children:0:props:serverProvidedParams:params" d:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] diff --git a/docs/shapes/__next._head.txt b/docs/shapes/__next._head.txt index 171861f4..462067a2 100644 --- a/docs/shapes/__next._head.txt +++ b/docs/shapes/__next._head.txt @@ -3,4 +3,4 @@ 3:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 4:"$Sreact.suspense" 5:I[27201,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"IconMark"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","h",{"children":[null,["$","$L2",null,{"children":[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]]}],["$","div",null,{"hidden":true,"children":["$","$L3",null,{"children":["$","$4",null,{"name":"Next.Metadata","children":[["$","title","0",{"children":"MapGenius – Explore maps for Tribes 2"}],["$","meta","1",{"name":"description","content":"Tribes 2 forever."}],["$","link","2",{"rel":"icon","href":"/t2-mapper/icon.png?icon.2911bba1.png","sizes":"108x128","type":"image/png"}],["$","$L5","3",{}]]}]}]}],null]}],"loading":null,"isPartial":false} diff --git a/docs/shapes/__next._index.txt b/docs/shapes/__next._index.txt index f8230d2e..42eb3c22 100644 --- a/docs/shapes/__next._index.txt +++ b/docs/shapes/__next._index.txt @@ -3,4 +3,4 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","template":["$","$L4",null,{}],"notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]]}]}]}]}]]}],"loading":null,"isPartial":false} diff --git a/docs/shapes/__next._tree.txt b/docs/shapes/__next._tree.txt index 48adfd6c..65288d7b 100644 --- a/docs/shapes/__next._tree.txt +++ b/docs/shapes/__next._tree.txt @@ -1,3 +1,3 @@ :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"shapes","paramType":null,"paramKey":"shapes","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":false}},"isRootLayout":true},"staleTime":300} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +0:{"buildId":"JablvlklHXp4NGWk4TTlC","tree":{"name":"","paramType":null,"paramKey":"","hasRuntimePrefetch":false,"slots":{"children":{"name":"shapes","paramType":null,"paramKey":"shapes","hasRuntimePrefetch":false,"slots":{"children":{"name":"__PAGE__","paramType":null,"paramKey":"__PAGE__","hasRuntimePrefetch":false,"slots":null,"isRootLayout":false}},"isRootLayout":false}},"isRootLayout":true},"staleTime":300} diff --git a/docs/shapes/__next.shapes.__PAGE__.txt b/docs/shapes/__next.shapes.__PAGE__.txt index 9dbdd6d6..a6b170e4 100644 --- a/docs/shapes/__next.shapes.__PAGE__.txt +++ b/docs/shapes/__next.shapes.__PAGE__.txt @@ -1,10 +1,10 @@ 1:"$Sreact.fragment" 2:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -3:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js"],"default"] +3:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","/t2-mapper/_next/static/chunks/12261e943ff623d2.js","/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js"],"default"] 6:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] 7:"$Sreact.suspense" -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","async":true}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","async":true}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","async":true}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js","async":true}]],["$","$L6",null,{"children":["$","$7",null,{"name":"Next.MetadataOutlet","children":"$@8"}]}]]}],"loading":null,"isPartial":false} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[["$","$L2",null,{"Component":"$3","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@4","$@5"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","async":true}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","async":true}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","async":true}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/12261e943ff623d2.js","async":true}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","async":true}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true}]],["$","$L6",null,{"children":["$","$7",null,{"name":"Next.MetadataOutlet","children":"$@8"}]}]]}],"loading":null,"isPartial":false} 4:{} 5:"$0:rsc:props:children:0:props:serverProvidedParams:params" 8:null diff --git a/docs/shapes/__next.shapes.txt b/docs/shapes/__next.shapes.txt index 0b76f1d5..30a01e63 100644 --- a/docs/shapes/__next.shapes.txt +++ b/docs/shapes/__next.shapes.txt @@ -1,4 +1,4 @@ 1:"$Sreact.fragment" 2:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 3:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] -0:{"buildId":"6xhnTWazjCi9htjLDl3f1","rsc":["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}]}]]}],"loading":null,"isPartial":false} +0:{"buildId":"JablvlklHXp4NGWk4TTlC","rsc":["$","$1","c",{"children":[null,["$","$L2",null,{"parallelRouterKey":"children","template":["$","$L3",null,{}]}]]}],"loading":null,"isPartial":false} diff --git a/docs/shapes/index.html b/docs/shapes/index.html index 6d92c190..d0f4aa9b 100644 --- a/docs/shapes/index.html +++ b/docs/shapes/index.html @@ -1 +1 @@ -MapGenius – Explore maps for Tribes 2 \ No newline at end of file +MapGenius – Explore maps for Tribes 2 \ No newline at end of file diff --git a/docs/shapes/index.txt b/docs/shapes/index.txt index 970a188e..1506006f 100644 --- a/docs/shapes/index.txt +++ b/docs/shapes/index.txt @@ -3,15 +3,15 @@ 3:I[39756,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 4:I[37457,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"default"] 5:I[47257,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ClientPageRoot"] -6:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js"],"default"] +6:I[39724,["/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","/t2-mapper/_next/static/chunks/12261e943ff623d2.js","/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","/t2-mapper/_next/static/chunks/153d5796298dee1e.js","/t2-mapper/_next/static/chunks/1a2c6dc513278881.js"],"default"] 9:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"OutletBoundary"] a:"$Sreact.suspense" c:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"ViewportBoundary"] e:I[97367,["/t2-mapper/_next/static/chunks/2f236954d6a65e12.js"],"MetadataBoundary"] 10:I[68027,[],"default"] :HL["/t2-mapper/_next/static/chunks/e620039d1c837dab.css","style"] -:HL["/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","style"] -0:{"P":null,"b":"6xhnTWazjCi9htjLDl3f1","c":["","shapes",""],"q":"","i":false,"f":[[["",{"children":["shapes",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/3e57999e46d7efb4.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/91476c9d2f29d071.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/53a9c1169e187e33.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/20b7c805b0b1f5f3.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/fe8d2153bfb8c263.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} +:HL["/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","style"] +0:{"P":null,"b":"JablvlklHXp4NGWk4TTlC","c":["","shapes",""],"q":"","i":false,"f":[[["",{"children":["shapes",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],[["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/e620039d1c837dab.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/89fcb9c19e93d0ef.js","async":true,"nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"defaultOptions":{"clearOnDefault":false},"children":["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]}]]}],{"children":[["$","$1","c",{"children":[null,["$","$L3",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L4",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":"$undefined","forbidden":"$undefined","unauthorized":"$undefined"}]]}],{"children":[["$","$1","c",{"children":[["$","$L5",null,{"Component":"$6","serverProvidedParams":{"searchParams":{},"params":{},"promises":["$@7","$@8"]}}],[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/chunks/12ed5d454f7c6ac3.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}],["$","script","script-0",{"src":"/t2-mapper/_next/static/chunks/88a5cf0ea7f16af4.js","async":true,"nonce":"$undefined"}],["$","script","script-1",{"src":"/t2-mapper/_next/static/chunks/14c6376ae0b23060.js","async":true,"nonce":"$undefined"}],["$","script","script-2",{"src":"/t2-mapper/_next/static/chunks/b00acbf8afd8b4b6.js","async":true,"nonce":"$undefined"}],["$","script","script-3",{"src":"/t2-mapper/_next/static/chunks/818dce712bc45cb4.js","async":true,"nonce":"$undefined"}],["$","script","script-4",{"src":"/t2-mapper/_next/static/chunks/2edeeda5ca6dc680.js","async":true,"nonce":"$undefined"}],["$","script","script-5",{"src":"/t2-mapper/_next/static/chunks/12261e943ff623d2.js","async":true,"nonce":"$undefined"}],["$","script","script-6",{"src":"/t2-mapper/_next/static/chunks/e1a8caa90a5343cf.js","async":true,"nonce":"$undefined"}],["$","script","script-7",{"src":"/t2-mapper/_next/static/chunks/153d5796298dee1e.js","async":true,"nonce":"$undefined"}],["$","script","script-8",{"src":"/t2-mapper/_next/static/chunks/1a2c6dc513278881.js","async":true,"nonce":"$undefined"}]],["$","$L9",null,{"children":["$","$a",null,{"name":"Next.MetadataOutlet","children":"$@b"}]}]]}],{},null,false,false]},null,false,false]},null,false,false],["$","$1","h",{"children":[null,["$","$Lc",null,{"children":"$Ld"}],["$","div",null,{"hidden":true,"children":["$","$Le",null,{"children":["$","$a",null,{"name":"Next.Metadata","children":"$Lf"}]}]}],null]}],false]],"m":"$undefined","G":["$10",[]],"S":true} 7:{} 8:"$0:f:0:1:1:children:1:children:0:props:children:0:props:serverProvidedParams:params" d:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"}]] diff --git a/eslint.config.mjs b/eslint.config.mjs index ff744b47..b36a91ec 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -4,7 +4,7 @@ import nextConfig from "eslint-config-next/core-web-vitals"; import tseslint from "typescript-eslint"; export default defineConfig( - { ignores: ["docs/**", "generated/**"] }, + { ignores: [".yalc/**", "docs/**", "generated/**"] }, eslint.configs.recommended, tseslint.configs.recommended, ...nextConfig, @@ -15,6 +15,9 @@ export default defineConfig( "error", { args: "none", caughtErrors: "none", varsIgnorePattern: "^_" }, ], + "react-hooks/immutability": "warn", + "react-hooks/refs": "warn", + "react-hooks/set-state-in-effect": "warn", }, }, ); diff --git a/fly.toml b/fly.toml new file mode 100644 index 00000000..7010a930 --- /dev/null +++ b/fly.toml @@ -0,0 +1,39 @@ +# fly.toml app configuration file generated for t2-relay on 2026-03-08T16:25:10-07:00 +# +# See https://fly.io/docs/reference/configuration/ for information about how to use this file. +# + +app = 't2-relay' +primary_region = 'ord' + +[build] + dockerfile = 'relay/Dockerfile' + +[[mounts]] + source = 'gamedata' + destination = '/data' + +[[services]] + protocol = 'tcp' + internal_port = 8765 + auto_stop_machines = 'off' + + [[services.ports]] + port = 443 + handlers = ['tls', 'http'] + + [[services.ports]] + port = 80 + handlers = ['http'] + + [[services.http_checks]] + interval = 30000 + timeout = 5000 + method = 'GET' + path = '/health' + +[[vm]] + memory = '1gb' + cpu_kind = 'shared' + cpus = 1 + memory_mb = 1024 diff --git a/package-lock.json b/package-lock.json index 2433b754..5508e614 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,13 +20,17 @@ "nipplejs": "^0.10.2", "nuqs": "^2.8.9", "picomatch": "^4.0.3", + "pino": "^10.3.1", + "pino-pretty": "^13.1.3", "react": "^19.2.4", "react-dom": "^19.2.4", "react-error-boundary": "^6.0.1", "react-icons": "^5.5.0", "t2-demo-parser": "file:.yalc/t2-demo-parser", "three": "^0.182.0", + "tsx": "^4.21.0", "unzipper": "^0.12.3", + "ws": "^8.19.0", "zustand": "^5.0.11" }, "devDependencies": { @@ -38,7 +42,9 @@ "@types/react": "^19.2.14", "@types/three": "^0.182.0", "@types/unzipper": "^0.10.11", + "@types/ws": "^8.18.1", "babel-plugin-react-compiler": "^1.0.0", + "concurrently": "^9.2.1", "eslint": "^9.39.2", "eslint-config-next": "^16.1.1", "express": "^5.2.1", @@ -48,7 +54,6 @@ "prettier-plugin-glsl": "^0.2.2", "puppeteer": "^24.34.0", "rimraf": "^6.1.2", - "tsx": "^4.21.0", "typescript": "5.9.3", "typescript-eslint": "^8.51.0", "vitest": "^4.0.18" @@ -465,7 +470,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -482,7 +486,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -499,7 +502,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -516,7 +518,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -533,7 +534,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -550,7 +550,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -567,7 +566,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -584,7 +582,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -601,7 +598,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -618,7 +614,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -635,7 +630,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -652,7 +646,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -669,7 +662,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -686,7 +678,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -703,7 +694,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -720,7 +710,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -737,7 +726,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -754,7 +742,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -771,7 +758,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -788,7 +774,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -805,7 +790,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -822,7 +806,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -839,7 +822,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -856,7 +838,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -873,7 +854,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -890,7 +870,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1944,6 +1923,12 @@ "node": ">=20.8" } }, + "node_modules/@pinojs/redact": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@pinojs/redact/-/redact-0.4.0.tgz", + "integrity": "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==", + "license": "MIT" + }, "node_modules/@puppeteer/browsers": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.11.0.tgz", @@ -2708,6 +2693,16 @@ "integrity": "sha512-GPe4AsfOSpqWd3xA/0gwoKod13ChcfV67trvxaW2krUbgb9gxQjnCx8zGshzMl8LSHZlNH5gQ8LNScsDuc7nGQ==", "license": "MIT" }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yauzl": { "version": "2.10.3", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.3.tgz", @@ -3686,6 +3681,15 @@ "node": ">= 0.4" } }, + "node_modules/atomic-sleep": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz", + "integrity": "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==", + "license": "MIT", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -4222,6 +4226,12 @@ "dev": true, "license": "MIT" }, + "node_modules/colorette": { + "version": "2.0.20", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz", + "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", + "license": "MIT" + }, "node_modules/commander": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/commander/-/commander-14.0.0.tgz", @@ -4239,6 +4249,47 @@ "dev": true, "license": "MIT" }, + "node_modules/concurrently": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz", + "integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "4.1.2", + "rxjs": "7.8.2", + "shell-quote": "1.8.3", + "supports-color": "8.1.1", + "tree-kill": "1.2.2", + "yargs": "17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/content-disposition": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", @@ -4432,6 +4483,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/dateformat": { + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.6.3.tgz", + "integrity": "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==", + "license": "MIT", + "engines": { + "node": "*" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -4621,7 +4681,6 @@ "version": "1.4.5", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", - "dev": true, "license": "MIT", "dependencies": { "once": "^1.4.0" @@ -4842,7 +4901,6 @@ "version": "0.27.1", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.1.tgz", "integrity": "sha512-yY35KZckJJuVVPXpvjgxiCuVEJT67F6zDeVTv4rizyPrfGBUpZQsvmxnN+C371c2esD/hNMjj4tpBhuueLN7aA==", - "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -5574,6 +5632,12 @@ ], "license": "MIT" }, + "node_modules/fast-copy": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/fast-copy/-/fast-copy-4.0.2.tgz", + "integrity": "sha512-ybA6PDXIXOXivLJK/z9e+Otk7ve13I4ckBvGO5I2RRmBU1gMHLVDJYEuJYhGwez7YNlYji2M2DvVU+a9mSFDlw==", + "license": "MIT" + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -5632,6 +5696,12 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "license": "MIT" + }, "node_modules/fastq": { "version": "1.20.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.20.1.tgz", @@ -5816,7 +5886,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -5975,7 +6044,6 @@ "version": "4.10.1", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", "integrity": "sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==", - "dev": true, "license": "MIT", "dependencies": { "resolve-pkg-maps": "^1.0.0" @@ -6179,6 +6247,12 @@ "node": ">= 0.4" } }, + "node_modules/help-me": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/help-me/-/help-me-5.0.0.tgz", + "integrity": "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==", + "license": "MIT" + }, "node_modules/hermes-estree": { "version": "0.25.1", "resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz", @@ -6850,6 +6924,15 @@ "jiti": "lib/jiti-cli.mjs" } }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -7233,7 +7316,6 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -7566,6 +7648,15 @@ ], "license": "MIT" }, + "node_modules/on-exit-leak-free": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/on-exit-leak-free/-/on-exit-leak-free-2.1.2.tgz", + "integrity": "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==", + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/on-finished": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", @@ -7583,7 +7674,6 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, "license": "ISC", "dependencies": { "wrappy": "1" @@ -7854,6 +7944,79 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pino": { + "version": "10.3.1", + "resolved": "https://registry.npmjs.org/pino/-/pino-10.3.1.tgz", + "integrity": "sha512-r34yH/GlQpKZbU1BvFFqOjhISRo1MNx1tWYsYvmj6KIRHSPMT2+yHOEb1SG6NMvRoHRF0a07kCOox/9yakl1vg==", + "license": "MIT", + "dependencies": { + "@pinojs/redact": "^0.4.0", + "atomic-sleep": "^1.0.0", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^3.0.0", + "pino-std-serializers": "^7.0.0", + "process-warning": "^5.0.0", + "quick-format-unescaped": "^4.0.3", + "real-require": "^0.2.0", + "safe-stable-stringify": "^2.3.1", + "sonic-boom": "^4.0.1", + "thread-stream": "^4.0.0" + }, + "bin": { + "pino": "bin.js" + } + }, + "node_modules/pino-abstract-transport": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pino-abstract-transport/-/pino-abstract-transport-3.0.0.tgz", + "integrity": "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==", + "license": "MIT", + "dependencies": { + "split2": "^4.0.0" + } + }, + "node_modules/pino-pretty": { + "version": "13.1.3", + "resolved": "https://registry.npmjs.org/pino-pretty/-/pino-pretty-13.1.3.tgz", + "integrity": "sha512-ttXRkkOz6WWC95KeY9+xxWL6AtImwbyMHrL1mSwqwW9u+vLp/WIElvHvCSDg0xO/Dzrggz1zv3rN5ovTRVowKg==", + "license": "MIT", + "dependencies": { + "colorette": "^2.0.7", + "dateformat": "^4.6.3", + "fast-copy": "^4.0.0", + "fast-safe-stringify": "^2.1.1", + "help-me": "^5.0.0", + "joycon": "^3.1.1", + "minimist": "^1.2.6", + "on-exit-leak-free": "^2.1.0", + "pino-abstract-transport": "^3.0.0", + "pump": "^3.0.0", + "secure-json-parse": "^4.0.0", + "sonic-boom": "^4.0.1", + "strip-json-comments": "^5.0.2" + }, + "bin": { + "pino-pretty": "bin.js" + } + }, + "node_modules/pino-pretty/node_modules/strip-json-comments": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-5.0.3.tgz", + "integrity": "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw==", + "license": "MIT", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pino-std-serializers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/pino-std-serializers/-/pino-std-serializers-7.1.0.tgz", + "integrity": "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==", + "license": "MIT" + }, "node_modules/possible-typed-array-names": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", @@ -7945,6 +8108,22 @@ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "license": "MIT" }, + "node_modules/process-warning": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-5.0.0.tgz", + "integrity": "sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -8022,7 +8201,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", - "dev": true, "license": "MIT", "dependencies": { "end-of-stream": "^1.1.0", @@ -8117,6 +8295,12 @@ ], "license": "MIT" }, + "node_modules/quick-format-unescaped": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz", + "integrity": "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==", + "license": "MIT" + }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -8220,6 +8404,15 @@ "util-deprecate": "~1.0.1" } }, + "node_modules/real-require": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", + "integrity": "sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==", + "license": "MIT", + "engines": { + "node": ">= 12.13.0" + } + }, "node_modules/reflect.getprototypeof": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", @@ -8331,7 +8524,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" @@ -8461,6 +8653,16 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, "node_modules/safe-array-concat": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz", @@ -8536,6 +8738,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -8549,6 +8760,22 @@ "integrity": "sha512-eNv+WrVbKu1f3vbYJT/xtiF5syA5HPIMtf9IgY/nKg0sWqzAUEvqY/xm7OcZc/qafLx/iO9FgOmeSAp4v5ti/Q==", "license": "MIT" }, + "node_modules/secure-json-parse": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/secure-json-parse/-/secure-json-parse-4.1.0.tgz", + "integrity": "sha512-l4KnYfEyqYJxDwlNVyRfO2E4NTHfMKAWdUuA8J0yve2Dz/E/PdBepY03RvyJpssIpRFwJoCD55wA+mEDs6ByWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/semver": { "version": "7.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", @@ -8736,6 +8963,19 @@ "node": ">=8" } }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", @@ -8860,6 +9100,15 @@ "node": ">= 14" } }, + "node_modules/sonic-boom": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/sonic-boom/-/sonic-boom-4.2.1.tgz", + "integrity": "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==", + "license": "MIT", + "dependencies": { + "atomic-sleep": "^1.0.0" + } + }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -8890,6 +9139,15 @@ "node": ">=0.10.0" } }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/stable-hash": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz", @@ -9245,6 +9503,18 @@ "b4a": "^1.6.4" } }, + "node_modules/thread-stream": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-4.0.0.tgz", + "integrity": "sha512-4iMVL6HAINXWf1ZKZjIPcz5wYaOdPhtO8ATvZ+Xqp3BTdaqtAwQkNmKORqcIo5YkQqGXq5cwfswDwMqqQNrpJA==", + "license": "MIT", + "dependencies": { + "real-require": "^0.2.0" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/three": { "version": "0.182.0", "resolved": "https://registry.npmjs.org/three/-/three-0.182.0.tgz", @@ -9350,6 +9620,16 @@ "node": ">=0.6" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/troika-three-text": { "version": "0.52.4", "resolved": "https://registry.npmjs.org/troika-three-text/-/troika-three-text-0.52.4.tgz", @@ -9429,7 +9709,6 @@ "version": "4.21.0", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", - "dev": true, "license": "MIT", "dependencies": { "esbuild": "~0.27.0", @@ -10161,14 +10440,12 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, "license": "ISC" }, "node_modules/ws": { - "version": "8.18.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", - "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", - "dev": true, + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.19.0.tgz", + "integrity": "sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==", "license": "MIT", "engines": { "node": ">=10.0.0" diff --git a/package.json b/package.json index 5a3c01d6..a3f6125f 100644 --- a/package.json +++ b/package.json @@ -14,12 +14,18 @@ "deploy": "npm run build && git add -f docs && git commit -m \"Deploy\" && git push", "format": "prettier --write .", "lint": "eslint .", + "login": "node --env-file-if-exists=.env --env-file-if-exists=.env.local --import=tsx/esm scripts/t2-login.ts", "postbuild": "git checkout -- public/base && touch docs/.nojekyll", "prebuild": "git checkout -- docs && rimraf public/base && mv docs/base public/", + "relay:dev": "node --env-file-if-exists=.env.local --watch --import=tsx/esm relay/server.ts", + "relay": "node --env-file-if-exists=.env.local --import=tsx/esm relay/server.ts", "serve:static": "tsx scripts/serve-static.ts", + "server-list": "node --env-file-if-exists=.env --env-file-if-exists=.env.local --import=tsx/esm scripts/t2-server-list.ts", + "start:both": "concurrently npm:start npm:relay:dev", "start": "next dev --turbopack", - "test": "vitest run", + "test-connect": "node --env-file-if-exists=.env.local --import=tsx/esm scripts/test-connect.ts", "test:watch": "vitest", + "test": "vitest run", "typecheck": "tsc --noEmit" }, "dependencies": { @@ -34,13 +40,17 @@ "nipplejs": "^0.10.2", "nuqs": "^2.8.9", "picomatch": "^4.0.3", + "pino": "^10.3.1", + "pino-pretty": "^13.1.3", "react": "^19.2.4", "react-dom": "^19.2.4", "react-error-boundary": "^6.0.1", "react-icons": "^5.5.0", "t2-demo-parser": "file:.yalc/t2-demo-parser", "three": "^0.182.0", + "tsx": "^4.21.0", "unzipper": "^0.12.3", + "ws": "^8.19.0", "zustand": "^5.0.11" }, "devDependencies": { @@ -52,7 +62,9 @@ "@types/react": "^19.2.14", "@types/three": "^0.182.0", "@types/unzipper": "^0.10.11", + "@types/ws": "^8.18.1", "babel-plugin-react-compiler": "^1.0.0", + "concurrently": "^9.2.1", "eslint": "^9.39.2", "eslint-config-next": "^16.1.1", "express": "^5.2.1", @@ -62,7 +74,6 @@ "prettier-plugin-glsl": "^0.2.2", "puppeteer": "^24.34.0", "rimraf": "^6.1.2", - "tsx": "^4.21.0", "typescript": "5.9.3", "typescript-eslint": "^8.51.0", "vitest": "^4.0.18" diff --git a/relay/BitStreamWriter.ts b/relay/BitStreamWriter.ts new file mode 100644 index 00000000..947e46b7 --- /dev/null +++ b/relay/BitStreamWriter.ts @@ -0,0 +1,136 @@ +/** + * Bit-level stream writer, mirroring the V12 engine's BitStream write methods. + * Bits are written LSB-first within each byte, matching the read convention. + */ +export class BitStreamWriter { + private data: Uint8Array; + private bitNum: number; + private maxBitNum: number; + + constructor(maxBytes = 1500) { + this.data = new Uint8Array(maxBytes); + this.bitNum = 0; + this.maxBitNum = maxBytes << 3; + } + + getCurPos(): number { + return this.bitNum; + } + + setCurPos(pos: number): void { + this.bitNum = pos; + } + + getBytePosition(): number { + return (this.bitNum + 7) >> 3; + } + + getByteCount(): number { + return this.getBytePosition(); + } + + /** Get a copy of the written bytes. */ + getBuffer(): Uint8Array { + return this.data.slice(0, this.getByteCount()); + } + + writeFlag(value: boolean): void { + if (this.bitNum >= this.maxBitNum) return; + if (value) { + this.data[this.bitNum >> 3] |= 1 << (this.bitNum & 0x7); + } else { + this.data[this.bitNum >> 3] &= ~(1 << (this.bitNum & 0x7)); + } + this.bitNum++; + } + + /** Write N bits from an unsigned integer, LSB-first. */ + writeInt(value: number, bitCount: number): void { + if (bitCount === 0) return; + value = value >>> 0; + for (let i = 0; i < bitCount; i++) { + if (value & (1 << i)) { + this.data[this.bitNum >> 3] |= 1 << (this.bitNum & 0x7); + } else { + this.data[this.bitNum >> 3] &= ~(1 << (this.bitNum & 0x7)); + } + this.bitNum++; + } + } + + /** Write a signed integer: 1-bit sign flag + (bitCount-1) magnitude bits. */ + writeSignedInt(value: number, bitCount: number): void { + if (value < 0) { + this.writeFlag(true); + this.writeInt(-value, bitCount - 1); + } else { + this.writeFlag(false); + this.writeInt(value, bitCount - 1); + } + } + + writeU8(value: number): void { + this.writeInt(value & 0xff, 8); + } + + writeU16(value: number): void { + this.writeInt(value & 0xffff, 16); + } + + writeU32(value: number): void { + this.writeInt(value >>> 0, 32); + } + + writeS32(value: number): void { + this.writeU32(value | 0); + } + + /** Shared buffer for F32 writes. */ + private static readonly f32Buf = new ArrayBuffer(4); + private static readonly f32View = new DataView(BitStreamWriter.f32Buf); + private static readonly f32U8 = new Uint8Array(BitStreamWriter.f32Buf); + + writeF32(value: number): void { + BitStreamWriter.f32View.setFloat32(0, value, true); + for (let i = 0; i < 4; i++) { + this.writeU8(BitStreamWriter.f32U8[i]); + } + } + + /** Write a float normalized to [0, 1]. */ + writeFloat(value: number, bitCount: number): void { + const maxVal = (1 << bitCount) - 1; + this.writeInt(Math.round(value * maxVal), bitCount); + } + + /** Write a float normalized to [-1, 1]. */ + writeSignedFloat(value: number, bitCount: number): void { + const maxVal = (1 << bitCount) - 1; + this.writeInt(Math.round((value + 1.0) * 0.5 * maxVal), bitCount); + } + + writeRangedU32(value: number, rangeStart: number, rangeEnd: number): void { + const rangeSize = rangeEnd - rangeStart + 1; + const rangeBits = Math.ceil(Math.log2(rangeSize)) || 1; + this.writeInt(value - rangeStart, rangeBits); + } + + /** Write raw bits from a Uint8Array. */ + writeBitsBuffer(data: Uint8Array, bitCount: number): void { + for (let i = 0; i < bitCount; i++) { + const byteIndex = i >> 3; + const bitIndex = i & 0x7; + const bit = (data[byteIndex] >> bitIndex) & 1; + if (bit) { + this.data[this.bitNum >> 3] |= 1 << (this.bitNum & 0x7); + } else { + this.data[this.bitNum >> 3] &= ~(1 << (this.bitNum & 0x7)); + } + this.bitNum++; + } + } + + writeBytes(bytes: Uint8Array): void { + this.writeBitsBuffer(bytes, bytes.length * 8); + } +} diff --git a/relay/Dockerfile b/relay/Dockerfile new file mode 100644 index 00000000..c539ace8 --- /dev/null +++ b/relay/Dockerfile @@ -0,0 +1,17 @@ +FROM node:22-slim +WORKDIR /app + +COPY package.json package-lock.json ./ +COPY .yalc/ .yalc/ +RUN npm ci --omit=dev + +COPY relay/ relay/ +COPY public/manifest.json public/manifest.json + +ENV RELAY_PORT=8765 +ENV GAME_BASE_PATH=/data/base +ENV MANIFEST_PATH=/app/public/manifest.json + +EXPOSE 8765 + +CMD ["node", "--import=tsx/esm", "relay/server.ts"] diff --git a/relay/HuffmanWriter.ts b/relay/HuffmanWriter.ts new file mode 100644 index 00000000..84b23ca0 --- /dev/null +++ b/relay/HuffmanWriter.ts @@ -0,0 +1,223 @@ +import { BitStreamWriter } from "./BitStreamWriter.js"; + +/** Hardcoded character frequency table from the V12 engine (bitStream.cc). */ +const CSM_CHAR_FREQS: number[] = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 329, 21, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2809, 68, 0, 27, 0, 58, 3, 62, 4, 7, 0, 0, 15, 65, 554, 3, + 394, 404, 189, 117, 30, 51, 27, 15, 34, 32, 80, 1, 142, 3, 142, 39, + 0, 144, 125, 44, 122, 275, 70, 135, 61, 127, 8, 12, 113, 246, 122, 36, + 185, 1, 149, 309, 335, 12, 11, 14, 54, 151, 0, 0, 2, 0, 0, 211, + 0, 2090, 344, 736, 993, 2872, 701, 605, 646, 1552, 328, 305, 1240, 735, 1533, 1713, + 562, 3, 1775, 1149, 1469, 979, 407, 553, 59, 279, 31, 0, 0, 0, 68, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +]; + +const PROB_BOOST = 1; + +function isAlphaNumeric(c: number): boolean { + return ( + (c >= 48 && c <= 57) || + (c >= 65 && c <= 90) || + (c >= 97 && c <= 122) + ); +} + +interface HuffLeaf { + pop: number; + symbol: number; + numBits: number; + code: number; +} + +interface HuffNode { + pop: number; + index0: number; + index1: number; +} + +interface HuffWrap { + node: HuffNode | null; + leaf: HuffLeaf | null; +} + +function wrapGetPop(w: HuffWrap): number { + return w.node ? w.node.pop : w.leaf!.pop; +} + +let leaves: HuffLeaf[] = []; +let tablesBuilt = false; + +function buildTables(): void { + if (tablesBuilt) return; + tablesBuilt = true; + + leaves = []; + for (let i = 0; i < 256; i++) { + leaves.push({ + pop: CSM_CHAR_FREQS[i] + (isAlphaNumeric(i) ? PROB_BOOST : 0) + PROB_BOOST, + symbol: i, + numBits: 0, + code: 0, + }); + } + + const nodes: HuffNode[] = [{ pop: 0, index0: 0, index1: 0 }]; + let currWraps = 256; + const wraps: HuffWrap[] = []; + for (let i = 0; i < 256; i++) { + wraps.push({ node: null, leaf: leaves[i] }); + } + + while (currWraps !== 1) { + let min1 = 0xfffffffe; + let min2 = 0xffffffff; + let index1 = -1; + let index2 = -1; + + for (let i = 0; i < currWraps; i++) { + const pop = wrapGetPop(wraps[i]); + if (pop < min1) { + min2 = min1; + index2 = index1; + min1 = pop; + index1 = i; + } else if (pop < min2) { + min2 = pop; + index2 = i; + } + } + + const determineIndex = (wrap: HuffWrap): number => { + if (wrap.leaf !== null) { + return -(leaves.indexOf(wrap.leaf) + 1); + } + return nodes.indexOf(wrap.node!); + }; + + const newNode: HuffNode = { + pop: wrapGetPop(wraps[index1]) + wrapGetPop(wraps[index2]), + index0: determineIndex(wraps[index1]), + index1: determineIndex(wraps[index2]), + }; + nodes.push(newNode); + + const mergeIndex = index1 < index2 ? index1 : index2; + const nukeIndex = index1 > index2 ? index1 : index2; + wraps[mergeIndex] = { node: newNode, leaf: null }; + if (nukeIndex !== currWraps - 1) { + wraps[nukeIndex] = wraps[currWraps - 1]; + } + currWraps--; + } + + nodes[0] = wraps[0].node!; + + function generateCodes(code: number, nodeIndex: number, depth: number): void { + if (nodeIndex < 0) { + const leaf = leaves[-(nodeIndex + 1)]; + leaf.code = code; + leaf.numBits = depth; + } else { + const node = nodes[nodeIndex]; + generateCodes(code, node.index0, depth + 1); + generateCodes(code | (1 << depth), node.index1, depth + 1); + } + } + + generateCodes(0, 0, 0); +} + +/** Write a Huffman-encoded string to a BitStreamWriter. */ +export function writeHuffBuffer(bs: BitStreamWriter, str: string): void { + buildTables(); + + // Always use Huffman compression (flag=true) + bs.writeFlag(true); + bs.writeInt(str.length, 8); + + for (let i = 0; i < str.length; i++) { + const charCode = str.charCodeAt(i) & 0xff; + const leaf = leaves[charCode]; + // Write Huffman code bits LSB-first + for (let b = 0; b < leaf.numBits; b++) { + bs.writeFlag((leaf.code & (1 << b)) !== 0); + } + } +} + +/** + * Write a Huffman-encoded string (readString inverse). + * When the server's BitStream has a stringBuffer set (compression point), + * readString reads an extra flag before the Huffman data. We must write + * that flag. Since we don't track buffer state, we always write false + * (no prefix match), then the full Huffman string. + */ +export function writeString( + bs: BitStreamWriter, + str: string, + compressed: boolean = false, +): void { + if (compressed) { + // Compression buffer is active on the reader side. + // Write false = no prefix match with buffer, send full string. + bs.writeFlag(false); + } + writeHuffBuffer(bs, str); +} + +/** + * Pack a net string (inverse of BitStream.unpackNetString). + * Code 0 = empty, code 1 = Huffman string, code 3 = integer. + */ +export function packNetString( + bs: BitStreamWriter, + str: string, + compressed: boolean = false, +): void { + if (str === "" || str == null) { + bs.writeInt(0, 2); + return; + } + + // Check if it's a tagged string (\x01) + if (str.charCodeAt(0) === 1) { + bs.writeInt(2, 2); + const tag = parseInt(str.slice(1), 10); + bs.writeInt(tag, 10); + return; + } + + // Check if it's a simple integer + const num = parseInt(str, 10); + if (!isNaN(num) && String(num) === str) { + bs.writeInt(3, 2); + const neg = num < 0; + const absNum = Math.abs(num); + bs.writeFlag(neg); + if (absNum < 128) { + bs.writeFlag(true); + bs.writeInt(absNum, 7); + } else if (absNum < 32768) { + bs.writeFlag(false); + bs.writeFlag(true); + bs.writeInt(absNum, 15); + } else { + bs.writeFlag(false); + bs.writeFlag(false); + bs.writeInt(absNum, 31); + } + return; + } + + // Normal string + bs.writeInt(1, 2); + writeString(bs, str, compressed); +} diff --git a/relay/auth.ts b/relay/auth.ts new file mode 100644 index 00000000..13da7616 --- /dev/null +++ b/relay/auth.ts @@ -0,0 +1,385 @@ +import crypto from "node:crypto"; +import { authLog } from "./logger.js"; + +/** + * T2csri authentication — reimplements the TribesNext challenge-response + * flow in TypeScript. The relay acts as the client side. + * + * Flow (after Torque-level ConnectAccept): + * 1. Server sends: t2csri_pokeClient(version) + * 2. Client sends: certificate in 200-byte chunks via t2csri_sendCertChunk + * 3. Client sends: t2csri_sendChallenge(clientChallenge) + * 4. Server sends: encrypted challenge chunks via t2csri_getChallengeChunk + * 5. Server sends: t2csri_decryptChallenge + * 6. Client decrypts, verifies, sends: t2csri_challengeResponse(serverChallenge) + */ + +export interface AccountCredentials { + /** Tab-separated: username\tguid\te\tn\tsig */ + certificate: string; + /** Hex-encoded RSA private exponent (after RC4 decryption). */ + privateKey: string; +} + +/** + * Decrypt the RC4-encrypted private key using the account password. + * + * The stored format is `nonce:encryptedHex` where: + * - nonce = SHA1 of the plaintext private key (used for verification) + * - encryptedHex = hex-encoded RC4-encrypted private key bytes + * - RC4 key = SHA1(password + nonce), with 2048 bytes discarded from stream + * + * Based on t2csri_decryptAccountKey in clientSide.cs. + */ +export function decryptAccountKey( + encryptedKeyBase64: string, + _username: string, + password: string, +): string { + // Decode the base64 to get the "nonce:encryptedHex" string + const stored = Buffer.from(encryptedKeyBase64, "base64").toString("ascii"); + const colonIdx = stored.indexOf(":"); + if (colonIdx === -1) { + throw new Error("Invalid encrypted key format: missing colon separator"); + } + const nonce = stored.slice(0, colonIdx); + const encryptedHex = stored.slice(colonIdx + 1); + + // RC4 key = SHA1(password + nonce) as ASCII hex string (not hex-decoded) + // T2csri uses strCmp(char, "") to get ASCII values, so the key is the + // raw 40-char hex string, not the 20-byte decoded value. + const rc4Key = sha1(password + nonce); + + // Hex-decode the encrypted data + const encryptedBytes = Buffer.from(encryptedHex, "hex"); + + // RC4 decrypt with 2048-byte stream discard + const decrypted = rc4WithDiscard( + Buffer.from(rc4Key, "ascii"), + encryptedBytes, + 2048, + ); + + // Result is the hex-encoded private key + const privateKeyHex = decrypted.toString("hex"); + + // Verify against nonce (nonce = SHA1 of plaintext hex) + const hash = sha1(privateKeyHex); + if (hash === nonce) { + return privateKeyHex; + } + + // T2csri tries fixing the last nibble/byte if hash doesn't match + const truncated = privateKeyHex.slice(0, -2); + for (let i = 0; i < 16; i++) { + const candidate = truncated + i.toString(16); + if (sha1(candidate) === nonce) return candidate; + } + for (let i = 0; i < 256; i++) { + const candidate = truncated + i.toString(16).padStart(2, "0"); + if (sha1(candidate) === nonce) return candidate; + } + + authLog.warn("Private key hash verification failed (password may be wrong)"); + return privateKeyHex; +} + +/** Load credentials from environment variables. */ +export function loadCredentials(): AccountCredentials | null { + const certificate = process.env.T2_ACCOUNT_CERTIFICATE; + const encryptedKey = process.env.T2_ACCOUNT_ENCRYPTED_KEY; + const username = process.env.T2_ACCOUNT_NAME; + const password = process.env.T2_ACCOUNT_PASSWORD; + + if (!certificate) { + authLog.warn("T2_ACCOUNT_CERTIFICATE not set"); + return null; + } + + let privateKey: string; + + if (encryptedKey && username && password) { + privateKey = decryptAccountKey(encryptedKey, username, password); + } else { + authLog.warn( + "T2_ACCOUNT_ENCRYPTED_KEY / T2_ACCOUNT_NAME / T2_ACCOUNT_PASSWORD not fully set", + ); + return null; + } + + const cert = Buffer.from(certificate, "base64").toString("ascii"); + return { certificate: cert, privateKey }; +} + +/** + * Generate a random hex challenge string. + * Mirrors T2csri's `rand(18446744073709551615).to_s(16)` — a random + * 64-bit integer converted to hex WITHOUT leading zeros. This is critical: + * the challenge round-trips through BigInt→hex conversions (`.to_i(16)` / + * `.to_s(16)`) during RSA encryption/decryption, which strip leading zeros. + * If we generated "06ab..." it would decrypt as "6ab..." and fail to match. + */ +export function generateChallenge(): string { + const bytes = crypto.randomBytes(8); + const num = BigInt("0x" + bytes.toString("hex")); + return num.toString(16); // no leading zeros, matches Ruby .to_s(16) +} + +/** Get the hex representation of an IPv4 address (e.g. "192.168.1.1" -> "c0a80101"). */ +export function ipToHex(ip: string): string { + return ip + .split(".") + .map((octet) => parseInt(octet, 10).toString(16).padStart(2, "0")) + .join(""); +} + +/** + * Build the client challenge string: random_challenge + server_ip_hex. + */ +export function buildClientChallenge(serverIp: string): { + fullChallenge: string; + randomPart: string; +} { + const randomPart = generateChallenge(); + const ipHex = ipToHex(serverIp); + return { fullChallenge: randomPart + ipHex, randomPart }; +} + +/** + * RSA modular exponentiation: base^exp mod modulus. + * All values are hex strings. + */ +export function rsaModExp( + baseHex: string, + expHex: string, + modHex: string, +): string { + const base = BigInt("0x" + baseHex); + const exp = BigInt("0x" + expHex); + const mod = BigInt("0x" + modHex); + + const result = modPow(base, exp, mod); + // No padding — matches T2csri's Ruby `.to_s(16)` which strips leading zeros. + // Both server and client use unpadded hex throughout the challenge flow. + return result.toString(16); +} + +/** Efficient modular exponentiation using square-and-multiply. */ +function modPow(base: bigint, exp: bigint, mod: bigint): bigint { + if (mod === 1n) return 0n; + let result = 1n; + base = ((base % mod) + mod) % mod; + while (exp > 0n) { + if (exp & 1n) { + result = (result * base) % mod; + } + exp >>= 1n; + base = (base * base) % mod; + } + return result; +} + +/** + * Decrypt the server's encrypted challenge using our private key. + * encrypted = challenge^e mod n (server encrypted with our public key) + * decrypted = encrypted^d mod n (we decrypt with private key) + */ +export function decryptChallenge( + encryptedHex: string, + privateKeyHex: string, + modulusHex: string, +): string { + return rsaModExp(encryptedHex, privateKeyHex, modulusHex); +} + +/** + * Process the decrypted challenge from the server. + * Returns the server challenge portion if valid. + */ +export function processDecryptedChallenge( + decryptedHex: string, + originalClientChallenge: string, +): { valid: boolean; serverChallenge: string } { + // The decrypted value should be: clientChallenge + serverChallenge + const clientPart = decryptedHex.slice(0, originalClientChallenge.length); + + if (clientPart.toLowerCase() !== originalClientChallenge.toLowerCase()) { + return { valid: false, serverChallenge: "" }; + } + + const serverChallenge = decryptedHex.slice(originalClientChallenge.length); + return { valid: true, serverChallenge }; +} + +/** SHA1 hash of a string, returned as hex. */ +function sha1(data: string): string { + return crypto.createHash("sha1").update(data).digest("hex"); +} + +/** RC4 encrypt/decrypt with optional stream discard (drop-N). */ +function rc4WithDiscard( + key: Buffer, + data: Buffer, + discardBytes: number = 0, +): Buffer { + // Initialize S-box + const S = new Uint8Array(256); + for (let i = 0; i < 256; i++) S[i] = i; + + let j = 0; + for (let i = 0; i < 256; i++) { + j = (j + S[i] + key[i % key.length]) & 0xff; + [S[i], S[j]] = [S[j], S[i]]; + } + + let si = 0; + j = 0; + + // Discard initial bytes from the keystream + for (let k = 0; k < discardBytes; k++) { + si = (si + 1) & 0xff; + j = (j + S[si]) & 0xff; + [S[si], S[j]] = [S[j], S[si]]; + } + + // Generate keystream and XOR + const result = Buffer.alloc(data.length); + for (let k = 0; k < data.length; k++) { + si = (si + 1) & 0xff; + j = (j + S[si]) & 0xff; + [S[si], S[j]] = [S[j], S[si]]; + result[k] = data[k] ^ S[(S[si] + S[j]) & 0xff]; + } + + return result; +} + +/** + * T2csri authentication state machine. + * Manages the challenge-response flow over an established connection. + */ +export class T2csriAuth { + private credentials: AccountCredentials; + private clientChallenge = ""; + private encryptedChallenge = ""; + private _authenticated = false; + + constructor(credentials: AccountCredentials) { + this.credentials = credentials; + } + + get authenticated(): boolean { + return this._authenticated; + } + + /** + * Handle t2csri_pokeClient from server. + * Returns commands to send back (cert chunks + challenge). + */ + onPokeClient( + _version: string, + serverIp: string, + ): { commands: Array<{ name: string; args: string[] }> } { + const commands: Array<{ name: string; args: string[] }> = []; + + // Send certificate in 200-byte chunks + const cert = this.credentials.certificate; + for (let i = 0; i < cert.length; i += 200) { + commands.push({ + name: "t2csri_sendCertChunk", + args: [cert.substring(i, i + 200)], + }); + } + + // Generate and send client challenge + const { fullChallenge } = buildClientChallenge(serverIp); + this.clientChallenge = fullChallenge; + commands.push({ + name: "t2csri_sendChallenge", + args: [fullChallenge], + }); + + return { commands }; + } + + /** Handle t2csri_getChallengeChunk from server. */ + onChallengeChunk(chunk: string): void { + this.encryptedChallenge += chunk; + } + + /** + * Handle t2csri_decryptChallenge from server. + * Returns the challenge response command to send, or null on failure. + */ + onDecryptChallenge(): { + command: { name: string; args: string[] }; + } | null { + // Sanitize: must be hex only + const challenge = this.encryptedChallenge.toLowerCase(); + authLog.info( + { challengeLen: challenge.length, clientChallengeLen: this.clientChallenge.length }, + "Auth: starting challenge decryption", + ); + for (let i = 0; i < challenge.length; i++) { + const c = challenge.charCodeAt(i); + const isHex = + (c >= 48 && c <= 57) || // 0-9 + (c >= 97 && c <= 102); // a-f + if (!isHex) { + authLog.error( + { charCode: c, pos: i, char: challenge[i] }, + "Invalid characters in server challenge", + ); + return null; + } + } + + // Parse certificate to get modulus (n) + const fields = this.credentials.certificate.split("\t"); + const modulusHex = fields[3]; + + authLog.debug( + { encryptedLen: challenge.length, modulusLen: modulusHex?.length, privateKeyLen: this.credentials.privateKey.length }, + "Auth: RSA parameters", + ); + + // Decrypt using private key + const decrypted = decryptChallenge( + challenge, + this.credentials.privateKey, + modulusHex, + ); + + authLog.debug( + { + decryptedLen: decrypted.length, + decryptedPrefix: decrypted.slice(0, 40), + clientChallenge: this.clientChallenge, + }, + "Auth: decryption result", + ); + + // Verify client challenge is intact + const result = processDecryptedChallenge(decrypted, this.clientChallenge); + if (!result.valid) { + authLog.error( + { + decryptedPrefix: decrypted.slice(0, 40), + expectedPrefix: this.clientChallenge, + }, + "Server sent back wrong client challenge", + ); + return null; + } + + void result.serverChallenge; // verified + this._authenticated = true; + + return { + command: { + name: "t2csri_challengeResponse", + args: [result.serverChallenge], + }, + }; + } +} diff --git a/relay/crc.ts b/relay/crc.ts new file mode 100644 index 00000000..8d25f6ac --- /dev/null +++ b/relay/crc.ts @@ -0,0 +1,175 @@ +import fs from "node:fs/promises"; +import path from "node:path"; + +// CRC-32 lookup table (reflected polynomial 0xEDB88320) +const crcTable = new Uint32Array(256); +for (let i = 0; i < 256; i++) { + let crc = i; + for (let j = 0; j < 8; j++) { + crc = crc & 1 ? (crc >>> 1) ^ 0xedb88320 : crc >>> 1; + } + crcTable[i] = crc; +} + +/** + * Raw CRC-32 over a buffer, continuing from an initial value. + * Tribes 2 uses raw CRC (no XOR-in/XOR-out) — verified against + * decompiled FUN_004411b0 in Tribes2.exe. + */ +export function crc32(data: Uint8Array, initial = 0): number { + let crc = initial; + for (let i = 0; i < data.length; i++) { + crc = (crc >>> 8) ^ crcTable[(crc ^ data[i]) & 0xff]; + } + return crc >>> 0; +} + +/** + * Classes that derive from ShapeBaseData in Tribes 2. + * Determined by which DataBlockParser unpack functions call shapeBaseDataUnpack. + */ +const SHAPE_BASE_DATA_CLASSES = new Set([ + "ShapeBaseData", + "PlayerData", + "VehicleData", + "FlyingVehicleData", + "HoverVehicleData", + "WheeledVehicleData", + "StaticShapeData", + "TurretData", + "ItemData", + "CameraData", + "MissionMarkerData", +]); + +export interface CRCDataBlock { + objectId: number; + className: string; + shapeName: string; +} + +// Manifest types (mirrored from src/manifest.ts) +type SourceTuple = [sourcePath: string] | [sourcePath: string, actualPath: string]; +type ResourceEntry = [firstSeenPath: string, ...SourceTuple[]]; +interface Manifest { + resources: Record; +} + +let cachedManifest: Manifest | null = null; + +/** + * Path to manifest.json. Defaults to `public/manifest.json` relative to the + * project root, but can be overridden via `MANIFEST_PATH` env var for + * deployment outside the monorepo layout. + */ +async function loadManifest(basePath: string): Promise { + if (cachedManifest) return cachedManifest; + const manifestPath = + process.env.MANIFEST_PATH || + path.join(basePath, "..", "..", "public", "manifest.json"); + const raw = await fs.readFile(manifestPath, "utf-8"); + cachedManifest = JSON.parse(raw) as Manifest; + return cachedManifest; +} + +/** Resolve a game resource path to a local file path using the manifest. */ +async function resolveGameFile( + resourcePath: string, + basePath: string, +): Promise { + const manifest = await loadManifest(basePath); + const key = resourcePath.toLowerCase().replace(/\\/g, "/"); + const entry = manifest.resources[key]; + if (!entry) return null; + const [firstSeenPath, ...sources] = entry; + const [sourcePath, actualPath] = sources[sources.length - 1]; + if (sourcePath) { + return path.join(basePath, "@vl2", sourcePath, actualPath ?? firstSeenPath); + } + return path.join(basePath, actualPath ?? firstSeenPath); +} + +/** + * Compute the game CRC matching Tribes 2's FUN_00440580. + * + * Algorithm: + * 1. Start with seed as initial CRC value + * 2. For each ShapeBaseData datablock (sorted by objectId): + * - CRC-32 the shape file ("shapes/"), using running CRC + * - Accumulate file size + * - If includeTextures and not PlayerData: also CRC texture files + * 3. Final: crc += totalSize + */ +export async function computeGameCRC( + seed: number, + datablocks: CRCDataBlock[], + basePath: string, + includeTextures = false, +): Promise<{ crc: number; totalSize: number }> { + // Sort by objectId to match the binary's iteration order (0-2047) + const sorted = [...datablocks] + .filter((db) => SHAPE_BASE_DATA_CLASSES.has(db.className) && db.shapeName) + .sort((a, b) => a.objectId - b.objectId); + + let crc = seed; + let totalSize = 0; + let filesFound = 0; + let filesMissing = 0; + + console.log( + `[crc] starting computation: seed=0x${(seed >>> 0).toString(16)}, ` + + `${sorted.length} ShapeBaseData datablocks (of ${datablocks.length} total), ` + + `includeTextures=${includeTextures}`, + ); + + for (const db of sorted) { + const shapePath = `shapes/${db.shapeName}`; + const localPath = await resolveGameFile(shapePath, basePath); + if (!localPath) { + console.log( + `[crc] SKIP id=${db.objectId} ${db.className} "${db.shapeName}" — not found in manifest`, + ); + filesMissing++; + continue; + } + + let data: Uint8Array; + try { + data = new Uint8Array(await fs.readFile(localPath)); + } catch { + console.log( + `[crc] SKIP id=${db.objectId} ${db.className} "${db.shapeName}" — file read failed`, + ); + filesMissing++; + continue; + } + + const prevCrc = crc; + crc = crc32(data, crc); + totalSize += data.length; + filesFound++; + + console.log( + `[crc] #${filesFound} id=${db.objectId} ${db.className} "${db.shapeName}" ` + + `size=${data.length} crc=0x${prevCrc.toString(16)}→0x${crc.toString(16)}`, + ); + + // TODO: If includeTextures && db.className !== "PlayerData", + // parse the DTS to enumerate textures and CRC each + // textures/.png and textures/.bm8 file. + // Most servers don't enable $Host::CRCTextures, so this is deferred. + if (includeTextures && db.className !== "PlayerData") { + // Texture CRC not yet implemented — would need DTS parsing + // to enumerate material textures for each shape. + } + } + + crc = (crc + totalSize) >>> 0; + + console.log( + `[crc] RESULT: ${filesFound} files CRC'd, ${filesMissing} missing, ` + + `crc=0x${crc.toString(16)}, totalSize=${totalSize}`, + ); + + return { crc, totalSize }; +} diff --git a/relay/gameConnection.ts b/relay/gameConnection.ts new file mode 100644 index 00000000..4274a594 --- /dev/null +++ b/relay/gameConnection.ts @@ -0,0 +1,850 @@ +import dgram from "node:dgram"; +import { EventEmitter } from "node:events"; +import { + ConnectionProtocol, + ClientNetStringTable, + buildConnectChallengeRequest, + buildConnectRequest, + buildClientGamePacket, + buildRemoteCommandEvent, + buildCRCChallengeResponseEvent, + buildGhostingMessageEvent, + buildDisconnectPacket, + type ClientEvent, + type ClientMoveData, +} from "./protocol.js"; +import { BitStream } from "t2-demo-parser"; +import { T2csriAuth, loadCredentials } from "./auth.js"; +import { connLog } from "./logger.js"; +import type { ConnectionStatus } from "./types.js"; +import { computeGameCRC, type CRCDataBlock } from "./crc.js"; + +// Tribes 2 protocol version and class CRC from the binary. +// These must match what the server expects. +const PROTOCOL_VERSION = 0x33; // 51 — from Tribes2.exe binary + +// Real T2 client sends at ~32ms tick rate. Using 32ms ensures the server +// receives steady acks for guaranteed event delivery (datablock phase). +const KEEPALIVE_INTERVAL_MS = 32; +const CONNECT_TIMEOUT_MS = 30000; + +interface GameConnectionEvents { + status: [status: ConnectionStatus, message?: string]; + packet: [data: Uint8Array]; + ping: [ms: number]; + error: [error: Error]; + close: []; +} + +/** + * Manages a UDP connection to a Tribes 2 game server. + * Handles the connection handshake, keepalive, and packet forwarding. + */ +export class GameConnection extends EventEmitter { + private socket: dgram.Socket | null = null; + private host: string; + private port: number; + private protocol = new ConnectionProtocol(); + private auth: T2csriAuth | null = null; + + private clientConnectSequence = Math.floor(Math.random() * 0xffffffff); + private serverConnectSequence = 0; + private _status: ConnectionStatus = "disconnected"; + private keepaliveTimer: ReturnType | null = null; + private handshakeTimer: ReturnType | null = null; + private challengeRetryTimer: ReturnType | null = null; + private authDelayTimer: ReturnType | null = null; + + private nextSendEventSeq = 0; + private pendingEvents: ClientEvent[] = []; + /** Events sent but not yet acked, keyed by packet sequence number. */ + private sentEventsByPacket = new Map(); + /** Events waiting to be sent (new or retransmitted from lost packets). */ + private eventSendQueue: { seq: number; event: ClientEvent }[] = []; + private stringTable = new ClientNetStringTable(); + /** Incrementing move index so the server doesn't deduplicate our moves. */ + private moveIndex = 0; + private dataPacketCount = 0; + private rawMessageCount = 0; + private sendMoveCount = 0; + private _mapName?: string; + private observerEnforced = false; + /** Buffered move state — merged into the next keepalive tick. */ + private bufferedMove: ClientMoveData | null = null; + /** Ticks remaining to hold the current trigger state before clearing. */ + private triggerHoldTicks = 0; + /** Send timestamps by sequence number for RTT measurement. */ + private sendTimestamps = new Map(); + /** Smoothed RTT in ms (exponential moving average). */ + private smoothedPing = 0; + private lastPingEmit = 0; + + constructor(address: string) { + super(); + const [host, portStr] = address.split(":"); + this.host = host; + this.port = parseInt(portStr, 10); + + // Wire up packet delivery notifications for event retransmission. + this.protocol.onNotify = (packetSeq, acked) => { + this.handlePacketNotify(packetSeq, acked); + }; + } + + get status(): ConnectionStatus { + return this._status; + } + + get connectSequence(): number { + return (this.clientConnectSequence ^ this.serverConnectSequence) >>> 0; + } + + get mapName(): string | undefined { + return this._mapName; + } + + private setStatus(status: ConnectionStatus, message?: string): void { + this._status = status; + this.emit("status", status, message); + } + + /** Initiate connection to the game server. */ + async connect(): Promise { + connLog.info( + { host: this.host, port: this.port }, + "Connecting to game server", + ); + const credentials = loadCredentials(); + if (credentials) { + connLog.info("T2csri credentials loaded"); + this.auth = new T2csriAuth(credentials); + } else { + connLog.warn("No T2csri credentials — connecting without auth"); + } + + this.socket = dgram.createSocket("udp4"); + this.socket.on("message", (msg) => this.handleMessage(msg)); + this.socket.on("error", (err) => { + this.emit("error", err); + this.disconnect(); + }); + + this.setStatus("connecting"); + + // Start the handshake + this.sendChallengeRequest(); + + // Set overall connection timeout + this.handshakeTimer = setTimeout(() => { + if (this._status !== "connected" && this._status !== "authenticating") { + connLog.warn("Connection timed out"); + this.setStatus("disconnected", "Connection timed out"); + this.disconnect(); + } + }, CONNECT_TIMEOUT_MS); + } + + /** Send the initial ConnectChallengeRequest. */ + private sendChallengeRequest(): void { + this.setStatus("challenging"); + const packet = buildConnectChallengeRequest( + PROTOCOL_VERSION, + this.clientConnectSequence, + ); + connLog.info( + { bytes: packet.length, clientSeq: this.clientConnectSequence }, + "Sending ConnectChallengeRequest", + ); + this.sendRaw(packet); + + // Retry challenge if no response + this.challengeRetryTimer = setTimeout(() => { + this.challengeRetryTimer = null; + if (this._status === "challenging") { + connLog.info("No challenge response, retrying"); + this.sendRaw(packet); + } + }, 2000); + } + + /** Handle an incoming UDP message. */ + private handleMessage(msg: Buffer): void { + if (msg.length === 0) return; + + this.rawMessageCount++; + if (this.rawMessageCount <= 30 || this.rawMessageCount % 50 === 0) { + connLog.debug( + { bytes: msg.length, firstByte: msg[0], rawTotal: this.rawMessageCount }, + "Raw UDP message received", + ); + } + + const firstByte = msg[0]; + + if (this.isOOBPacket(firstByte)) { + connLog.debug( + { type: firstByte, bytes: msg.length }, + "Received OOB packet", + ); + this.handleOOBPacket(msg); + } else { + this.handleDataPacket(msg); + } + } + + /** Check if a packet is OOB (out-of-band) vs data protocol. */ + private isOOBPacket(firstByte: number): boolean { + // Disconnect (38) can arrive at any time + if (firstByte === 38) return true; + const oobTypes = [26, 28, 30, 32, 34, 36, 38, 40]; + return ( + this._status !== "connected" && + this._status !== "authenticating" && + oobTypes.includes(firstByte) + ); + } + + /** Handle out-of-band handshake packets. */ + private handleOOBPacket(msg: Buffer): void { + const type = msg[0]; + + switch (type) { + case 28: // ChallengeReject + this.handleChallengeReject(msg); + break; + case 30: // ConnectChallengeResponse + this.handleChallengeResponse(msg); + break; + case 34: // ConnectReject + this.handleConnectReject(msg); + break; + case 36: // ConnectAccept + this.handleConnectAccept(msg); + break; + case 38: { // Disconnect — U8(type) + U32(seq1) + U32(seq2) + HuffString(reason) + let reason = "Server disconnected"; + if (msg.length > 9) { + try { + const data = new Uint8Array(msg.buffer, msg.byteOffset, msg.byteLength); + // Skip 9-byte header (1 type + 4 connectSeq + 4 connectSeq2). + // Reason is Huffman-encoded via BitStream::writeString (no stringBuffer). + const bs = new BitStream(data.subarray(9)); + const parsed = bs.readString(); + if (parsed) reason = parsed; + } catch { + // Fall back to default reason + } + } + connLog.warn({ reason, bytes: msg.length }, "Server sent Disconnect packet"); + this.setStatus("disconnected", reason); + this.disconnect(); + break; + } + default: + connLog.warn({ type, bytes: msg.length }, "Unknown OOB packet type"); + } + } + + /** Handle ChallengeReject (type 28): U8(28) + U32(connectSeq) + ASCII reason. */ + private handleChallengeReject(msg: Buffer): void { + let reason = "Challenge rejected"; + if (msg.length > 5) { + const chars: number[] = []; + for (let i = 5; i < msg.length && msg[i] !== 0; i++) { + chars.push(msg[i]); + } + if (chars.length > 0) { + reason = String.fromCharCode(...chars); + } + } + connLog.warn({ reason }, "ChallengeReject received"); + this.setStatus("disconnected", reason); + this.disconnect(); + } + + /** Handle ConnectChallengeResponse. */ + private handleChallengeResponse(msg: Buffer): void { + if (msg.length < 14) { + connLog.error( + { bytes: msg.length }, + "ChallengeResponse too short", + ); + return; + } + + const dv = new DataView( + msg.buffer, + msg.byteOffset, + msg.byteLength, + ); + const serverProtocolVersion = dv.getUint32(1, true); + this.serverConnectSequence = dv.getUint32(5, true); + const echoedClientSeq = dv.getUint32(9, true); + + connLog.info( + { + serverProto: serverProtocolVersion, + serverSeq: this.serverConnectSequence, + echoedClientSeq, + }, + "Received ChallengeResponse", + ); + + if (echoedClientSeq !== this.clientConnectSequence) { + connLog.error( + { expected: this.clientConnectSequence, got: echoedClientSeq }, + "Client connect sequence mismatch", + ); + return; + } + + // Send ConnectRequest + const connectArgv = this.buildConnectArgv(); + const packet = buildConnectRequest( + this.serverConnectSequence, + this.clientConnectSequence, + PROTOCOL_VERSION, + false, // not pre-authenticated + connectArgv, + ); + connLog.info( + { bytes: packet.length, argv: connectArgv }, + "Sending ConnectRequest", + ); + this.sendRaw(packet); + } + + /** Build the connection argv (name, race/gender, skin, voice, voicePitch). */ + private buildConnectArgv(): string[] { + const name = process.env.T2_ACCOUNT_NAME || "Observer"; + return [ + name, // player name + "Male Human", // race/gender + "beagle", // skin + "male1", // voice + "1.0", // voice pitch + ]; + } + + /** Handle ConnectAccept. */ + private handleConnectAccept(_msg: Buffer): void { + connLog.info( + { + clientSeq: this.clientConnectSequence, + serverSeq: this.serverConnectSequence, + xorSeq: this.connectSequence, + connectSeqBit: this.connectSequence & 1, + }, + "ConnectAccept received — connection established", + ); + this.protocol.connectSequence = this.connectSequence; + this.startKeepalive(); + + if (this.auth) { + connLog.info("Starting T2csri authentication"); + this.setStatus("authenticating"); + } else { + this.enforceObserver(); + this.setStatus("connected"); + } + } + + /** Handle ConnectReject. */ + private handleConnectReject(msg: Buffer): void { + let reason = "Connection rejected"; + if (msg.length > 1) { + const chars: number[] = []; + for (let i = 1; i < msg.length && msg[i] !== 0; i++) { + chars.push(msg[i]); + } + reason = String.fromCharCode(...chars); + } + connLog.warn({ reason }, "ConnectReject received"); + this.setStatus("disconnected", reason); + this.disconnect(); + } + + /** Handle a data protocol packet (established connection). */ + private handleDataPacket(msg: Buffer): void { + const data = new Uint8Array(msg.buffer, msg.byteOffset, msg.byteLength); + + this.dataPacketCount++; + if (this.dataPacketCount <= 20 || this.dataPacketCount % 50 === 0) { + connLog.debug( + { bytes: data.length, total: this.dataPacketCount }, + "Data packet received", + ); + } + + // Forward the raw packet to the browser for parsing + this.emit("packet", data); + + // We still need to process the dnet header locally to track ack state + this.processPacketForAcks(data); + + } + + /** Process a packet's dnet header to maintain ack state. */ + private processPacketForAcks(data: Uint8Array): void { + if (data.length < 4) return; + + const bs = new BitStream(data); + + bs.readFlag(); // gameFlag + const connectSeqBit = bs.readInt(1); + const seqNumber = bs.readInt(9); + const highestAck = bs.readInt(9); + const packetType = bs.readInt(2); + const ackByteCount = bs.readInt(3); + const ackMask = ackByteCount > 0 ? bs.readInt(8 * ackByteCount) : 0; + + const result = this.protocol.processReceivedHeader({ + seqNumber, + highestAck, + packetType, + connectSeqBit, + ackByteCount, + ackMask, + }); + + // Respond to PingPackets (type=1) with our own PingPacket. + // The server's processRawPacket calls sendPingResponse on receiving a + // PingPacket. Without this response, the server may time us out. + if (packetType === 1) { + connLog.debug({ seq: seqNumber }, "Received PingPacket, sending ping response"); + const pingResponse = this.protocol.buildPingPacket(); + this.sendRaw(pingResponse); + } + + if (this.dataPacketCount <= 20 || this.dataPacketCount % 50 === 0) { + connLog.debug( + { + seq: seqNumber, + ack: highestAck, + type: packetType, + csb: connectSeqBit, + ackBytes: ackByteCount, + accepted: result.accepted, + dispatch: result.dispatchData, + ourSeq: this.protocol.lastSendSeq, + ourAck: this.protocol.lastSeqRecvd, + }, + "Packet header parsed", + ); + } + + // Measure RTT from the acked sequence's send timestamp. + const sendTime = this.sendTimestamps.get(highestAck); + if (sendTime) { + const rtt = Date.now() - sendTime; + this.sendTimestamps.delete(highestAck); + // Exponential moving average (alpha=0.5 for responsive updates). + this.smoothedPing = + this.smoothedPing === 0 ? rtt : this.smoothedPing * 0.5 + rtt * 0.5; + // Emit ping updates at most every 2 seconds. + const now = Date.now(); + if (now - this.lastPingEmit >= 2000) { + this.lastPingEmit = now; + this.emit("ping", Math.round(this.smoothedPing)); + } + } + + if (!result.accepted) { + connLog.warn( + { + seq: seqNumber, + ack: highestAck, + type: packetType, + csb: connectSeqBit, + expectedCsb: this.protocol.connectSequence & 1, + lastSeqRecvd: this.protocol.lastSeqRecvd, + lastSendSeq: this.protocol.lastSendSeq, + highestAckedSeq: this.protocol.highestAckedSeq, + total: this.dataPacketCount, + }, + "Data packet REJECTED by protocol", + ); + } + } + + /** Handle a parsed T2csri event from the browser. */ + handleAuthEvent( + eventName: string, + args: string[], + ): void { + if (!this.auth) return; + + switch (eventName) { + case "t2csri_pokeClient": { + connLog.info("Auth: received pokeClient, sending certificate + challenge"); + const result = this.auth.onPokeClient( + args[0] || "", + this.host, + ); + for (const cmd of result.commands) { + this.sendCommand(cmd.name, ...cmd.args); + } + break; + } + + case "t2csri_getChallengeChunk": { + connLog.debug( + { chunkLen: args[0]?.length ?? 0 }, + "Auth: received challenge chunk", + ); + this.auth.onChallengeChunk(args[0] || ""); + break; + } + + case "t2csri_decryptChallenge": { + connLog.info("Auth: decrypting challenge"); + const result = this.auth.onDecryptChallenge(); + if (result) { + const delay = 64 + Math.floor(Math.random() * 448); + connLog.info( + { delayMs: delay }, + "Auth: challenge verified, sending response", + ); + this.authDelayTimer = setTimeout(() => { + this.authDelayTimer = null; + if (this._status !== "authenticating") return; + this.sendCommand( + result.command.name, + ...result.command.args, + ); + this.enforceObserver(); + this.setStatus("connected"); + }, delay); + } else { + connLog.error("Auth: challenge verification failed"); + this.setStatus("disconnected", "Authentication failed"); + this.disconnect(); + } + break; + } + } + } + + /** Respond to a CRCChallengeEvent by echoing values (legacy fallback). */ + handleCRCChallenge(crcValue: number, field1: number, field2: number): void { + connLog.info( + { crcValue, field1, field2 }, + "CRC challenge received, sending echo response (legacy)", + ); + const event = buildCRCChallengeResponseEvent(crcValue, field1, field2); + this.pendingEvents.push(event); + this.flushEvents(); + } + + /** + * Compute correct CRC over game shape files and send the response. + * The browser sends us the datablock list (from SimDataBlockEvents) + * along with the challenge seed and field2 to echo. + */ + async computeAndSendCRC( + seed: number, + field2: number, + datablocks: CRCDataBlock[], + includeTextures: boolean, + basePath: string, + ): Promise { + connLog.info( + { seed: `0x${(seed >>> 0).toString(16)}`, datablocks: datablocks.length, includeTextures }, + "Computing CRC over game files", + ); + try { + const { crc, totalSize } = await computeGameCRC(seed, datablocks, basePath, includeTextures); + connLog.info( + { crc: `0x${(crc >>> 0).toString(16)}`, totalSize }, + "CRC computed, sending response", + ); + const event = buildCRCChallengeResponseEvent(crc, totalSize, field2); + this.pendingEvents.push(event); + this.flushEvents(); + } catch (e) { + connLog.error({ err: e }, "CRC computation failed"); + } + } + + /** + * Respond to a GhostingMessageEvent type 0 (GhostAlwaysDone) from the server. + * Sends back type 1 to enable ghosting (sets mGhosting=true on server). + */ + handleGhostAlwaysDone(sequence: number, ghostCount: number): void { + connLog.info( + { sequence, ghostCount }, + "GhostAlwaysDone received, sending acknowledgment (type 1)", + ); + const event = buildGhostingMessageEvent(sequence, 1, ghostCount); + this.pendingEvents.push(event); + this.flushEvents(); + } + + /** Send a commandToServer as a RemoteCommandEvent. */ + sendCommand(command: string, ...args: string[]): void { + connLog.debug({ command, args, eventSeq: this.nextSendEventSeq }, "Sending commandToServer"); + const events = buildRemoteCommandEvent(this.stringTable, command, ...args); + this.pendingEvents.push(...events); + this.flushEvents(); + } + + /** Flush pending events in a data packet. */ + private flushEvents(): void { + // Assign sequence numbers to new pending events and add to send queue. + for (const event of this.pendingEvents.splice(0)) { + const seq = this.nextSendEventSeq++; + this.eventSendQueue.push({ seq, event }); + } + if (this.eventSendQueue.length === 0) return; + + this.sendDataPacketWithEvents(); + } + + /** + * Build and send a data packet that includes events from the send queue. + * Events stay tracked per-packet so they can be re-queued on loss. + */ + private sendDataPacketWithEvents( + move?: ClientMoveData, + ): void { + const events = this.eventSendQueue.splice(0); + if (events.length === 0) return; + + const startSeq = events[0].seq; + + connLog.debug( + { + eventCount: events.length, + seqRange: `${startSeq}-${events[events.length - 1].seq}`, + sendSeq: this.protocol.lastSendSeq + 1, + }, + "Sending data packet with guaranteed events", + ); + + // Track which events are in this packet for ack/loss handling. + // lastSendSeq+1 because buildSendPacketHeader increments it. + const packetSeq = this.protocol.lastSendSeq + 1; + this.sentEventsByPacket.set(packetSeq, events); + + const moveData = move ?? { + x: 0, y: 0, z: 0, + yaw: 0, pitch: 0, roll: 0, + freeLook: false, + trigger: [false, false, false, false, false, false], + }; + + const packet = buildClientGamePacket(this.protocol, { + moves: [moveData], + moveStartIndex: this.moveIndex++, + events: events.map((e) => e.event), + nextSendEventSeq: startSeq, + }); + this.sendRaw(packet); + } + + /** Handle packet delivery notification from the protocol layer. */ + private handlePacketNotify(packetSeq: number, acked: boolean): void { + const events = this.sentEventsByPacket.get(packetSeq); + if (!events || events.length === 0) { + this.sentEventsByPacket.delete(packetSeq); + return; + } + + this.sentEventsByPacket.delete(packetSeq); + + if (acked) { + connLog.debug( + { + packetSeq, + ackedEvents: events.map((e) => e.seq), + }, + "Guaranteed events acked", + ); + } else { + // Packet was lost — re-queue events at the HEAD of the send queue + // so they are retransmitted in the next outgoing data packet. + connLog.warn( + { + packetSeq, + lostEvents: events.map((e) => e.seq), + }, + "Packet lost, re-queuing guaranteed events for retransmission", + ); + this.eventSendQueue.unshift(...events); + } + } + + /** Enforce observer team so we spectate instead of spawning. */ + private enforceObserver(): void { + if (this.observerEnforced) return; + this.observerEnforced = true; + connLog.info("Enforcing observer mode (setPlayerTeam 0)"); + this.sendCommand("setPlayerTeam", "0"); + } + + /** Set the map name (from GameInfoResponse during server query). */ + setMapName(mapName: string): void { + this._mapName = mapName; + } + + /** + * Buffer a move to be sent in the next keepalive tick. + * Moves are merged into the 32ms keepalive cadence rather than sent as + * separate packets, because the server's Camera control object processes + * moves from the regular tick stream (separate extra packets can be + * ignored or cause trigger edge detection issues). + */ + sendMove(move: ClientMoveData): void { + this.sendMoveCount++; + if (this.sendMoveCount <= 5 || this.sendMoveCount % 100 === 0) { + connLog.debug( + { yaw: move.yaw, pitch: move.pitch, x: move.x, y: move.y, z: move.z, total: this.sendMoveCount }, + "Sending move", + ); + } + // During trigger hold, merge trigger flags so rapid move updates + // (e.g. from useFrame at 60fps) can't overwrite a pending trigger + // before the server sees it. + if (this.triggerHoldTicks > 0 && this.bufferedMove) { + move = { + ...move, + trigger: this.bufferedMove.trigger.map( + (held, i) => held || (move.trigger[i] ?? false), + ), + }; + } + this.bufferedMove = move; + // If any trigger is set, hold it for 2 ticks to ensure the server + // sees the edge (true then false on the next tick). + if (move.trigger.some(Boolean)) { + this.triggerHoldTicks = 2; + } + } + + /** Send the current move state as a keepalive packet at the tick rate. */ + private sendTickMove(): void { + const move: ClientMoveData = this.bufferedMove ?? { + x: 0, + y: 0, + z: 0, + yaw: 0, + pitch: 0, + roll: 0, + freeLook: false, + trigger: [false, false, false, false, false, false], + }; + + // Record send time keyed by the 9-bit sequence number (0–511) that the + // server will echo back in highestAck. lastSendSeq is the full counter; + // the wire format uses only the low 9 bits. + const nextSeq9 = (this.protocol.lastSendSeq + 1) & 0x1ff; + this.sendTimestamps.set(nextSeq9, Date.now()); + + // Absorb any new pending events into the send queue. + for (const event of this.pendingEvents.splice(0)) { + const seq = this.nextSendEventSeq++; + this.eventSendQueue.push({ seq, event }); + } + + // If we have events waiting to be sent (new or re-queued from lost + // packets), include them in this tick's data packet. + if (this.eventSendQueue.length > 0) { + this.sendDataPacketWithEvents(move); + } else { + const packet = buildClientGamePacket(this.protocol, { + moves: [move], + moveStartIndex: this.moveIndex++, + }); + this.sendRaw(packet); + } + + // Count down trigger hold, then clear triggers. + if (this.triggerHoldTicks > 0) { + this.triggerHoldTicks--; + if (this.triggerHoldTicks === 0 && this.bufferedMove) { + this.bufferedMove = { + ...this.bufferedMove, + trigger: [false, false, false, false, false, false], + }; + } + } + } + + /** Start keepalive timer. */ + private startKeepalive(): void { + let keepaliveCount = 0; + this.keepaliveTimer = setInterval(() => { + keepaliveCount++; + if (keepaliveCount % 300 === 0) { // ~10s at 32ms tick rate + connLog.info( + { + dataPackets: this.dataPacketCount, + rawMessages: this.rawMessageCount, + ourSeq: this.protocol.lastSendSeq, + ourAck: this.protocol.lastSeqRecvd, + theirAck: this.protocol.highestAckedSeq, + }, + "Connection status", + ); + } + this.sendTickMove(); + }, KEEPALIVE_INTERVAL_MS); + } + + /** Send raw bytes to the server. */ + private sendRaw(data: Uint8Array): void { + if (!this.socket) return; + this.socket.send(data, this.port, this.host, (err) => { + if (err) { + connLog.error({ err, bytes: data.length }, "UDP send failed"); + } + }); + } + + /** Disconnect from the server, sending a Disconnect OOB packet first. */ + disconnect(): void { + if (this._status === "disconnected" && !this.socket) return; + + connLog.info("Disconnecting"); + + // Send a Disconnect packet so the server knows we're leaving + if (this.socket && this.serverConnectSequence !== 0) { + try { + const packet = buildDisconnectPacket(this.connectSequence); + this.socket.send(packet, this.port, this.host); + connLog.info("Sent Disconnect packet to server"); + } catch { + // Best effort + } + } + + if (this.keepaliveTimer) { + clearInterval(this.keepaliveTimer); + this.keepaliveTimer = null; + } + if (this.challengeRetryTimer) { + clearTimeout(this.challengeRetryTimer); + this.challengeRetryTimer = null; + } + if (this.authDelayTimer) { + clearTimeout(this.authDelayTimer); + this.authDelayTimer = null; + } + if (this.handshakeTimer) { + clearTimeout(this.handshakeTimer); + this.handshakeTimer = null; + } + if (this.socket) { + try { + this.socket.close(); + } catch { + // Already closed + } + this.socket = null; + } + if (this._status !== "disconnected") { + this.setStatus("disconnected"); + } + this.emit("close"); + } +} diff --git a/relay/logger.ts b/relay/logger.ts new file mode 100644 index 00000000..3cb5fb07 --- /dev/null +++ b/relay/logger.ts @@ -0,0 +1,25 @@ +import pino from "pino"; + +const isDev = process.env.NODE_ENV !== "production"; + +export const logger = pino({ + level: process.env.LOG_LEVEL || (isDev ? "debug" : "info"), + ...(isDev && { + transport: { + target: "pino-pretty", + options: { colorize: true }, + }, + }), +}); + +/** Relay server (WebSocket + dispatch). */ +export const relayLog = logger.child({ module: "relay" }); + +/** UDP game connection handshake and protocol. */ +export const connLog = logger.child({ module: "conn" }); + +/** Master server / server list queries. */ +export const masterLog = logger.child({ module: "master" }); + +/** T2csri authentication. */ +export const authLog = logger.child({ module: "auth" }); diff --git a/relay/masterQuery.ts b/relay/masterQuery.ts new file mode 100644 index 00000000..f905f945 --- /dev/null +++ b/relay/masterQuery.ts @@ -0,0 +1,308 @@ +import dgram from "node:dgram"; +import { BitStream } from "t2-demo-parser"; +import type { ServerInfo } from "./types.js"; +import { buildGamePingRequest, buildGameInfoRequest } from "./protocol.js"; +import { masterLog } from "./logger.js"; + +const QUERY_TIMEOUT_MS = 5000; +const PHASE_TIMEOUT_MS = 3000; + +/** Required build version for client compatibility. */ +const REQUIRED_BUILD_VERSION = 25034; + +/** Parse a "host:port" string into components. */ +function parseAddress(addr: string): { host: string; port: number } { + const [host, portStr] = addr.split(":"); + return { host, port: parseInt(portStr, 10) }; +} + +/** + * Query the TribesNext master server for a list of active game servers, + * then ping each one for details via UDP. + * + * Two-phase query matching the real Tribes 2 client: + * 1. GamePingRequest (type 14) -> server name, version, protocol + * 2. GameInfoRequest (type 18) -> mod, map, game type, players + */ +export async function queryServerList( + masterAddress: string, +): Promise { + masterLog.info({ master: masterAddress }, "Querying master server"); + const addresses = await queryMasterHTTP(masterAddress); + masterLog.info( + { count: addresses.length }, + "Master returned server addresses", + ); + if (addresses.length === 0) return []; + + const servers = await queryServers(addresses); + masterLog.info( + { compatible: servers.length, total: addresses.length }, + "Server query complete", + ); + return servers; +} + +/** Query the TribesNext master server via HTTP GET /list, with retries. */ +async function queryMasterHTTP(masterAddress: string): Promise { + const maxAttempts = 3; + const url = `http://${masterAddress}/list`; + for (let attempt = 1; attempt <= maxAttempts; attempt++) { + try { + masterLog.debug({ url, attempt }, "Fetching server list"); + const res = await fetch(url, { + signal: AbortSignal.timeout(QUERY_TIMEOUT_MS), + }); + const body = await res.text(); + return body + .trim() + .split("\n") + .map((line) => line.trim()) + .filter((addr) => addr.includes(":") && addr.includes(".")); + } catch (err) { + masterLog.warn( + { err: err instanceof Error ? err.message : err, attempt, maxAttempts }, + "Master HTTP query failed", + ); + if (attempt < maxAttempts) { + const delay = attempt * 1000; + masterLog.info({ delayMs: delay }, "Retrying master query"); + await new Promise((r) => setTimeout(r, delay)); + } + } + } + masterLog.error("Master HTTP query failed after all retries"); + return []; +} + +/** Ping info from GamePingResponse (type 16). */ +interface PingInfo { + name: string; + buildVersion: number; + protocolVersion: number; + ping: number; +} + +/** Info from GameInfoResponse (type 20). */ +interface GameInfo { + mod: string; + gameType: string; + mapName: string; + status: number; + playerCount: number; + maxPlayers: number; + botCount: number; +} + +/** Two-phase UDP query: ping first, then info request. */ +async function queryServers(addresses: string[]): Promise { + const socket = dgram.createSocket("udp4"); + const pingResults = new Map(); + const infoResults = new Map(); + const pingTimes = new Map(); + + /** Resolve an rinfo address back to a queried address. */ + function resolveAddr(rinfo: dgram.RemoteInfo): string { + let addr = `${rinfo.address}:${rinfo.port}`; + if (!pingTimes.has(addr)) { + for (const [key] of pingTimes) { + const { port } = parseAddress(key); + if (port === rinfo.port) { + addr = key; + break; + } + } + } + return addr; + } + + // Phase 1: Send pings, collect responses + masterLog.debug( + { count: addresses.length }, + "Phase 1: sending GamePingRequests", + ); + await new Promise((resolve) => { + const timeout = setTimeout(() => resolve(), PHASE_TIMEOUT_MS); + + socket.on("message", (msg, rinfo) => { + const addr = resolveAddr(rinfo); + const type = msg[0]; + + if (type === 16) { + const info = parsePingResponse(msg, pingTimes.get(addr)); + if (info) { + pingResults.set(addr, info); + masterLog.debug( + { addr, name: info.name, build: info.buildVersion, ping: info.ping }, + "Ping response", + ); + } + if (pingResults.size >= addresses.length) { + clearTimeout(timeout); + resolve(); + } + } else if (type === 20) { + const info = parseInfoResponse(msg); + if (info) infoResults.set(addr, info); + } + }); + + socket.on("error", () => { + clearTimeout(timeout); + resolve(); + }); + + for (const addr of addresses) { + const { host, port } = parseAddress(addr); + pingTimes.set(addr, Date.now()); + socket.send(buildGamePingRequest(), port, host); + } + }); + + masterLog.debug( + { responded: pingResults.size, total: addresses.length }, + "Phase 1 complete", + ); + + // Phase 2: Send info requests to servers that responded to ping + // and are running the correct version. + const compatibleAddrs = [...pingResults.entries()] + .filter(([, info]) => info.buildVersion === REQUIRED_BUILD_VERSION) + .map(([addr]) => addr); + + if (compatibleAddrs.length > 0) { + socket.removeAllListeners("message"); + + masterLog.debug( + { count: compatibleAddrs.length }, + "Phase 2: sending GameInfoRequests", + ); + + await new Promise((resolve) => { + const timeout = setTimeout(() => resolve(), PHASE_TIMEOUT_MS); + + socket.on("message", (msg, rinfo) => { + const addr = resolveAddr(rinfo); + if (msg[0] === 20) { + const info = parseInfoResponse(msg); + if (info) infoResults.set(addr, info); + if (infoResults.size >= compatibleAddrs.length) { + clearTimeout(timeout); + resolve(); + } + } + }); + + for (const addr of compatibleAddrs) { + if (infoResults.has(addr)) continue; + const { host, port } = parseAddress(addr); + socket.send(buildGameInfoRequest(), port, host); + } + + const remaining = compatibleAddrs.filter((a) => !infoResults.has(a)); + if (remaining.length === 0) { + clearTimeout(timeout); + resolve(); + } + }); + } + + socket.removeAllListeners(); + socket.close(); + + // Combine results + const servers: ServerInfo[] = []; + for (const [addr, ping] of pingResults) { + if (ping.buildVersion !== REQUIRED_BUILD_VERSION) continue; + const info = infoResults.get(addr); + servers.push({ + address: addr, + name: ping.name, + mod: info?.mod ?? "", + gameType: info?.gameType ?? "", + mapName: info?.mapName ?? "", + playerCount: info?.playerCount ?? 0, + maxPlayers: info?.maxPlayers ?? 0, + botCount: info?.botCount ?? 0, + ping: ping.ping, + buildVersion: ping.buildVersion, + passwordRequired: info ? (info.status & 0x02) !== 0 : false, + }); + } + + return servers; +} + +/** + * Parse a GamePingResponse (type 16). + * + * Format (from decompiled Tribes2.exe): + * U8 type (16) + * U8 flags + * U32 key + * HuffString versionString (e.g. "VER5") + * U32 protocolVersion + * U32 minProtocolVersion + * U32 buildVersion (e.g. 25034) + * HuffString serverName (24 chars max) + */ +function parsePingResponse( + data: Buffer, + sendTime?: number, +): PingInfo | null { + if (data.length < 7 || data[0] !== 16) return null; + try { + const bs = new BitStream( + new Uint8Array(data.buffer, data.byteOffset + 6, data.length - 6), + ); + bs.readString(); // versionString + const protocolVersion = bs.readU32(); + bs.readU32(); // minProtocolVersion + const buildVersion = bs.readU32(); + const name = bs.readString(); + return { + name, + buildVersion, + protocolVersion, + ping: sendTime ? Date.now() - sendTime : 0, + }; + } catch { + return null; + } +} + +/** + * Parse a GameInfoResponse (type 20). + * + * Format (from decompiled Tribes2.exe): + * U8 type (20) + * U8 flags + * U32 key + * HuffString mod (mod paths, e.g. "Classic") + * HuffString missionTypeDisplayName (e.g. "Capture the Flag") + * HuffString missionDisplayName (map name) + * U8 status flags + * U8 playerCount + * U8 maxPlayers + * U8 botCount + * U16 cpuMhz + * HuffString serverInfo ($Host::Info — description, NOT the name) + */ +function parseInfoResponse(data: Buffer): GameInfo | null { + if (data.length < 7 || data[0] !== 20) return null; + try { + const bs = new BitStream( + new Uint8Array(data.buffer, data.byteOffset + 6, data.length - 6), + ); + const mod = bs.readString(); + const gameType = bs.readString(); + const mapName = bs.readString(); + const status = bs.readU8(); + const playerCount = bs.readU8(); + const maxPlayers = bs.readU8(); + const botCount = bs.readU8(); + return { mod, gameType, mapName, status, playerCount, maxPlayers, botCount }; + } catch { + return null; + } +} diff --git a/relay/protocol.ts b/relay/protocol.ts new file mode 100644 index 00000000..7e040c4f --- /dev/null +++ b/relay/protocol.ts @@ -0,0 +1,546 @@ +import { BitStreamWriter } from "./BitStreamWriter.js"; +import { packNetString, writeString } from "./HuffmanWriter.js"; + +const DataPacket = 0; +const PingPacket = 1; +const AckPacket = 2; + +const NetEventClassFirst = 255; +const CRCChallengeResponseEventClassId = NetEventClassFirst + 1; // index 1 +const GhostingMessageEventClassId = NetEventClassFirst + 4; // index 4 +const NetStringEventClassId = NetEventClassFirst + 7; // index 7 +const RemoteCommandEventClassId = NetEventClassFirst + 9; // index 9 + +/** + * Manages the connection protocol state for the client side. + * Mirrors ConnectionProtocol from dnet.cc, but for building outgoing packets. + */ +export class ConnectionProtocol { + lastSeqRecvdAtSend: number[] = new Array(32).fill(0); + lastSeqRecvd = 0; + highestAckedSeq = 0; + lastSendSeq = 0; + ackMask = 0; + connectSequence = 0; + lastRecvAckAck = 0; + + /** Called for each outgoing packet when its delivery status is determined. */ + onNotify: ((packetSeq: number, acked: boolean) => void) | null = null; + + private _sendCount = 0; + + buildSendPacketHeader( + packetType: number = DataPacket, + ): BitStreamWriter { + const bs = new BitStreamWriter(1500); + + // gameFlag — always true for data connection packets + bs.writeFlag(true); + + // connectSeqBit — LSB of connectSequence + bs.writeInt(this.connectSequence & 1, 1); + + // Increment send sequence + this.lastSendSeq = (this.lastSendSeq + 1) >>> 0; + this.lastSeqRecvdAtSend[this.lastSendSeq & 0x1f] = + this.lastSeqRecvd >>> 0; + + // seqNumber (9 bits) + bs.writeInt(this.lastSendSeq & 0x1ff, 9); + + // highestAck (9 bits) — the highest seq we've received from server + bs.writeInt(this.lastSeqRecvd & 0x1ff, 9); + + // packetType (2 bits) + bs.writeInt(packetType, 2); + + // ackByteCount (3 bits) + ackMask + // We need to send back our ack mask for packets we've received + const mask = this.ackMask >>> 0; + let ackByteCount = 0; + if (mask !== 0) { + if (mask & 0xff000000) ackByteCount = 4; + else if (mask & 0x00ff0000) ackByteCount = 3; + else if (mask & 0x0000ff00) ackByteCount = 2; + else ackByteCount = 1; + } + bs.writeInt(ackByteCount, 3); + if (ackByteCount > 0) { + bs.writeInt(mask, ackByteCount * 8); + } + + this._sendCount++; + if (this._sendCount <= 30 || this._sendCount % 50 === 0) { + const typeName = packetType === 0 ? "data" : packetType === 1 ? "ping" : "ack"; + console.log( + `[proto] SEND #${this._sendCount} seq=${this.lastSendSeq} ` + + `highestAck=${this.lastSeqRecvd} type=${typeName} ` + + `ackBytes=${ackByteCount} mask=0x${mask.toString(16).padStart(8, "0")} ` + + `(${mask.toString(2).replace(/^0+/, "") || "0"})`, + ); + } + + return bs; + } + + /** Process a received packet header, updating our state. */ + processReceivedHeader(header: { + seqNumber: number; + highestAck: number; + packetType: number; + connectSeqBit: number; + ackByteCount: number; + ackMask: number; + }): { accepted: boolean; dispatchData: boolean } { + if (header.connectSeqBit !== (this.connectSequence & 1)) { + return { accepted: false, dispatchData: false }; + } + if (header.ackByteCount > 4 || header.packetType > 2) { + return { accepted: false, dispatchData: false }; + } + + let seqNumber = + (header.seqNumber | (this.lastSeqRecvd & 0xffff_fe00)) >>> 0; + if (seqNumber < this.lastSeqRecvd) { + seqNumber = (seqNumber + 0x200) >>> 0; + } + if (this.lastSeqRecvd + 0x1f < seqNumber) { + return { accepted: false, dispatchData: false }; + } + + let highestAck = + (header.highestAck | (this.highestAckedSeq & 0xffff_fe00)) >>> 0; + if (highestAck < this.highestAckedSeq) { + highestAck = (highestAck + 0x200) >>> 0; + } + if (this.lastSendSeq < highestAck) { + return { accepted: false, dispatchData: false }; + } + + const seqShift = (seqNumber - this.lastSeqRecvd) & 0x1f; + this.ackMask = (this.ackMask << seqShift) >>> 0; + if (header.packetType === DataPacket) { + this.ackMask = (this.ackMask | 1) >>> 0; + } + + for ( + let ackSeq = this.highestAckedSeq + 1; + ackSeq <= highestAck; + ackSeq++ + ) { + const isAcked = + (header.ackMask & (1 << ((highestAck - ackSeq) & 0x1f))) !== 0; + if (isAcked) { + this.lastRecvAckAck = + this.lastSeqRecvdAtSend[ackSeq & 0x1f] >>> 0; + } + if (this.onNotify) { + this.onNotify(ackSeq, isAcked); + } + } + if (seqNumber - this.lastRecvAckAck > 0x20) { + this.lastRecvAckAck = seqNumber - 0x20; + } + this.highestAckedSeq = highestAck; + + const dispatchData = + this.lastSeqRecvd !== seqNumber && + header.packetType === DataPacket; + this.lastSeqRecvd = seqNumber; + + return { accepted: true, dispatchData }; + } + + /** Build a ping response packet. */ + buildPingPacket(): Uint8Array { + const bs = this.buildSendPacketHeader(PingPacket); + return bs.getBuffer(); + } + + /** Build an ack-only packet (no game data). */ + buildAckPacket(): Uint8Array { + const bs = this.buildSendPacketHeader(AckPacket); + return bs.getBuffer(); + } + + /** + * Build a data packet with game payload. + * The caller provides a callback that writes game data to the stream + * after the dnet header. + */ + buildDataPacket( + writePayload: (bs: BitStreamWriter) => void, + ): Uint8Array { + const bs = this.buildSendPacketHeader(DataPacket); + writePayload(bs); + return bs.getBuffer(); + } +} + +/** + * Build a GameConnection client data packet. + * Client→Server format (from checkPacketSend + GameConnection::writePacket): + * 1. Rate info (2 flag bits from checkPacketSend, before writePacket) + * 2. GameConnection fields: + * a. Flag (firstPerson: cameraPos == 0) + * b. U32 (controlObjectChecksum) + * c. moveWritePacket (move count + packed moves) + * d. Flag (updateFirstPerson) — false for observer + * e. Flag (updateCameraFov) — false for observer + * 3. NetConnection::writePacket: + * a. eventWritePacket (events) + * b. ghostWritePacket (ghosts — client doesn't write any) + */ +export function buildClientGamePacket( + protocol: ConnectionProtocol, + options: { + moves?: ClientMoveData[]; + moveStartIndex?: number; + events?: ClientEvent[]; + nextSendEventSeq?: number; + } = {}, +): Uint8Array { + return protocol.buildDataPacket((bs) => { + // NetConnection::checkPacketSend writes rate info BEFORE writePacket. + // handlePacket on the server reads these before calling readPacket. + // Both sides send rate flags — we send false (no changes). + bs.writeFlag(false); // mCurRate.changed + bs.writeFlag(false); // mMaxRate.changed + + // GameConnection::writePacket (client→server path) + // 1. First person flag (cameraPos == 0 → firstPerson) + bs.writeFlag(false); // not first person + + // 2. 32-bit control object value + bs.writeU32(0); + + // 3. moveWritePacket: writeInt(start, 32) + writeInt(count, 5) + moves + const moves = options.moves ?? []; + bs.writeU32(options.moveStartIndex ?? 0); + bs.writeInt(moves.length, 5); // MoveCountBits = 5 + for (const move of moves) { + writeMove(bs, move); + } + + // 4. FOV change flag (Tribes 2 binary reads one flag here, not two + // like TorqueSDK-1.2 — verified against decompiled Tribes2.exe) + bs.writeFlag(false); + + // NetConnection::writePacket — events + ghosts + // eventWritePacket: + // Unguaranteed events: none from observer + bs.writeFlag(false); // end unguaranteed + // Guaranteed events + if (options.events && options.events.length > 0) { + let seq = options.nextSendEventSeq ?? 0; + for (const event of options.events) { + bs.writeFlag(true); // more guaranteed events + bs.writeFlag(false); // not sequential shortcut + bs.writeInt(seq & 0x7f, 7); + seq++; + bs.writeInt(event.classId - NetEventClassFirst, 6); + event.write(bs); + } + } + bs.writeFlag(false); // end guaranteed events + + // ghostWritePacket: client doesn't ghost, so nothing written + // (doesGhostFrom() returns false for client) + }); +} + +export interface ClientMoveData { + /** Movement axes: float [-1, 1]. Encoded as 6-bit unsigned (0-32, center=16). */ + x: number; + y: number; + z: number; + /** Rotation deltas: float (radians per tick). Encoded as 16-bit signed (×65536). + * Server adds these directly to camera rotation each tick. */ + yaw: number; + pitch: number; + roll: number; + freeLook: boolean; + trigger: boolean[]; +} + +export interface ClientEvent { + classId: number; + write: (bs: BitStreamWriter) => void; +} + +/** + * Write a Move struct to the stream. + * + * Wire format (from Tribes2.exe FUN_00601800): + * flag(yaw?) + optional 16-bit yaw (rotation, signed) + * flag(pitch?) + optional 16-bit pitch + * flag(roll?) + optional 16-bit roll + * 6-bit x + 6-bit y + 6-bit z (movement, unsigned 0-32, center=16) + * flag(freeLook) + 6×flag(trigger) + */ +function writeMove(bs: BitStreamWriter, move: ClientMoveData): void { + // Rotation (flag + optional 16-bit signed). + // Pack: int16 = (int)(radians * 65536). Server unpacks: float = (short)int16 / 65536. + const pyaw = Math.round(move.yaw * 65536) | 0; + const ppitch = Math.round(move.pitch * 65536) | 0; + const proll = Math.round(move.roll * 65536) | 0; + + if (pyaw !== 0) { + bs.writeFlag(true); + bs.writeInt(pyaw & 0xffff, 16); + } else { + bs.writeFlag(false); + } + if (ppitch !== 0) { + bs.writeFlag(true); + bs.writeInt(ppitch & 0xffff, 16); + } else { + bs.writeFlag(false); + } + if (proll !== 0) { + bs.writeFlag(true); + bs.writeInt(proll & 0xffff, 16); + } else { + bs.writeFlag(false); + } + + // Movement (6-bit unsigned, 0-32, center=16). + // Pack: uint6 = clamp(float * 16 + 16, 0, 32). Server unpacks: float = (val - 16) / 16. + const px = Math.max(0, Math.min(32, Math.round(move.x * 16 + 16))); + const py = Math.max(0, Math.min(32, Math.round(move.y * 16 + 16))); + const pz = Math.max(0, Math.min(32, Math.round(move.z * 16 + 16))); + bs.writeInt(px, 6); + bs.writeInt(py, 6); + bs.writeInt(pz, 6); + + // FreeLook flag + bs.writeFlag(move.freeLook); + + // Trigger keys (6 triggers) + for (let i = 0; i < 6; i++) { + bs.writeFlag(move.trigger[i] ?? false); + } +} + +/** + * Client-side net string table for tagged string synchronization. + * Assigns 10-bit IDs to strings and generates NetStringEvents to + * register them with the server before use in RemoteCommandEvents. + */ +export class ClientNetStringTable { + private nextId = 1; + private strings = new Map(); + + /** Get or assign a 10-bit string ID. Returns the ID and whether it's new. */ + getOrAdd(str: string): { id: number; isNew: boolean } { + const existing = this.strings.get(str); + if (existing !== undefined) return { id: existing, isNew: false }; + const id = this.nextId++; + if (id > 1023) throw new Error("Net string table overflow (10-bit IDs)"); + this.strings.set(str, id); + return { id, isNew: true }; + } +} + +/** Build a NetStringEvent to register a string with the server. */ +export function buildNetStringEvent( + id: number, + value: string, +): ClientEvent { + return { + classId: NetStringEventClassId, + write(bs: BitStreamWriter) { + // NetStringEvent::pack (FUN_00589b60 inverse): + // writeInt(id, 10) + writeFlag(hasValue) + writeString(value) + bs.writeInt(id, 10); + bs.writeFlag(true); + writeString(bs, value, true); + }, + }; +} + +/** + * Build a RemoteCommandEvent for commandToServer. + * The function name must be sent as a TagString (type=2, 10-bit ID) + * with a corresponding NetStringEvent sent beforehand. + * Returns the RemoteCommandEvent and any required NetStringEvents. + */ +export function buildRemoteCommandEvent( + stringTable: ClientNetStringTable, + command: string, + ...args: string[] +): ClientEvent[] { + const events: ClientEvent[] = []; + + // Register the function name in the string table + const { id: cmdId, isNew } = stringTable.getOrAdd(command); + if (isNew) { + events.push(buildNetStringEvent(cmdId, command)); + } + + // Build the RemoteCommandEvent + events.push({ + classId: RemoteCommandEventClassId, + write(bs: BitStreamWriter) { + // RemoteCommandEvent::pack (FUN_005bfd40): + // writeInt(argc, 5) then argc × conn->packString + // argv[0] = function name (must be TagString for process() to work) + const argc = Math.min(1 + args.length, 20); + bs.writeInt(argc, 5); + // Pack function name as TagString (type=2, 10-bit ID) + bs.writeInt(2, 2); // TagString type + bs.writeInt(cmdId, 10); + // Pack remaining args as regular strings + for (let i = 0; i < argc - 1; i++) { + packNetString(bs, args[i], true); + } + }, + }); + + return events; +} + +/** + * Build a CRCChallengeResponseEvent to reply to the server's CRC challenge. + * Format: 3×U32 (crcValue, field1, field2). + * The real client computes CRC over game files; we echo back dummy values. + * The server always proceeds to the script callback regardless of CRC match + * (but schedules a delayed kick if values are wrong). + */ +export function buildCRCChallengeResponseEvent( + crcValue: number, + field1: number, + field2: number, +): ClientEvent { + return { + classId: CRCChallengeResponseEventClassId, + write(bs: BitStreamWriter) { + bs.writeU32(crcValue); + bs.writeU32(field1); + bs.writeU32(field2); + }, + }; +} + +/** + * Build a GhostingMessageEvent to acknowledge GhostAlwaysDone from the server. + * When the server sends type 0 (GhostAlwaysDone), the client must respond + * with type 1 to enable ghost writes (mGhosting=true on the server). + */ +export function buildGhostingMessageEvent( + sequence: number, + message: number, + ghostCount: number, +): ClientEvent { + return { + classId: GhostingMessageEventClassId, + write(bs: BitStreamWriter) { + bs.writeU32(sequence); + bs.writeInt(message, 3); + bs.writeInt(ghostCount, 11); + }, + }; +} + +// ── Out-of-band (OOB) packet types ── + +/** + * Build a ConnectChallengeRequest (type 26) OOB packet. + * Format from Tribes2.exe: U8(26) + U32(proto) + U32(seq) + HuffString(password) + Flag(auth) + */ +export function buildConnectChallengeRequest( + protocolVersion: number, + clientConnectSequence: number, + joinPassword: string = "", +): Uint8Array { + const bs = new BitStreamWriter(512); + bs.writeU8(26); // ConnectChallengeRequest type + bs.writeU32(protocolVersion); + bs.writeU32(clientConnectSequence); + writeString(bs, joinPassword); + // No auth data + bs.writeFlag(false); + return bs.getBuffer(); +} + +/** Build a ConnectRequest (type 32) OOB packet. */ +export function buildConnectRequest( + serverConnectSequence: number, + clientConnectSequence: number, + protocolVersion: number, + authenticated: boolean, + argv: string[] = [], +): Uint8Array { + const bs = new BitStreamWriter(1024); + bs.writeU8(32); // ConnectRequest type + bs.writeU32(serverConnectSequence); + bs.writeU32(clientConnectSequence); + bs.writeU32(protocolVersion); + bs.writeFlag(authenticated); + + // argc + argv (connection parameters: name, race, skin, voice, etc.) + // Argv uses Huffman-encoded strings per Tribes2.exe binary. + bs.writeU32(argv.length); + for (const arg of argv) { + writeString(bs, arg); + } + + return bs.getBuffer(); +} + +/** Build a Disconnect (type 38) OOB packet. */ +export function buildDisconnectPacket( + connectSequence: number, +): Uint8Array { + const bs = new BitStreamWriter(64); + bs.writeU8(38); // Disconnect type + bs.writeU32(connectSequence); + writeString(bs, ""); // reason + return bs.getBuffer(); +} + +// ── Master server query packets ── + +/** Build a MasterServerListRequest (type 6). */ +export function buildMasterServerListRequest( + queryFlags: number = 0, + key: number = 0, +): Uint8Array { + const bs = new BitStreamWriter(256); + bs.writeU8(6); // MasterServerListRequest + bs.writeU8(queryFlags); + bs.writeU32(key); + // Game type / mission type filters (empty = all) + bs.writeU8(0xff); // maxPlayers filter (0xff = any) + bs.writeU32(0); // regionMask (0 = any) + bs.writeU32(0); // version (0 = any) + bs.writeU8(0); // filter flags + bs.writeU8(0); // maxBots + bs.writeU16(0); // minCPU + bs.writeU8(0); // buddyCount + return bs.getBuffer(); +} + +/** Build a GamePingRequest (type 14). */ +export function buildGamePingRequest( + flags: number = 0, + key: number = 0, +): Uint8Array { + const bs = new BitStreamWriter(64); + bs.writeU8(14); // GamePingRequest + bs.writeU8(flags); + bs.writeU32(key); + return bs.getBuffer(); +} + +/** Build a GameInfoRequest (type 18). */ +export function buildGameInfoRequest( + flags: number = 0, + key: number = 0, +): Uint8Array { + const bs = new BitStreamWriter(64); + bs.writeU8(18); // GameInfoRequest + bs.writeU8(flags); + bs.writeU32(key); + return bs.getBuffer(); +} diff --git a/relay/server.ts b/relay/server.ts new file mode 100644 index 00000000..0a5945b3 --- /dev/null +++ b/relay/server.ts @@ -0,0 +1,369 @@ +import http from "node:http"; +import fs from "node:fs/promises"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import { WebSocketServer, WebSocket } from "ws"; +import { queryServerList } from "./masterQuery.js"; +import { GameConnection } from "./gameConnection.js"; +import { loadCredentials } from "./auth.js"; +import { relayLog } from "./logger.js"; +import type { ClientMessage, ServerMessage, ServerInfo } from "./types.js"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +/** Base path for game files (extracted VL2 contents). */ +const GAME_BASE_PATH = + process.env.GAME_BASE_PATH || path.resolve(__dirname, "..", "docs", "base"); + +const MANIFEST_PATH = + process.env.MANIFEST_PATH || + path.resolve(GAME_BASE_PATH, "..", "..", "public", "manifest.json"); + +const RELAY_PORT = parseInt(process.env.RELAY_PORT || "8765", 10); +const MASTER_SERVER = + process.env.T2_MASTER_SERVER || "master.tribesnext.com"; + +/** HTTP server for health checks; WebSocket upgrades are handled separately. */ +const httpServer = http.createServer(async (req, res) => { + if (req.url === "/health") { + const checks: Record = {}; + + // Check game assets directory. + try { + const stat = await fs.stat(GAME_BASE_PATH); + const entries = await fs.readdir(GAME_BASE_PATH); + checks.gameAssets = { + ok: stat.isDirectory() && entries.length > 0, + detail: `${entries.length} entries in ${GAME_BASE_PATH}`, + }; + } catch { + checks.gameAssets = { ok: false, detail: `${GAME_BASE_PATH} not found` }; + } + + // Check manifest. + try { + const raw = await fs.readFile(MANIFEST_PATH, "utf-8"); + const manifest = JSON.parse(raw); + const count = Object.keys(manifest.resources ?? {}).length; + checks.manifest = { ok: count > 0, detail: `${count} resources` }; + } catch { + checks.manifest = { ok: false, detail: `${MANIFEST_PATH} not found` }; + } + + // Check credentials. + const creds = loadCredentials(); + checks.credentials = { + ok: creds !== null, + detail: creds ? "loaded" : "missing or incomplete", + }; + + const allOk = Object.values(checks).every((c) => c.ok); + res.writeHead(allOk ? 200 : 503, { "Content-Type": "application/json" }); + res.end(JSON.stringify({ status: allOk ? "ok" : "degraded", checks }, null, 2)); + return; + } + + res.writeHead(404); + res.end(); +}); + +const wss = new WebSocketServer({ server: httpServer }); +httpServer.listen(RELAY_PORT, "0.0.0.0", () => { + relayLog.info({ port: RELAY_PORT }, "Relay server listening"); +}); + +/** Cached server list from the most recent master query. */ +let cachedServers: ServerInfo[] = []; + +wss.on("connection", (ws) => { + relayLog.info("Browser client connected"); + + let gameConnection: GameConnection | null = null; + let lastJoinAddress: string | null = null; + let retryCount = 0; + let retryTimer: ReturnType | null = null; + + const MAX_RETRIES = 3; + const RETRY_DELAY_MS = 6000; + const RETRYABLE_REASONS = ["Server is cycling mission"]; + + async function connectToServer(ws: WebSocket, address: string): Promise { + if (gameConnection) { + gameConnection.disconnect(); + } + + gameConnection = new GameConnection(address); + + // Set mapName from the cached server list if available. + const cachedServer = cachedServers.find( + (s) => s.address === address, + ); + if (cachedServer?.mapName) { + gameConnection.setMapName(cachedServer.mapName); + } + + gameConnection.on("status", (status, statusMessage) => { + relayLog.info( + { + status, + statusMessage, + connectSequence: gameConnection?.connectSequence, + mapName: gameConnection?.mapName, + }, + "Game connection status changed", + ); + + // Auto-retry on retryable disconnect reasons. + if ( + status === "disconnected" && + statusMessage && + RETRYABLE_REASONS.some((r) => statusMessage.includes(r)) && + retryCount < MAX_RETRIES && + lastJoinAddress === address + ) { + retryCount++; + relayLog.info( + { attempt: retryCount, maxRetries: MAX_RETRIES, delay: RETRY_DELAY_MS }, + "Retryable disconnect — will reconnect", + ); + sendToClient(ws, { + type: "status", + status: "connecting", + message: `${statusMessage} — retrying (${retryCount}/${MAX_RETRIES})...`, + connectSequence: gameConnection?.connectSequence, + mapName: gameConnection?.mapName, + }); + retryTimer = setTimeout(() => { + retryTimer = null; + if (lastJoinAddress === address && ws.readyState === WebSocket.OPEN) { + connectToServer(ws, address); + } + }, RETRY_DELAY_MS); + return; + } + + sendToClient(ws, { + type: "status", + status, + message: statusMessage, + connectSequence: gameConnection?.connectSequence, + mapName: gameConnection?.mapName, + }); + }); + + gameConnection.on("ping", (ms) => { + sendToClient(ws, { type: "ping", ms }); + }); + + let forwardedPackets = 0; + gameConnection.on("packet", (packetData) => { + forwardedPackets++; + if (ws.readyState === WebSocket.OPEN) { + ws.send(packetData, { binary: true }); + } else { + relayLog.warn( + { wsState: ws.readyState, total: forwardedPackets }, + "Dropped game packet — WebSocket not open", + ); + } + if (forwardedPackets <= 5 || forwardedPackets % 500 === 0) { + relayLog.debug( + { bytes: packetData.length, total: forwardedPackets }, + "Forwarded game packet to browser", + ); + } + }); + + gameConnection.on("error", (err) => { + relayLog.error({ err }, "Game connection error"); + sendToClient(ws, { + type: "error", + message: err.message, + }); + }); + + gameConnection.on("close", () => { + relayLog.info("Game connection closed"); + gameConnection = null; + }); + + await gameConnection.connect(); + } + + ws.on("message", async (data, isBinary) => { + try { + if (isBinary) { + return; + } + + const message: ClientMessage = JSON.parse(data.toString()); + await handleClientMessage(ws, message); + } catch (e) { + const err = e instanceof Error ? e.message : String(e); + relayLog.error({ err: e }, "Error handling client message"); + sendToClient(ws, { type: "error", message: err }); + } + }); + + ws.on("close", () => { + relayLog.info("Browser client disconnected"); + if (retryTimer) { + clearTimeout(retryTimer); + retryTimer = null; + } + if (gameConnection) { + gameConnection.disconnect(); + gameConnection = null; + } + }); + + async function handleClientMessage( + ws: WebSocket, + message: ClientMessage, + ): Promise { + switch (message.type) { + case "listServers": { + relayLog.info("Querying master server for server list"); + try { + const servers = await queryServerList(MASTER_SERVER); + cachedServers = servers; + relayLog.info( + { count: servers.length }, + "Returning server list to browser", + ); + sendToClient(ws, { type: "serverList", servers }); + } catch (e) { + relayLog.error({ err: e }, "Master query failed"); + sendToClient(ws, { + type: "error", + message: `Master query failed: ${e}`, + }); + } + break; + } + + case "joinServer": { + relayLog.info({ address: message.address }, "Join server requested"); + if (gameConnection) { + relayLog.info("Disconnecting existing game connection"); + gameConnection.disconnect(); + } + if (retryTimer) { + clearTimeout(retryTimer); + retryTimer = null; + } + retryCount = 0; + lastJoinAddress = message.address; + + await connectToServer(ws, message.address); + break; + } + + case "disconnect": { + relayLog.info("Disconnect requested"); + if (retryTimer) { + clearTimeout(retryTimer); + retryTimer = null; + } + if (gameConnection) { + gameConnection.disconnect(); + gameConnection = null; + } + break; + } + + case "sendCommand": { + if (gameConnection) { + const authEvents = [ + "t2csri_pokeClient", + "t2csri_getChallengeChunk", + "t2csri_decryptChallenge", + ]; + if (authEvents.includes(message.command)) { + relayLog.debug( + { event: message.command }, + "Forwarding auth event from browser", + ); + gameConnection.handleAuthEvent( + message.command, + message.args, + ); + } else { + relayLog.debug( + { command: message.command }, + "Forwarding command to server", + ); + gameConnection.sendCommand(message.command, ...message.args); + } + } + break; + } + + case "sendCRCResponse": { + if (gameConnection) { + relayLog.debug("Forwarding CRC response from browser (legacy echo)"); + gameConnection.handleCRCChallenge( + message.crcValue, + message.field1, + message.field2, + ); + } + break; + } + + case "sendCRCCompute": { + if (gameConnection) { + relayLog.info( + { datablocks: message.datablocks.length, includeTextures: message.includeTextures }, + "Computing CRC from game files", + ); + gameConnection.computeAndSendCRC( + message.seed, + message.field2, + message.datablocks, + message.includeTextures, + GAME_BASE_PATH, + ); + } + break; + } + + case "sendGhostAck": { + if (gameConnection) { + relayLog.debug("Forwarding ghost ack from browser"); + gameConnection.handleGhostAlwaysDone( + message.sequence, + message.ghostCount, + ); + } + break; + } + + case "wsPing": { + sendToClient(ws, { type: "wsPong", ts: message.ts }); + break; + } + + case "sendMove": { + if (gameConnection) { + gameConnection.sendMove({ + x: message.move.x, + y: message.move.y, + z: message.move.z, + yaw: message.move.yaw, + pitch: message.move.pitch, + roll: message.move.roll, + freeLook: message.move.freeLook, + trigger: message.move.trigger, + }); + } + break; + } + } + } +}); + +function sendToClient(ws: WebSocket, message: ServerMessage): void { + if (ws.readyState === WebSocket.OPEN) { + ws.send(JSON.stringify(message)); + } +} diff --git a/relay/types.ts b/relay/types.ts new file mode 100644 index 00000000..19ee9fbe --- /dev/null +++ b/relay/types.ts @@ -0,0 +1,64 @@ +/** Messages from browser client to relay server. */ +export type ClientMessage = + | { type: "listServers" } + | { type: "joinServer"; address: string } + | { type: "disconnect" } + | { type: "sendMove"; move: ClientMove } + | { type: "sendCommand"; command: string; args: string[] } + | { type: "sendCRCResponse"; crcValue: number; field1: number; field2: number } + | { type: "sendCRCCompute"; seed: number; field2: number; includeTextures: boolean; datablocks: { objectId: number; className: string; shapeName: string }[] } + | { type: "sendGhostAck"; sequence: number; ghostCount: number } + | { type: "wsPing"; ts: number }; + +/** Messages from relay server to browser client. */ +export type ServerMessage = + | { type: "serverList"; servers: ServerInfo[] } + | { type: "status"; status: ConnectionStatus; message?: string; connectSequence?: number; mapName?: string } + | { type: "gamePacket"; data: Uint8Array } + | { type: "ping"; ms: number } + | { type: "wsPong"; ts: number } + | { type: "error"; message: string }; + +export interface ServerInfo { + address: string; + name: string; + mod: string; + gameType: string; + mapName: string; + playerCount: number; + maxPlayers: number; + botCount: number; + ping: number; + buildVersion: number; + passwordRequired: boolean; +} + +export type ConnectionStatus = + | "connecting" + | "challenging" + | "authenticating" + | "connected" + | "disconnected"; + +export interface ClientMove { + /** Movement axes: float [-1, 1]. 0 = no movement. */ + x: number; + y: number; + z: number; + /** Rotation deltas: float (radians per tick). 0 = no rotation change. */ + yaw: number; + pitch: number; + roll: number; + trigger: boolean[]; + freeLook: boolean; +} + +export interface RelayConfig { + port: number; + accountName: string; + accountPassword: string; + accountCertificate: string; + accountEncryptedKey: string; + authServerAddress: string; + masterServerAddress: string; +} diff --git a/scripts/check-mount-points.ts b/scripts/check-mount-points.ts index 31d03383..a73f26ac 100644 --- a/scripts/check-mount-points.ts +++ b/scripts/check-mount-points.ts @@ -102,7 +102,7 @@ function getNodeWorldPosition( if (nodeIdx === -1) return null; // Walk up parent chain accumulating translations (ignoring rotation for now) - let pos: [number, number, number] = [0, 0, 0]; + const pos: [number, number, number] = [0, 0, 0]; let current: number | undefined = nodeIdx; while (current != null) { const node = json.nodes[current]; diff --git a/scripts/convert-wav.ts b/scripts/convert-wav.ts index d8569342..f6c2a93f 100644 --- a/scripts/convert-wav.ts +++ b/scripts/convert-wav.ts @@ -26,7 +26,7 @@ async function run({ try { await fs.stat(oggFile); continue; // .ogg already exists, skip - } catch {} + } catch { /* expected */ } } inputFiles.push(wavFile); } diff --git a/scripts/t2-login.ts b/scripts/t2-login.ts new file mode 100644 index 00000000..05bb9ea1 --- /dev/null +++ b/scripts/t2-login.ts @@ -0,0 +1,322 @@ +/** + * Downloads TribesNext account credentials (certificate + encrypted private key) + * from the auth server using username and password. + * + * Usage: + * tsx scripts/t2-login.ts [--env=] + * + * Reads T2_ACCOUNT_NAME and T2_ACCOUNT_PASSWORD from .env / environment (or prompts). + * Writes/updates T2_ACCOUNT_CERTIFICATE and T2_ACCOUNT_ENCRYPTED_KEY in the + * target env file (default: .env.local). + * + * This only needs to be run once — the credentials persist until you change + * your password or the auth server rotates keys. + */ + +import crypto from "node:crypto"; +import net from "node:net"; +import http from "node:http"; +import fs from "node:fs/promises"; +import path from "node:path"; +import readline from "node:readline/promises"; + +const ROOT = path.resolve(import.meta.dirname, ".."); + +function sha1(data: string): string { + return crypto.createHash("sha1").update(data).digest("hex"); +} + +/** Parse --env= from argv, resolve relative to project root. */ +function getEnvFilePath(): string { + for (const arg of process.argv.slice(2)) { + const match = arg.match(/^--env=(.+)$/); + if (match) { + return path.resolve(ROOT, match[1]); + } + } + return path.resolve(ROOT, ".env.local"); +} + +/** + * Read an env file and return its lines. Returns an empty array if the + * file doesn't exist. + */ +async function readEnvLines(filePath: string): Promise { + try { + const content = await fs.readFile(filePath, "utf-8"); + return content.split("\n"); + } catch { + return []; + } +} + +/** + * Update env file content: replace existing keys in-place, append new ones. + * Preserves comments, blank lines, and ordering of untouched keys. + */ +function updateEnvLines( + existingLines: string[], + updates: Record, +): string[] { + const remaining = new Set(Object.keys(updates)); + const result: string[] = []; + + for (const line of existingLines) { + const match = line.match(/^([A-Z_][A-Z0-9_]*)=/); + if (match && remaining.has(match[1])) { + result.push(`${match[1]}=${updates[match[1]]}`); + remaining.delete(match[1]); + } else { + result.push(line); + } + } + + // Append any keys that weren't already in the file + if (remaining.size > 0) { + // Ensure there's a blank line before new entries (unless file is empty + // or already ends with one) + const last = result[result.length - 1]; + if (result.length > 0 && last !== "" && last !== undefined) { + result.push(""); + } + for (const key of remaining) { + result.push(`${key}=${updates[key]}`); + } + } + + // Ensure file ends with a newline + if (result[result.length - 1] !== "") { + result.push(""); + } + + return result; +} + +/** Look up the auth server address from tribesnext.com */ +async function findAuthServer(): Promise { + return new Promise((resolve, reject) => { + const req = http.get("http://www.tribesnext.com/auth", (res) => { + let body = ""; + res.on("data", (chunk: Buffer) => { + body += chunk.toString(); + }); + res.on("end", () => { + const lines = body.trim().split("\n"); + for (const line of lines) { + const fields = line.split("\t"); + if (fields.length >= 1 && fields[0].includes(":")) { + resolve(fields[0]); + return; + } + } + reject(new Error("Could not parse auth server address from response")); + }); + }); + req.on("error", reject); + req.setTimeout(10000, () => { + req.destroy(); + reject(new Error("Auth server lookup timed out")); + }); + }); +} + +/** Download account credentials from the auth server via TCP. */ +async function downloadAccount( + authAddress: string, + username: string, + password: string, +): Promise<{ certificate: string; encryptedKey: string }> { + const [host, portStr] = authAddress.split(":"); + const port = parseInt(portStr, 10); + + // Build the request hash (same as t2csri_downloadAccount) + const authStored = sha1("3.14159265" + username.toLowerCase() + password); + const utc = Math.floor(Date.now() / 1000).toString(); + const timeNonce = sha1(utc + username.toLowerCase()); + const requestHash = sha1(authStored + timeNonce); + const payload = `RECOVER\t${username}\t${utc}\t${requestHash}\n`; + + return new Promise((resolve, reject) => { + const socket = new net.Socket(); + let buffer = ""; + let idleTimer: ReturnType | null = null; + + // Overall timeout if we never get any data at all. + socket.setTimeout(15000); + + socket.connect(port, host, () => { + socket.write(payload); + }); + + socket.on("data", (data: Buffer) => { + buffer += data.toString(); + // The auth server doesn't close the connection after responding. + // Mimic Torque's 700ms idle timeout to detect response completion. + if (idleTimer) clearTimeout(idleTimer); + idleTimer = setTimeout(() => { + socket.destroy(); + processResponse(); + }, 700); + }); + + socket.on("end", () => { + processResponse(); + }); + + socket.on("timeout", () => { + socket.destroy(); + reject(new Error("Auth server connection timed out")); + }); + + socket.on("error", (err: Error) => { + reject(err); + }); + + socket.on("close", () => { + processResponse(); + }); + + let processed = false; + function processResponse() { + if (processed) return; + processed = true; + if (idleTimer) clearTimeout(idleTimer); + + const trimmed = buffer.trim(); + + if (trimmed === "RECOVERERROR") { + reject(new Error("Auth server returned RECOVERERROR (malformed request)")); + return; + } + if (trimmed === "NOTFOUND") { + reject(new Error("Account not found. Check your username.")); + return; + } + if (trimmed === "INVALIDPASSWORD") { + reject(new Error("Invalid password.")); + return; + } + + // Success response format: + // Line 1: CERT: + // Line 2: EXP: + const lines = trimmed.split("\n"); + if (lines.length < 2) { + reject(new Error(`Unexpected response from auth server: ${trimmed.slice(0, 200)}`)); + return; + } + + let certLine = lines[0]; + let expLine = lines[1]; + + // Strip the "CERT: " prefix + if (certLine.startsWith("CERT:")) { + certLine = certLine.substring(6).trim(); + } + + // Strip the "EXP: " prefix if present + if (expLine.startsWith("EXP:")) { + expLine = expLine.substring(5).trim(); + } + + resolve({ + certificate: certLine, + encryptedKey: expLine, + }); + } + }); +} + +async function main() { + const envFilePath = getEnvFilePath(); + + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + }); + + // Credentials come from process.env (loaded via --env-file-if-exists in + // the npm script, or set manually in the shell environment). + let username = process.env.T2_ACCOUNT_NAME || ""; + let password = process.env.T2_ACCOUNT_PASSWORD || ""; + + if (!username) { + username = await rl.question("TribesNext username: "); + } else { + console.log(`Using username: ${username}`); + } + + if (!password) { + password = await rl.question("TribesNext password: "); + } else { + console.log("Using password from environment"); + } + + rl.close(); + + if (!username || !password) { + console.error("Username and password are required."); + process.exit(1); + } + + // Step 1: Find auth server + let authAddress = process.env.T2_AUTH_SERVER || ""; + if (authAddress) { + console.log(`Using auth server from environment: ${authAddress}`); + } else { + console.log("Looking up auth server..."); + try { + authAddress = await findAuthServer(); + console.log(`Auth server: ${authAddress}`); + } catch (e) { + console.error("Failed to find auth server:", e); + process.exit(1); + } + } + + // Step 2: Download credentials + console.log("Downloading account credentials..."); + let credentials: { certificate: string; encryptedKey: string }; + try { + credentials = await downloadAccount(authAddress, username, password); + } catch (e) { + console.error("Failed to download credentials:", e); + process.exit(1); + } + + console.log("Successfully downloaded credentials!"); + + // Verify the certificate looks valid + const certFields = credentials.certificate.split("\t"); + if (certFields.length >= 4) { + console.log(` Account: ${certFields[0]}`); + console.log(` GUID: ${certFields[1]}`); + console.log(` Public key length: ${certFields[3].length} hex chars`); + } + + // Step 3: Update the env file + const certB64 = Buffer.from(credentials.certificate).toString("base64"); + const keyB64 = Buffer.from(credentials.encryptedKey).toString("base64"); + + const existingLines = await readEnvLines(envFilePath); + const updatedLines = updateEnvLines( + existingLines.length > 0 ? existingLines : ["# Generated by scripts/t2-login.ts"], + { + T2_ACCOUNT_NAME: username, + T2_ACCOUNT_PASSWORD: password, + T2_ACCOUNT_CERTIFICATE: certB64, + T2_ACCOUNT_ENCRYPTED_KEY: keyB64, + }, + ); + + await fs.writeFile(envFilePath, updatedLines.join("\n"), "utf-8"); + console.log(`\nCredentials written to ${envFilePath}`); + console.log( + "The relay server will read these automatically. Run: npm run relay:dev", + ); +} + +main().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/scripts/t2-server-list.ts b/scripts/t2-server-list.ts new file mode 100644 index 00000000..0058aadf --- /dev/null +++ b/scripts/t2-server-list.ts @@ -0,0 +1,69 @@ +/** + * Queries the TribesNext master server for active game servers and prints + * their details to the console. Useful for testing the master query protocol + * without going through the browser. + * + * Usage: + * npm run server-list + */ + +import { queryServerList } from "../relay/masterQuery.js"; + +const MASTER_SERVER = + process.env.T2_MASTER_SERVER || "master.tribesnext.com"; + +async function main() { + console.log(`Master server: ${MASTER_SERVER}`); + console.log("Querying server list...\n"); + + try { + const servers = await queryServerList(MASTER_SERVER); + + if (servers.length === 0) { + console.log("No servers found."); + return; + } + + console.log(`Found ${servers.length} server(s):\n`); + + // Print as a table + const nameWidth = Math.max( + 11, + ...servers.map((s) => s.name.length), + ); + const header = [ + "Server Name".padEnd(nameWidth), + "Map".padEnd(20), + "Type".padEnd(18), + "Mod".padEnd(12), + "Players".padEnd(9), + "Ping".padEnd(6), + "Address", + ].join(" "); + + console.log(header); + console.log("-".repeat(header.length)); + + for (const server of servers) { + console.log( + [ + server.name.padEnd(nameWidth), + server.mapName.padEnd(20), + server.gameType.padEnd(18), + server.mod.padEnd(12), + `${server.playerCount}/${server.maxPlayers}`.padEnd(9), + `${server.ping}ms`.padEnd(6), + server.address, + ].join(" "), + ); + } + } catch (e) { + console.error("Query failed:", e); + process.exit(1); + } +} + +main().catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/src/components/AudioContext.tsx b/src/components/AudioContext.tsx index f9d259ca..77ac73e4 100644 --- a/src/components/AudioContext.tsx +++ b/src/components/AudioContext.tsx @@ -41,11 +41,26 @@ export function AudioProvider({ children }: { children: ReactNode }) { camera.add(listener); } + listener.setMasterVolume(0.8); + setAudioContext({ audioLoader, audioListener: listener, }); + // Resume the AudioContext on user interaction to satisfy browser autoplay + // policy. Without this, sounds won't play until the user clicks/taps. + const resumeOnGesture = () => { + const ctx = listener?.context; + if (!ctx || ctx.state !== "suspended") return; + ctx.resume().finally(() => { + document.removeEventListener("click", resumeOnGesture); + document.removeEventListener("keydown", resumeOnGesture); + }); + }; + document.addEventListener("click", resumeOnGesture); + document.addEventListener("keydown", resumeOnGesture); + // Suspend/resume the Web AudioContext when demo playback pauses/resumes. // This freezes all playing sounds at their current position rather than // stopping them, so they resume seamlessly. @@ -56,14 +71,17 @@ export function AudioProvider({ children }: { children: ReactNode }) { if (!ctx) return; if (status === "paused") { ctx.suspend(); - } else if (status === "playing" && ctx.state === "suspended") { + } else if (ctx.state === "suspended") { ctx.resume(); } }, ); return () => { + document.removeEventListener("click", resumeOnGesture); + document.removeEventListener("keydown", resumeOnGesture); unsubscribe(); + if (listener) camera.remove(listener); }; }, [camera]); diff --git a/src/components/AudioEmitter.tsx b/src/components/AudioEmitter.tsx index 277081ac..e875b439 100644 --- a/src/components/AudioEmitter.tsx +++ b/src/components/AudioEmitter.tsx @@ -8,8 +8,6 @@ import { PositionalAudio, Vector3, } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getFloat, getInt, getPosition, getProperty } from "../mission"; import { audioToUrl } from "../loaders"; import { useAudio } from "./AudioContext"; import { useDebug, useSettings } from "./SettingsProvider"; @@ -19,30 +17,49 @@ import { engineStore } from "../state"; // Global audio buffer cache shared across all audio components. export const audioBufferCache = new Map(); -// ── Demo sound rate tracking ── -// Track active demo sounds so their playbackRate can be updated when the -// playback rate changes (e.g. slow-motion or fast-forward). -// Maps each sound to its intrinsic pitch (1.0 for normal sounds, or the -// voice pitch multiplier for chat sounds). -const _activeDemoSounds = new Map, number>(); +// Track active sounds so their playbackRate can be updated when the playback +// rate changes (e.g. slow-motion or fast-forward). Maps each sound to its +// intrinsic pitch (1.0 for normal, or the voice pitch multiplier for chat). +const _activeSounds = new Map, number>(); -/** Register a sound for automatic playback rate tracking. */ -export function trackDemoSound( +/** Register a sound for automatic playback rate tracking during streaming. */ +export function trackSound( sound: Audio, basePitch = 1, ): void { - _activeDemoSounds.set(sound, basePitch); + _activeSounds.set(sound, basePitch); } -/** Unregister a tracked demo sound. */ -export function untrackDemoSound(sound: Audio): void { - _activeDemoSounds.delete(sound); +/** Unregister a tracked sound. */ +export function untrackSound(sound: Audio): void { + _activeSounds.delete(sound); +} + +/** + * Generation counter incremented on each stopAllTrackedSounds() call. + * Async sound callbacks check this to avoid playing after teardown. + */ +let _soundGeneration = 0; + +/** Current sound generation — capture before async work, check on completion. */ +export function getSoundGeneration(): number { + return _soundGeneration; +} + +/** Stop and unregister all tracked sounds. Called on recording change. */ +export function stopAllTrackedSounds(): void { + _soundGeneration++; + for (const [sound] of _activeSounds) { + try { sound.stop(); } catch { /* already stopped */ } + try { sound.disconnect(); } catch { /* already disconnected */ } + } + _activeSounds.clear(); } engineStore.subscribe( (state) => state.playback.rate, (rate) => { - for (const [sound, basePitch] of _activeDemoSounds) { + for (const [sound, basePitch] of _activeSounds) { try { sound.setPlaybackRate(basePitch * rate); } catch { @@ -108,7 +125,9 @@ export function playOneShotSound( return; } const rate = engineStore.getState().playback.rate; + const gen = _soundGeneration; getCachedAudioBuffer(url, audioLoader, (buffer) => { + if (gen !== _soundGeneration) return; try { if (resolved.is3D && parent) { const sound = new PositionalAudio(audioListener); @@ -125,11 +144,11 @@ export function playOneShotSound( sound.position.copy(position); } parent.add(sound); - _activeDemoSounds.set(sound, 1); + _activeSounds.set(sound, 1); sound.play(); sound.source!.onended = () => { - _activeDemoSounds.delete(sound); - sound.disconnect(); + _activeSounds.delete(sound); + try { sound.disconnect(); } catch { /* already disconnected */ } parent.remove(sound); }; } else { @@ -137,11 +156,11 @@ export function playOneShotSound( sound.setBuffer(buffer); sound.setVolume(resolved.volume); sound.setPlaybackRate(rate); - _activeDemoSounds.set(sound, 1); + _activeSounds.set(sound, 1); sound.play(); sound.source!.onended = () => { - _activeDemoSounds.delete(sound); - sound.disconnect(); + _activeSounds.delete(sound); + try { sound.disconnect(); } catch { /* already disconnected */ } }; } } catch { @@ -173,40 +192,62 @@ export function getCachedAudioBuffer( } export const AudioEmitter = memo(function AudioEmitter({ - object, + entity, }: { - object: TorqueObject; + entity: { + audioFileName?: string; + audioVolume?: number; + audioMinDistance?: number; + audioMaxDistance?: number; + audioMinLoopGap?: number; + audioMaxLoopGap?: number; + audioIs3D?: boolean; + audioIsLooping?: boolean; + position?: [number, number, number]; + }; }) { const { debugMode } = useDebug(); - const fileName = getProperty(object, "fileName") ?? ""; - const volume = getFloat(object, "volume") ?? 1; - const minDistance = getFloat(object, "minDistance") ?? 1; - const maxDistance = getFloat(object, "maxDistance") ?? 1; - const minLoopGap = getFloat(object, "minLoopGap") ?? 0; - const maxLoopGap = getFloat(object, "maxLoopGap") ?? 0; - const is3D = getInt(object, "is3D") ?? 0; + const fileName = entity.audioFileName ?? ""; + const volume = entity.audioVolume ?? 1; + const minDistance = entity.audioMinDistance ?? 1; + const maxDistance = entity.audioMaxDistance ?? 1; + const minLoopGap = entity.audioMinLoopGap ?? 0; + const maxLoopGap = entity.audioMaxLoopGap ?? 0; + const is3D = (entity.audioIs3D ?? true) ? 1 : 0; + const isLooping = entity.audioIsLooping ?? true; - const [x, y, z] = getPosition(object); + const [x, y, z] = entity.position ?? [0, 0, 0]; const { scene, camera } = useThree(); const { audioLoader, audioListener } = useAudio(); const { audioEnabled } = useSettings(); const soundRef = useRef | null>(null); - const loopTimerRef = useRef(null); - const loopGapIntervalRef = useRef(null); + const loopTimerRef = useRef | null>(null); + const loopGapIntervalRef = useRef | null>(null); const isLoadedRef = useRef(false); const isInRangeRef = useRef(false); const emitterPosRef = useRef(new Vector3(x, y, z)); + // Generation counter: incremented when the sound object is recreated so + // that stale setTimeout callbacks from a previous sound are discarded. + const generationRef = useRef(0); const clearTimers = () => { - if (loopTimerRef.current) clearTimeout(loopTimerRef.current); - if (loopGapIntervalRef.current) clearTimeout(loopGapIntervalRef.current); + if (loopTimerRef.current != null) { + clearTimeout(loopTimerRef.current); + loopTimerRef.current = null; + } + if (loopGapIntervalRef.current != null) { + clearTimeout(loopGapIntervalRef.current); + loopGapIntervalRef.current = null; + } }; // Create sound object on mount. useEffect(() => { if (!audioLoader || !audioListener) return; + generationRef.current++; + let sound: Audio; if (is3D) { const positional = new PositionalAudio(audioListener); @@ -227,9 +268,10 @@ export const AudioEmitter = memo(function AudioEmitter({ return () => { clearTimers(); - try { sound.stop(); } catch {} - sound.disconnect(); + try { sound.stop(); } catch { /* already stopped */ } + try { sound.disconnect(); } catch { /* already disconnected */ } if (is3D) scene.remove(sound); + soundRef.current = null; isLoadedRef.current = false; isInRangeRef.current = false; }; @@ -243,8 +285,10 @@ export const AudioEmitter = memo(function AudioEmitter({ scene, ]); - // Setup looping logic (only called when audio loads). - const setupLooping = (sound: Audio) => { + // Setup looping logic (only called from effects/timers, never during render). + const setupLooping = (sound: Audio, gen: number) => { + if (!isLooping) return; + if (minLoopGap > 0 || maxLoopGap > 0) { const gapMin = Math.max(0, minLoopGap); const gapMax = Math.max(gapMin, maxLoopGap); @@ -254,12 +298,15 @@ export const AudioEmitter = memo(function AudioEmitter({ sound.loop = false; const checkLoop = () => { + // Discard callbacks from a previous sound generation. + if (gen !== generationRef.current) return; if (sound.isPlaying === false) { loopTimerRef.current = setTimeout(() => { + if (gen !== generationRef.current) return; try { sound.play(); - setupLooping(sound); - } catch {} + setupLooping(sound, gen); + } catch { /* expected */ } }, gap); } else { loopGapIntervalRef.current = setTimeout(checkLoop, 100); @@ -273,25 +320,33 @@ export const AudioEmitter = memo(function AudioEmitter({ // Load and play audio. For 3D, gated by proximity; for 2D, plays immediately. const loadAndPlay = (sound: Audio) => { + if (!audioLoader) return; + const gen = generationRef.current; if (!isLoadedRef.current) { - const audioUrl = audioToUrl(fileName); + let audioUrl: string; + try { + audioUrl = audioToUrl(fileName); + } catch { + return; + } getCachedAudioBuffer(audioUrl, audioLoader, (audioBuffer) => { + if (gen !== generationRef.current) return; if (!sound.buffer) { sound.setBuffer(audioBuffer); isLoadedRef.current = true; try { sound.play(); - setupLooping(sound); - } catch {} + setupLooping(sound, gen); + } catch { /* expected */ } } }); } else { try { if (!sound.isPlaying) { sound.play(); - setupLooping(sound); + setupLooping(sound, gen); } - } catch {} + } catch { /* expected */ } } }; @@ -318,18 +373,19 @@ export const AudioEmitter = memo(function AudioEmitter({ } else if (!isNowInRange && wasInRange) { isInRangeRef.current = false; clearTimers(); - try { sound.stop(); } catch {} + try { sound.stop(); } catch { /* expected */ } } }); - // Stop audio if disabled. + // Stop audio if disabled; reset range state so re-enabling triggers playback. useEffect(() => { const sound = soundRef.current; if (!sound) return; if (!audioEnabled) { clearTimers(); - try { sound.stop(); } catch {} + try { sound.stop(); } catch { /* expected */ } + isInRangeRef.current = false; } }, [audioEnabled]); diff --git a/src/components/Camera.tsx b/src/components/Camera.tsx index f4e37510..28e7d936 100644 --- a/src/components/Camera.tsx +++ b/src/components/Camera.tsx @@ -1,26 +1,37 @@ import { useEffect, useId, useMemo } from "react"; +import { Quaternion, Vector3 } from "three"; import { useCameras } from "./CamerasProvider"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation } from "../mission"; -import { Vector3 } from "three"; +import type { CameraEntity } from "../state/gameEntityTypes"; -export function Camera({ object }: { object: TorqueObject }) { +export function Camera({ entity }: { entity: CameraEntity }) { const { registerCamera, unregisterCamera } = useCameras(); const id = useId(); - const dataBlock = getProperty(object, "dataBlock"); - const position = useMemo(() => getPosition(object), [object]); - const q = useMemo(() => getRotation(object), [object]); + const dataBlock = entity.cameraDataBlock; + const position = useMemo( + () => + entity.position + ? new Vector3(...entity.position) + : new Vector3(), + [entity.position], + ); + const rotation = useMemo( + () => + entity.rotation + ? new Quaternion(...entity.rotation) + : new Quaternion(), + [entity.rotation], + ); useEffect(() => { if (dataBlock === "Observer") { - const camera = { id, position: new Vector3(...position), rotation: q }; + const camera = { id, position, rotation }; registerCamera(camera); return () => { unregisterCamera(camera); }; } - }, [id, dataBlock, registerCamera, unregisterCamera, position, q]); + }, [id, dataBlock, registerCamera, unregisterCamera, position, rotation]); // Maps can define preset observer camera locations. You should be able to jump // to an observer camera position and then fly around from that starting point diff --git a/src/components/CamerasProvider.tsx b/src/components/CamerasProvider.tsx index 9b3dc877..b35c8fbc 100644 --- a/src/components/CamerasProvider.tsx +++ b/src/components/CamerasProvider.tsx @@ -53,7 +53,7 @@ export function CamerasProvider({ children }: { children: ReactNode }) { const unregisterCamera = useCallback((camera: CameraEntry) => { setCameraMap((prevCameraMap) => { - const { [camera.id]: removedCamera, ...remainingCameras } = prevCameraMap; + const { [camera.id]: _removedCamera, ...remainingCameras } = prevCameraMap; return remainingCameras; }); }, []); diff --git a/src/components/ChatSoundPlayer.tsx b/src/components/ChatSoundPlayer.tsx index ec150b6d..c9949853 100644 --- a/src/components/ChatSoundPlayer.tsx +++ b/src/components/ChatSoundPlayer.tsx @@ -2,10 +2,10 @@ import { useEffect, useRef } from "react"; import { Audio } from "three"; import { audioToUrl } from "../loaders"; import { useAudio } from "./AudioContext"; -import { getCachedAudioBuffer, trackDemoSound, untrackDemoSound } from "./AudioEmitter"; +import { getCachedAudioBuffer, getSoundGeneration, trackSound, untrackSound } from "./AudioEmitter"; import { useSettings } from "./SettingsProvider"; import { engineStore, useEngineSelector } from "../state"; -import type { DemoChatMessage } from "../demo/types"; +import type { ChatMessage } from "../stream/types"; /** * Plays non-positional sound effects for chat messages with ~w sound tags. @@ -21,7 +21,7 @@ export function ChatSoundPlayer() { const timeSec = useEngineSelector( (state) => state.playback.streamSnapshot?.timeSec, ); - const playedSetRef = useRef(new WeakSet()); + const playedSetRef = useRef(new WeakSet()); // Track active voice chat sound per sender so a new voice bind from the // same player stops their previous one (matching Tribes 2 behavior). const activeBySenderRef = useRef( @@ -51,29 +51,31 @@ export function ChatSoundPlayer() { const pitch = msg.soundPitch ?? 1; const rate = engineStore.getState().playback.rate; const sender = msg.sender; + const gen = getSoundGeneration(); getCachedAudioBuffer(url, audioLoader, (buffer) => { + if (gen !== getSoundGeneration()) return; // Stop the sender's previous voice chat sound. if (sender) { const prev = activeBySender.get(sender); if (prev) { - try { prev.stop(); } catch {} - untrackDemoSound(prev); - prev.disconnect(); + try { prev.stop(); } catch { /* already stopped */ } + untrackSound(prev); + try { prev.disconnect(); } catch { /* already disconnected */ } activeBySender.delete(sender); } } const sound = new Audio(audioListener); sound.setBuffer(buffer); sound.setPlaybackRate(pitch * rate); - trackDemoSound(sound, pitch); + trackSound(sound, pitch); if (sender) { activeBySender.set(sender, sound); } sound.play(); // Clean up the source node once playback finishes. sound.source!.onended = () => { - untrackDemoSound(sound); - sound.disconnect(); + untrackSound(sound); + try { sound.disconnect(); } catch { /* already disconnected */ } if (sender && activeBySender.get(sender) === sound) { activeBySender.delete(sender); } diff --git a/src/components/CloudLayers.tsx b/src/components/CloudLayers.tsx index f1c3c326..0d0c29be 100644 --- a/src/components/CloudLayers.tsx +++ b/src/components/CloudLayers.tsx @@ -15,8 +15,7 @@ import { Group, } from "three"; import { loadDetailMapList, textureToUrl } from "../loaders"; -import type { TorqueObject } from "../torqueScript"; -import { getFloat, getProperty } from "../mission"; +import type { SceneSky } from "../scene/types"; import { useDebug, useSettings } from "./SettingsProvider"; const noop = () => {}; @@ -460,43 +459,29 @@ function useDetailMapList(name: string | undefined) { } export interface CloudLayersProps { - object: TorqueObject; + scene: SceneSky; } /** * CloudLayers component renders multiple cloud layers as domed meshes. * Matches the Tribes 2 cloud rendering system. - * - * Reads from TorqueObject: - * - materialList: DML file containing cloud textures at indices 7+ - * - cloudSpeed1/2/3: Speed for each cloud layer - * - cloudHeightPer0/1/2: Height percentage for each layer - * - windVelocity: Wind direction for cloud movement */ -export function CloudLayers({ object }: CloudLayersProps) { - const materialList = getProperty(object, "materialList"); +export function CloudLayers({ scene }: CloudLayersProps) { + const materialList = scene.materialList || undefined; const { data: detailMapList } = useDetailMapList(materialList); // From Tribes 2 sky.cc line 1170: mRadius = visibleDistance * 0.95 - const visibleDistance = getFloat(object, "visibleDistance") ?? 500; + const visibleDistance = scene.visibleDistance > 0 ? scene.visibleDistance : 500; const radius = visibleDistance * 0.95; const cloudSpeeds = useMemo( - () => [ - getFloat(object, "cloudSpeed1") ?? 0.0001, - getFloat(object, "cloudSpeed2") ?? 0.0002, - getFloat(object, "cloudSpeed3") ?? 0.0003, - ], - [object], + () => scene.cloudLayers.map((l, i) => l.speed || [0.0001, 0.0002, 0.0003][i]), + [scene.cloudLayers], ); const cloudHeights = useMemo( - () => [ - getFloat(object, "cloudHeightPer1") ?? 0.35, - getFloat(object, "cloudHeightPer2") ?? 0.25, - getFloat(object, "cloudHeightPer3") ?? 0.2, - ], - [object], + () => scene.cloudLayers.map((l, i) => l.heightPercent || [0.35, 0.25, 0.2][i]), + [scene.cloudLayers], ); // Wind direction from windVelocity @@ -504,16 +489,13 @@ export function CloudLayers({ object }: CloudLayersProps) { // Our cloud geometry has UV U along world X, UV V along world Z. // Rotate 90 degrees clockwise to match Torque's coordinate system. const windDirection = useMemo(() => { - const windVelocity = getProperty(object, "windVelocity"); - if (windVelocity) { - const [x, y] = windVelocity.split(" ").map((s: string) => parseFloat(s)); - if (x !== 0 || y !== 0) { - // Rotate 90 degrees clockwise: (x, y) -> (y, -x) - return new Vector2(y, -x).normalize(); - } + const { x, y } = scene.windVelocity; + if (x !== 0 || y !== 0) { + // Rotate 90 degrees clockwise: (x, y) -> (y, -x) + return new Vector2(y, -x).normalize(); } return new Vector2(1, 0); - }, [object]); + }, [scene.windVelocity]); // Extract cloud layer configurations from DML (indices 7+) const layers = useMemo(() => { diff --git a/src/components/DemoEntities.tsx b/src/components/DemoEntities.tsx deleted file mode 100644 index b2f9eca0..00000000 --- a/src/components/DemoEntities.tsx +++ /dev/null @@ -1,204 +0,0 @@ -import { Component, memo, Suspense } from "react"; -import type { ErrorInfo, MutableRefObject, ReactNode } from "react"; -import { entityTypeColor } from "../demo/demoPlaybackUtils"; -import { FloatingLabel } from "./FloatingLabel"; -import { useDebug } from "./SettingsProvider"; -import { DemoPlayerModel } from "./DemoPlayerModel"; -import { DemoShapeModel, DemoWeaponModel, DemoExplosionShape } from "./DemoShapeModel"; -import { DemoSpriteProjectile, DemoTracerProjectile } from "./DemoProjectiles"; -import { PlayerNameplate } from "./PlayerNameplate"; -import { FlagMarker } from "./FlagMarker"; -import { useEngineSelector } from "../state"; -import type { DemoEntity, DemoStreamingPlayback } from "../demo/types"; - -/** - * Renders a non-camera demo entity. - * The group name must match the entity ID so the AnimationMixer can target it. - * Player entities use DemoPlayerModel for skeletal animation; others use - * DemoShapeModel. - */ -export const DemoEntityGroup = memo(function DemoEntityGroup({ - entity, - timeRef, - playback, -}: { - entity: DemoEntity; - timeRef: MutableRefObject; - playback?: DemoStreamingPlayback; -}) { - const debug = useDebug(); - const debugMode = debug?.debugMode ?? false; - const controlPlayerGhostId = useEngineSelector( - (state) => state.playback.streamSnapshot?.controlPlayerGhostId, - ); - const name = String(entity.id); - - if (entity.visual?.kind === "tracer") { - return ( - - - - - - {debugMode ? : null} - - - ); - } - - if (entity.visual?.kind === "sprite") { - return ( - - - - - - {debugMode ? : null} - - - ); - } - - if (!entity.dataBlock) { - const isFlag = ((entity.targetRenderFlags ?? 0) & 0x2) !== 0; - return ( - - - - - - - {debugMode ? : null} - - {isFlag && ( - - - - )} - - ); - } - - const fallback = ( - - - - - ); - - // Player entities use skeleton-preserving DemoPlayerModel for animation. - if (entity.type === "Player") { - const isControlPlayer = entity.id === controlPlayerGhostId; - const hasFlag = ((entity.targetRenderFlags ?? 0) & 0x2) !== 0; - return ( - - - - - - - - {!isControlPlayer && ( - - - - )} - {hasFlag && ( - - - - )} - - - ); - } - - // Explosion entities with DTS shapes use a specialized renderer - // that handles faceViewer, size keyframes, and fade-out. - if (entity.type === "Explosion" && entity.dataBlock && playback) { - return ( - - - - - - - - - - ); - } - - const isFlag = ((entity.targetRenderFlags ?? 0) & 0x2) !== 0; - - return ( - - - - - - - - - {entity.weaponShape && ( - - - - - - - - )} - {isFlag && ( - - - - )} - - ); -}); - -export function DemoMissingShapeLabel({ entity }: { entity: DemoEntity }) { - const id = String(entity.id); - const bits: string[] = []; - bits.push(`${id} (${entity.type})`); - if (entity.className) bits.push(`class ${entity.className}`); - if (typeof entity.ghostIndex === "number") bits.push(`ghost ${entity.ghostIndex}`); - if (typeof entity.dataBlockId === "number") bits.push(`db ${entity.dataBlockId}`); - bits.push( - entity.shapeHint - ? `shapeHint ${entity.shapeHint}` - : "shapeHint ", - ); - return {bits.join(" | ")}; -} - -/** Error boundary that renders a fallback when shape loading fails. */ -export class ShapeErrorBoundary extends Component< - { children: ReactNode; fallback: ReactNode }, - { hasError: boolean } -> { - state = { hasError: false }; - - static getDerivedStateFromError() { - return { hasError: true }; - } - - componentDidCatch(error: Error, info: ErrorInfo) { - console.warn( - "[demo] Shape load failed:", - error.message, - info.componentStack, - ); - } - - render() { - if (this.state.hasError) { - return this.props.fallback; - } - return this.props.children; - } -} diff --git a/src/components/DemoPlayback.tsx b/src/components/DemoPlayback.tsx index 8b8db2d0..fa39a5fc 100644 --- a/src/components/DemoPlayback.tsx +++ b/src/components/DemoPlayback.tsx @@ -1,9 +1,9 @@ -import { useDemoRecording } from "./DemoProvider"; -import { StreamingDemoPlayback } from "./DemoPlaybackStreaming"; +import { useRecording } from "./RecordingProvider"; +import { DemoPlaybackController } from "./DemoPlaybackController"; export function DemoPlayback() { - const recording = useDemoRecording(); + const recording = useRecording(); if (!recording) return null; - return ; + return ; } diff --git a/src/components/DemoPlaybackStreaming.tsx b/src/components/DemoPlaybackController.tsx similarity index 64% rename from src/components/DemoPlaybackStreaming.tsx rename to src/components/DemoPlaybackController.tsx index dad17b80..3600ddff 100644 --- a/src/components/DemoPlaybackStreaming.tsx +++ b/src/components/DemoPlaybackController.tsx @@ -2,34 +2,74 @@ import { Suspense, useCallback, useEffect, useRef, useState } from "react"; import { useFrame } from "@react-three/fiber"; import { useGLTF } from "@react-three/drei"; import { - Group, Quaternion, Vector3, } from "three"; import { - buildStreamDemoEntity, DEFAULT_EYE_HEIGHT, STREAM_TICK_SEC, torqueHorizontalFovToThreeVerticalFov, -} from "../demo/demoPlaybackUtils"; +} from "../stream/playbackUtils"; import { shapeToUrl } from "../loaders"; -import { TickProvider } from "./TickProvider"; -import { DemoEntityGroup } from "./DemoEntities"; -import { DemoParticleEffects } from "./DemoParticleEffects"; -import { PlayerEyeOffset } from "./DemoPlayerModel"; +import { ParticleEffects } from "./ParticleEffects"; +import { PlayerEyeOffset } from "./PlayerModel"; +import { stopAllTrackedSounds } from "./AudioEmitter"; import { useEngineStoreApi, advanceEffectClock } from "../state"; +import { gameEntityStore } from "../state/gameEntityStore"; +import { + streamPlaybackStore, + resetStreamPlayback, +} from "../state/streamPlaybackStore"; +import { streamEntityToGameEntity } from "../stream/entityBridge"; import type { - DemoEntity, - DemoRecording, - DemoStreamEntity, - DemoStreamSnapshot, -} from "../demo/types"; + StreamRecording, + StreamEntity, + StreamSnapshot, +} from "../stream/types"; +import type { GameEntity } from "../state/gameEntityTypes"; +import { isSceneEntity } from "../state/gameEntityTypes"; -type EntityById = Map; +type EntityById = Map; + +/** Safely access a field that exists only on some GameEntity variants. */ +function getField(entity: GameEntity, field: string): string | undefined { + return (entity as unknown as Record)[field] as string | undefined; +} + +/** Mutate render-affecting fields on an entity in-place from stream data. + * Components read these fields imperatively in useFrame — no React + * re-render is needed. This is the key to avoiding Suspense starvation. */ +function mutateRenderFields( + renderEntity: GameEntity, + stream: StreamEntity, +): void { + switch (renderEntity.renderType) { + case "Player": { + const e = renderEntity as unknown as Record; + e.threads = stream.threads; + e.weaponShape = stream.weaponShape; + e.weaponImageState = stream.weaponImageState; + e.weaponImageStates = stream.weaponImageStates; + e.playerName = stream.playerName; + e.iffColor = stream.iffColor; + e.headPitch = stream.headPitch; + e.headYaw = stream.headYaw; + e.targetRenderFlags = stream.targetRenderFlags; + break; + } + case "Shape": { + const e = renderEntity as unknown as Record; + e.threads = stream.threads; + e.targetRenderFlags = stream.targetRenderFlags; + e.iffColor = stream.iffColor; + break; + } + } +} /** Cache entity-by-id Maps per snapshot so they're built once, not every frame. */ -const _snapshotEntityCache = new WeakMap(); -function getEntityMap(snapshot: DemoStreamSnapshot): EntityById { +const _snapshotEntityCache = new WeakMap(); +function getEntityMap(snapshot: StreamSnapshot): EntityById { let map = _snapshotEntityCache.get(snapshot); if (!map) { map = new Map(snapshot.entities.map((e) => [e.id, e])); @@ -38,6 +78,16 @@ function getEntityMap(snapshot: DemoStreamSnapshot): EntityById { return map; } +/** Push the current entity map to the game entity store. + * Only triggers a version bump (and subscriber notifications) when the + * entity set changed (adds/removes). Render-field updates are mutated + * in-place on existing entity objects and read imperatively in useFrame. */ +function pushEntitiesToStore(entityMap: Map): void { + gameEntityStore + .getState() + .setAllStreamEntities(Array.from(entityMap.values())); +} + const _tmpVec = new Vector3(); const _interpQuatA = new Quaternion(); const _interpQuatB = new Quaternion(); @@ -46,115 +96,70 @@ const _orbitDir = new Vector3(); const _orbitTarget = new Vector3(); const _orbitCandidate = new Vector3(); -export function StreamingDemoPlayback({ recording }: { recording: DemoRecording }) { +export function DemoPlaybackController({ recording }: { recording: StreamRecording }) { const engineStore = useEngineStoreApi(); - const rootRef = useRef(null); - const timeRef = useRef(0); const playbackClockRef = useRef(0); - const prevTickSnapshotRef = useRef(null); - const currentTickSnapshotRef = useRef(null); + const prevTickSnapshotRef = useRef(null); + const currentTickSnapshotRef = useRef(null); const eyeOffsetRef = useRef(new Vector3(0, DEFAULT_EYE_HEIGHT, 0)); const streamRef = useRef(recording.streamingPlayback ?? null); - const publishedSnapshotRef = useRef(null); - const entityMapRef = useRef>(new Map()); - const lastSyncedSnapshotRef = useRef(null); - const [entities, setEntities] = useState([]); + const publishedSnapshotRef = useRef(null); + const entityMapRef = useRef>(new Map()); + const lastSyncedSnapshotRef = useRef(null); const [firstPersonShape, setFirstPersonShape] = useState(null); - const syncRenderableEntities = useCallback((snapshot: DemoStreamSnapshot) => { + const syncRenderableEntities = useCallback((snapshot: StreamSnapshot) => { if (snapshot === lastSyncedSnapshotRef.current) return; lastSyncedSnapshotRef.current = snapshot; const prevMap = entityMapRef.current; - const nextMap = new Map(); + const nextMap = new Map(); let shouldRebuild = false; for (const entity of snapshot.entities) { let renderEntity = prevMap.get(entity.id); - // Identity change → new component (unmount/remount) + // Identity change -> new component (unmount/remount). + // Compare fields that, when changed, require a full entity rebuild. const needsNewIdentity = !renderEntity || - renderEntity.type !== entity.type || - renderEntity.dataBlock !== entity.dataBlock || - renderEntity.weaponShape !== entity.weaponShape || - renderEntity.className !== entity.className || + renderEntity.className !== (entity.className ?? entity.type) || renderEntity.ghostIndex !== entity.ghostIndex || renderEntity.dataBlockId !== entity.dataBlockId || - renderEntity.shapeHint !== entity.shapeHint; + renderEntity.shapeHint !== entity.shapeHint || + getField(renderEntity, "shapeName") !== entity.dataBlock || + // weaponShape changes only force rebuild for non-Player shapes + // (turrets, vehicles). Players handle weapon changes internally + // via PlayerModel's Mount0 bone, and rebuilding on weapon change + // would lose animation state (death animations, etc.). + (renderEntity.renderType !== "Player" && + getField(renderEntity, "weaponShape") !== entity.weaponShape); if (needsNewIdentity) { - renderEntity = buildStreamDemoEntity( - entity.id, - entity.type, - entity.dataBlock, - entity.visual, - entity.direction, - entity.weaponShape, - entity.playerName, - entity.className, - entity.ghostIndex, - entity.dataBlockId, - entity.shapeHint, - entity.explosionDataBlockId, - entity.faceViewer, - ); - renderEntity.playerName = entity.playerName; - renderEntity.iffColor = entity.iffColor; - renderEntity.targetRenderFlags = entity.targetRenderFlags; - renderEntity.threads = entity.threads; - renderEntity.weaponImageState = entity.weaponImageState; - renderEntity.weaponImageStates = entity.weaponImageStates; - renderEntity.headPitch = entity.headPitch; - renderEntity.headYaw = entity.headYaw; - renderEntity.direction = entity.direction; - renderEntity.visual = entity.visual; - renderEntity.explosionDataBlockId = entity.explosionDataBlockId; - renderEntity.faceViewer = entity.faceViewer; - renderEntity.spawnTime = snapshot.timeSec; - shouldRebuild = true; - } else if ( - renderEntity.playerName !== entity.playerName || - renderEntity.iffColor !== entity.iffColor || - renderEntity.targetRenderFlags !== entity.targetRenderFlags || - renderEntity.threads !== entity.threads || - renderEntity.weaponImageState !== entity.weaponImageState || - renderEntity.weaponImageStates !== entity.weaponImageStates || - renderEntity.headPitch !== entity.headPitch || - renderEntity.headYaw !== entity.headYaw || - renderEntity.direction !== entity.direction || - renderEntity.visual !== entity.visual - ) { - // Render-affecting field changed → new object so React.memo sees - // a different reference and re-renders this entity's component. - renderEntity = { - ...renderEntity, - playerName: entity.playerName, - iffColor: entity.iffColor, - targetRenderFlags: entity.targetRenderFlags, - threads: entity.threads, - weaponImageState: entity.weaponImageState, - weaponImageStates: entity.weaponImageStates, - headPitch: entity.headPitch, - headYaw: entity.headYaw, - direction: entity.direction, - visual: entity.visual, - }; + renderEntity = streamEntityToGameEntity(entity, snapshot.timeSec); shouldRebuild = true; + } else { + // Mutate render fields in-place on the existing entity object. + // Components read these imperatively in useFrame — no React + // re-render needed. This avoids store churn that starves Suspense. + mutateRenderFields(renderEntity, entity); } - // else: no render-affecting changes, keep same object reference - // so React.memo can skip re-rendering this entity. - // Keyframe update (mutable — only used as fallback position for - // retained explosion entities; useFrame reads from snapshot entities). - if (renderEntity.keyframes.length === 0) { - renderEntity.keyframes.push({ + nextMap.set(entity.id, renderEntity); + + // Keyframe update (mutable -- used for fallback position for + // retained explosion entities and per-frame reads in useFrame). + // Scene entities and None don't have keyframes. + if (isSceneEntity(renderEntity) || renderEntity.renderType === "None") continue; + const keyframes = renderEntity.keyframes!; + if (keyframes.length === 0) { + keyframes.push({ time: snapshot.timeSec, position: entity.position ?? [0, 0, 0], rotation: entity.rotation ?? [0, 0, 0, 1], }); } - const kf = renderEntity.keyframes[0]; + const kf = keyframes[0]; kf.time = snapshot.timeSec; if (entity.position) kf.position = entity.position; if (entity.rotation) kf.rotation = entity.rotation; @@ -164,8 +169,6 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording kf.actionAnim = entity.actionAnim; kf.actionAtEnd = entity.actionAtEnd; kf.damageState = entity.damageState; - - nextMap.set(entity.id, renderEntity); } // Retain explosion entities with DTS shapes after they leave the snapshot. @@ -173,8 +176,8 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording for (const [id, entity] of prevMap) { if (nextMap.has(id)) continue; if ( - entity.type === "Explosion" && - entity.dataBlock && + entity.renderType === "Explosion" && + entity.shapeName && entity.spawnTime != null ) { const age = snapshot.timeSec - entity.spawnTime; @@ -192,14 +195,15 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording entityMapRef.current = nextMap; if (shouldRebuild) { - setEntities(Array.from(nextMap.values())); + pushEntitiesToStore(nextMap); } let nextFirstPersonShape: string | null = null; if (snapshot.camera?.mode === "first-person" && snapshot.camera.controlEntityId) { const entity = nextMap.get(snapshot.camera.controlEntityId); - if (entity?.dataBlock) { - nextFirstPersonShape = entity.dataBlock; + const sn = entity ? getField(entity, "shapeName") : undefined; + if (sn) { + nextFirstPersonShape = sn; } } setFirstPersonShape((prev) => @@ -208,15 +212,24 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording }, []); useEffect(() => { + // Stop any lingering sounds from the previous recording before setting + // up the new one. One-shot sounds and looping projectile sounds survive + // across recording changes because ParticleEffects doesn't unmount. + stopAllTrackedSounds(); + streamRef.current = recording.streamingPlayback ?? null; entityMapRef.current = new Map(); lastSyncedSnapshotRef.current = null; publishedSnapshotRef.current = null; - timeRef.current = 0; + resetStreamPlayback(); playbackClockRef.current = 0; prevTickSnapshotRef.current = null; currentTickSnapshotRef.current = null; + const stream = streamRef.current; + streamPlaybackStore.setState({ playback: stream }); + gameEntityStore.getState().beginStreaming(); + if (!stream) { engineStore.getState().setPlaybackStreamSnapshot(null); return; @@ -224,21 +237,26 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording stream.reset(); // Preload weapon effect shapes (explosions) so they're cached before - // the first projectile detonates — otherwise the GLB fetch latency + // the first projectile detonates -- otherwise the GLB fetch latency // causes the short-lived explosion entity to expire before it renders. for (const shape of stream.getEffectShapes()) { useGLTF.preload(shapeToUrl(shape)); } const snapshot = stream.getSnapshot(); - timeRef.current = snapshot.timeSec; + + streamPlaybackStore.setState({ time: snapshot.timeSec }); playbackClockRef.current = snapshot.timeSec; prevTickSnapshotRef.current = snapshot; currentTickSnapshotRef.current = snapshot; syncRenderableEntities(snapshot); + engineStore.getState().setPlaybackStreamSnapshot(snapshot); publishedSnapshotRef.current = snapshot; return () => { + stopAllTrackedSounds(); + gameEntityStore.getState().endStreaming(); + resetStreamPlayback(); engineStore.getState().setPlaybackStreamSnapshot(null); }; }, [recording, engineStore, syncRenderableEntities]); @@ -254,7 +272,7 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording const externalSeekWhilePaused = !isPlaying && Math.abs(requestedTimeSec - playbackClockRef.current) > 0.0005; const externalSeekWhilePlaying = - isPlaying && Math.abs(requestedTimeSec - timeRef.current) > 0.05; + isPlaying && Math.abs(requestedTimeSec - streamPlaybackStore.getState().time) > 0.05; const isSeeking = externalSeekWhilePaused || externalSeekWhilePlaying; if (isSeeking) { // Sync stream cursor to UI/programmatic seek. @@ -305,33 +323,19 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording Math.min(1, (playbackClockRef.current - tickStartTime) / STREAM_TICK_SEC), ); - timeRef.current = playbackClockRef.current; + streamPlaybackStore.setState({ time: playbackClockRef.current }); if (snapshot.exhausted && isPlaying) { playbackClockRef.current = Math.min(playbackClockRef.current, snapshot.timeSec); } + syncRenderableEntities(renderCurrent); - const publishedSnapshot = publishedSnapshotRef.current; - const shouldPublish = - !publishedSnapshot || - renderCurrent.timeSec !== publishedSnapshot.timeSec || - renderCurrent.exhausted !== publishedSnapshot.exhausted || - renderCurrent.status.health !== publishedSnapshot.status.health || - renderCurrent.status.energy !== publishedSnapshot.status.energy || - renderCurrent.camera?.mode !== publishedSnapshot.camera?.mode || - renderCurrent.camera?.controlEntityId !== - publishedSnapshot.camera?.controlEntityId || - renderCurrent.camera?.orbitTargetId !== - publishedSnapshot.camera?.orbitTargetId || - renderCurrent.chatMessages.length !== publishedSnapshot.chatMessages.length || - renderCurrent.teamScores.length !== publishedSnapshot.teamScores.length || - renderCurrent.teamScores.some( - (ts, i) => - ts.score !== publishedSnapshot.teamScores[i]?.score || - ts.playerCount !== publishedSnapshot.teamScores[i]?.playerCount, - ); + // Publish the entity map for imperative reads by components in useFrame. + // This is a plain object assignment — no React re-renders triggered. + streamPlaybackStore.getState().entities = entityMapRef.current; - if (shouldPublish) { + // Publish snapshot when it changed. + if (renderCurrent !== publishedSnapshotRef.current) { publishedSnapshotRef.current = renderCurrent; storeState.setPlaybackStreamSnapshot(renderCurrent); } @@ -346,7 +350,14 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording ? renderPrev.camera : null; - if (currentCamera) { + // When freeFlyCamera is active, skip stream camera positioning so + // ObserverControls drives the camera instead. + const freeFly = streamPlaybackStore.getState().freeFlyCamera; + // In live mode, LiveObserver owns camera rotation (client-side prediction). + // DemoPlaybackController still handles position, FOV, and entity interpolation. + const isLive = recording.source === "live"; + + if (currentCamera && !freeFly) { if (previousCamera) { const px = previousCamera.position[0]; const py = previousCamera.position[1]; @@ -359,20 +370,25 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording const iz = pz + (cz - pz) * interpT; state.camera.position.set(iy, iz, ix); - _interpQuatA.set(...previousCamera.rotation); - _interpQuatB.set(...currentCamera.rotation); - _interpQuatA.slerp(_interpQuatB, interpT); - state.camera.quaternion.copy(_interpQuatA); + if (!isLive) { + _interpQuatA.set(...previousCamera.rotation); + _interpQuatB.set(...currentCamera.rotation); + _interpQuatA.slerp(_interpQuatB, interpT); + state.camera.quaternion.copy(_interpQuatA); + } } else { state.camera.position.set( currentCamera.position[1], currentCamera.position[2], currentCamera.position[0], ); - state.camera.quaternion.set(...currentCamera.rotation); + if (!isLive) { + state.camera.quaternion.set(...currentCamera.rotation); + } } if ( + !isLive && Number.isFinite(currentCamera.fov) && "isPerspectiveCamera" in state.camera && (state.camera as any).isPerspectiveCamera @@ -393,20 +409,28 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording } } + // Imperative position interpolation via the shared entity root. const currentEntities = getEntityMap(renderCurrent); const previousEntities = getEntityMap(renderPrev); const renderEntities = entityMapRef.current; - const root = rootRef.current; + const root = streamPlaybackStore.getState().root; if (root) { for (const child of root.children) { - let entity = currentEntities.get(child.name); + // Scene infrastructure (terrain, interiors, sky, etc.) handles its + // own positioning — skip interpolation and visibility management. + const renderEntity = renderEntities.get(child.name); + if (renderEntity && isSceneEntity(renderEntity)) { + continue; + } + + const entity = currentEntities.get(child.name); // Retained entities (e.g. explosion shapes kept alive past their // snapshot lifetime) won't be in the snapshot entity map. Fall back // to their last-known keyframe position from the render entity. if (!entity) { - const renderEntity = renderEntities.get(child.name); - if (renderEntity?.keyframes[0]?.position) { - const kf = renderEntity.keyframes[0]; + const kfs = renderEntity && "keyframes" in renderEntity ? renderEntity.keyframes : undefined; + if (kfs?.[0]?.position) { + const kf = kfs[0]; child.visible = true; child.position.set(kf.position[1], kf.position[2], kf.position[0]); continue; @@ -452,7 +476,7 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording } const mode = currentCamera?.mode; - if (mode === "third-person" && root && currentCamera?.orbitTargetId) { + if (!freeFly && !isLive && mode === "third-person" && root && currentCamera?.orbitTargetId) { const targetGroup = root.children.find( (child) => child.name === currentCamera.orbitTargetId, ); @@ -495,7 +519,7 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording } } - if (mode === "first-person" && root && currentCamera?.controlEntityId) { + if (!freeFly && mode === "first-person" && root && currentCamera?.controlEntityId) { const playerGroup = root.children.find( (child) => child.name === currentCamera.controlEntityId, ); @@ -518,13 +542,8 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording }); return ( - - - {entities.map((entity) => ( - - ))} - - + @@ -533,6 +552,6 @@ export function StreamingDemoPlayback({ recording }: { recording: DemoRecording )} - + ); } diff --git a/src/components/DemoControls.module.css b/src/components/DemoPlaybackControls.module.css similarity index 100% rename from src/components/DemoControls.module.css rename to src/components/DemoPlaybackControls.module.css diff --git a/src/components/DemoControls.tsx b/src/components/DemoPlaybackControls.tsx similarity index 81% rename from src/components/DemoControls.tsx rename to src/components/DemoPlaybackControls.tsx index addbd1f4..ce9b153c 100644 --- a/src/components/DemoControls.tsx +++ b/src/components/DemoPlaybackControls.tsx @@ -1,13 +1,13 @@ import { useCallback, useEffect, type ChangeEvent } from "react"; import { - useDemoActions, - useDemoCurrentTime, - useDemoDuration, - useDemoIsPlaying, - useDemoRecording, - useDemoSpeed, -} from "./DemoProvider"; -import styles from "./DemoControls.module.css"; + usePlaybackActions, + useCurrentTime, + useDuration, + useIsPlaying, + useRecording, + useSpeed, +} from "./RecordingProvider"; +import styles from "./DemoPlaybackControls.module.css"; const SPEED_OPTIONS = [0.25, 0.5, 1, 2, 4]; @@ -17,13 +17,13 @@ function formatTime(seconds: number): string { return `${m}:${s.toString().padStart(2, "0")}`; } -export function DemoControls() { - const recording = useDemoRecording(); - const isPlaying = useDemoIsPlaying(); - const currentTime = useDemoCurrentTime(); - const duration = useDemoDuration(); - const speed = useDemoSpeed(); - const { play, pause, seek, setSpeed } = useDemoActions(); +export function DemoPlaybackControls() { + const recording = useRecording(); + const isPlaying = useIsPlaying(); + const currentTime = useCurrentTime(); + const duration = useDuration(); + const speed = useSpeed(); + const { play, pause, seek, setSpeed } = usePlaybackActions(); // Spacebar toggles play/pause during demo playback. useEffect(() => { @@ -65,7 +65,7 @@ export function DemoControls() { [setSpeed], ); - if (!recording) return null; + if (!recording || !Number.isFinite(recording.duration)) return null; return (
+ import("./PlayerModel").then((mod) => ({ default: mod.PlayerModel })), +); + +const ExplosionShape = lazy(() => + import("./ShapeModel").then((mod) => ({ + default: mod.ExplosionShape, + })), +); + +const TracerProjectile = lazy(() => + import("./Projectiles").then((mod) => ({ + default: mod.TracerProjectile, + })), +); + +const SpriteProjectile = lazy(() => + import("./Projectiles").then((mod) => ({ + default: mod.SpriteProjectile, + })), +); + +const ForceFieldBareRenderer = lazy(() => + import("./ForceFieldBare").then((mod) => ({ + default: mod.ForceFieldBare, + })), +); + +const AudioEmitter = lazy(() => + import("./AudioEmitter").then((mod) => ({ default: mod.AudioEmitter })), +); + +const WaterBlock = lazy(() => + import("./WaterBlock").then((mod) => ({ default: mod.WaterBlock })), +); + +const TEAM_NAMES: Record = { + 1: "Storm", + 2: "Inferno", +}; + +/** + * Renders a GameEntity by dispatching to the appropriate renderer based + * on renderType. Does NOT handle positioning — the caller is responsible + * for placing the entity group in world space (either declaratively for + * mission mode or imperatively for streaming interpolation). + */ +export const EntityRenderer = memo(function EntityRenderer({ + entity, +}: { + entity: GameEntity; +}) { + switch (entity.renderType) { + case "Shape": + return ; + case "ForceFieldBare": + return ; + case "Player": + return ; + case "Explosion": + return ; + case "Tracer": + return ; + case "Sprite": + return ; + case "AudioEmitter": + return ; + case "Camera": + return ; + case "WayPoint": + return ; + case "TerrainBlock": + return ; + case "InteriorInstance": + return ; + case "Sky": + return ; + case "Sun": + // Sun lighting is handled by SceneLighting (rendered outside EntityScene) + return null; + case "WaterBlock": + return ( + + + + ); + case "MissionArea": + return null; + case "None": + return null; + } +}); + +// ── Shape Entity ── + +function ShapeEntity({ entity }: { entity: ShapeEntityType }) { + const { animationEnabled } = useSettings(); + const groupRef = useRef(null); + + // Y-axis spinning for Items with rotate=true + useFrame(() => { + if (!groupRef.current || !entity.rotate || !animationEnabled) return; + const t = performance.now() / 1000; + groupRef.current.rotation.y = (t / 3.0) * Math.PI * 2; + }); + + if (!entity.shapeName) return null; + + const torqueObject = entity.runtimeObject as TorqueObject | undefined; + const shapeType = (entity.shapeType ?? "StaticShape") as StaticShapeType; + + // Flag label for flag Items + const isFlag = entity.dataBlock?.toLowerCase() === "flag"; + const teamName = + entity.teamId && entity.teamId > 0 ? TEAM_NAMES[entity.teamId] : null; + const flagLabel = isFlag && teamName ? `${teamName} Flag` : null; + + const loadingColor = + entity.shapeType === "Item" + ? "pink" + : entity.threads + ? "#00ff88" + : "yellow"; + + return ( + + + + {flagLabel ? ( + {flagLabel} + ) : null} + + {entity.barrelShapeName && ( + + + + + + )} + + + ); +} + +// ── Force Field Entity ── + +function ForceFieldBareEntity({ entity }: { entity: ForceFieldBareEntityType }) { + if (!entity.forceFieldData) return null; + return ( + + + + ); +} + +// ── Player Entity ── + +function PlayerEntity({ entity }: { entity: PlayerEntityType }) { + if (!entity.shapeName) return null; + + return ( + + + + ); +} + +// ── Explosion Entity ── + +function ExplosionEntity({ entity }: { entity: ExplosionEntityType }) { + const playback = streamPlaybackStore.getState().playback; + + // ExplosionShape still expects a StreamEntity-shaped object. + // Adapt minimally until that component is also refactored. + const streamEntity = { + id: entity.id, + type: "Explosion" as const, + dataBlock: entity.shapeName, + position: entity.position, + rotation: entity.rotation, + faceViewer: entity.faceViewer, + explosionDataBlockId: entity.explosionDataBlockId, + }; + + if (!entity.shapeName || !playback) return null; + + return ( + + + + ); +} + +// ── Tracer Entity ── + +function TracerEntity({ entity }: { entity: TracerEntityType }) { + return ( + + + + ); +} + +// ── Sprite Entity ── + +function SpriteEntity({ entity }: { entity: SpriteEntityType }) { + return ( + + + + ); +} + +// ── Audio Entity ── + +function AudioEntity({ entity }: { entity: AudioEmitterEntityType }) { + const { audioEnabled } = useSettings(); + if (!entity.audioFileName || !audioEnabled) return null; + + return ( + + + + ); +} diff --git a/src/components/EntityScene.tsx b/src/components/EntityScene.tsx new file mode 100644 index 00000000..16edefd8 --- /dev/null +++ b/src/components/EntityScene.tsx @@ -0,0 +1,293 @@ +import { lazy, memo, Suspense, useCallback, useMemo, useRef, useState } from "react"; +import { Quaternion } from "three"; +import type { Group } from "three"; +import { useFrame } from "@react-three/fiber"; +import { useAllGameEntities } from "../state"; +import type { GameEntity, PositionedEntity, PlayerEntity } from "../state/gameEntityTypes"; +import { isSceneEntity } from "../state/gameEntityTypes"; +import { streamPlaybackStore } from "../state/streamPlaybackStore"; +import { EntityRenderer } from "./EntityRenderer"; +import { PlayerNameplate } from "./PlayerNameplate"; +import { FlagMarker } from "./FlagMarker"; +import { FloatingLabel } from "./FloatingLabel"; +import { entityTypeColor } from "../stream/playbackUtils"; +import { useDebug } from "./SettingsProvider"; +import { useEngineSelector } from "../state"; + + +const WeaponModel = lazy(() => + import("./ShapeModel").then((mod) => ({ + default: mod.WeaponModel, + })), +); + +/** + * The ONE rendering component tree for all game entities. + * Reads from the game entity store (active layer: mission or stream entities). + * Data sources (mission .mis, demo .rec, live server) are controllers that + * populate the store — this component doesn't know or care which is active. + */ +export function EntityScene({ missionType }: { missionType?: string }) { + const debug = useDebug(); + const debugMode = debug?.debugMode ?? false; + + const rootRef = useCallback((node: Group | null) => { + streamPlaybackStore.setState({ root: node }); + }, []); + + return ( + + + + ); +} + +/** Renders all game entities. Uses an ID-stable selector so the component + * only re-renders when entities are added or removed, not when their + * fields change. Entity references are cached so that once an entity + * renders and loads resources via Suspense, it keeps its reference stable. */ +const EntityLayer = memo(function EntityLayer({ + missionType, + debugMode, +}: { + missionType?: string; + debugMode: boolean; +}) { + const entities = useAllGameEntities(); + + // Cache entity references by ID so that in-place field mutations + // (threads, colors, weapon shape) don't cause React to see a new + // object and remount Suspense boundaries. The cache IS updated when + // the store provides a genuinely new object reference (identity + // rebuild: armor change, datablock change, etc.). + const cacheRef = useRef(new Map()); + const cache = cacheRef.current; + + const currentIds = new Set(); + for (const entity of entities) { + currentIds.add(entity.id); + cache.set(entity.id, entity); + } + // Remove entities no longer in the set + for (const id of cache.keys()) { + if (!currentIds.has(id)) { + cache.delete(id); + } + } + + const filtered = useMemo(() => { + const result: GameEntity[] = []; + const lowerType = missionType?.toLowerCase(); + for (const entity of cache.values()) { + if (lowerType && entity.missionTypesList) { + const types = new Set( + entity.missionTypesList + .toLowerCase() + .split(/\s+/) + .filter(Boolean), + ); + if (types.size > 0 && !types.has(lowerType)) continue; + } + result.push(entity); + } + return result; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [entities, missionType]); + + return ( + <> + {filtered.map((entity) => ( + + ))} + + ); +}); + +const EntityWrapper = memo(function EntityWrapper({ + entity, + debugMode, +}: { + entity: GameEntity; + debugMode: boolean; +}) { + // Scene infrastructure handles its own positioning — render directly. + // The named group allows the interpolation loop to identify and skip them. + if (isSceneEntity(entity)) { + return ( + + + + ); + } + + if (entity.renderType === "None") return null; + + // From here, entity is a PositionedEntity + return ; +}); + +/** Renders the player nameplate, subscribing to controlPlayerGhostId + * internally so that PositionedEntityWrapper doesn't need to. This keeps + * engine store mutations from triggering synchronous selector evaluations + * on every positioned entity (which was starving Suspense retries for + * shape GLB loading). */ +function PlayerNameplateIfVisible({ entity }: { entity: PlayerEntity }) { + const controlPlayerGhostId = useEngineSelector( + (state) => state.playback.streamSnapshot?.controlPlayerGhostId, + ); + if (entity.id === controlPlayerGhostId) return null; + return ; +} + +/** Imperatively tracks targetRenderFlags bit 0x2 on a game entity and + * mounts/unmounts FlagMarker when the flag state changes. Entity field + * mutations don't trigger React re-renders (ID-only equality), so this + * uses useFrame to poll the mutable field. */ +function FlagMarkerSlot({ entity }: { entity: GameEntity }) { + const flagRef = useRef(false); + const [isFlag, setIsFlag] = useState(() => { + const flags = "targetRenderFlags" in entity ? (entity.targetRenderFlags as number | undefined) : undefined; + return ((flags ?? 0) & 0x2) !== 0; + }); + flagRef.current = isFlag; + + useFrame(() => { + const flags = "targetRenderFlags" in entity ? (entity.targetRenderFlags as number | undefined) : undefined; + const nowFlag = ((flags ?? 0) & 0x2) !== 0; + if (nowFlag !== flagRef.current) { + flagRef.current = nowFlag; + setIsFlag(nowFlag); + } + }); + + if (!isFlag) return null; + return ( + + + + ); +} + +function PositionedEntityWrapper({ + entity, + debugMode, +}: { + entity: PositionedEntity; + debugMode: boolean; +}) { + const position = entity.position; + const scale = entity.scale; + const quaternion = useMemo(() => { + if (!entity.rotation) return undefined; + return new Quaternion(...entity.rotation); + }, [entity.rotation]); + + const isPlayer = entity.renderType === "Player"; + + // Entities without a resolved shape get a wireframe placeholder. + if (entity.renderType === "Shape" && !entity.shapeName) { + return ( + + + + + + {debugMode && } + + + ); + } + + const fallback = + entity.renderType === "Explosion" ? null : ( + + + + + ); + + const shapeName = "shapeName" in entity ? entity.shapeName : undefined; + const weaponShape = "weaponShape" in entity ? entity.weaponShape : undefined; + + return ( + + + + + + + + {isPlayer && ( + + + + )} + + {debugMode && !shapeName && entity.renderType !== "Shape" && ( + + )} + + {weaponShape && shapeName && !isPlayer && ( + + + + + + + + )} + + ); +} + +function MissingShapeLabel({ entity }: { entity: GameEntity }) { + const bits: string[] = []; + bits.push(`${entity.id} (${entity.className})`); + if (typeof entity.ghostIndex === "number") bits.push(`ghost ${entity.ghostIndex}`); + if (typeof entity.dataBlockId === "number") bits.push(`db ${entity.dataBlockId}`); + bits.push( + entity.shapeHint + ? `shapeHint ${entity.shapeHint}` + : "shapeHint ", + ); + return {bits.join(" | ")}; +} + +/** Error boundary that renders a fallback when shape loading fails. */ +import { Component } from "react"; +import type { ErrorInfo, ReactNode } from "react"; + +export class ShapeErrorBoundary extends Component< + { children: ReactNode; fallback: ReactNode }, + { hasError: boolean } +> { + state = { hasError: false }; + + static getDerivedStateFromError() { + return { hasError: true }; + } + + componentDidCatch(error: Error, info: ErrorInfo) { + console.warn( + "[entity] Shape load failed:", + error.message, + info.componentStack, + ); + } + + render() { + if (this.state.hasError) { + return this.props.fallback; + } + return this.props.children; + } +} diff --git a/src/components/FeaturesProvider.tsx b/src/components/FeaturesProvider.tsx new file mode 100644 index 00000000..770a0324 --- /dev/null +++ b/src/components/FeaturesProvider.tsx @@ -0,0 +1,40 @@ +"use client"; + +import { createContext, useContext, useState, type ReactNode } from "react"; +import { useQueryState, parseAsString } from "nuqs"; + +type Features = { + live: boolean; +}; + +const defaultFeatures: Features = { + live: false, +}; + +const FeaturesContext = createContext(defaultFeatures); + +export function useFeatures(): Features { + return useContext(FeaturesContext); +} + +/** Reads `?features=live,demo,...` once on mount and provides feature flags. */ +export function FeaturesProvider({ children }: { children: ReactNode }) { + const [featuresParam] = useQueryState("features", parseAsString); + const [features] = useState(() => { + const tokens = new Set( + (featuresParam ?? "") + .split(",") + .map((s) => s.trim().toLowerCase()) + .filter(Boolean), + ); + return { + live: tokens.has("live"), + }; + }); + + return ( + + {children} + + ); +} diff --git a/src/components/FlagMarker.tsx b/src/components/FlagMarker.tsx index e1b42c38..c29a4e08 100644 --- a/src/components/FlagMarker.tsx +++ b/src/components/FlagMarker.tsx @@ -1,10 +1,12 @@ import { useRef } from "react"; -import type { MutableRefObject } from "react"; import { useFrame, useThree } from "@react-three/fiber"; import { Html } from "@react-three/drei"; import { Group, Vector3 } from "three"; import { textureToUrl } from "../loaders"; -import type { DemoEntity } from "../demo/types"; +interface FlagEntity { + id: string; + iffColor?: { r: number; g: number; b: number }; +} import styles from "./FlagMarker.module.css"; const FLAG_ICON_HEIGHT = 1.5; @@ -18,12 +20,7 @@ const _tmpVec = new Vector3(); * friendly, red for enemy — matching Tribes 2's sensor group color system). * Always visible regardless of distance. */ -export function FlagMarker({ - entity, -}: { - entity: DemoEntity; - timeRef: MutableRefObject; -}) { +export function FlagMarker({ entity }: { entity: FlagEntity }) { const markerRef = useRef(null); const iconRef = useRef(null); const distRef = useRef(null); diff --git a/src/components/FogProvider.tsx b/src/components/FogProvider.tsx index ca0acffb..f1c42b83 100644 --- a/src/components/FogProvider.tsx +++ b/src/components/FogProvider.tsx @@ -19,6 +19,7 @@ import { useFrame } from "@react-three/fiber"; import { Color } from "three"; import type { TorqueObject } from "../torqueScript"; import { getFloat, getProperty } from "../mission"; +import type { SceneSky } from "../scene/types"; /** Maximum number of fog volumes supported (matches Torque) */ export const MAX_FOG_VOLUMES = 3; @@ -182,6 +183,34 @@ export function parseFogState( }; } +/** Build FogState directly from a typed SceneSky (no string parsing). */ +export function fogStateFromScene(sky: SceneSky): FogState { + const fogDistance = sky.fogDistance; + const visibleDistance = sky.visibleDistance > 0 ? sky.visibleDistance : 1000; + const { r, g, b } = sky.fogColor; + const fogColor = new Color().setRGB(r, g, b).convertSRGBToLinear(); + + const fogVolumes: FogVolume[] = []; + for (const vol of sky.fogVolumes) { + if (vol.visibleDistance <= 0 || vol.maxHeight <= vol.minHeight) continue; + fogVolumes.push({ + visibleDistance: vol.visibleDistance, + minHeight: vol.minHeight, + maxHeight: vol.maxHeight, + percentage: 1.0, + }); + } + + const fogLine = fogVolumes.reduce( + (max, vol) => Math.max(max, vol.maxHeight), + 0, + ); + + const enabled = visibleDistance > fogDistance; + + return { fogDistance, visibleDistance, fogColor, fogVolumes, fogLine, enabled }; +} + /** * Create initial fog uniforms structure. */ diff --git a/src/components/ForceFieldBare.tsx b/src/components/ForceFieldBare.tsx index 798411ea..310041d5 100644 --- a/src/components/ForceFieldBare.tsx +++ b/src/components/ForceFieldBare.tsx @@ -1,4 +1,4 @@ -import { memo, Suspense, useEffect, useMemo, useRef } from "react"; +import { Suspense, useEffect, useMemo, useRef } from "react"; import { useTexture } from "@react-three/drei"; import { useFrame } from "@react-three/fiber"; import { @@ -8,56 +8,23 @@ import { DoubleSide, NoColorSpace, RepeatWrapping, - Texture, } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation, getScale } from "../mission"; +import type { Texture } from "three"; +import type { ForceFieldData } from "../state/gameEntityTypes"; import { textureToUrl } from "../loaders"; import { useSettings } from "./SettingsProvider"; -import { useDatablock } from "./useDatablock"; import { createForceFieldMaterial, OPACITY_FACTOR, } from "../forceFieldMaterial"; -/** - * Get texture URLs from datablock. - * Datablock defines textures as texture[0], texture[1], etc. which become - * properties texture0, texture1, etc. (TorqueScript array indexing flattens to suffix) - */ -function getTextureUrls( - datablock: TorqueObject | undefined, - numFrames: number, -): string[] { - const textures: string[] = []; - for (let i = 0; i < numFrames; i++) { - // TorqueScript array indexing: texture[0] -> texture0 - const texturePath = getProperty(datablock, `texture${i}`); - if (texturePath) { - textures.push(textureToUrl(texturePath)); - } - } - return textures; -} - -function parseColor(colorStr: string): [number, number, number] { - const parts = colorStr.split(" ").map((s) => parseFloat(s)); - return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0]; -} - function setupForceFieldTexture(texture: Texture) { texture.wrapS = texture.wrapT = RepeatWrapping; - // NoColorSpace - values pass through directly to display without conversion, - // matching how WaterBlock handles textures in custom ShaderMaterial. texture.colorSpace = NoColorSpace; texture.flipY = false; texture.needsUpdate = true; } -/** - * Creates a box geometry with origin at corner (like Torque) instead of center. - * Handles disposal automatically. - */ function useCornerBoxGeometry(scale: [number, number, number]) { const geometry = useMemo(() => { const [x, y, z] = scale; @@ -73,90 +40,16 @@ function useCornerBoxGeometry(scale: [number, number, number]) { return geometry; } -interface ForceFieldGeometryProps { - scale: [number, number, number]; - color: [number, number, number]; - baseTranslucency: number; -} - -interface ForceFieldMeshProps extends ForceFieldGeometryProps { - textureUrls: string[]; - numFrames: number; - framesPerSec: number; - scrollSpeed: number; - umapping: number; - vmapping: number; -} - -function ForceFieldMesh({ - scale, - color, - baseTranslucency, - textureUrls, - numFrames, - framesPerSec, - scrollSpeed, - umapping, - vmapping, -}: ForceFieldMeshProps) { - const { animationEnabled } = useSettings(); - const geometry = useCornerBoxGeometry(scale); - const textures = useTexture(textureUrls, (textures) => { - textures.forEach((tex) => setupForceFieldTexture(tex)); - }); - - // Create shader material once (uniforms updated in useFrame) - const material = useMemo(() => { - return createForceFieldMaterial({ - textures, - scale, - umapping, - vmapping, - color, - baseTranslucency, - }); - }, [textures, scale, umapping, vmapping, color, baseTranslucency]); - - useEffect(() => { - return () => material.dispose(); - }, [material]); - - // Animation state - const elapsedRef = useRef(0); - - // Animate frame and scroll - useFrame((_, delta) => { - if (!animationEnabled) { - elapsedRef.current = 0; - material.uniforms.currentFrame.value = 0; - material.uniforms.vScroll.value = 0; - return; - } - - elapsedRef.current += delta; - - // Frame animation - material.uniforms.currentFrame.value = - Math.floor(elapsedRef.current * framesPerSec) % numFrames; - - // UV scrolling - material.uniforms.vScroll.value = elapsedRef.current * scrollSpeed; - }); - - // renderOrder ensures force fields render after water (which uses default 0). - // Water writes depth, force fields don't - so depth testing gives correct - // per-pixel occlusion (underwater force fields are hidden, above-water visible). - return ; -} - function ForceFieldFallback({ scale, color, baseTranslucency, -}: ForceFieldGeometryProps) { +}: { + scale: [number, number, number]; + color: [number, number, number]; + baseTranslucency: number; +}) { const geometry = useCornerBoxGeometry(scale); - - // Use color directly - no gamma correction needed to match main shader const fallbackColor = useMemo( () => new Color(color[0], color[1], color[2]), [color], @@ -171,82 +64,101 @@ function ForceFieldFallback({ blending={AdditiveBlending} side={DoubleSide} depthWrite={false} - fog={false} // Standard fog doesn't work with additive blending + fog={false} /> ); } -export const ForceFieldBare = memo(function ForceFieldBare({ - object, +function ForceFieldMesh({ + scale, + data, }: { - object: TorqueObject; + scale: [number, number, number]; + data: ForceFieldData; }) { - const position = useMemo(() => getPosition(object), [object]); - const quaternion = useMemo(() => getRotation(object), [object]); - const scale = useMemo(() => getScale(object), [object]); - - // Look up the datablock - rendering properties like color, translucency, etc. - // are stored on the datablock, not the instance (see forceFieldBare.cc) - const datablock = useDatablock(getProperty(object, "dataBlock")); - - // All rendering properties come from the datablock - const colorStr = getProperty(datablock, "color"); - const color = useMemo( - () => - colorStr ? parseColor(colorStr) : ([1, 1, 1] as [number, number, number]), - [colorStr], - ); - - const baseTranslucency = - parseFloat(getProperty(datablock, "baseTranslucency")) || 1; - const numFrames = parseInt(getProperty(datablock, "numFrames"), 10) || 1; - const framesPerSec = parseFloat(getProperty(datablock, "framesPerSec")) || 1; - const scrollSpeed = parseFloat(getProperty(datablock, "scrollSpeed")) || 0; - const umapping = parseFloat(getProperty(datablock, "umapping")) || 1; - const vmapping = parseFloat(getProperty(datablock, "vmapping")) || 1; + const { animationEnabled } = useSettings(); + const geometry = useCornerBoxGeometry(scale); const textureUrls = useMemo( - () => getTextureUrls(datablock, numFrames), - [datablock, numFrames], + () => data.textures.map((t) => textureToUrl(t)), + [data.textures], + ); + + const textures = useTexture(textureUrls, (textures) => { + textures.forEach((tex) => setupForceFieldTexture(tex)); + }); + + const material = useMemo(() => { + return createForceFieldMaterial({ + textures, + scale, + umapping: data.umapping, + vmapping: data.vmapping, + color: data.color, + baseTranslucency: data.baseTranslucency, + }); + }, [textures, scale, data]); + + useEffect(() => { + return () => material.dispose(); + }, [material]); + + const elapsedRef = useRef(0); + + useFrame((_, delta) => { + if (!animationEnabled) { + elapsedRef.current = 0; + material.uniforms.currentFrame.value = 0; + material.uniforms.vScroll.value = 0; + return; + } + elapsedRef.current += delta; + material.uniforms.currentFrame.value = + Math.floor(elapsedRef.current * data.framesPerSec) % data.numFrames; + material.uniforms.vScroll.value = elapsedRef.current * data.scrollSpeed; + }); + + return ; +} + +/** + * Renders a ForceFieldBare from pre-resolved ForceFieldData. + * Used by the unified EntityRenderer — does NOT read from TorqueObject/datablock. + */ +export function ForceFieldBare({ + data, + scale, +}: { + data: ForceFieldData; + scale: [number, number, number]; +}) { + const textureUrls = useMemo( + () => data.textures.map((t) => textureToUrl(t)), + [data.textures], ); - // Render fallback mesh when textures are missing instead of disappearing. if (textureUrls.length === 0) { return ( - - - + ); } return ( - - - } - > - - - + } + > + + ); -}); +} diff --git a/src/components/GenericShape.tsx b/src/components/GenericShape.tsx index 5c26a84a..07bd949b 100644 --- a/src/components/GenericShape.tsx +++ b/src/components/GenericShape.tsx @@ -21,7 +21,7 @@ import * as SkeletonUtils from "three/examples/jsm/utils/SkeletonUtils.js"; import { setupTexture } from "../textureUtils"; import { useDebug, useSettings } from "./SettingsProvider"; import { useShapeInfo, isOrganicShape } from "./ShapeInfoProvider"; -import { useEngineSelector, demoEffectNow, engineStore } from "../state"; +import { useEngineSelector, effectNow, engineStore } from "../state"; import { FloatingLabel } from "./FloatingLabel"; import { useIflTexture, @@ -36,15 +36,13 @@ import { injectShapeLighting } from "../shapeMaterial"; import { processShapeScene, replaceWithShapeMaterial, -} from "../demo/demoPlaybackUtils"; -import type { DemoThreadState } from "../demo/types"; +} from "../stream/playbackUtils"; +import type { ThreadState as StreamThreadState } from "../stream/types"; /** Returns pausable time in seconds for demo mode, real time otherwise. */ function shapeNowSec(): number { - const status = engineStore.getState().playback.status; - return status !== "stopped" - ? demoEffectNow() / 1000 - : performance.now() / 1000; + const { recording } = engineStore.getState().playback; + return recording != null ? effectNow() / 1000 : performance.now() / 1000; } /** Shared props for texture rendering components */ @@ -250,6 +248,8 @@ const IflTexture = memo(function IflTexture({ ); }); +const EMPTY_FLAG_NAMES = new Set(); + const StaticTexture = memo(function StaticTexture({ material, shapeName, @@ -261,7 +261,13 @@ const StaticTexture = memo(function StaticTexture({ animated = false, }: TextureProps) { const resourcePath = material.userData.resource_path; - const flagNames = new Set(material.userData.flag_names ?? []); + const flagNames = useMemo( + () => + material.userData.flag_names + ? new Set(material.userData.flag_names) + : EMPTY_FLAG_NAMES, + [material.userData.flag_names], + ); const url = useMemo(() => { if (!resourcePath) { @@ -424,40 +430,41 @@ function HardcodedShape({ label }: { label?: string }) { * Wrapper component that handles the common ErrorBoundary + Suspense + ShapeModel * pattern used across shape-rendering components. */ -export function ShapeRenderer({ +export const ShapeRenderer = memo(function ShapeRenderer({ loadingColor = "yellow", - demoThreads, + streamEntity, children, }: { loadingColor?: string; - demoThreads?: DemoThreadState[]; + /** Stable entity reference whose `.threads` field is mutated in-place. */ + streamEntity?: { threads?: StreamThreadState[] }; children?: React.ReactNode; }) { const { object, shapeName } = useShapeInfo(); if (!shapeName) { return ( - `} /> + `} /> ); } if (HARDCODED_SHAPES.has(shapeName.toLowerCase())) { - return ; + return ; } return ( + } > }> - + {children} ); -} +}); /** Vis node info collected from the scene for vis opacity animation. */ interface VisNode { @@ -475,9 +482,6 @@ interface ThreadState { startTime: number; } -// Thread slot constants matching power.cs globals -const DEPLOY_THREAD = 3; - /** * Unified shape renderer. Clones the full scene graph (preserving skeleton * bindings), applies Tribes 2 materials via processShapeScene, and drives @@ -486,124 +490,123 @@ const DEPLOY_THREAD = 3; */ export const ShapeModel = memo(function ShapeModel({ gltf, - demoThreads, + streamEntity, }: { gltf: ReturnType; - demoThreads?: DemoThreadState[]; + /** Stable entity reference whose `.threads` field is mutated in-place. */ + streamEntity?: { threads?: StreamThreadState[] }; }) { const { object, shapeName } = useShapeInfo(); const { debugMode } = useDebug(); const { animationEnabled } = useSettings(); const runtime = useEngineSelector((state) => state.runtime.runtime); - const { - clonedScene, - mixer, - clipsByName, - visNodesBySequence, - iflMeshes, - } = useMemo(() => { - const scene = SkeletonUtils.clone(gltf.scene) as Group; + const { clonedScene, mixer, clipsByName, visNodesBySequence, iflMeshes } = + useMemo(() => { + const scene = SkeletonUtils.clone(gltf.scene) as Group; - // Detect IFL materials BEFORE processShapeScene replaces them, since the - // replacement materials lose the original userData (flag_names, resource_path). - const iflInfos: Array<{ - mesh: any; - iflPath: string; - hasVisSequence: boolean; - iflSequence?: string; - iflDuration?: number; - iflCyclic?: boolean; - iflToolBegin?: number; - }> = []; - scene.traverse((node: any) => { - if (!node.isMesh || !node.material) return; - const mat = Array.isArray(node.material) - ? node.material[0] - : node.material; - if (!mat?.userData) return; - const flags = new Set(mat.userData.flag_names ?? []); - const rp: string | undefined = mat.userData.resource_path; - if (flags.has("IflMaterial") && rp) { - const ud = node.userData; - // ifl_sequence is set by the addon when ifl_matters links this IFL to - // a controlling sequence. vis_sequence is a separate system (opacity - // animation) and must NOT be used as a fallback — the two are independent. - const iflSeq = ud?.ifl_sequence - ? String(ud.ifl_sequence).toLowerCase() - : undefined; - const iflDur = ud?.ifl_duration - ? Number(ud.ifl_duration) - : undefined; - const iflCyclic = ud?.ifl_sequence ? !!ud.ifl_cyclic : undefined; - const iflToolBegin = ud?.ifl_tool_begin != null - ? Number(ud.ifl_tool_begin) - : undefined; - iflInfos.push({ - mesh: node, - iflPath: `textures/${rp}.ifl`, - hasVisSequence: !!(ud?.vis_sequence), - iflSequence: iflSeq, - iflDuration: iflDur, - iflCyclic, - iflToolBegin, - }); - } - }); - - processShapeScene(scene); - - // Un-hide IFL meshes that don't have a vis sequence — they should always - // be visible. IFL meshes WITH vis sequences stay hidden until their - // sequence is activated by playThread. - for (const { mesh, hasVisSequence } of iflInfos) { - if (!hasVisSequence) { - mesh.visible = true; - } - } - - // Collect ALL vis-animated nodes, grouped by sequence name. - const visBySeq = new Map(); - scene.traverse((node: any) => { - if (!node.isMesh) return; - const ud = node.userData; - if (!ud) return; - const kf = ud.vis_keyframes; - const dur = ud.vis_duration; - const seqName = (ud.vis_sequence ?? "").toLowerCase(); - if (!seqName || !Array.isArray(kf) || kf.length <= 1 || !dur || dur <= 0) - return; - - let list = visBySeq.get(seqName); - if (!list) { - list = []; - visBySeq.set(seqName, list); - } - list.push({ - mesh: node, - keyframes: kf, - duration: dur, - cyclic: !!ud.vis_cyclic, + // Detect IFL materials BEFORE processShapeScene replaces them, since the + // replacement materials lose the original userData (flag_names, resource_path). + const iflInfos: Array<{ + mesh: any; + iflPath: string; + hasVisSequence: boolean; + iflSequence?: string; + iflDuration?: number; + iflCyclic?: boolean; + iflToolBegin?: number; + }> = []; + scene.traverse((node: any) => { + if (!node.isMesh || !node.material) return; + const mat = Array.isArray(node.material) + ? node.material[0] + : node.material; + if (!mat?.userData) return; + const flags = new Set(mat.userData.flag_names ?? []); + const rp: string | undefined = mat.userData.resource_path; + if (flags.has("IflMaterial") && rp) { + const ud = node.userData; + // ifl_sequence is set by the addon when ifl_matters links this IFL to + // a controlling sequence. vis_sequence is a separate system (opacity + // animation) and must NOT be used as a fallback — the two are independent. + const iflSeq = ud?.ifl_sequence + ? String(ud.ifl_sequence).toLowerCase() + : undefined; + const iflDur = ud?.ifl_duration ? Number(ud.ifl_duration) : undefined; + const iflCyclic = ud?.ifl_sequence ? !!ud.ifl_cyclic : undefined; + const iflToolBegin = + ud?.ifl_tool_begin != null ? Number(ud.ifl_tool_begin) : undefined; + iflInfos.push({ + mesh: node, + iflPath: `textures/${rp}.ifl`, + hasVisSequence: !!ud?.vis_sequence, + iflSequence: iflSeq, + iflDuration: iflDur, + iflCyclic, + iflToolBegin, + }); + } }); - }); - // Build clips by name (case-insensitive) - const clips = new Map(); - for (const clip of gltf.animations) { - clips.set(clip.name.toLowerCase(), clip); - } + processShapeScene(scene, shapeName ?? undefined); - // Only create a mixer if there are skeleton animation clips. - const mix = clips.size > 0 ? new AnimationMixer(scene) : null; + // Un-hide IFL meshes that don't have a vis sequence — they should always + // be visible. IFL meshes WITH vis sequences stay hidden until their + // sequence is activated by playThread. + for (const { mesh, hasVisSequence } of iflInfos) { + if (!hasVisSequence) { + mesh.visible = true; + } + } - return { - clonedScene: scene, - mixer: mix, - clipsByName: clips, - visNodesBySequence: visBySeq, - iflMeshes: iflInfos, - }; - }, [gltf]); + // Collect ALL vis-animated nodes, grouped by sequence name. + const visBySeq = new Map(); + scene.traverse((node: any) => { + if (!node.isMesh) return; + const ud = node.userData; + if (!ud) return; + const kf = ud.vis_keyframes; + const dur = ud.vis_duration; + const seqName = (ud.vis_sequence ?? "").toLowerCase(); + if ( + !seqName || + !Array.isArray(kf) || + kf.length <= 1 || + !dur || + dur <= 0 + ) + return; + + let list = visBySeq.get(seqName); + if (!list) { + list = []; + visBySeq.set(seqName, list); + } + list.push({ + mesh: node, + keyframes: kf, + duration: dur, + cyclic: !!ud.vis_cyclic, + }); + }); + + // Build clips by name (case-insensitive) + const clips = new Map(); + for (const clip of gltf.animations) { + clips.set(clip.name.toLowerCase(), clip); + } + + // Only create a mixer if there are skeleton animation clips. + const mix = clips.size > 0 ? new AnimationMixer(scene) : null; + + return { + clonedScene: scene, + mixer: mix, + clipsByName: clips, + visNodesBySequence: visBySeq, + iflMeshes: iflInfos, + }; + }, [gltf]); const threadsRef = useRef(new Map()); const iflMeshAtlasRef = useRef(new Map()); @@ -622,16 +625,16 @@ export const ShapeModel = memo(function ShapeModel({ const animationEnabledRef = useRef(animationEnabled); animationEnabledRef.current = animationEnabled; - // Stable ref for the deploy-end callback so useFrame can advance the - // lifecycle when animation is toggled off mid-deploy. - const onDeployEndRef = useRef<((slot: number) => void) | null>(null); - - // Refs for demo thread-driven animation (exposed from the main animation effect). - const demoThreadsRef = useRef(demoThreads); - demoThreadsRef.current = demoThreads; - const handlePlayThreadRef = useRef<((slot: number, seq: string) => void) | null>(null); + // Stream entity reference for imperative thread reads in useFrame. + // The entity is mutated in-place, so reading streamEntity?.threads + // always returns the latest value without requiring React re-renders. + const streamEntityRef = useRef(streamEntity); + streamEntityRef.current = streamEntity; + const handlePlayThreadRef = useRef< + ((slot: number, seq: string) => void) | null + >(null); const handleStopThreadRef = useRef<((slot: number) => void) | null>(null); - const prevDemoThreadsRef = useRef(undefined); + const prevDemoThreadsRef = useRef(undefined); // Load IFL texture atlases imperatively (processShapeScene can't resolve // .ifl paths since they require async loading of the frame list). @@ -648,26 +651,56 @@ export const ShapeModel = memo(function ShapeModel({ mat.map = atlas.texture; mat.needsUpdate = true; } - iflAnimInfosRef.current.push({ + const iflInfo = { atlas, sequenceName: info.iflSequence, sequenceDuration: info.iflDuration, cyclic: info.iflCyclic, toolBegin: info.iflToolBegin, - }); + }; + iflAnimInfosRef.current.push(iflInfo); iflMeshAtlasRef.current.set(info.mesh, atlas); }) - .catch(() => {}); + .catch((err) => { + console.warn( + `[ShapeModel] Failed to load IFL atlas for ${info.iflPath}:`, + err, + ); + }); } }, [iflMeshes]); - // Animation setup. Shared helpers (handlePlayThread, handleStopThread) are - // used by both mission rendering and demo playback. The lifecycle that - // decides WHEN to call them differs: mission mode auto-plays deploy and - // subscribes to TorqueScript; demo mode does nothing on mount and lets - // the useFrame handler drive everything from ghost thread data. + // DTS cyclic flags by sequence name. Cyclic sequences loop; non-cyclic + // play once and clamp. Falls back to assuming cyclic if data is absent. + const seqCyclicByName = useMemo(() => { + const map = new Map(); + const rawNames = gltf.scene.userData?.dts_sequence_names; + const rawCyclic = gltf.scene.userData?.dts_sequence_cyclic; + if (typeof rawNames === "string" && typeof rawCyclic === "string") { + try { + const names: string[] = JSON.parse(rawNames); + const cyclic: boolean[] = JSON.parse(rawCyclic); + for (let i = 0; i < names.length; i++) { + map.set(names[i].toLowerCase(), cyclic[i] ?? true); + } + } catch { + /* expected */ + } + } + return map; + }, [gltf]); + + // Animation setup. + // + // Mission mode (streamEntity absent): auto-play default looping sequences + // (power, ambient) so static shapes look alive. TorqueScript playThread/ + // stopThread/pauseThread events can override if scripts are loaded. + // + // Demo/live mode (streamEntity present): no auto-play. The useFrame + // handler reads ghost ThreadMask data and drives everything. useEffect(() => { const threads = threadsRef.current; + const isMissionMode = streamEntityRef.current == null; function prepareVisNode(v: VisNode) { v.mesh.visible = true; @@ -700,25 +733,15 @@ export const ShapeModel = memo(function ShapeModel({ if (clip && mixer) { const action = mixer.clipAction(clip); - if (seqLower === "deploy") { + const cyclic = seqCyclicByName.get(seqLower) ?? true; + if (cyclic) { + action.setLoop(LoopRepeat, Infinity); + } else { action.setLoop(LoopOnce, 1); action.clampWhenFinished = true; - } else { - action.setLoop(LoopRepeat, Infinity); } action.reset().play(); thread.action = action; - - // When animations are disabled, snap deploy to its end pose. - if (!animationEnabledRef.current && seqLower === "deploy") { - action.time = clip.duration; - mixer.update(0); - // In mission mode, onDeployEndRef advances the lifecycle. - // In demo mode it's null — the ghost data drives what's next. - if (onDeployEndRef.current) { - queueMicrotask(() => onDeployEndRef.current?.(slot)); - } - } } if (vNodes) { @@ -747,113 +770,44 @@ export const ShapeModel = memo(function ShapeModel({ handlePlayThreadRef.current = handlePlayThread; handleStopThreadRef.current = handleStopThread; - // ── Demo playback: all animation driven by ghost thread data ── - // No deploy lifecycle, no auto-play, no TorqueScript. The useFrame - // handler reads demoThreads and calls handlePlayThread/handleStopThread. - if (demoThreadsRef.current != null) { + // ── Demo/live mode: no auto-play, useFrame drives from ghost data ── + if (!isMissionMode) { return () => { handlePlayThreadRef.current = null; handleStopThreadRef.current = null; + prevDemoThreadsRef.current = undefined; for (const slot of [...threads.keys()]) handleStopThread(slot); }; } - // ── Mission rendering: deploy lifecycle + TorqueScript ── - const hasDeployClip = clipsByName.has("deploy"); - const useTorqueDeploy = !!(runtime && hasDeployClip && object.datablock); - - function fireOnEndSequence(slot: number) { - if (!runtime) return; - const dbName = object.datablock; - if (!dbName) return; - const datablock = runtime.getObjectByName(String(dbName)); - if (datablock) { - runtime.$.call(datablock, "onEndSequence", object, slot); - } - } - - onDeployEndRef.current = useTorqueDeploy - ? fireOnEndSequence - : () => startPostDeployThreads(); - - function startPostDeployThreads() { - const autoPlaySequences = ["ambient", "power"]; - for (const seqName of autoPlaySequences) { - const vNodes = visNodesBySequence.get(seqName); - if (vNodes) { - const startTime = shapeNowSec(); - for (const v of vNodes) prepareVisNode(v); - const slot = seqName === "power" ? 0 : 1; - threads.set(slot, { sequence: seqName, visNodes: vNodes, startTime }); - } - const clip = clipsByName.get(seqName); - if (clip && mixer) { - const action = mixer.clipAction(clip); - action.setLoop(LoopRepeat, Infinity); - action.reset().play(); - const slot = seqName === "power" ? 0 : 1; - const existing = threads.get(slot); - if (existing) { - existing.action = action; - } else { - threads.set(slot, { - sequence: seqName, - action, - startTime: shapeNowSec(), - }); - } - } - } - } - + // ── Mission mode ── const unsubs: (() => void)[] = []; - const onFinished = mixer - ? (e: { action: AnimationAction }) => { - for (const [slot, thread] of threads) { - if (thread.action === e.action) { - if (useTorqueDeploy) { - fireOnEndSequence(slot); - } else { - startPostDeployThreads(); - } - break; - } - } - } - : null; - - if (onFinished && mixer) { - mixer.addEventListener("finished", onFinished); - } - + // Subscribe to TorqueScript playThread/stopThread/pauseThread so + // scripts can control animations at runtime. if (runtime) { unsubs.push( runtime.$.onMethodCalled( "ShapeBase", "playThread", (thisObj, slot, sequence) => { - if (thisObj._id !== object._id) return; + if (thisObj._id !== object?._id) return; handlePlayThread(Number(slot), String(sequence)); }, ), ); unsubs.push( - runtime.$.onMethodCalled( - "ShapeBase", - "stopThread", - (thisObj, slot) => { - if (thisObj._id !== object._id) return; - handleStopThread(Number(slot)); - }, - ), + runtime.$.onMethodCalled("ShapeBase", "stopThread", (thisObj, slot) => { + if (thisObj._id !== object?._id) return; + handleStopThread(Number(slot)); + }), ); unsubs.push( runtime.$.onMethodCalled( "ShapeBase", "pauseThread", (thisObj, slot) => { - if (thisObj._id !== object._id) return; + if (thisObj._id !== object?._id) return; const thread = threads.get(Number(slot)); if (thread?.action) { thread.action.paused = true; @@ -863,25 +817,33 @@ export const ShapeModel = memo(function ShapeModel({ ); } - if (useTorqueDeploy) { - runtime.$.call(object, "deploy"); - } else if (hasDeployClip) { - handlePlayThread(DEPLOY_THREAD, "deploy"); - } else { - startPostDeployThreads(); + // Start default looping sequences immediately. Thread slots match + // power.cs globals: $PowerThread=0, $AmbientThread=1. + const defaults: Array<[number, string]> = [ + [0, "power"], + [1, "ambient"], + ]; + for (const [slot, seqName] of defaults) { + if (clipsByName.has(seqName) || visNodesBySequence.has(seqName)) { + handlePlayThread(slot, seqName); + } } return () => { - if (onFinished && mixer) { - mixer.removeEventListener("finished", onFinished); - } unsubs.forEach((fn) => fn()); - onDeployEndRef.current = null; handlePlayThreadRef.current = null; handleStopThreadRef.current = null; + prevDemoThreadsRef.current = undefined; for (const slot of [...threads.keys()]) handleStopThread(slot); }; - }, [mixer, clipsByName, visNodesBySequence, object, runtime]); + }, [ + mixer, + clipsByName, + visNodesBySequence, + seqCyclicByName, + object, + runtime, + ]); // Build DTS sequence index → animation name lookup. If the glTF has the // dts_sequence_names extra (set by the addon), use it for an exact mapping @@ -893,7 +855,9 @@ export const ShapeModel = memo(function ShapeModel({ try { const names: string[] = JSON.parse(raw); return names.map((n) => n.toLowerCase()); - } catch {} + } catch { + /* expected */ + } } return gltf.animations.map((a) => a.name.toLowerCase()); }, [gltf]); @@ -901,16 +865,20 @@ export const ShapeModel = memo(function ShapeModel({ useFrame((_, delta) => { const threads = threadsRef.current; - // In demo mode, scale animation by playback rate; freeze when paused. - const inDemo = demoThreadsRef.current != null; + // In demo/live mode, scale animation by playback rate; freeze when paused. + // Check streamEntity existence (not .threads) so shapes without thread + // data (e.g. Items) also freeze correctly when paused. + const inDemo = streamEntityRef.current != null; const playbackState = engineStore.getState().playback; - const effectDelta = !inDemo ? delta - : playbackState.status === "playing" ? delta * playbackState.rate - : 0; + const effectDelta = !inDemo + ? delta + : playbackState.status === "playing" + ? delta * playbackState.rate + : 0; // React to demo thread state changes. The ghost ThreadMask data tells us // exactly which DTS sequences are playing/stopped on each of 4 thread slots. - const currentDemoThreads = demoThreadsRef.current; + const currentDemoThreads = streamEntityRef.current?.threads; const prevDemoThreads = prevDemoThreadsRef.current; if (currentDemoThreads !== prevDemoThreads) { const playThread = handlePlayThreadRef.current; @@ -920,11 +888,11 @@ export const ShapeModel = memo(function ShapeModel({ if (playThread && stopThread) { prevDemoThreadsRef.current = currentDemoThreads; // Use sparse arrays instead of Maps — thread indices are 0-3. - const currentBySlot: Array = []; + const currentBySlot: Array = []; if (currentDemoThreads) { for (const t of currentDemoThreads) currentBySlot[t.index] = t; } - const prevBySlot: Array = []; + const prevBySlot: Array = []; if (prevDemoThreads) { for (const t of prevDemoThreads) prevBySlot[t.index] = t; } @@ -933,21 +901,24 @@ export const ShapeModel = memo(function ShapeModel({ const t = currentBySlot[slot]; const prev = prevBySlot[slot]; if (t) { - const changed = !prev - || prev.sequence !== t.sequence - || prev.state !== t.state - || prev.atEnd !== t.atEnd; + const changed = + !prev || + prev.sequence !== t.sequence || + prev.state !== t.state || + prev.atEnd !== t.atEnd; if (!changed) continue; // When only atEnd changed (false→true) on a playing thread with // the same sequence, the animation has finished on the server. // Don't restart it — snap to the end pose so one-shot animations // like "deploy" stay clamped instead of collapsing back. - const onlyAtEndChanged = prev - && prev.sequence === t.sequence - && prev.state === t.state - && t.state === 0 - && !prev.atEnd && t.atEnd; + const onlyAtEndChanged = + prev && + prev.sequence === t.sequence && + prev.state === t.state && + t.state === 0 && + !prev.atEnd && + t.atEnd; if (onlyAtEndChanged) { const thread = threads.get(slot); if (thread?.action) { @@ -975,24 +946,8 @@ export const ShapeModel = memo(function ShapeModel({ } } - if (mixer) { - // If animation is disabled and deploy is still mid-animation, - // snap to the fully-deployed pose and fire onEndSequence. - if (!animationEnabled) { - const deployThread = threads.get(DEPLOY_THREAD); - if (deployThread?.action) { - const clip = deployThread.action.getClip(); - if (deployThread.action.time < clip.duration - 0.001) { - deployThread.action.time = clip.duration; - mixer.update(0); - onDeployEndRef.current?.(DEPLOY_THREAD); - } - } - } - - if (animationEnabled) { - mixer.update(effectDelta); - } + if (mixer && animationEnabled) { + mixer.update(effectDelta); } // Drive vis opacity animations for active threads. @@ -1054,7 +1009,10 @@ export const ShapeModel = memo(function ShapeModel({ break; } } - updateAtlasFrame(info.atlas, getFrameIndexForTime(info.atlas, iflTime)); + updateAtlasFrame( + info.atlas, + getFrameIndexForTime(info.atlas, iflTime), + ); } else { // No controlling sequence: use accumulated real time. // (In the engine, these would stay at frame 0, but cycling is more @@ -1073,15 +1031,19 @@ export const ShapeModel = memo(function ShapeModel({ {debugMode ? ( - {object._id}: {shapeName} + {object?._id}: {shapeName} ) : null} ); }); -function ShapeModelLoader({ demoThreads }: { demoThreads?: DemoThreadState[] }) { +function ShapeModelLoader({ + streamEntity, +}: { + streamEntity?: { threads?: StreamThreadState[] }; +}) { const { shapeName } = useShapeInfo(); const gltf = useStaticShape(shapeName); - return ; + return ; } diff --git a/src/components/InspectorControls.module.css b/src/components/InspectorControls.module.css index 06592532..02e04494 100644 --- a/src/components/InspectorControls.module.css +++ b/src/components/InspectorControls.module.css @@ -13,40 +13,35 @@ justify-content: center; gap: 20px; } - .Dropdown { display: flex; align-items: center; justify-content: center; gap: 20px; } - .Group { display: flex; align-items: center; justify-content: center; gap: 20px; } - .CheckboxField, .LabelledButton { display: flex; align-items: center; gap: 6px; } - .Field { display: flex; align-items: center; gap: 6px; } - .IconButton { position: relative; display: flex; align-items: center; justify-content: center; - width: 28px; + min-width: 28px; height: 28px; margin: 0 0 0 -12px; font-size: 15px; @@ -65,52 +60,42 @@ background 0.2s, border-color 0.2s; } - .IconButton svg { pointer-events: none; } - @media (hover: hover) { .IconButton:hover { background: rgba(0, 98, 179, 0.8); border-color: rgba(255, 255, 255, 0.4); } } - .IconButton:active, .IconButton[aria-expanded="true"] { background: rgba(0, 98, 179, 0.7); border-color: rgba(255, 255, 255, 0.3); transform: translate(0, 1px); } - .IconButton[data-active="true"] { background: rgba(0, 117, 213, 0.9); border-color: rgba(255, 255, 255, 0.4); } - .ButtonLabel { font-size: 12px; } - .Toggle { composes: IconButton; margin: 0; } - .MapInfoButton { composes: IconButton; composes: LabelledButton; } - .MissionSelectWrapper { } - @media (max-width: 1279px) { .Dropdown[data-open="false"] { display: none; } - .Dropdown { position: absolute; top: calc(100% + 2px); @@ -128,47 +113,38 @@ padding: 12px; box-shadow: 0 0 12px rgba(0, 0, 0, 0.4); } - .Group { flex-wrap: wrap; gap: 12px 20px; } - .LabelledButton { width: auto; padding: 0 10px; } } - @media (max-width: 639px) { .Controls { right: 0; border-radius: 0; } - .MissionSelectWrapper { flex: 1 1 0; min-width: 0; } - .MissionSelectWrapper input { width: 100%; } - .Toggle { flex: 0 0 auto; } } - @media (min-width: 1280px) { .Toggle { display: none; } - .LabelledButton .ButtonLabel { display: none; } - .MapInfoButton { display: none; } diff --git a/src/components/InspectorControls.tsx b/src/components/InspectorControls.tsx index d01170b8..4eb359ad 100644 --- a/src/components/InspectorControls.tsx +++ b/src/components/InspectorControls.tsx @@ -8,16 +8,18 @@ import { MissionSelect } from "./MissionSelect"; import { useEffect, useState, useRef, RefObject } from "react"; import { CopyCoordinatesButton } from "./CopyCoordinatesButton"; import { LoadDemoButton } from "./LoadDemoButton"; -import { useDemoRecording } from "./DemoProvider"; +import { JoinServerButton } from "./JoinServerButton"; +import { useRecording } from "./RecordingProvider"; +import { useLiveConnectionOptional } from "./LiveConnection"; import { FiInfo, FiSettings } from "react-icons/fi"; import { Camera } from "three"; import styles from "./InspectorControls.module.css"; - export function InspectorControls({ missionName, missionType, onChangeMission, onOpenMapInfo, + onOpenServerBrowser, isTouch, cameraRef, }: { @@ -31,6 +33,7 @@ export function InspectorControls({ missionType: string; }) => void; onOpenMapInfo: () => void; + onOpenServerBrowser?: () => void; isTouch: boolean | null; cameraRef: RefObject; }) { @@ -47,20 +50,23 @@ export function InspectorControls({ const { speedMultiplier, setSpeedMultiplier, touchMode, setTouchMode } = useControls(); const { debugMode, setDebugMode } = useDebug(); - const demoRecording = useDemoRecording(); - const isDemoLoaded = demoRecording != null; + const demoRecording = useRecording(); + const live = useLiveConnectionOptional(); + const isLive = live?.adapter != null; + const isStreaming = demoRecording != null || isLive; + // Hide FOV/speed controls during .rec playback (faithfully replaying), + // but show them in .mis browsing and live observer mode. + const hideViewControls = isStreaming && !isLive; const [settingsOpen, setSettingsOpen] = useState(false); const dropdownRef = useRef(null); const buttonRef = useRef(null); const focusAreaRef = useRef(null); - // Focus the panel when it opens. useEffect(() => { if (settingsOpen) { dropdownRef.current?.focus(); } }, [settingsOpen]); - const handleDropdownBlur = (e: React.FocusEvent) => { const relatedTarget = e.relatedTarget as Node | null; if (relatedTarget && focusAreaRef.current?.contains(relatedTarget)) { @@ -68,7 +74,6 @@ export function InspectorControls({ } setSettingsOpen(false); }; - // Close on Escape and return focus to the gear button. const handlePanelKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Escape") { @@ -76,7 +81,6 @@ export function InspectorControls({ buttonRef.current?.focus(); } }; - return (
@@ -122,6 +126,9 @@ export function InspectorControls({ cameraRef={cameraRef} /> + {onOpenServerBrowser && ( + + )}
- {isDemoLoaded ? null : ( + {hideViewControls ? null : (
setFov(parseInt(event.target.value))} /> {fov}
)} - {isDemoLoaded ? null : ( + {hideViewControls ? null : (
setSpeedMultiplier(parseFloat(event.target.value)) } diff --git a/src/components/InteriorInstance.tsx b/src/components/InteriorInstance.tsx index e0723607..c27032a4 100644 --- a/src/components/InteriorInstance.tsx +++ b/src/components/InteriorInstance.tsx @@ -11,8 +11,12 @@ import { } from "three"; import { useGLTF, useTexture } from "@react-three/drei"; import { textureToUrl, interiorToUrl } from "../loaders"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation, getScale } from "../mission"; +import type { SceneInteriorInstance } from "../scene/types"; +import { + torqueToThree, + torqueScaleToThree, + matrixFToQuaternion, +} from "../scene/coordinates"; import { setupTexture } from "../textureUtils"; import { FloatingLabel } from "./FloatingLabel"; import { useDebug } from "./SettingsProvider"; @@ -41,18 +45,15 @@ function InteriorTexture({ const debugMode = debugContext?.debugMode ?? false; const url = textureToUrl(materialName); const texture = useTexture(url, (texture) => setupTexture(texture)); - // Check for self-illuminating flag in material userData // Note: The io_dif Blender add-on needs to be updated to export material flags const flagNames = new Set(material?.userData?.flag_names ?? []); const isSelfIlluminating = flagNames.has("SelfIlluminating"); - // Check for SurfaceOutsideVisible flag (surfaces that receive scene ambient light) const surfaceFlagNames = new Set( material?.userData?.surface_flag_names ?? [], ); const isSurfaceOutsideVisible = surfaceFlagNames.has("SurfaceOutsideVisible"); - // Inject volumetric fog and lighting multipliers into materials // NOTE: This hook must be called unconditionally (before any early returns) const onBeforeCompile = useCallback( @@ -64,11 +65,9 @@ function InteriorTexture({ }, [isSurfaceOutsideVisible], ); - // Refs for forcing shader recompilation const basicMaterialRef = useRef(null); const lambertMaterialRef = useRef(null); - // Force shader recompilation when debugMode changes // r3f doesn't sync defines prop changes, so we update the material directly useEffect(() => { @@ -81,12 +80,9 @@ function InteriorTexture({ mat.needsUpdate = true; } }, [debugMode]); - const defines = { DEBUG_MODE: debugMode ? 1 : 0 }; - // Key for shader structure changes (surfaceOutsideVisible affects lighting model) const materialKey = `${isSurfaceOutsideVisible}`; - // Self-illuminating materials are fullbright (unlit), no lightmap if (isSelfIlluminating) { return ( @@ -100,7 +96,6 @@ function InteriorTexture({ /> ); } - // MeshLambertMaterial for diffuse-only lighting (matches Tribes 2's GL pipeline) // Shader modifications in onBeforeCompile: // - Outside surfaces (SurfaceOutsideVisible): scene lighting + additive lightmap @@ -186,11 +181,11 @@ function InteriorMesh({ node }: { node: Mesh }) { } export const InteriorModel = memo(function InteriorModel({ - object, interiorFile, + ghostIndex, }: { - object: TorqueObject; interiorFile: string; + ghostIndex?: number; }) { const { nodes } = useInterior(interiorFile); const debugContext = useDebug(); @@ -205,7 +200,7 @@ export const InteriorModel = memo(function InteriorModel({ ))} {debugMode ? ( - {object._id}: {interiorFile} + {ghostIndex}: {interiorFile} ) : null} @@ -235,24 +230,40 @@ function DebugInteriorPlaceholder({ label }: { label?: string }) { } export const InteriorInstance = memo(function InteriorInstance({ - object, + scene, }: { - object: TorqueObject; + scene: SceneInteriorInstance; }) { - const interiorFile = getProperty(object, "interiorFile"); - const position = useMemo(() => getPosition(object), [object]); - const scale = useMemo(() => getScale(object), [object]); - const q = useMemo(() => getRotation(object), [object]); + const position = useMemo( + () => torqueToThree(scene.transform.position), + [scene.transform.position], + ); + const q = useMemo( + () => matrixFToQuaternion(scene.transform), + [scene.transform], + ); + const scale = useMemo(() => torqueScaleToThree(scene.scale), [scene.scale]); return ( + } + onError={(error) => { + console.warn( + `[interior] Failed to load ${scene.interiorFile}:`, + error.message, + ); + }} > }> - + diff --git a/src/components/Item.tsx b/src/components/Item.tsx deleted file mode 100644 index fcdc705c..00000000 --- a/src/components/Item.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { useMemo, useRef } from "react"; -import { useFrame } from "@react-three/fiber"; -import { Group } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation, getScale } from "../mission"; -import { ShapeRenderer } from "./GenericShape"; -import { ShapeInfoProvider } from "./ShapeInfoProvider"; -import { useSimGroup } from "./SimGroup"; -import { FloatingLabel } from "./FloatingLabel"; -import { useDatablock } from "./useDatablock"; -import { useSettings } from "./SettingsProvider"; - -/** Handles TorqueScript's various truthy representations. */ -function isTruthy(value: unknown): boolean { - if (typeof value === "string") { - const lower = value.toLowerCase(); - return lower !== "0" && lower !== "false" && lower !== ""; - } - return !!value; -} - -const TEAM_NAMES: Record = { - 1: "Storm", - 2: "Inferno", -}; - -export function Item({ object }: { object: TorqueObject }) { - const simGroup = useSimGroup(); - const datablockName = getProperty(object, "dataBlock") ?? ""; - const datablock = useDatablock(datablockName); - - const shouldRotate = isTruthy( - getProperty(object, "rotate") ?? getProperty(datablock, "rotate") - ); - - const position = useMemo(() => getPosition(object), [object]); - const scale = useMemo(() => getScale(object), [object]); - const q = useMemo(() => getRotation(object), [object]); - - const { animationEnabled } = useSettings(); - const groupRef = useRef(null); - - useFrame(() => { - if (!groupRef.current || !shouldRotate || !animationEnabled) return; - const t = performance.now() / 1000; - groupRef.current.rotation.y = (t / 3.0) * Math.PI * 2; - }); - - const shapeName = getProperty(datablock, "shapeFile"); - - if (!shapeName) { - console.error(` missing shape for datablock: ${datablockName}`); - } - - const isFlag = datablockName?.toLowerCase() === "flag"; - const team = simGroup?.team ?? null; - const teamName = team && team > 0 ? TEAM_NAMES[team] : null; - const label = isFlag && teamName ? `${teamName} Flag` : null; - - return ( - - - - {label ? {label} : null} - - - - ); -} diff --git a/src/components/JoinServerButton.module.css b/src/components/JoinServerButton.module.css new file mode 100644 index 00000000..d6a851ea --- /dev/null +++ b/src/components/JoinServerButton.module.css @@ -0,0 +1,29 @@ +.Root { + composes: IconButton from "./InspectorControls.module.css"; + composes: LabelledButton from "./InspectorControls.module.css"; + padding: 0 5px; +} +/* Text label ("Connect", "Connecting...") follows standard breakpoint rules. */ +.TextLabel { + composes: ButtonLabel from "./InspectorControls.module.css"; +} +/* Ping label is always visible regardless of breakpoint. */ +.PingLabel { + composes: ButtonLabel from "./InspectorControls.module.css"; + display: flex !important; + margin-right: 2px; +} +.LiveIcon { + font-size: 15px; +} +.Pulsing { + animation: blink 1.2s ease-out infinite; +} +@keyframes blink { + 0% { + opacity: 1; + } + 100% { + opacity: 0.25; + } +} diff --git a/src/components/JoinServerButton.tsx b/src/components/JoinServerButton.tsx new file mode 100644 index 00000000..903a420e --- /dev/null +++ b/src/components/JoinServerButton.tsx @@ -0,0 +1,53 @@ +import { BsFillLightningChargeFill } from "react-icons/bs"; +import { useLiveConnectionOptional } from "./LiveConnection"; +import styles from "./JoinServerButton.module.css"; + +function formatPing(ms: number): string { + return ms >= 1000 ? ms.toLocaleString() + "ms" : ms + "ms"; +} + +export function JoinServerButton({ + onOpenServerBrowser, +}: { + onOpenServerBrowser: () => void; +}) { + const live = useLiveConnectionOptional(); + if (!live) return null; + + const isLive = live.gameStatus === "connected"; + const isConnecting = + live.gameStatus === "connecting" || + live.gameStatus === "challenging" || + live.gameStatus === "authenticating"; + + return ( + + ); +} diff --git a/src/components/KeyboardOverlay.tsx b/src/components/KeyboardOverlay.tsx index ecba3ee8..2bdf2f48 100644 --- a/src/components/KeyboardOverlay.tsx +++ b/src/components/KeyboardOverlay.tsx @@ -1,10 +1,10 @@ import { useKeyboardControls } from "@react-three/drei"; import { Controls } from "./ObserverControls"; -import { useDemoRecording } from "./DemoProvider"; +import { useRecording } from "./RecordingProvider"; import styles from "./KeyboardOverlay.module.css"; export function KeyboardOverlay() { - const recording = useDemoRecording(); + const recording = useRecording(); const forward = useKeyboardControls((s) => s.forward); const backward = useKeyboardControls((s) => s.backward); const left = useKeyboardControls((s) => s.left); @@ -16,7 +16,9 @@ export function KeyboardOverlay() { const lookLeft = useKeyboardControls((s) => s.lookLeft); const lookRight = useKeyboardControls((s) => s.lookRight); - if (recording) return null; + // Show when no recording (map browsing) or during live mode. + // Hidden during demo playback (recording with finite duration). + if (recording && recording.source !== "live") return null; return (
diff --git a/src/components/LiveConnection.tsx b/src/components/LiveConnection.tsx new file mode 100644 index 00000000..c10606f2 --- /dev/null +++ b/src/components/LiveConnection.tsx @@ -0,0 +1,266 @@ +import { + createContext, + useContext, + useState, + useCallback, + useRef, + useEffect, +} from "react"; +import { RelayClient } from "../stream/relayClient"; +import { LiveStreamAdapter } from "../stream/liveStreaming"; +import type { + ClientMove, + ServerInfo, + ConnectionStatus, +} from "../../relay/types"; + +interface LiveConnectionState { + relayConnected: boolean; + gameStatus: ConnectionStatus | null; + gameStatusMessage?: string; + /** Map name from the server being joined (from GameInfoResponse or status). */ + mapName?: string; + /** Effective RTT to the game server (relay↔T2 + browser↔relay). */ + ping: number | null; + /** Browser↔relay WebSocket RTT in ms. */ + wsPing: number | null; + servers: ServerInfo[]; + serversLoading: boolean; + adapter: LiveStreamAdapter | null; + /** True once the first ghost entity arrives (game is rendering). */ + liveReady: boolean; +} + +interface LiveConnectionActions { + connectRelay: (url?: string) => void; + disconnectRelay: () => void; + listServers: () => void; + joinServer: (address: string) => void; + disconnectServer: () => void; + sendMove: (move: ClientMove) => void; + sendCommand: (command: string, ...args: string[]) => void; +} + +const LiveConnectionContext = createContext< + (LiveConnectionState & LiveConnectionActions) | null +>(null); + +export function useLiveConnection() { + const ctx = useContext(LiveConnectionContext); + if (!ctx) { + throw new Error("useLiveConnection must be used within LiveConnectionProvider"); + } + return ctx; +} + +export function useLiveConnectionOptional() { + return useContext(LiveConnectionContext); +} + +const DEFAULT_RELAY_URL = + process.env.NEXT_PUBLIC_RELAY_URL || "ws://localhost:8765"; + +export function LiveConnectionProvider({ + children, +}: { + children: React.ReactNode; +}) { + const relayRef = useRef(null); + const adapterRef = useRef(null); + // Queue of actions to run once the relay WebSocket opens. + const pendingRef = useRef void>>([]); + const listInFlightRef = useRef(false); + + const [relayConnected, setRelayConnected] = useState(false); + const [gameStatus, setGameStatus] = useState(null); + const [gameStatusMessage, setGameStatusMessage] = useState< + string | undefined + >(); + const [mapName, setMapName] = useState(); + const [servers, setServers] = useState([]); + const [serversLoading, setServersLoading] = useState(false); + const [adapter, setAdapter] = useState(null); + const [liveReady, setLiveReady] = useState(false); + const [relayPing, setRelayPing] = useState(null); + const [wsPing, setWsPing] = useState(null); + + const connectRelay = useCallback((url: string = DEFAULT_RELAY_URL) => { + if (relayRef.current) { + relayRef.current.close(); + relayRef.current = null; + } + + const relay = new RelayClient(url, { + onOpen() { + setRelayConnected(true); + // Flush any queued actions (e.g. listServers called before open). + for (const fn of pendingRef.current) fn(); + pendingRef.current = []; + }, + onStatus(status, message, _connectSequence, statusMapName) { + console.log( + `[relay] game status: ${status}${message ? ` — ${message}` : ""}${statusMapName ? ` map=${statusMapName}` : ""}`, + ); + setGameStatus(status); + setGameStatusMessage(message); + if (statusMapName) { + setMapName(statusMapName); + } + }, + onServerList(list) { + setServers(list); + setServersLoading(false); + listInFlightRef.current = false; + }, + onGamePacket(data) { + if (!adapterRef.current) { + console.warn("[relay] received game packet but no adapter is active"); + } + adapterRef.current?.feedPacket(data); + }, + onPing(ms) { + setRelayPing(ms); + }, + onWsPing(ms) { + setWsPing(ms); + }, + onError(message) { + console.error("Relay error:", message); + setServersLoading(false); + listInFlightRef.current = false; + }, + onClose() { + // Only update state if this is still the active relay. + if (relayRef.current === relay) { + relayRef.current = null; + setRelayConnected(false); + setGameStatus(null); + setMapName(undefined); + setRelayPing(null); + setWsPing(null); + setAdapter(null); + setLiveReady(false); + adapterRef.current = null; + pendingRef.current = []; + listInFlightRef.current = false; + } + }, + }); + + relay.connect(); + relayRef.current = relay; + }, []); + + const disconnectRelay = useCallback(() => { + relayRef.current?.close(); + relayRef.current = null; + adapterRef.current = null; + pendingRef.current = []; + setRelayConnected(false); + setGameStatus(null); + setMapName(undefined); + setAdapter(null); + setLiveReady(false); + }, []); + + const listServers = useCallback(() => { + if (listInFlightRef.current) return; + listInFlightRef.current = true; + + const doList = () => { + relayRef.current?.sendWsPing(); + relayRef.current?.listServers(); + }; + + setServersLoading(true); + + if (relayRef.current?.connected) { + doList(); + } else { + // Connect first, then list once the socket opens. + pendingRef.current.push(doList); + if (!relayRef.current) { + connectRelay(); + } + } + }, [connectRelay]); + + const joinServer = useCallback((address: string) => { + if (!relayRef.current) return; + + // Set mapName from the cached server list immediately so the browser + // can start loading the mission before the relay even connects to the + // game server. + const cachedServer = servers.find((s) => s.address === address); + if (cachedServer?.mapName) { + setMapName(cachedServer.mapName); + } + + const newAdapter = new LiveStreamAdapter(relayRef.current); + newAdapter.onReady = () => setLiveReady(true); + adapterRef.current = newAdapter; + setLiveReady(false); + setGameStatus(null); + setAdapter(newAdapter); + + relayRef.current.joinServer(address); + }, [servers]); + + const disconnectServer = useCallback(() => { + relayRef.current?.disconnectServer(); + adapterRef.current?.reset(); + adapterRef.current = null; + setAdapter(null); + setLiveReady(false); + setGameStatus(null); + setMapName(undefined); + setRelayPing(null); + }, []); + + const sendMove = useCallback((move: ClientMove) => { + relayRef.current?.sendMove(move); + }, []); + + const sendCommand = useCallback((command: string, ...args: string[]) => { + relayRef.current?.sendCommand(command, args); + }, []); + + // Clean up on unmount. + useEffect(() => { + return () => { + relayRef.current?.close(); + }; + }, []); + + // Effective RTT = relay↔T2 RTT + browser↔relay RTT. + const ping = + relayPing != null && wsPing != null + ? relayPing + wsPing + : relayPing ?? null; + + const value: LiveConnectionState & LiveConnectionActions = { + relayConnected, + gameStatus, + gameStatusMessage, + mapName, + ping, + wsPing, + servers, + serversLoading, + adapter, + liveReady, + connectRelay, + disconnectRelay, + listServers, + joinServer, + disconnectServer, + sendMove, + sendCommand, + }; + + return ( + + {children} + + ); +} diff --git a/src/components/LiveObserver.tsx b/src/components/LiveObserver.tsx new file mode 100644 index 00000000..4fddb1d0 --- /dev/null +++ b/src/components/LiveObserver.tsx @@ -0,0 +1,328 @@ +import { useRef, useEffect } from "react"; +import { useFrame, useThree } from "@react-three/fiber"; +import { Vector3 } from "three"; +import { useKeyboardControls } from "@react-three/drei"; +import { useLiveConnection } from "./LiveConnection"; +import { useEngineStoreApi } from "../state/engineStore"; +import { streamPlaybackStore } from "../state/streamPlaybackStore"; +import { Controls, MOUSE_SENSITIVITY, ARROW_LOOK_SPEED } from "./ObserverControls"; +import { useControls } from "./SettingsProvider"; +import { useTick, TICK_RATE } from "./TickProvider"; +import { + yawPitchToQuaternion, + MAX_PITCH, +} from "../stream/streamHelpers"; +import type { StreamRecording, StreamCamera } from "../stream/types"; +import type { LiveStreamAdapter } from "../stream/liveStreaming"; + +const TICK_INTERVAL = 1 / TICK_RATE; + +// Scratch objects to avoid per-frame allocations. +const _orbitDir = new Vector3(); +const _orbitTarget = new Vector3(); + +/** Predicted camera rotation state for client-side prediction. */ +interface PredictionState { + /** Absolute predicted yaw (Torque radians). */ + yaw: number; + /** Absolute predicted pitch (Torque radians). */ + pitch: number; + /** Previous tick's yaw, for inter-tick interpolation. */ + prevYaw: number; + /** Previous tick's pitch, for inter-tick interpolation. */ + prevPitch: number; + /** Whether prediction has been initialized from a server snapshot. */ + initialized: boolean; + /** Last server camera snapshot we synced from (identity check for new data). */ + lastSyncedCamera: StreamCamera | null; +} + +/** + * Bridges the LiveStreamAdapter into the playback pipeline. + * Sends Move structs to the relay and applies client-side rotation prediction + * so camera look feels responsive at frame rate, matching how the real + * Tribes 2 client works (predict locally, correct from server). + */ +export function LiveObserver() { + const { adapter, gameStatus, sendMove } = useLiveConnection(); + const store = useEngineStoreApi(); + const { speedMultiplier } = useControls(); + const activeAdapterRef = useRef(null); + const { gl } = useThree(); + const [, getKeys] = useKeyboardControls(); + + // Accumulated rotation deltas since last move was sent. Mouse events and + // arrow keys both add to these; consumed at the tick rate (32ms). + const deltaYawRef = useRef(0); + const deltaPitchRef = useRef(0); + + // Client-side prediction state. + const predRef = useRef({ + yaw: 0, + pitch: 0, + prevYaw: 0, + prevPitch: 0, + initialized: false, + lastSyncedCamera: null, + }); + + // Sub-tick accumulator for interpolation (0..TICK_INTERVAL). + const tickAccRef = useRef(0); + + // Wire adapter to engine store. + useEffect(() => { + if (adapter && (gameStatus === "connected" || gameStatus === "authenticating")) { + if (activeAdapterRef.current === adapter) return; + + console.log("[LiveObserver] wiring adapter to engine store"); + const liveRecording: StreamRecording = { + source: "live", + duration: Infinity, + missionName: null, + gameType: null, + streamingPlayback: adapter, + }; + + store.getState().setRecording(liveRecording); + store.getState().setPlaybackStatus("playing"); + activeAdapterRef.current = adapter; + // Reset prediction when connecting to a new server. + predRef.current.initialized = false; + predRef.current.lastSyncedCamera = null; + } else if (!adapter && activeAdapterRef.current) { + store.getState().setRecording(null); + activeAdapterRef.current = null; + predRef.current.initialized = false; + } + }, [adapter, gameStatus, store]); + + // Accumulate mouse deltas when pointer is locked or dragging. + useEffect(() => { + let dragging = false; + + const handleMouseMove = (e: MouseEvent) => { + if (document.pointerLockElement) { + // Match Three.js PointerLockControls default (0.002). + deltaYawRef.current += e.movementX * 0.002; + deltaPitchRef.current += e.movementY * 0.002; + } else if (dragging) { + deltaYawRef.current += e.movementX * MOUSE_SENSITIVITY; + deltaPitchRef.current += e.movementY * MOUSE_SENSITIVITY; + } + }; + + const handleMouseDown = (e: MouseEvent) => { + if (!document.pointerLockElement && e.target === gl.domElement) { + dragging = true; + } + }; + + const handleMouseUp = () => { + dragging = false; + }; + + document.addEventListener("mousemove", handleMouseMove); + document.addEventListener("mousedown", handleMouseDown); + document.addEventListener("mouseup", handleMouseUp); + return () => { + document.removeEventListener("mousemove", handleMouseMove); + document.removeEventListener("mousedown", handleMouseDown); + document.removeEventListener("mouseup", handleMouseUp); + }; + }, [gl.domElement]); + + // Left-click when pointer-locked: enter follow mode (from fly) or cycle + // to next player (in follow). Capture phase intercepts before ObserverControls. + useEffect(() => { + const handleClick = (e: MouseEvent) => { + if (!document.pointerLockElement || !activeAdapterRef.current) return; + e.stopImmediatePropagation(); + activeAdapterRef.current.cycleObserveNext(); + }; + + document.addEventListener("click", handleClick, { capture: true }); + return () => { + document.removeEventListener("click", handleClick, { capture: true }); + }; + }, [gl.domElement]); + + // 'O' toggles between follow and free-fly observer modes on the server. + useEffect(() => { + const handleKey = (e: KeyboardEvent) => { + if (e.code !== "KeyO" || e.metaKey || e.ctrlKey || e.altKey) return; + const target = e.target as HTMLElement; + if ( + target.tagName === "INPUT" || + target.tagName === "TEXTAREA" || + target.isContentEditable + ) { + return; + } + if (!activeAdapterRef.current) return; + + activeAdapterRef.current.toggleObserverMode(); + console.log(`[LiveObserver] observer mode: ${activeAdapterRef.current.observerMode}`); + }; + window.addEventListener("keydown", handleKey); + return () => window.removeEventListener("keydown", handleKey); + }, []); + + // Accumulate arrow-key rotation each render frame (frame-rate independent). + useFrame((_, delta) => { + if (!activeAdapterRef.current || gameStatus !== "connected") return; + const { lookUp, lookDown, lookLeft, lookRight } = getKeys(); + if (lookRight) deltaYawRef.current += ARROW_LOOK_SPEED * delta; + if (lookLeft) deltaYawRef.current -= ARROW_LOOK_SPEED * delta; + if (lookDown) deltaPitchRef.current += ARROW_LOOK_SPEED * delta; + if (lookUp) deltaPitchRef.current -= ARROW_LOOK_SPEED * delta; + }); + + // Send moves at the Torque tick rate (32Hz) and apply rotation prediction. + useTick(() => { + if (!activeAdapterRef.current || gameStatus !== "connected") return; + + const { forward, backward, left, right, up, down } = getKeys(); + + // Torque Camera axes: x = strafe (+ right), y = forward/back, z = up/down. + let mx = 0; + let my = 0; + let mz = 0; + if (forward) my += 1; + if (backward) my -= 1; + if (left) mx -= 1; + if (right) mx += 1; + if (up) mz += 1; + if (down) mz -= 1; + + // Consume accumulated rotation deltas. + const yaw = deltaYawRef.current; + const pitch = deltaPitchRef.current; + deltaYawRef.current = 0; + deltaPitchRef.current = 0; + + // Apply prediction: save previous tick state, then advance. + const pred = predRef.current; + pred.prevYaw = pred.yaw; + pred.prevPitch = pred.pitch; + pred.yaw += yaw; + pred.pitch = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, pred.pitch + pitch)); + // Reset sub-tick accumulator for interpolation. + tickAccRef.current = 0; + + // Scale movement axes by speed multiplier. Values > 1 still clamp to + // [-1, 1] server-side, but < 1 lets the user move slower. + const speed = Math.min(1, speedMultiplier); + sendMove({ + x: mx * speed, + y: my * speed, + z: mz * speed, + yaw, + pitch, + roll: 0, + trigger: [false, false, false, false, false, false], + freeLook: false, + }); + }); + + // Override camera rotation with predicted values at frame rate. + // Priority 1 ensures this runs AFTER DemoPlaybackController (priority 0), + // which handles position from server snapshots. + useFrame((state, delta) => { + if (!activeAdapterRef.current || gameStatus !== "connected") return; + + const pred = predRef.current; + + // Sync prediction base from each new server snapshot. The server's + // yaw/pitch is authoritative; we layer any pending (unconsumed) mouse + // deltas on top so the camera feels responsive between server updates. + const snapshot = activeAdapterRef.current.getSnapshot(); + const serverCam = snapshot?.camera; + if ( + serverCam && + serverCam !== pred.lastSyncedCamera && + typeof serverCam.yaw === "number" && + typeof serverCam.pitch === "number" + ) { + // Pending deltas not yet consumed by useTick — replay on top of server. + const pendingYaw = deltaYawRef.current; + const pendingPitch = deltaPitchRef.current; + + pred.prevYaw = pred.initialized ? pred.yaw : serverCam.yaw; + pred.prevPitch = pred.initialized ? pred.pitch : serverCam.pitch; + pred.yaw = serverCam.yaw + pendingYaw; + pred.pitch = Math.max( + -MAX_PITCH, + Math.min(MAX_PITCH, serverCam.pitch + pendingPitch), + ); + pred.lastSyncedCamera = serverCam; + pred.initialized = true; + } + + if (!pred.initialized) return; + + // Advance sub-tick accumulator for interpolation. + tickAccRef.current += delta; + const t = Math.min(1, tickAccRef.current / TICK_INTERVAL); + + // Interpolate between previous and current tick prediction, then add + // pending (unconsumed) mouse/arrow deltas so rotation responds at frame + // rate rather than waiting for the next useTick to consume them. + const interpYaw = pred.prevYaw + (pred.yaw - pred.prevYaw) * t + deltaYawRef.current; + const interpPitch = Math.max( + -MAX_PITCH, + Math.min( + MAX_PITCH, + pred.prevPitch + (pred.pitch - pred.prevPitch) * t + deltaPitchRef.current, + ), + ); + + // Convert predicted rotation to Three.js quaternion and apply. + const [qx, qy, qz, qw] = yawPitchToQuaternion(interpYaw, interpPitch); + + // For third-person (orbit) mode, recompute orbit position from predicted + // angles so the orbit responds at frame rate too. + if (serverCam?.mode === "third-person" && serverCam.orbitTargetId) { + const root = streamPlaybackStore.getState().root; + const targetGroup = root?.children.find( + (child) => child.name === serverCam.orbitTargetId, + ); + if (targetGroup) { + _orbitTarget.copy(targetGroup.position); + const entities = streamPlaybackStore.getState().entities; + const orbitEntity = entities.get(serverCam.orbitTargetId); + if (orbitEntity?.renderType === "Player") { + _orbitTarget.y += 1.0; + } + + const sx = Math.sin(interpPitch); + const cx = Math.cos(interpPitch); + const sz = Math.sin(interpYaw); + const cz = Math.cos(interpYaw); + _orbitDir.set(-cx, -sz * sx, -cz * sx); + + if (_orbitDir.lengthSq() > 1e-8) { + _orbitDir.normalize(); + const orbitDistance = Math.max(0.1, serverCam.orbitDistance ?? 4); + state.camera.position.copy(_orbitTarget).addScaledVector(_orbitDir, orbitDistance); + state.camera.lookAt(_orbitTarget); + } + } + } else { + // Observer fly or first-person: override rotation only (position comes + // from DemoPlaybackController's server snapshot interpolation). + state.camera.quaternion.set(qx, qy, qz, qw); + } + }); + + // Clean up on unmount. + useEffect(() => { + return () => { + if (activeAdapterRef.current) { + store.getState().setRecording(null); + activeAdapterRef.current = null; + } + }; + }, [store]); + + return null; +} diff --git a/src/components/LoadDemoButton.tsx b/src/components/LoadDemoButton.tsx index 94987b7d..cb50a2b5 100644 --- a/src/components/LoadDemoButton.tsx +++ b/src/components/LoadDemoButton.tsx @@ -1,24 +1,25 @@ import { useCallback, useRef } from "react"; import { MdOndemandVideo } from "react-icons/md"; -import { useDemoActions, useDemoRecording } from "./DemoProvider"; -import { createDemoStreamingRecording } from "../demo/streaming"; +import { usePlaybackActions, useRecording } from "./RecordingProvider"; +import { createDemoStreamingRecording } from "../stream/demoStreaming"; import styles from "./LoadDemoButton.module.css"; export function LoadDemoButton() { - const recording = useDemoRecording(); - const { setRecording } = useDemoActions(); + const recording = useRecording(); + const isDemoLoaded = recording?.source === "demo"; + const { setRecording } = usePlaybackActions(); const inputRef = useRef(null); const parseTokenRef = useRef(0); const handleClick = useCallback(() => { - if (recording) { + if (isDemoLoaded) { // Unload the current recording. parseTokenRef.current += 1; setRecording(null); return; } inputRef.current?.click(); - }, [recording, setRecording]); + }, [isDemoLoaded, setRecording]); const handleFileChange = useCallback( async (e: React.ChangeEvent) => { @@ -55,14 +56,15 @@ export function LoadDemoButton() { diff --git a/src/components/MapInfoDialog.module.css b/src/components/MapInfoDialog.module.css index 8ab3313c..a5e2b803 100644 --- a/src/components/MapInfoDialog.module.css +++ b/src/components/MapInfoDialog.module.css @@ -174,28 +174,7 @@ } .CloseButton { - padding: 4px 18px; - background: linear-gradient( - to bottom, - rgba(41, 172, 156, 0.7), - rgba(0, 80, 65, 0.7) - ); - border: 1px solid rgba(41, 97, 84, 0.6); - border-top-color: rgba(101, 185, 176, 0.5); - border-radius: 3px; - box-shadow: - inset 0 1px 0 rgba(120, 220, 195, 0.2), - inset 0 -1px 0 rgba(0, 0, 0, 0.3), - 0 2px 4px rgba(0, 0, 0, 0.4); - color: rgba(154, 239, 225, 0.9); - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5); - font-size: 14px; - font-weight: 500; - cursor: pointer; -} - -.CloseButton:active { - transform: translate(0, 1px); + composes: DialogButton from "./DialogButton.module.css"; } .Hint { diff --git a/src/components/MapInfoDialog.tsx b/src/components/MapInfoDialog.tsx index 67a5946e..43fc6507 100644 --- a/src/components/MapInfoDialog.tsx +++ b/src/components/MapInfoDialog.tsx @@ -50,7 +50,7 @@ function getBitmapUrl( try { const key = getStandardTextureResourceKey(`textures/gui/${bitmap}`); return getUrlForPath(key); - } catch {} + } catch { /* expected */ } } // Fall back to Load_.png convention (multiplayer missions) try { @@ -58,7 +58,7 @@ function getBitmapUrl( `textures/gui/Load_${missionName}`, ); return getUrlForPath(key); - } catch {} + } catch { /* expected */ } return null; } @@ -179,7 +179,7 @@ export function MapInfoDialog({ dialogRef.current?.focus(); try { document.exitPointerLock(); - } catch {} + } catch { /* expected */ } } }, [open]); diff --git a/src/components/Mission.tsx b/src/components/Mission.tsx index 7e89b9cc..c127832e 100644 --- a/src/components/Mission.tsx +++ b/src/components/Mission.tsx @@ -3,7 +3,6 @@ import picomatch from "picomatch"; import { loadMission } from "../loaders"; import { type ParsedMission } from "../mission"; import { createScriptLoader } from "../torqueScript/scriptLoader.browser"; -import { SimObject } from "./SimObject"; import { memo, useEffect, useMemo, useState } from "react"; import { RuntimeProvider } from "./RuntimeProvider"; import { @@ -11,7 +10,6 @@ import { createScriptCache, FileSystemHandler, runServer, - TorqueObject, TorqueRuntime, } from "../torqueScript"; import { @@ -21,8 +19,9 @@ import { getSourceAndPath, } from "../manifest"; import { MissionProvider } from "./MissionContext"; -import { engineStore } from "../state"; +import { engineStore, gameEntityStore } from "../state"; import { ignoreScripts } from "../torqueScript/ignoreScripts"; +import { walkMissionTree } from "../stream/missionEntityBridge"; const loadScript = createScriptLoader(); // Shared cache for parsed scripts - survives runtime restarts @@ -52,7 +51,7 @@ function useParsedMission(name: string) { } interface ExecutedMissionState { - missionGroup: TorqueObject | undefined; + ready: boolean; runtime: TorqueRuntime | undefined; progress: number; } @@ -63,7 +62,7 @@ function useExecutedMission( parsedMission: ParsedMission | undefined, ): ExecutedMissionState { const [state, setState] = useState({ - missionGroup: undefined, + ready: false, runtime: undefined, progress: 0, }); @@ -105,7 +104,11 @@ function useExecutedMission( // Refresh the reactive runtime snapshot at mission-ready time. engineStore.getState().setRuntime(runtime); const missionGroup = runtime.getObjectByName("MissionGroup"); - setState({ missionGroup, runtime, progress: 1 }); + if (missionGroup) { + const gameEntities = walkMissionTree(missionGroup, runtime); + gameEntityStore.getState().setAllEntities(gameEntities); + } + setState({ ready: true, runtime, progress: 1 }); }) .catch((err) => { if (err instanceof Error && err.name === "AbortError") { @@ -134,6 +137,7 @@ function useExecutedMission( controller.abort(); unsubscribeRuntimeEvents?.(); engineStore.getState().clearRuntime(); + gameEntityStore.getState().clearEntities(); runtime.destroy(); }; }, [missionName, missionType, parsedMission]); @@ -154,20 +158,19 @@ export const Mission = memo(function Mission({ }: MissionProps) { const { data: parsedMission } = useParsedMission(name); - const { missionGroup, runtime, progress } = useExecutedMission( + const { ready, runtime, progress } = useExecutedMission( name, missionType, parsedMission, ); - const isLoading = !parsedMission || !missionGroup || !runtime; + const isLoading = !parsedMission || !ready || !runtime; const missionContext = useMemo( () => ({ metadata: parsedMission, missionType, - missionGroup, }), - [parsedMission, missionType, missionGroup], + [parsedMission, missionType], ); useEffect(() => { @@ -180,9 +183,7 @@ export const Mission = memo(function Mission({ return ( - - - + ); }); diff --git a/src/components/MissionContext.tsx b/src/components/MissionContext.tsx index 022bf8f5..a24b47fd 100644 --- a/src/components/MissionContext.tsx +++ b/src/components/MissionContext.tsx @@ -1,11 +1,9 @@ import { createContext, useContext } from "react"; import { ParsedMission } from "../mission"; -import { TorqueObject } from "../torqueScript"; export type MissionContextType = { metadata: ParsedMission; missionType: string; - missionGroup: TorqueObject; }; const MissionContext = createContext(null); diff --git a/src/components/MissionSelect.tsx b/src/components/MissionSelect.tsx index 8b6334d3..d6e90c86 100644 --- a/src/components/MissionSelect.tsx +++ b/src/components/MissionSelect.tsx @@ -274,7 +274,7 @@ export function MissionSelect({ onFocus={() => { try { document.exitPointerLock(); - } catch {} + } catch { /* expected */ } combobox.show(); }} onKeyDown={(e) => { diff --git a/src/components/ObserverControls.tsx b/src/components/ObserverControls.tsx index 88d7e6e9..2994ccc4 100644 --- a/src/components/ObserverControls.tsx +++ b/src/components/ObserverControls.tsx @@ -5,6 +5,7 @@ import { useKeyboardControls } from "@react-three/drei"; import { PointerLockControls } from "three-stdlib"; import { useControls } from "./SettingsProvider"; import { useCameras } from "./CamerasProvider"; +import { streamPlaybackStore } from "../state/streamPlaybackStore"; export enum Controls { forward = "forward", @@ -29,13 +30,15 @@ export enum Controls { } const BASE_SPEED = 80; -const LOOK_SPEED = 1; // radians/sec const MIN_SPEED_ADJUSTMENT = 0.05; const MAX_SPEED_ADJUSTMENT = 0.5; -const DRAG_SENSITIVITY = 0.003; const MAX_PITCH = Math.PI / 2 - 0.01; // ~89° const DRAG_THRESHOLD = 3; // px of movement before it counts as a drag +/** Shared mouse/look sensitivity used across all modes (.mis, .rec, live). */ +export const MOUSE_SENSITIVITY = 0.003; +export const ARROW_LOOK_SPEED = 1; // radians/sec + function CameraMovement() { const { speedMultiplier, setSpeedMultiplier } = useControls(); const [subscribe, getKeys] = useKeyboardControls(); @@ -90,8 +93,8 @@ function CameraMovement() { didDrag = true; euler.setFromQuaternion(camera.quaternion, "YXZ"); - euler.y -= e.movementX * DRAG_SENSITIVITY; - euler.x -= e.movementY * DRAG_SENSITIVITY; + euler.y -= e.movementX * MOUSE_SENSITIVITY; + euler.x -= e.movementY * MOUSE_SENSITIVITY; euler.x = Math.max(-MAX_PITCH, Math.min(MAX_PITCH, euler.x)); camera.quaternion.setFromEuler(euler); }; @@ -176,6 +179,11 @@ function CameraMovement() { }, [gl.domElement, setSpeedMultiplier]); useFrame((state, delta) => { + // When streaming is active and not in free-fly mode, the stream + // (DemoPlaybackController) drives the camera — skip our movement. + const spState = streamPlaybackStore.getState(); + if (spState.playback && !spState.freeFlyCamera) return; + const { forward, backward, @@ -192,10 +200,10 @@ function CameraMovement() { // Arrow keys: rotate camera look direction if (lookUp || lookDown || lookLeft || lookRight) { lookEuler.current.setFromQuaternion(camera.quaternion, "YXZ"); - if (lookLeft) lookEuler.current.y += LOOK_SPEED * delta; - if (lookRight) lookEuler.current.y -= LOOK_SPEED * delta; - if (lookUp) lookEuler.current.x += LOOK_SPEED * delta; - if (lookDown) lookEuler.current.x -= LOOK_SPEED * delta; + if (lookLeft) lookEuler.current.y += ARROW_LOOK_SPEED * delta; + if (lookRight) lookEuler.current.y -= ARROW_LOOK_SPEED * delta; + if (lookUp) lookEuler.current.x += ARROW_LOOK_SPEED * delta; + if (lookDown) lookEuler.current.x -= ARROW_LOOK_SPEED * delta; lookEuler.current.x = Math.max( -MAX_PITCH, Math.min(MAX_PITCH, lookEuler.current.x), diff --git a/src/components/DemoParticleEffects.tsx b/src/components/ParticleEffects.tsx similarity index 97% rename from src/components/DemoParticleEffects.tsx rename to src/components/ParticleEffects.tsx index ea4e94e8..3ad8f596 100644 --- a/src/components/DemoParticleEffects.tsx +++ b/src/components/ParticleEffects.tsx @@ -26,7 +26,7 @@ import { } from "three"; import { audioToUrl, textureToUrl } from "../loaders"; import { loadTexture } from "../textureUtils"; -import { setupEffectTexture } from "../demo/demoPlaybackUtils"; +import { setupEffectTexture } from "../stream/playbackUtils"; import { EmitterInstance, resolveEmitterData, @@ -37,19 +37,20 @@ import { } from "../particles/shaders"; import type { EmitterDataResolved } from "../particles/types"; import type { - DemoStreamSnapshot, - DemoStreamingPlayback, -} from "../demo/types"; + StreamSnapshot, + StreamingPlayback, +} from "../stream/types"; import { useDebug, useSettings } from "./SettingsProvider"; import { useAudio } from "./AudioContext"; import { resolveAudioProfile, playOneShotSound, getCachedAudioBuffer, - trackDemoSound, - untrackDemoSound, + getSoundGeneration, + trackSound, + untrackSound, } from "./AudioEmitter"; -import { demoEffectNow, engineStore } from "../state"; +import { effectNow, engineStore } from "../state"; // ── Constants ── @@ -707,12 +708,12 @@ function syncBuffers(active: ActiveEmitter): void { const MAX_PROJECTILE_SOUNDS = 20; -export function DemoParticleEffects({ +export function ParticleEffects({ playback, snapshotRef, }: { - playback: DemoStreamingPlayback; - snapshotRef: React.RefObject; + playback: StreamingPlayback; + snapshotRef: React.RefObject; }) { const { debugMode } = useDebug(); const { audioEnabled } = useSettings(); @@ -857,7 +858,7 @@ export function DemoParticleEffects({ material: sphereMat, label: labelSprite, labelMaterial: labelMat, - creationTime: demoEffectNow(), + creationTime: effectNow(), lifetimeMS: Math.max(resolved.lifetimeMS, 3000), targetRadius: radius, }); @@ -901,7 +902,7 @@ export function DemoParticleEffects({ geometry: geo, bottomGeometry: bottomGeo, material: mat, - creationTime: demoEffectNow(), + creationTime: effectNow(), lifetimeMS: swData.lifetimeMS, data: swData, radius: 0, @@ -1087,7 +1088,7 @@ export function DemoParticleEffects({ // ── Update explosion wireframe spheres ── const spheres = activeExplosionSpheresRef.current; - const now = demoEffectNow(); + const now = effectNow(); for (let i = spheres.length - 1; i >= 0; i--) { const sphere = spheres[i]; const elapsed = now - sphere.creationTime; @@ -1230,8 +1231,10 @@ export function DemoParticleEffects({ try { const url = audioToUrl(resolved.filename); + const gen = getSoundGeneration(); getCachedAudioBuffer(url, audioLoader, (buffer) => { - // Entity may have despawned by the time the buffer loads. + // Recording may have been unloaded by the time the buffer loads. + if (gen !== getSoundGeneration()) return; if (!currentEntityIds.has(entity.id)) return; if (projSounds.has(entity.id)) return; const group = groupRef.current; @@ -1252,7 +1255,7 @@ export function DemoParticleEffects({ entity.position![0], ); group.add(sound); - trackDemoSound(sound); + trackSound(sound); sound.play(); projSounds.set(entity.id, sound); }); @@ -1264,9 +1267,9 @@ export function DemoParticleEffects({ // Despawn: stop sounds for entities no longer present. for (const [entityId, sound] of projSounds) { if (!currentEntityIds.has(entityId)) { - untrackDemoSound(sound); - try { sound.stop(); } catch {} - sound.disconnect(); + untrackSound(sound); + try { sound.stop(); } catch { /* already stopped */ } + try { sound.disconnect(); } catch { /* already disconnected */ } groupRef.current?.remove(sound); projSounds.delete(entityId); } @@ -1356,9 +1359,9 @@ export function DemoParticleEffects({ trailEntitiesRef.current.clear(); // Clean up projectile sounds. for (const [, sound] of projectileSoundsRef.current) { - untrackDemoSound(sound); - try { sound.stop(); } catch {} - sound.disconnect(); + untrackSound(sound); + try { sound.stop(); } catch { /* already stopped */ } + try { sound.disconnect(); } catch { /* already disconnected */ } if (group) group.remove(sound); } projectileSoundsRef.current.clear(); diff --git a/src/components/PlayerHUD.tsx b/src/components/PlayerHUD.tsx index 8b5184a6..6589e83e 100644 --- a/src/components/PlayerHUD.tsx +++ b/src/components/PlayerHUD.tsx @@ -1,13 +1,13 @@ -import { useDemoRecording } from "./DemoProvider"; +import { useRecording } from "./RecordingProvider"; import { useEngineSelector } from "../state"; import { textureToUrl } from "../loaders"; import type { ChatSegment, - DemoChatMessage, - DemoStreamEntity, + ChatMessage, + StreamEntity, TeamScore, WeaponsHudSlot, -} from "../demo/types"; +} from "../stream/types"; import styles from "./PlayerHUD.module.css"; // ── Compass ── const COMPASS_URL = textureToUrl("gui/hud_new_compass"); @@ -64,7 +64,7 @@ function Reticle() { if (!snap || snap.camera?.mode !== "first-person") return undefined; const ctrl = snap.controlPlayerGhostId; if (!ctrl) return undefined; - return snap.entities.find((e: DemoStreamEntity) => e.id === ctrl) + return snap.entities.find((e: StreamEntity) => e.id === ctrl) ?.weaponShape; }); if (weaponShape === undefined) return null; @@ -257,7 +257,7 @@ const CHAT_COLOR_CLASSES: Record = { function segmentColorClass(colorCode: number): string { return CHAT_COLOR_CLASSES[colorCode] ?? CHAT_COLOR_CLASSES[0]; } -function chatColorClass(msg: DemoChatMessage): string { +function chatColorClass(msg: ChatMessage): string { if (msg.colorCode != null && CHAT_COLOR_CLASSES[msg.colorCode]) { return CHAT_COLOR_CLASSES[msg.colorCode]; } @@ -278,12 +278,12 @@ function ChatWindow() { const fadeDuration = 1.5; const cutoff = timeSec - (fadeStart + fadeDuration); const visible = messages.filter( - (m: DemoChatMessage) => m.timeSec > cutoff && m.text.trim() !== "", + (m: ChatMessage) => m.timeSec > cutoff && m.text.trim() !== "", ); if (!visible.length) return null; return (
- {visible.map((msg: DemoChatMessage, i: number) => { + {visible.map((msg: ChatMessage, i: number) => { const age = timeSec - msg.timeSec; const opacity = age <= fadeStart @@ -435,7 +435,7 @@ function PackAndInventoryHUD() { } // ── Main HUD ── export function PlayerHUD() { - const recording = useDemoRecording(); + const recording = useRecording(); const streamSnapshot = useEngineSelector( (state) => state.playback.streamSnapshot, ); diff --git a/src/components/DemoPlayerModel.tsx b/src/components/PlayerModel.tsx similarity index 73% rename from src/components/DemoPlayerModel.tsx rename to src/components/PlayerModel.tsx index b5f3c8d3..1233c515 100644 --- a/src/components/DemoPlayerModel.tsx +++ b/src/components/PlayerModel.tsx @@ -1,4 +1,4 @@ -import { Suspense, useEffect, useMemo, useRef } from "react"; +import { Suspense, useEffect, useMemo, useRef, useState } from "react"; import type { MutableRefObject } from "react"; import { useFrame } from "@react-three/fiber"; import { @@ -21,25 +21,27 @@ import { getKeyframeAtTime, getPosedNodeTransform, processShapeScene, -} from "../demo/demoPlaybackUtils"; -import { pickMoveAnimation } from "../demo/playerAnimation"; -import { WeaponImageStateMachine } from "../demo/weaponStateMachine"; -import type { WeaponAnimState } from "../demo/weaponStateMachine"; +} from "../stream/playbackUtils"; +import { pickMoveAnimation } from "../stream/playerAnimation"; +import { WeaponImageStateMachine } from "../stream/weaponStateMachine"; +import type { WeaponAnimState } from "../stream/weaponStateMachine"; import { getAliasedActions } from "../torqueScript/shapeConstructor"; import { useStaticShape } from "./GenericShape"; -import { ShapeErrorBoundary } from "./DemoEntities"; +import { ShapeErrorBoundary } from "./EntityScene"; import { useAudio } from "./AudioContext"; import { resolveAudioProfile, playOneShotSound, getCachedAudioBuffer, - trackDemoSound, - untrackDemoSound, + getSoundGeneration, + trackSound, + untrackSound, } from "./AudioEmitter"; import { audioToUrl } from "../loaders"; import { useSettings } from "./SettingsProvider"; import { useEngineStoreApi, useEngineSelector } from "../state"; -import type { DemoEntity } from "../demo/types"; +import { streamPlaybackStore } from "../state/streamPlaybackStore"; +import type { PlayerEntity } from "../state/gameEntityTypes"; /** * Map weapon shape to the arm blend animation (armThread). @@ -54,6 +56,72 @@ function getArmThread(weaponShape: string | undefined): string { return "lookde"; } +/** Number of table actions in the engine's ActionAnimationList. */ +const NUM_TABLE_ACTION_ANIMS = 7; + +/** Table action names in engine order (indices 0-6). */ +const TABLE_ACTION_NAMES = ["root", "run", "back", "side", "fall", "jump", "land"]; + + +interface ActionAnimEntry { + /** GLB clip name (lowercase, e.g. "diehead"). */ + clipName: string; + /** Engine alias (lowercase, e.g. "death1"). */ + alias: string; +} + +/** + * Build the engine's action index -> animation entry mapping from a + * TSShapeConstructor's sequence entries (e.g. `"heavy_male_root.dsq root"`). + * + * The engine builds its action list as: + * 1. Table actions (0-6): found by searching for aliased names (root, run, etc.) + * 2. Non-table actions (7+): remaining sequences in TSShapeConstructor order. + */ +function buildActionAnimMap( + sequences: string[], + shapePrefix: string, +): Map { + const result = new Map(); + + // Parse each sequence entry into { clipName, alias }. + const parsed: Array<{ clipName: string; alias: string }> = []; + for (const entry of sequences) { + const spaceIdx = entry.indexOf(" "); + if (spaceIdx === -1) continue; + const dsqFile = entry.slice(0, spaceIdx).toLowerCase(); + const alias = entry.slice(spaceIdx + 1).trim().toLowerCase(); + if (!alias || !dsqFile.startsWith(shapePrefix) || !dsqFile.endsWith(".dsq")) + continue; + const clipName = dsqFile.slice(shapePrefix.length, -4); + if (clipName) parsed.push({ clipName, alias }); + } + + // Find which parsed entries are table actions (by alias name). + const tableEntryIndices = new Set(); + for (let i = 0; i < TABLE_ACTION_NAMES.length; i++) { + const name = TABLE_ACTION_NAMES[i]; + for (let pi = 0; pi < parsed.length; pi++) { + if (parsed[pi].alias === name) { + tableEntryIndices.add(pi); + result.set(i, parsed[pi]); + break; + } + } + } + + // Non-table actions: remaining entries in TSShapeConstructor order. + let actionIdx = NUM_TABLE_ACTION_ANIMS; + for (let pi = 0; pi < parsed.length; pi++) { + if (!tableEntryIndices.has(pi)) { + result.set(actionIdx, parsed[pi]); + actionIdx++; + } + } + + return result; +} + /** Stop, disconnect, and remove a looping PositionalAudio from its parent. */ function stopLoopingSound( soundRef: React.MutableRefObject, @@ -62,9 +130,9 @@ function stopLoopingSound( ) { const sound = soundRef.current; if (!sound) return; - untrackDemoSound(sound); - try { sound.stop(); } catch {} - sound.disconnect(); + untrackSound(sound); + try { sound.stop(); } catch { /* already stopped */ } + try { sound.disconnect(); } catch { /* already disconnected */ } parent?.remove(sound); soundRef.current = null; stateRef.current = -1; @@ -78,19 +146,14 @@ function stopLoopingSound( * (Root, Forward, Back, Side, Fall) selected from the keyframe velocity data. * Weapon is attached to the animated Mount0 bone. */ -export function DemoPlayerModel({ - entity, - timeRef, -}: { - entity: DemoEntity; - timeRef: MutableRefObject; -}) { +export function PlayerModel({ entity }: { entity: PlayerEntity }) { const engineStore = useEngineStoreApi(); - const gltf = useStaticShape(entity.dataBlock!); + const shapeName = entity.shapeName ?? entity.dataBlock; + const gltf = useStaticShape(shapeName!); const shapeAliases = useEngineSelector((state) => { - const shapeName = entity.dataBlock?.toLowerCase(); - return shapeName - ? state.runtime.sequenceAliases.get(shapeName) + const sn = shapeName?.toLowerCase(); + return sn + ? state.runtime.sequenceAliases.get(sn) : undefined; }); @@ -129,6 +192,21 @@ export function DemoPlayerModel({ const activeArmRef = useRef(null); const currentAnimRef = useRef({ name: "root", timeScale: 1 }); const isDeadRef = useRef(false); + // Action animation (taunts, celebrations, etc.) tracking. + const actionAnimRef = useRef(undefined); + + // Build action index -> animation clip name mapping from TSShapeConstructor. + const actionAnimMap = useMemo(() => { + const playback = engineStore.getState().playback; + const sp = playback.recording?.streamingPlayback; + const sn = shapeName?.toLowerCase(); + if (!sp || !sn) return new Map(); + const sequences = sp.getShapeConstructorSequences(sn); + if (!sequences) return new Map(); + // Derive prefix: "heavy_male.dts" -> "heavy_male_" + const stem = sn.replace(/\.dts$/i, ""); + return buildActionAnimMap(sequences, stem + "_"); + }, [engineStore, shapeName]); useEffect(() => { const actions = getAliasedActions(gltf.animations, mixer, shapeAliases); @@ -223,49 +301,64 @@ export function DemoPlayerModel({ useEffect(() => { const cleanups: (() => void)[] = []; for (const { mesh, initialize } of iflInitializers) { - initialize(mesh, () => timeRef.current) + initialize(mesh, () => streamPlaybackStore.getState().time) .then((dispose) => cleanups.push(dispose)) .catch(() => {}); } return () => cleanups.forEach((fn) => fn()); }, [iflInitializers]); + // Track weaponShape changes. The entity is mutated in-place by the + // streaming layer (no React re-render), so we sync it in useFrame. + const weaponShapeRef = useRef(entity.weaponShape); + const [currentWeaponShape, setCurrentWeaponShape] = useState( + entity.weaponShape, + ); + // Per-frame animation selection and mixer update. useFrame((_, delta) => { + if (entity.weaponShape !== weaponShapeRef.current) { + weaponShapeRef.current = entity.weaponShape; + setCurrentWeaponShape(entity.weaponShape); + } const playback = engineStore.getState().playback; const isPlaying = playback.status === "playing"; - const time = timeRef.current; + const time = streamPlaybackStore.getState().time; // Resolve velocity at current playback time. - const kf = getKeyframeAtTime(entity.keyframes, time); + const kf = getKeyframeAtTime(entity.keyframes ?? [], time); const isDead = kf?.damageState != null && kf.damageState >= 1; const actions = animActionsRef.current; - // Alive→Dead transition: play a random death animation. + // Alive->Dead transition: play the server-specified death animation. if (isDead && !isDeadRef.current) { isDeadRef.current = true; - const deathClips = [...actions.keys()].filter((k) => - k.startsWith("death"), - ); - if (deathClips.length > 0) { - const pick = deathClips[Math.floor(Math.random() * deathClips.length)]; - const prevAction = actions.get( - currentAnimRef.current.name.toLowerCase(), - ); - if (prevAction) prevAction.fadeOut(ANIM_TRANSITION_TIME); + // The server sends the death animation as an actionAnim index. + const deathEntry = kf.actionAnim != null + ? actionAnimMap.get(kf.actionAnim) + : undefined; + if (deathEntry) { + const deathAction = actions.get(deathEntry.clipName); + if (deathAction) { + const prevAction = actions.get( + currentAnimRef.current.name.toLowerCase(), + ); + if (prevAction) prevAction.fadeOut(ANIM_TRANSITION_TIME); - const deathAction = actions.get(pick)!; - deathAction.setLoop(LoopOnce, 1); - deathAction.clampWhenFinished = true; - deathAction.reset().fadeIn(ANIM_TRANSITION_TIME).play(); - currentAnimRef.current = { name: pick, timeScale: 1 }; + deathAction.setLoop(LoopOnce, 1); + deathAction.clampWhenFinished = true; + deathAction.reset().fadeIn(ANIM_TRANSITION_TIME).play(); + currentAnimRef.current = { name: deathEntry.clipName, timeScale: 1 }; + actionAnimRef.current = kf.actionAnim; + } } } - // Dead→Alive transition: stop death animation, let movement resume. + // Dead->Alive transition: stop death animation, let movement resume. if (!isDead && isDeadRef.current) { isDeadRef.current = false; + actionAnimRef.current = undefined; const deathAction = actions.get(currentAnimRef.current.name.toLowerCase()); if (deathAction) { @@ -279,8 +372,61 @@ export function DemoPlayerModel({ if (rootAction) rootAction.reset().play(); } - // Movement animation selection (skip while dead). - if (!isDeadRef.current) { + // Action animation (taunts, celebrations, etc.). + // Non-table actions (index >= 7) override movement animation. + const actionAnim = kf?.actionAnim; + const prevActionAnim = actionAnimRef.current; + if (!isDeadRef.current && actionAnim !== prevActionAnim) { + actionAnimRef.current = actionAnim; + const isNonTableAction = actionAnim != null && actionAnim >= NUM_TABLE_ACTION_ANIMS; + const wasNonTableAction = prevActionAnim != null && prevActionAnim >= NUM_TABLE_ACTION_ANIMS; + + if (isNonTableAction) { + // Start or change action animation. + const entry = actionAnimMap.get(actionAnim); + if (entry) { + const actionAction = actions.get(entry.clipName); + if (actionAction) { + const prevAction = actions.get(currentAnimRef.current.name.toLowerCase()); + if (prevAction) prevAction.fadeOut(ANIM_TRANSITION_TIME); + actionAction.setLoop(LoopOnce, 1); + actionAction.clampWhenFinished = true; + actionAction.reset().fadeIn(ANIM_TRANSITION_TIME).play(); + currentAnimRef.current = { name: entry.clipName, timeScale: 1 }; + } + } + } else if (wasNonTableAction) { + // Action ended -- stop the action clip and resume movement. + const prevEntry = actionAnimMap.get(prevActionAnim); + if (prevEntry) { + const prevAction = actions.get(prevEntry.clipName); + if (prevAction) { + prevAction.fadeOut(ANIM_TRANSITION_TIME); + prevAction.setLoop(LoopRepeat, Infinity); + prevAction.clampWhenFinished = false; + } + } + currentAnimRef.current = { name: "root", timeScale: 1 }; + const rootAction = actions.get("root"); + if (rootAction) rootAction.reset().fadeIn(ANIM_TRANSITION_TIME).play(); + } + } + + // If atEnd, clamp the action animation at its final frame. + if (actionAnim != null && actionAnim >= NUM_TABLE_ACTION_ANIMS && kf?.actionAtEnd) { + const entry = actionAnimMap.get(actionAnim); + if (entry) { + const actionAction = actions.get(entry.clipName); + if (actionAction) { + actionAction.paused = true; + } + } + } + + // Movement animation selection (skip while dead or playing action anim). + const playingActionAnim = actionAnimRef.current != null && + actionAnimRef.current >= NUM_TABLE_ACTION_ANIMS; + if (!isDeadRef.current && !playingActionAnim) { const anim = pickMoveAnimation( kf?.velocity, kf?.rotation ?? [0, 0, 0, 1], @@ -361,13 +507,13 @@ export function DemoPlayerModel({ - {entity.weaponShape && mount0 && ( - + {currentWeaponShape && mount0 && ( + @@ -377,7 +523,7 @@ export function DemoPlayerModel({ } /** - * Build a DTS sequence-index → name lookup from GLB metadata. + * Build a DTS sequence-index -> name lookup from GLB metadata. * Weapon GLBs include `dts_sequence_names` in scene extras, providing the * original DTS sequence ordering that datablock state indices reference. */ @@ -407,15 +553,15 @@ function buildSeqIndexToName( */ function AnimatedWeaponModel({ entity, + weaponShape, mount0, - timeRef, }: { - entity: DemoEntity; + entity: PlayerEntity; + weaponShape: string; mount0: Object3D; - timeRef: MutableRefObject; }) { const engineStore = useEngineStoreApi(); - const weaponGltf = useStaticShape(entity.weaponShape!); + const weaponGltf = useStaticShape(weaponShape); // Clone weapon with skeleton bindings, create dedicated mixer. const { weaponClone, weaponMixer, seqIndexToName, visNodesBySequence, weaponIflInitializers } = @@ -501,7 +647,7 @@ function AnimatedWeaponModel({ useEffect(() => { const cleanups: (() => void)[] = []; for (const { mesh, initialize } of weaponIflInitializers) { - initialize(mesh, () => timeRef.current) + initialize(mesh, () => streamPlaybackStore.getState().time) .then((dispose) => cleanups.push(dispose)) .catch(() => {}); } @@ -607,8 +753,10 @@ function AnimatedWeaponModel({ if (!loopingSoundRef.current) { try { const url = audioToUrl(resolved.filename); + const gen = getSoundGeneration(); getCachedAudioBuffer(url, audioLoader, (buffer) => { // Guard: state may have changed by the time buffer loads. + if (gen !== getSoundGeneration()) return; if (loopingSoundRef.current) return; // Read live state index (not the closure-captured one). const currentIdx = sm.stateIndex; @@ -622,12 +770,12 @@ function AnimatedWeaponModel({ sound.setPlaybackRate(playback.rate); sound.setLoop(true); weaponClone.add(sound); - trackDemoSound(sound); + trackSound(sound); sound.play(); loopingSoundRef.current = sound; loopingSoundStateRef.current = currentIdx; }); - } catch {} + } catch { /* expected */ } } } else { playOneShotSound( @@ -702,7 +850,7 @@ function applyWeaponAnim( } if (!targetName) { - // No sequence for this state — stop current animation. + // No sequence for this state -- stop current animation. if (currentName) { const prev = actions.get(currentName); if (prev) prev.fadeOut(ANIM_TRANSITION_TIME); @@ -768,8 +916,8 @@ export function PlayerEyeOffset({ const eye = getPosedNodeTransform(gltf.scene, gltf.animations, "Eye"); if (eye) { // Convert from GLB space to entity space via ShapeRenderer's R90: - // R90 maps GLB (x,y,z) → entity (z, y, -x). - // This gives ~(0.169, 2.122, 0.0) — 17cm forward and 2.12m up. + // R90 maps GLB (x,y,z) -> entity (z, y, -x). + // This gives ~(0.169, 2.122, 0.0) -- 17cm forward and 2.12m up. eyeOffsetRef.current.set(eye.position.z, eye.position.y, -eye.position.x); } else { eyeOffsetRef.current.set(0, DEFAULT_EYE_HEIGHT, 0); diff --git a/src/components/PlayerNameplate.tsx b/src/components/PlayerNameplate.tsx index cef594a0..94bda529 100644 --- a/src/components/PlayerNameplate.tsx +++ b/src/components/PlayerNameplate.tsx @@ -1,12 +1,12 @@ import { useMemo, useRef, useState } from "react"; -import type { MutableRefObject } from "react"; import { useFrame, useThree } from "@react-three/fiber"; import { Html } from "@react-three/drei"; import { Box3, Object3D, Vector3 } from "three"; -import { getKeyframeAtTime } from "../demo/demoPlaybackUtils"; +import { getKeyframeAtTime } from "../stream/playbackUtils"; import { textureToUrl } from "../loaders"; import { useStaticShape } from "./GenericShape"; -import type { DemoEntity } from "../demo/types"; +import { streamPlaybackStore } from "../state/streamPlaybackStore"; +import type { PlayerEntity } from "../state/gameEntityTypes"; import styles from "./PlayerNameplate.module.css"; /** Max distance at which nameplates are visible. */ @@ -27,14 +27,8 @@ const _tmpVec = new Vector3(); * Floating nameplate above a player model showing the entity name and a health * bar. Fades out with distance. */ -export function PlayerNameplate({ - entity, - timeRef, -}: { - entity: DemoEntity; - timeRef: MutableRefObject; -}) { - const gltf = useStaticShape(entity.dataBlock!); +export function PlayerNameplate({ entity }: { entity: PlayerEntity }) { + const gltf = useStaticShape((entity.shapeName ?? entity.dataBlock)!); const { camera } = useThree(); const groupRef = useRef(null); const iffContainerRef = useRef(null); @@ -46,9 +40,11 @@ export function PlayerNameplate({ const displayName = useMemo(() => { if (entity.playerName) return entity.playerName; if (typeof entity.id === "string") { - return entity.id.replace(/^player_/, "Player "); + const m = entity.id.match(/\d+/); + if (m) return ``; + return entity.id; } - return `Player ${entity.id}`; + return ""; }, [entity.id, entity.playerName]); // Derive IFF height from the shape's bounding box. @@ -58,9 +54,10 @@ export function PlayerNameplate({ }, [gltf.scene]); // Check whether this entity has any health data at all. + const keyframes = entity.keyframes ?? []; const hasHealthData = useMemo( - () => entity.keyframes.some((kf) => kf.health != null), - [entity.keyframes], + () => keyframes.some((kf) => kf.health != null), + [keyframes], ); useFrame(() => { @@ -87,7 +84,7 @@ export function PlayerNameplate({ if (!shouldBeVisible) return; // Hide nameplate when player is dead. - const kf = getKeyframeAtTime(entity.keyframes, timeRef.current); + const kf = getKeyframeAtTime(keyframes, streamPlaybackStore.getState().time); const health = kf?.health ?? 1; if (kf?.damageState != null && kf.damageState >= 1) { if (iffContainerRef.current) iffContainerRef.current.style.opacity = "0"; @@ -116,7 +113,7 @@ export function PlayerNameplate({ entity.iffColor.r > entity.iffColor.g ? IFF_ENEMY_URL : IFF_FRIENDLY_URL; - if (iffImgRef.current.src !== url) { + if (iffImgRef.current.getAttribute("src") !== url) { iffImgRef.current.src = url; } } diff --git a/src/components/DemoProjectiles.tsx b/src/components/Projectiles.tsx similarity index 93% rename from src/components/DemoProjectiles.tsx rename to src/components/Projectiles.tsx index 1ab11df5..f857d522 100644 --- a/src/components/DemoProjectiles.tsx +++ b/src/components/Projectiles.tsx @@ -14,9 +14,9 @@ import { setupEffectTexture, torqueVecToThree, setQuaternionFromDir, -} from "../demo/demoPlaybackUtils"; +} from "../stream/playbackUtils"; import { textureToUrl } from "../loaders"; -import type { DemoEntity, DemoTracerVisual, DemoSpriteVisual } from "../demo/types"; +import type { TracerVisual, SpriteVisual } from "../stream/types"; const _tracerDir = new Vector3(); const _tracerDirFromCam = new Vector3(); @@ -26,7 +26,7 @@ const _tracerEnd = new Vector3(); const _tracerWorldPos = new Vector3(); const _upY = new Vector3(0, 1, 0); -export function DemoSpriteProjectile({ visual }: { visual: DemoSpriteVisual }) { +export function SpriteProjectile({ visual }: { visual: SpriteVisual }) { const url = textureToUrl(visual.texture); const texture = useTexture(url, (tex) => { const t = Array.isArray(tex) ? tex[0] : tex; @@ -55,12 +55,12 @@ export function DemoSpriteProjectile({ visual }: { visual: DemoSpriteVisual }) { ); } -export function DemoTracerProjectile({ +export function TracerProjectile({ entity, visual, }: { - entity: DemoEntity; - visual: DemoTracerVisual; + entity: { keyframes?: Array<{ position?: [number, number, number]; velocity?: [number, number, number] }>; direction?: [number, number, number] }; + visual: TracerVisual; }) { const tracerRef = useRef(null); const tracerPosRef = useRef(null); @@ -88,7 +88,7 @@ export function DemoTracerProjectile({ const posAttr = tracerPosRef.current; if (!tracerMesh || !posAttr) return; - const kf = entity.keyframes[0]; + const kf = entity.keyframes?.[0]; const pos = kf?.position; const direction = entity.direction ?? kf?.velocity; if (!pos || !direction) { diff --git a/src/components/DemoProvider.tsx b/src/components/RecordingProvider.tsx similarity index 65% rename from src/components/DemoProvider.tsx rename to src/components/RecordingProvider.tsx index cbb74edb..5c865d26 100644 --- a/src/components/DemoProvider.tsx +++ b/src/components/RecordingProvider.tsx @@ -1,45 +1,45 @@ import { useCallback, type ReactNode } from "react"; -import type { DemoRecording } from "../demo/types"; +import type { StreamRecording } from "../stream/types"; import { useEngineSelector } from "../state"; -export function DemoProvider({ children }: { children: ReactNode }) { +export function RecordingProvider({ children }: { children: ReactNode }) { return <>{children}; } -export function useDemoRecording(): DemoRecording | null { +export function useRecording(): StreamRecording | null { return useEngineSelector((state) => state.playback.recording); } -export function useDemoIsPlaying(): boolean { +export function useIsPlaying(): boolean { return useEngineSelector((state) => state.playback.status === "playing"); } -export function useDemoCurrentTime(): number { +export function useCurrentTime(): number { return useEngineSelector((state) => state.playback.timeMs / 1000); } -export function useDemoDuration(): number { +export function useDuration(): number { return useEngineSelector((state) => state.playback.durationMs / 1000); } -export function useDemoSpeed(): number { +export function useSpeed(): number { return useEngineSelector((state) => state.playback.rate); } -export function useDemoActions() { - const recording = useDemoRecording(); - const setDemoRecording = useEngineSelector((state) => state.setDemoRecording); +export function usePlaybackActions() { + const recording = useRecording(); + const setRecording = useEngineSelector((state) => state.setRecording); const setPlaybackStatus = useEngineSelector( (state) => state.setPlaybackStatus, ); const setPlaybackTime = useEngineSelector((state) => state.setPlaybackTime); const setPlaybackRate = useEngineSelector((state) => state.setPlaybackRate); - const setRecording = useCallback( - (recording: DemoRecording | null) => { - setDemoRecording(recording); + const setRec = useCallback( + (recording: StreamRecording | null) => { + setRecording(recording); }, - [setDemoRecording], + [setRecording], ); const play = useCallback(() => { @@ -66,7 +66,7 @@ export function useDemoActions() { ); return { - setRecording, + setRecording: setRec, play, pause, seek, diff --git a/src/components/RuntimeProvider.tsx b/src/components/RuntimeProvider.tsx index 26e38679..18dd0c35 100644 --- a/src/components/RuntimeProvider.tsx +++ b/src/components/RuntimeProvider.tsx @@ -1,18 +1,18 @@ import { createContext, ReactNode, useContext } from "react"; import type { TorqueRuntime } from "../torqueScript"; -import { TickProvider } from "./TickProvider"; + const RuntimeContext = createContext(null); -interface RuntimeProviderProps { +export interface RuntimeProviderProps { runtime: TorqueRuntime; - children: ReactNode; + children?: ReactNode; } export function RuntimeProvider({ runtime, children }: RuntimeProviderProps) { return ( - {children} + {children} ); } diff --git a/src/components/SceneLighting.tsx b/src/components/SceneLighting.tsx new file mode 100644 index 00000000..d4bc8881 --- /dev/null +++ b/src/components/SceneLighting.tsx @@ -0,0 +1,81 @@ +import { useEffect, useMemo } from "react"; +import { Color, Vector3 } from "three"; +import { useSceneSun } from "../state/gameEntityStore"; +import { torqueToThree } from "../scene/coordinates"; +import { updateGlobalSunUniforms } from "../globalSunUniforms"; + +/** + * Renders scene-global lights (directional sun + ambient) derived from the + * Sun entity in the game entity store. Rendered outside EntityScene so that + * lights are siblings of the scene graph root rather than buried inside a + * group — works around r3f reconciliation issues where lights added inside + * dynamically-populated groups sometimes fail to illuminate existing meshes. + */ +export function SceneLighting() { + const sunData = useSceneSun(); + + if (!sunData) { + // Fallback lighting when no Sun entity exists yet + return ; + } + + return ; +} + +function SunLighting({ sunData }: { sunData: NonNullable> }) { + const direction = useMemo(() => { + const [x, y, z] = torqueToThree(sunData.direction); + const len = Math.sqrt(x * x + y * y + z * z); + return new Vector3(x / len, y / len, z / len); + }, [sunData.direction]); + + const lightPosition = useMemo(() => { + const distance = 5000; + return new Vector3( + -direction.x * distance, + -direction.y * distance, + -direction.z * distance, + ); + }, [direction]); + + const color = useMemo( + () => new Color(sunData.color.r, sunData.color.g, sunData.color.b), + [sunData.color], + ); + + const ambient = useMemo( + () => new Color(sunData.ambient.r, sunData.ambient.g, sunData.ambient.b), + [sunData.ambient], + ); + + const sunLightPointsDown = direction.y < 0; + + useEffect(() => { + updateGlobalSunUniforms(sunLightPointsDown); + }, [sunLightPointsDown]); + + const shadowCameraSize = 4096; + + return ( + <> + + + + ); +} diff --git a/src/components/ServerBrowser.module.css b/src/components/ServerBrowser.module.css new file mode 100644 index 00000000..35ceed52 --- /dev/null +++ b/src/components/ServerBrowser.module.css @@ -0,0 +1,178 @@ +.Dialog { + position: relative; + width: 860px; + height: 560px; + max-width: calc(100dvw - 40px); + max-height: calc(100dvh - 40px); + display: grid; + grid-template-columns: 100%; + grid-template-rows: auto 1fr auto; + background: rgba(20, 37, 38, 0.8); + border: 1px solid rgba(65, 131, 139, 0.6); + border-radius: 4px; + box-shadow: + 0 0 50px rgba(0, 0, 0, 0.4), + inset 0 0 60px rgba(1, 7, 13, 0.6); + color: #b0d5c9; + font-size: 14px; + line-height: 1.5; + overflow: hidden; + outline: none; + user-select: text; + -webkit-touch-callout: default; +} + +.Overlay { + position: fixed; + inset: 0; + background: rgba(0, 0, 0, 0.7); + z-index: 10; + display: flex; + align-items: center; + justify-content: center; + padding: 20px; +} + +.Header { + display: flex; + align-items: center; + gap: 12px; + padding: 12px 16px 10px; + border-bottom: 1px solid rgba(0, 190, 220, 0.25); +} + +.Title { + font-size: 18px; + font-weight: 500; + color: #7dffff; + margin: 0; + text-shadow: 0 1px 6px rgba(0, 0, 0, 0.4); + flex: 1; +} + +.RefreshButton { + composes: DialogButton from "./DialogButton.module.css"; + padding: 3px 14px; + font-size: 12px; +} + +.ServerCount { + font-size: 12px; + color: rgba(201, 220, 216, 0.4); +} + +.TableWrapper { + overflow-y: auto; + min-height: 0; +} + +.Table { + width: 100%; + border-collapse: collapse; + font-size: 13px; +} + +.Table th { + position: sticky; + top: 0; + background: rgba(10, 25, 26, 0.95); + padding: 6px 12px; + text-align: left; + cursor: pointer; + user-select: none; + border-bottom: 1px solid rgba(0, 190, 220, 0.2); + font-weight: 500; + font-size: 11px; + letter-spacing: 0.04em; + text-transform: uppercase; + color: rgba(125, 255, 255, 0.6); +} + +.Table th:hover { + color: #7dffff; +} + +.Table th:nth-child(2), +.Table td:nth-child(2), +.Table th:nth-child(3), +.Table td:nth-child(3) { + text-align: right; +} + +.Table td { + padding: 3px 12px; + border-bottom: 1px solid rgba(255, 255, 255, 0.04); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 340px; + font-weight: 500; +} + +.Table tbody tr { + cursor: pointer; +} + +.Table tbody tr:hover { + background: rgba(65, 131, 139, 0.12); +} + +.Selected { + background: rgba(93, 255, 225, 0.9) !important; + color: #1e2828; +} + +.PasswordIcon { + color: rgba(255, 200, 60, 0.6); + margin-right: 4px; + font-size: 11px; +} + +.Empty { + text-align: center; + color: rgba(201, 220, 216, 0.3); + padding: 32px 12px !important; + font-style: italic; +} + +.Footer { + display: flex; + align-items: center; + gap: 16px; + padding: 10px 12px; + border-top: 1px solid rgba(0, 190, 220, 0.25); + background: rgba(2, 20, 21, 0.7); + flex-shrink: 0; +} + +.JoinButton { + composes: DialogButton from "./DialogButton.module.css"; +} + +.CloseButton { + composes: Secondary from "./DialogButton.module.css"; +} + +.Hint { + font-size: 12px; + color: rgba(201, 220, 216, 0.3); + margin-left: auto; +} + +@media (max-width: 719px) { + .Dialog { + width: 100%; + height: 100%; + max-width: 100dvw; + max-height: 100dvh; + border-radius: 0; + } + + .Hint { + display: none; + } + + .Table td { + max-width: 200px; + } +} diff --git a/src/components/ServerBrowser.tsx b/src/components/ServerBrowser.tsx new file mode 100644 index 00000000..456386bd --- /dev/null +++ b/src/components/ServerBrowser.tsx @@ -0,0 +1,194 @@ +import { useState, useEffect, useCallback, useRef, useMemo } from "react"; +import type { ServerInfo } from "../../relay/types"; +import styles from "./ServerBrowser.module.css"; +export function ServerBrowser({ + open, + onClose, + servers, + loading, + onRefresh, + onJoin, + wsPing, +}: { + open: boolean; + onClose: () => void; + servers: ServerInfo[]; + loading: boolean; + onRefresh: () => void; + onJoin: (address: string) => void; + /** Browser↔relay RTT to add to server pings for effective latency. */ + wsPing?: number | null; +}) { + const [selectedAddress, setSelectedAddress] = useState(null); + const [sortKey, setSortKey] = useState("ping"); + const [sortDir, setSortDir] = useState<"asc" | "desc">("asc"); + const dialogRef = useRef(null); + const onRefreshRef = useRef(onRefresh); + onRefreshRef.current = onRefresh; + const didAutoRefreshRef = useRef(false); + useEffect(() => { + if (open) { + dialogRef.current?.focus(); + try { + document.exitPointerLock(); + } catch { + /* expected */ + } + } else { + didAutoRefreshRef.current = false; + } + }, [open]); + // Refresh on open if no servers cached + useEffect(() => { + if (open && servers.length === 0 && !didAutoRefreshRef.current) { + didAutoRefreshRef.current = true; + onRefreshRef.current(); + } + }, [open]); // eslint-disable-line react-hooks/exhaustive-deps + // Block keyboard events from reaching Three.js while open + useEffect(() => { + if (!open) return; + const handleKeyDown = (e: KeyboardEvent) => { + e.stopPropagation(); + if (e.key === "Escape") { + onClose(); + } + }; + window.addEventListener("keydown", handleKeyDown, true); + return () => window.removeEventListener("keydown", handleKeyDown, true); + }, [open, onClose]); + const handleSort = useCallback( + (key: keyof ServerInfo) => { + if (sortKey === key) { + setSortDir((d) => (d === "asc" ? "desc" : "asc")); + } else { + setSortKey(key); + setSortDir("desc"); + } + }, + [sortKey], + ); + + const sorted = useMemo(() => { + return [...servers].sort((a, b) => { + const av = a[sortKey]; + const bv = b[sortKey]; + const cmp = + typeof av === "number" && typeof bv === "number" + ? av - bv + : String(av).localeCompare(String(bv)); + return sortDir === "asc" ? cmp : -cmp; + }); + }, [servers, sortDir, sortKey]); + + const handleJoin = useCallback(() => { + if (selectedAddress) { + onJoin(selectedAddress); + onClose(); + } + }, [selectedAddress, onJoin, onClose]); + + if (!open) return null; + + return ( +
+
e.stopPropagation()} + > +
+

Server Browser

+ + {servers.length} server{servers.length !== 1 ? "s" : ""} + + +
+
+ + + + + + + + + + + + + {sorted.map((server) => ( + setSelectedAddress(server.address)} + onDoubleClick={() => { + setSelectedAddress(server.address); + onJoin(server.address); + onClose(); + }} + > + + + + + + + + ))} + {sorted.length === 0 && !loading && ( + + + + )} + {loading && sorted.length === 0 && ( + + + + )} + +
handleSort("name")}>Server Name handleSort("playerCount")}>Players handleSort("ping")}>Ping handleSort("mapName")}>Map handleSort("gameType")}>Type handleSort("mod")}>Mod
+ {server.passwordRequired && ( + 🔒 + )} + {server.name} + + {server.playerCount}/{server.maxPlayers} + + {wsPing != null + ? (server.ping + wsPing).toLocaleString() + : "\u2014"} + {server.mapName}{server.gameType}{server.mod}
+ No servers found +
+ Querying master server... +
+
+
+ + + Double-click a server to join +
+
+
+ ); +} diff --git a/src/components/ShapeInfoProvider.tsx b/src/components/ShapeInfoProvider.tsx index 10436106..73f6a2f8 100644 --- a/src/components/ShapeInfoProvider.tsx +++ b/src/components/ShapeInfoProvider.tsx @@ -19,7 +19,7 @@ export function isOrganicShape(shapeName: string): boolean { } interface ShapeInfoContextValue { - object: TorqueObject; + object?: TorqueObject; shapeName: string; type: StaticShapeType; isOrganic: boolean; @@ -41,7 +41,7 @@ export function ShapeInfoProvider({ shapeName, type, }: { - object: TorqueObject; + object?: TorqueObject; children: ReactNode; shapeName: string; type: StaticShapeType; diff --git a/src/components/DemoShapeModel.tsx b/src/components/ShapeModel.tsx similarity index 92% rename from src/components/DemoShapeModel.tsx rename to src/components/ShapeModel.tsx index 2b0da7cf..89a7c1cd 100644 --- a/src/components/DemoShapeModel.tsx +++ b/src/components/ShapeModel.tsx @@ -7,14 +7,14 @@ import { Vector3, } from "three"; import type { Group, Material } from "three"; -import { demoEffectNow, engineStore } from "../state"; +import { effectNow, engineStore } from "../state"; import * as SkeletonUtils from "three/examples/jsm/utils/SkeletonUtils.js"; import { _r90, _r90inv, getPosedNodeTransform, processShapeScene, -} from "../demo/demoPlaybackUtils"; +} from "../stream/playbackUtils"; import { loadIflAtlas, getFrameIndexForTime, @@ -27,38 +27,8 @@ import { } from "./GenericShape"; import { ShapeInfoProvider } from "./ShapeInfoProvider"; import type { TorqueObject } from "../torqueScript"; -import type { DemoThreadState, DemoStreamEntity } from "../demo/types"; -import type { DemoStreamingPlayback } from "../demo/types"; - -/** Renders a shape model for a demo entity using the existing shape pipeline. */ -export function DemoShapeModel({ - shapeName, - entityId, - threads, -}: { - shapeName: string; - entityId: number | string; - threads?: DemoThreadState[]; -}) { - const torqueObject = useMemo( - () => ({ - _class: "player", - _className: "Player", - _id: typeof entityId === "number" ? entityId : 0, - }), - [entityId], - ); - - return ( - - - - ); -} +import type { StreamEntity } from "../stream/types"; +import type { StreamingPlayback } from "../stream/types"; /** * Map weapon shape to the arm blend animation (armThread). @@ -82,7 +52,7 @@ function getArmThread(weaponShape: string | undefined): string { * The mount transform is conjugated by ShapeRenderer's 90° Y rotation: * T_mount = R90 * M0 * MP^(-1) * R90^(-1). */ -export function DemoWeaponModel({ +export function WeaponModel({ shapeName, playerShapeName, }: { @@ -92,6 +62,7 @@ export function DemoWeaponModel({ const playerGltf = useStaticShape(playerShapeName); const weaponGltf = useStaticShape(shapeName); + // eslint-disable-next-line react-hooks/preserve-manual-memoization const mountTransform = useMemo(() => { // Get Mount0 from the player's posed skeleton with arm animation applied. const armThread = getArmThread(shapeName); @@ -239,16 +210,17 @@ function interpolateSize( * Renders an explosion DTS shape using useStaticShape (shared GLTF cache) * with custom rendering for faceViewer, vis/IFL animation, and size keyframes. */ -export function DemoExplosionShape({ +export function ExplosionShape({ entity, playback, }: { - entity: DemoStreamEntity; - playback: DemoStreamingPlayback; + entity: StreamEntity; + playback: StreamingPlayback; }) { const gltf = useStaticShape(entity.dataBlock!); const groupRef = useRef(null); - const startTimeRef = useRef(demoEffectNow()); + const startTimeRef = useRef(effectNow()); + // eslint-disable-next-line react-hooks/purity const randAngleRef = useRef(Math.random() * Math.PI * 2); const iflAtlasesRef = useRef>([]); @@ -303,7 +275,7 @@ export function DemoExplosionShape({ } }); - processShapeScene(scene); + processShapeScene(scene, entity.dataBlock); // Collect vis-animated nodes keyed by sequence name. const visNodes: VisNode[] = []; @@ -400,7 +372,7 @@ export function DemoExplosionShape({ const effectDelta = playbackState.status === "playing" ? delta * playbackState.rate : 0; - const elapsed = demoEffectNow() - startTimeRef.current; + const elapsed = effectNow() - startTimeRef.current; const t = Math.min(elapsed / lifetimeMS, 1); const elapsedSec = elapsed / 1000; diff --git a/src/components/ShapeSelect.tsx b/src/components/ShapeSelect.tsx index 2077dd4c..8cd349b8 100644 --- a/src/components/ShapeSelect.tsx +++ b/src/components/ShapeSelect.tsx @@ -166,7 +166,7 @@ export function ShapeSelect({ onFocus={() => { try { document.exitPointerLock(); - } catch {} + } catch { /* expected */ } combobox.show(); }} onKeyDown={(e) => { diff --git a/src/components/SimGroup.tsx b/src/components/SimGroup.tsx deleted file mode 100644 index a1fe38de..00000000 --- a/src/components/SimGroup.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { createContext, useContext, useMemo } from "react"; -import type { TorqueObject } from "../torqueScript"; -import { SimObject } from "./SimObject"; -import { useRuntimeChildIds, useRuntimeObjectById } from "../state"; - -export type SimGroupContextType = { - object: TorqueObject; - parent: SimGroupContextType; - hasTeams: boolean; - team: null | number; -}; - -const SimGroupContext = createContext(null); - -export function useSimGroup() { - return useContext(SimGroupContext); -} - -export function SimGroup({ object }: { object: TorqueObject }) { - const liveObject = useRuntimeObjectById(object._id) ?? object; - const parent = useSimGroup(); - const childIds = useRuntimeChildIds(liveObject._id, liveObject._children ?? []); - - const simGroup: SimGroupContextType = useMemo(() => { - let team: number | null = null; - let hasTeams = false; - - if (parent && parent.hasTeams) { - hasTeams = true; - if (parent.team != null) { - team = parent.team; - } else if (liveObject._name) { - const match = liveObject._name.match(/^team(\d+)$/i); - if (match) { - team = parseInt(match[1], 10); - } - } - } else if (liveObject._name) { - hasTeams = liveObject._name.toLowerCase() === "teams"; - } - - return { - // the current SimGroup's data - object: liveObject, - // the closest ancestor of this SimGroup - parent, - // whether this is, or is the descendant of, the "Teams" SimGroup - hasTeams, - // what team this is for, when this is either a "Team" SimGroup itself, - // or a descendant of one - team, - }; - }, [liveObject, parent]); - - return ( - - {childIds.map((childId) => ( - - ))} - - ); -} diff --git a/src/components/SimObject.tsx b/src/components/SimObject.tsx deleted file mode 100644 index 915718d6..00000000 --- a/src/components/SimObject.tsx +++ /dev/null @@ -1,110 +0,0 @@ -import { lazy, Suspense, useMemo } from "react"; -import type { TorqueObject } from "../torqueScript"; -import { TerrainBlock } from "./TerrainBlock"; -import { SimGroup } from "./SimGroup"; -import { InteriorInstance } from "./InteriorInstance"; -import { Sky } from "./Sky"; -import { Sun } from "./Sun"; -import { TSStatic } from "./TSStatic"; -import { StaticShape } from "./StaticShape"; -import { Item } from "./Item"; -import { Turret } from "./Turret"; -import { WayPoint } from "./WayPoint"; -import { Camera } from "./Camera"; -import { useSettings } from "./SettingsProvider"; -import { useMission } from "./MissionContext"; -import { getProperty } from "../mission"; -import { useEngineSelector, useRuntimeObjectById } from "../state"; - -const AudioEmitter = lazy(() => - import("./AudioEmitter").then((mod) => ({ default: mod.AudioEmitter })), -); - -function ConditionalAudioEmitter(props) { - const { audioEnabled } = useSettings(); - return audioEnabled ? : null; -} - -// Not every map will have force fields. -const ForceFieldBare = lazy(() => - import("./ForceFieldBare").then((mod) => ({ default: mod.ForceFieldBare })), -); - -// Not every map will have water. -const WaterBlock = lazy(() => - import("./WaterBlock").then((mod) => ({ default: mod.WaterBlock })), -); - -const componentMap = { - AudioEmitter: ConditionalAudioEmitter, - Camera, - ForceFieldBare, - InteriorInstance, - Item, - SimGroup, - Sky, - StaticShape, - Sun, - TerrainBlock, - TSStatic, - Turret, - WaterBlock, - WayPoint, -}; - -/** - * During demo playback, these mission-authored classes are rendered from demo - * ghosts instead of the mission runtime scene tree. - */ -const demoGhostAuthoritativeClasses = new Set([ - "ForceFieldBare", - "Item", - "StaticShape", - "Turret", -]); - -interface SimObjectProps { - object?: TorqueObject; - objectId?: number; -} - -export function SimObject({ object, objectId }: SimObjectProps) { - const liveObject = useRuntimeObjectById(objectId ?? object?._id); - const resolvedObject = liveObject ?? object; - const { missionType } = useMission(); - const isDemoPlaybackActive = useEngineSelector( - (state) => state.playback.recording != null, - ); - - // FIXME: In theory we could make sure TorqueScript is calling `hide()` - // based on the mission type already, which is built-in behavior, then just - // make sure we respect the hidden/visible state here. For now do it this way. - const shouldShowObject = useMemo(() => { - if (!resolvedObject) { - return false; - } - const missionTypesList = new Set( - (getProperty(resolvedObject, "missionTypesList") ?? "") - .toLowerCase() - .split(/\s+/) - .filter(Boolean), - ); - return ( - !missionTypesList.size || missionTypesList.has(missionType.toLowerCase()) - ); - }, [resolvedObject, missionType]); - - if (!resolvedObject) { - return null; - } - - const Component = componentMap[resolvedObject._className]; - const isSuppressedByDemoAuthority = - isDemoPlaybackActive && - demoGhostAuthoritativeClasses.has(resolvedObject._className); - return shouldShowObject && Component ? ( - - {!isSuppressedByDemoAuthority && } - - ) : null; -} diff --git a/src/components/Sky.tsx b/src/components/Sky.tsx index 3f6f2335..eac7f114 100644 --- a/src/components/Sky.tsx +++ b/src/components/Sky.tsx @@ -3,12 +3,11 @@ import { useQuery } from "@tanstack/react-query"; import { useThree, useFrame } from "@react-three/fiber"; import { useCubeTexture } from "@react-three/drei"; import { Color, Fog } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getInt, getProperty } from "../mission"; +import type { SceneSky } from "../scene/types"; import { useSettings } from "./SettingsProvider"; import { loadDetailMapList, textureToUrl } from "../loaders"; import { CloudLayers } from "./CloudLayers"; -import { parseFogState, type FogState } from "./FogProvider"; +import { fogStateFromScene, type FogState } from "./FogProvider"; import { installCustomFogShader } from "../fogShader"; import { globalFogUniforms, @@ -20,18 +19,13 @@ import { // Track if fog shader has been installed (idempotent installation) let fogShaderInstalled = false; -/** - * Parse a Tribes 2 color string (space-separated RGB or RGBA values 0-1). - * Returns [sRGB Color, linear Color] or undefined if no color string. - */ -function parseColorString( - colorString: string | undefined, -): [Color, Color] | undefined { - if (!colorString) return undefined; - const [r, g, b] = colorString.split(" ").map((s) => parseFloat(s)); +import type { Color3 } from "../scene/types"; + +/** Convert a Color3 to [sRGB Color, linear Color]. */ +function color3ToThree(c: Color3): [Color, Color] { return [ - new Color().setRGB(r, g, b), - new Color().setRGB(r, g, b).convertSRGBToLinear(), + new Color().setRGB(c.r, c.g, c.b), + new Color().setRGB(c.r, c.g, c.b).convertSRGBToLinear(), ]; } @@ -600,29 +594,29 @@ function DynamicFog({ return null; } -export function Sky({ object }: { object: TorqueObject }) { - const { fogEnabled, highQualityFog } = useSettings(); +export function Sky({ scene }: { scene: SceneSky }) { + const { fogEnabled } = useSettings(); // Skybox textures - const materialList = getProperty(object, "materialList"); + const materialList = scene.materialList || undefined; const skySolidColor = useMemo( - () => parseColorString(getProperty(object, "SkySolidColor")), - [object], + () => color3ToThree(scene.skySolidColor), + [scene.skySolidColor], ); - const useSkyTextures = getInt(object, "useSkyTextures") ?? 1; + const useSkyTextures = scene.useSkyTextures; - // Parse full fog state from Sky object using FogProvider's parser + // Parse full fog state from typed scene sky const fogState = useMemo( - () => parseFogState(object, highQualityFog), - [object, highQualityFog], + () => fogStateFromScene(scene), + [scene], ); // Get sRGB fog color for background const fogColor = useMemo( - () => parseColorString(getProperty(object, "fogColor")), - [object], + () => color3ToThree(scene.fogColor), + [scene.fogColor], ); const skyColor = skySolidColor || fogColor; @@ -635,32 +629,32 @@ export function Sky({ object }: { object: TorqueObject }) { // Set scene background color directly using useThree // This ensures the gap between fogged terrain and skybox blends correctly - const { scene, gl } = useThree(); + const { scene: threeScene, gl } = useThree(); useEffect(() => { if (hasFogParams) { // Use effective fog color for background (matches terrain fog) const bgColor = effectiveFogColor.clone(); - scene.background = bgColor; + threeScene.background = bgColor; // Also set the renderer clear color as a fallback gl.setClearColor(bgColor); } else if (skyColor) { const bgColor = skyColor[0].clone(); - scene.background = bgColor; + threeScene.background = bgColor; gl.setClearColor(bgColor); } else { - scene.background = null; + threeScene.background = null; } return () => { - scene.background = null; + threeScene.background = null; }; - }, [scene, gl, hasFogParams, effectiveFogColor, skyColor]); + }, [threeScene, gl, hasFogParams, effectiveFogColor, skyColor]); // Get linear sky solid color for the solid color sky shader const linearSkySolidColor = skySolidColor?.[1]; return ( <> - {materialList && useSkyTextures ? ( + {materialList && useSkyTextures && materialList.length > 0 ? ( {/* Key forces remount when mission changes to clear texture caches */} - + {/* Always render DynamicFog when mission has fog params. Pass fogEnabled to control visibility - this avoids shader recompilation diff --git a/src/components/StaticShape.tsx b/src/components/StaticShape.tsx deleted file mode 100644 index 2c05f245..00000000 --- a/src/components/StaticShape.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useMemo } from "react"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation, getScale } from "../mission"; -import { ShapeRenderer } from "./GenericShape"; -import { ShapeInfoProvider } from "./ShapeInfoProvider"; -import { useDatablock } from "./useDatablock"; - -export function StaticShape({ object }: { object: TorqueObject }) { - const datablockName = getProperty(object, "dataBlock") ?? ""; - const datablock = useDatablock(datablockName); - - const position = useMemo(() => getPosition(object), [object]); - const q = useMemo(() => getRotation(object), [object]); - const scale = useMemo(() => getScale(object), [object]); - - const shapeName = getProperty(datablock, "shapeFile"); - - if (!shapeName) { - console.error( - ` missing shape for datablock: ${datablockName}`, - ); - } - - return ( - - - - - - ); -} diff --git a/src/components/Sun.tsx b/src/components/Sun.tsx index 8b0c4d7a..ab855160 100644 --- a/src/components/Sun.tsx +++ b/src/components/Sun.tsx @@ -1,26 +1,17 @@ import { useEffect, useMemo } from "react"; import { Color, Vector3 } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getProperty } from "../mission"; +import type { SceneSun } from "../scene/types"; +import { torqueToThree } from "../scene/coordinates"; import { updateGlobalSunUniforms } from "../globalSunUniforms"; -export function Sun({ object }: { object: TorqueObject }) { - // Parse sun direction - points FROM sun TO scene - // Torque uses Z-up, Three.js uses Y-up +export function Sun({ scene }: { scene: SceneSun }) { + // Sun direction - points FROM sun TO scene + // Convert Torque (X-right, Y-forward, Z-up) to Three.js (X-right, Y-up, Z-backward) const direction = useMemo(() => { - const directionStr = - getProperty(object, "direction") ?? "0.57735 0.57735 -0.57735"; - const [tx, ty, tz] = directionStr - .split(" ") - .map((s: string) => parseFloat(s)); - // Convert Torque (X, Y, Z) to Three.js: - // Swap Y/Z for coordinate system: (tx, ty, tz) -> (tx, tz, ty) - const x = tx; - const y = tz; - const z = ty; + const [x, y, z] = torqueToThree(scene.direction); const len = Math.sqrt(x * x + y * y + z * z); return new Vector3(x / len, y / len, z / len); - }, [object]); + }, [scene.direction]); // Position light far away, opposite to direction (light shines FROM position) const lightPosition = useMemo(() => { @@ -32,17 +23,15 @@ export function Sun({ object }: { object: TorqueObject }) { ); }, [direction]); - const color = useMemo(() => { - const colorStr = getProperty(object, "color") ?? "0.7 0.7 0.7 1"; - const [r, g, b] = colorStr.split(" ").map((s: string) => parseFloat(s)); - return new Color(r, g, b); - }, [object]); + const color = useMemo( + () => new Color(scene.color.r, scene.color.g, scene.color.b), + [scene.color], + ); - const ambient = useMemo(() => { - const ambientStr = getProperty(object, "ambient") ?? "0.5 0.5 0.5 1"; - const [r, g, b] = ambientStr.split(" ").map((s: string) => parseFloat(s)); - return new Color(r, g, b); - }, [object]); + const ambient = useMemo( + () => new Color(scene.ambient.r, scene.ambient.g, scene.ambient.b), + [scene.ambient], + ); // Torque lighting check (terrLighting.cc): if light direction points up, // terrain surfaces with upward normals receive only ambient light. diff --git a/src/components/TSStatic.tsx b/src/components/TSStatic.tsx index 3f6f1d43..5fd16c4f 100644 --- a/src/components/TSStatic.tsx +++ b/src/components/TSStatic.tsx @@ -1,22 +1,30 @@ import { useMemo } from "react"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty, getRotation, getScale } from "../mission"; +import type { SceneTSStatic } from "../scene/types"; +import { + torqueToThree, + torqueScaleToThree, + matrixFToQuaternion, +} from "../scene/coordinates"; import { ShapeRenderer } from "./GenericShape"; import { ShapeInfoProvider } from "./ShapeInfoProvider"; - -export function TSStatic({ object }: { object: TorqueObject }) { - const shapeName = getProperty(object, "shapeName"); - - const position = useMemo(() => getPosition(object), [object]); - const q = useMemo(() => getRotation(object), [object]); - const scale = useMemo(() => getScale(object), [object]); - - if (!shapeName) { - console.error(" missing shapeName for object", object); +export function TSStatic({ scene }: { scene: SceneTSStatic }) { + const position = useMemo( + () => torqueToThree(scene.transform.position), + [scene.transform.position], + ); + const q = useMemo( + () => matrixFToQuaternion(scene.transform), + [scene.transform], + ); + const scale = useMemo(() => torqueScaleToThree(scene.scale), [scene.scale]); + if (!scene.shapeName) { + console.error( + " missing shapeName for ghostIndex", + scene.ghostIndex, + ); } - return ( - + diff --git a/src/components/TerrainBlock.tsx b/src/components/TerrainBlock.tsx index 258ed3ee..257cb57e 100644 --- a/src/components/TerrainBlock.tsx +++ b/src/components/TerrainBlock.tsx @@ -16,24 +16,22 @@ import { UnsignedByteType, Vector3, } from "three"; -import type { TorqueObject } from "../torqueScript"; -import { getFloat, getInt, getProperty } from "../mission"; +import type { SceneTerrainBlock } from "../scene/types"; +import { torqueToThree } from "../scene/coordinates"; +import { useSceneSky, useSceneSun } from "../state/gameEntityStore"; import { loadTerrain } from "../loaders"; import { uint16ToFloat32 } from "../arrayUtils"; import { setupMask } from "../textureUtils"; import { TerrainTile } from "./TerrainTile"; -import { useSceneObject } from "./useSceneObject"; import { createTerrainHeightSampler, setTerrainHeightSampler, } from "../terrainHeight"; - const DEFAULT_SQUARE_SIZE = 8; const DEFAULT_VISIBLE_DISTANCE = 600; const TERRAIN_SIZE = 256; const LIGHTMAP_SIZE = 512; // Match Tribes 2's 512x512 lightmap const HEIGHT_SCALE = 2048; // Matches displacementScale for terrain - /** * Create terrain geometry with Torque-style alternating diagonal triangulation. * @@ -55,15 +53,12 @@ function createTerrainGeometry(size: number, segments: number): BufferGeometry { const positions = new Float32Array(vertexCount * 3); const normals = new Float32Array(vertexCount * 3); const uvs = new Float32Array(vertexCount * 2); - // Pre-allocate index buffer: segments² squares × 2 triangles × 3 indices // Use Uint32Array since vertex count (257² = 66049) exceeds Uint16 max (65535) const indexCount = segments * segments * 6; const indices = new Uint32Array(indexCount); let indexOffset = 0; - const segmentSize = size / segments; - // Create vertices in X-Y plane (same as PlaneGeometry) // PlaneGeometry goes from top-left to bottom-right with UVs 0→1 // X: -size/2 to +size/2 (left to right) @@ -71,23 +66,19 @@ function createTerrainGeometry(size: number, segments: number): BufferGeometry { for (let row = 0; row <= segments; row++) { for (let col = 0; col <= segments; col++) { const idx = row * (segments + 1) + col; - // Position in X-Y plane (Z=0), centered at origin positions[idx * 3] = col * segmentSize - size / 2; // X: -size/2 to +size/2 positions[idx * 3 + 1] = size / 2 - row * segmentSize; // Y: +size/2 to -size/2 positions[idx * 3 + 2] = 0; // Z: 0 (will be displaced after rotation) - // Default normal pointing +Z (out of plane, will become +Y after rotation) normals[idx * 3] = 0; normals[idx * 3 + 1] = 0; normals[idx * 3 + 2] = 1; - // UV coordinates (0 to 1), matching PlaneGeometry uvs[idx * 2] = col / segments; uvs[idx * 2 + 1] = 1 - row / segments; // Flip V so row 0 is at V=1 } } - // Create triangle indices with Torque-style alternating diagonals // Using CCW winding for front face (Three.js default) for (let row = 0; row < segments; row++) { @@ -100,10 +91,8 @@ function createTerrainGeometry(size: number, segments: number): BufferGeometry { const b = a + 1; const c = (row + 1) * (segments + 1) + col; const d = c + 1; - // Torque's split decision: ((x ^ y) & 1) == 0 means Split45 const split45 = ((col ^ row) & 1) === 0; - if (split45) { // Split45: diagonal from a to d (top-left to bottom-right in screen space) // Triangle 1: a, c, d (CCW from front) @@ -127,21 +116,17 @@ function createTerrainGeometry(size: number, segments: number): BufferGeometry { } } } - geometry.setIndex(new BufferAttribute(indices, 1)); geometry.setAttribute("position", new Float32BufferAttribute(positions, 3)); geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3)); geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2)); - // Apply same rotations as the original PlaneGeometry approach: // rotateX(-90°) puts the X-Y plane into X-Z (horizontal), with +Y becoming up // rotateY(-90°) rotates around Y axis to match terrain coordinate system geometry.rotateX(-Math.PI / 2); geometry.rotateY(-Math.PI / 2); - return geometry; } - /** * Displace terrain vertices on CPU and compute smooth normals from heightmap gradients. * @@ -163,54 +148,44 @@ function displaceTerrainAndComputeNormals( const uvs = uvAttr.array as Float32Array; const normals = normalAttr.array as Float32Array; const vertexCount = posAttr.count; - // Helper to get height at heightmap coordinates with clamping (integer coords) const getHeightInt = (col: number, row: number): number => { col = Math.max(0, Math.min(TERRAIN_SIZE - 1, col)); row = Math.max(0, Math.min(TERRAIN_SIZE - 1, row)); return (heightMap[row * TERRAIN_SIZE + col] / 65535) * HEIGHT_SCALE; }; - // Helper to get bilinearly interpolated height (matches GPU texture sampling) const getHeight = (col: number, row: number): number => { col = Math.max(0, Math.min(TERRAIN_SIZE - 1, col)); row = Math.max(0, Math.min(TERRAIN_SIZE - 1, row)); - const col0 = Math.floor(col); const row0 = Math.floor(row); const col1 = Math.min(col0 + 1, TERRAIN_SIZE - 1); const row1 = Math.min(row0 + 1, TERRAIN_SIZE - 1); - const fx = col - col0; const fy = row - row0; - const h00 = (heightMap[row0 * TERRAIN_SIZE + col0] / 65535) * HEIGHT_SCALE; const h10 = (heightMap[row0 * TERRAIN_SIZE + col1] / 65535) * HEIGHT_SCALE; const h01 = (heightMap[row1 * TERRAIN_SIZE + col0] / 65535) * HEIGHT_SCALE; const h11 = (heightMap[row1 * TERRAIN_SIZE + col1] / 65535) * HEIGHT_SCALE; - // Bilinear interpolation const h0 = h00 * (1 - fx) + h10 * fx; const h1 = h01 * (1 - fx) + h11 * fx; return h0 * (1 - fy) + h1 * fy; }; - // Process each vertex for (let i = 0; i < vertexCount; i++) { const u = uvs[i * 2]; const v = uvs[i * 2 + 1]; - // Map UV to heightmap coordinates - must match Torque's terrain sampling. // Torque formula: floor(worldPos / squareSize) & BlockMask // UV 0→1 maps to world 0→2048, squareSize=8, so: floor(UV * 256) & 255 // This wraps at edges for seamless terrain tiling. const col = Math.floor(u * TERRAIN_SIZE) & (TERRAIN_SIZE - 1); const row = Math.floor(v * TERRAIN_SIZE) & (TERRAIN_SIZE - 1); - // Use direct integer sampling to match GPU nearest-neighbor filtering const height = getHeightInt(col, row); positions[i * 3 + 1] = height; - // Compute normal using central differences on heightmap with smooth interpolation. // Use fractional coordinates for gradient sampling to get smooth normals. const colF = u * (TERRAIN_SIZE - 1); @@ -219,11 +194,9 @@ function displaceTerrainAndComputeNormals( const hR = getHeight(colF + 1, rowF); // right const hD = getHeight(colF, rowF + 1); // down (increasing row) const hU = getHeight(colF, rowF - 1); // up (decreasing row) - // Gradients in heightmap space (col increases = +U, row increases = +V) const dCol = (hR - hL) / 2; // height change per column const dRow = (hD - hU) / 2; // height change per row - // Now map heightmap gradients to world-space normal // After rotateX(-PI/2) and rotateY(-PI/2): // - U direction (col) maps to world +Z @@ -234,7 +207,6 @@ function displaceTerrainAndComputeNormals( let nx = dRow; let ny = squareSize; let nz = dCol; - // Normalize const len = Math.sqrt(nx * nx + ny * ny + nz * nz); if (len > 0) { @@ -246,16 +218,13 @@ function displaceTerrainAndComputeNormals( ny = 1; nz = 0; } - normals[i * 3] = nx; normals[i * 3 + 1] = ny; normals[i * 3 + 2] = nz; } - posAttr.needsUpdate = true; normalAttr.needsUpdate = true; } - /** * Ray-march through heightmap to determine if a point is in shadow. * Uses the same coordinate system as the terrain geometry. @@ -284,52 +253,42 @@ function rayMarchShadow( const stepCol = lightDir.z / squareSize; const stepRow = lightDir.x / squareSize; const stepHeight = lightDir.y; - // Normalize to step ~0.5 heightmap units per iteration for good sampling const horizontalLen = Math.sqrt(stepCol * stepCol + stepRow * stepRow); if (horizontalLen < 0.0001) { // Light is nearly vertical - no self-shadowing possible return 1.0; } - const stepScale = 0.5 / horizontalLen; const dCol = stepCol * stepScale; const dRow = stepRow * stepScale; const dHeight = stepHeight * stepScale; - let col = startCol; let row = startRow; let height = startHeight + 0.1; // Small offset to avoid self-intersection - // March until we exit terrain bounds or confirm we're lit const maxSteps = TERRAIN_SIZE * 3; // Enough to cross terrain diagonally for (let i = 0; i < maxSteps; i++) { col += dCol; row += dRow; height += dHeight; - // Check if ray exited terrain bounds horizontally if (col < 0 || col >= TERRAIN_SIZE || row < 0 || row >= TERRAIN_SIZE) { return 1.0; // Exited terrain, not in shadow } - // Check if ray is above max terrain height if (height > HEIGHT_SCALE) { return 1.0; // Above all terrain, not in shadow } - // Sample terrain height at current position const terrainHeight = getHeight(col, row); - // If ray is below terrain surface, we're in shadow if (height < terrainHeight) { return 0.0; } } - return 1.0; // Reached max steps, assume not in shadow } - /** * Generate a terrain lightmap texture with smooth normals and ray-traced shadows. * @@ -360,39 +319,31 @@ function generateTerrainLightmap( // Clamp to valid range (don't wrap for shadow rays) const clampedCol = Math.max(0, Math.min(TERRAIN_SIZE - 1, col)); const clampedRow = Math.max(0, Math.min(TERRAIN_SIZE - 1, row)); - const col0 = Math.floor(clampedCol); const row0 = Math.floor(clampedRow); const col1 = Math.min(col0 + 1, TERRAIN_SIZE - 1); const row1 = Math.min(row0 + 1, TERRAIN_SIZE - 1); - const fx = clampedCol - col0; const fy = clampedRow - row0; - const h00 = heightMap[row0 * TERRAIN_SIZE + col0] / 65535; const h10 = heightMap[row0 * TERRAIN_SIZE + col1] / 65535; const h01 = heightMap[row1 * TERRAIN_SIZE + col0] / 65535; const h11 = heightMap[row1 * TERRAIN_SIZE + col1] / 65535; - // Bilinear interpolation const h0 = h00 * (1 - fx) + h10 * fx; const h1 = h01 * (1 - fx) + h11 * fx; return (h0 * (1 - fy) + h1 * fy) * HEIGHT_SCALE; }; - // Light direction (negate sun direction since it points FROM sun) const lightDir = new Vector3( -sunDirection.x, -sunDirection.y, -sunDirection.z, ).normalize(); - const lightmapData = new Uint8Array(LIGHTMAP_SIZE * LIGHTMAP_SIZE); - // Epsilon for gradient sampling (in heightmap units) // Use 0.5 to sample across a reasonable distance for smooth gradients const eps = 0.5; - // Generate lightmap by computing normal and shadow at each pixel for (let lRow = 0; lRow < LIGHTMAP_SIZE; lRow++) { for (let lCol = 0; lCol < LIGHTMAP_SIZE; lCol++) { @@ -401,28 +352,22 @@ function generateTerrainLightmap( // With 2 lightmap pixels per terrain square: pos = lCol/2 + 0.25 const col = lCol / 2 + 0.25; const row = lRow / 2 + 0.25; - // Get height at this position for shadow ray starting point const surfaceHeight = getInterpolatedHeight(col, row); - // Compute gradient using central differences on interpolated heights const hL = getInterpolatedHeight(col - eps, row); const hR = getInterpolatedHeight(col + eps, row); const hU = getInterpolatedHeight(col, row - eps); const hD = getInterpolatedHeight(col, row + eps); - // Gradient in heightmap units const dCol = (hR - hL) / (2 * eps); const dRow = (hD - hU) / (2 * eps); - // Convert to world-space normal - must match displaceTerrainAndComputeNormals // After geometry rotations: U (col) → +Z, V (row) → +X const nx = -dRow; const ny = squareSize; const nz = -dCol; - const len = Math.sqrt(nx * nx + ny * ny + nz * nz); - // Compute NdotL const NdotL = Math.max( 0, @@ -430,7 +375,6 @@ function generateTerrainLightmap( (ny / len) * lightDir.y + (nz / len) * lightDir.z, ); - // Ray-march to determine shadow (only if surface faces the light) let shadow = 1.0; if (NdotL > 0) { @@ -443,14 +387,12 @@ function generateTerrainLightmap( getInterpolatedHeight, ); } - // Store NdotL * shadow in lightmap lightmapData[lRow * LIGHTMAP_SIZE + lCol] = Math.floor( NdotL * shadow * 255, ); } } - const texture = new DataTexture( lightmapData, LIGHTMAP_SIZE, @@ -465,10 +407,8 @@ function generateTerrainLightmap( texture.magFilter = LinearFilter; texture.minFilter = LinearFilter; texture.needsUpdate = true; - return texture; } - /** * Load a .ter file, used for terrain heightmap and texture info. */ @@ -478,39 +418,32 @@ function useTerrain(terrainFile: string) { queryFn: () => loadTerrain(terrainFile), }); } - /** - * Get visibleDistance from the Sky object, used to determine how far terrain - * tiles should render. This matches Tribes 2's terrain tiling behavior. + * Get visibleDistance from the Sky scene object, used to determine how far + * terrain tiles should render. This matches Tribes 2's terrain tiling behavior. */ function useVisibleDistance(): number { - const sky = useSceneObject("Sky"); + const sky = useSceneSky(); if (!sky) return DEFAULT_VISIBLE_DISTANCE; - const highVisibleDistance = getFloat(sky, "high_visibleDistance"); - if (highVisibleDistance != null && highVisibleDistance > 0) { - return highVisibleDistance; - } - return getFloat(sky, "visibleDistance") ?? DEFAULT_VISIBLE_DISTANCE; + return sky.visibleDistance > 0 + ? sky.visibleDistance + : DEFAULT_VISIBLE_DISTANCE; } - interface TileAssignment { tileX: number; tileZ: number; } - /** * Create a visibility mask texture from emptySquares data. */ function createVisibilityMask(emptySquares: number[]): DataTexture { const maskData = new Uint8Array(TERRAIN_SIZE * TERRAIN_SIZE); maskData.fill(255); // Start with everything visible - for (const squareId of emptySquares) { const x = squareId & 0xff; const y = (squareId >> 8) & 0xff; const count = squareId >> 16; const rowOffset = y * TERRAIN_SIZE; - for (let i = 0; i < count; i++) { const index = rowOffset + x + i; if (index < maskData.length) { @@ -518,7 +451,6 @@ function createVisibilityMask(emptySquares: number[]): DataTexture { } } } - const texture = new DataTexture( maskData, TERRAIN_SIZE, @@ -531,22 +463,19 @@ function createVisibilityMask(emptySquares: number[]): DataTexture { texture.magFilter = NearestFilter; texture.minFilter = NearestFilter; texture.needsUpdate = true; - return texture; } - export const TerrainBlock = memo(function TerrainBlock({ - object, + scene, }: { - object: TorqueObject; + scene: SceneTerrainBlock; }) { - const terrainFile = getProperty(object, "terrainFile"); - const squareSize = getInt(object, "squareSize") ?? DEFAULT_SQUARE_SIZE; - const detailTexture = getProperty(object, "detailTexture"); + const terrainFile = scene.terrFileName; + const squareSize = scene.squareSize || DEFAULT_SQUARE_SIZE; + const detailTexture = scene.detailTextureName || undefined; const blockSize = squareSize * 256; const visibleDistance = useVisibleDistance(); const camera = useThree((state) => state.camera); - // Torque ignores the mission's terrain position and always uses a fixed formula: // setPosition(Point3F(-squareSize * (BlockSize >> 1), -squareSize * (BlockSize >> 1), 0)); // where BlockSize = 256. See tribes2-engine/terrain/terrData.cc:679 @@ -554,28 +483,21 @@ export const TerrainBlock = memo(function TerrainBlock({ const offset = -squareSize * (TERRAIN_SIZE / 2); return { x: offset, z: offset }; }, [squareSize]); - - const emptySquares = useMemo(() => { - const value = getProperty(object, "emptySquares"); - return value ? value.split(" ").map((s: string) => parseInt(s, 10)) : []; - }, [object]); - + const emptySquares = useMemo( + () => scene.emptySquareRuns ?? [], + [scene.emptySquareRuns], + ); const { data: terrain } = useTerrain(terrainFile); - // Shared geometry for all tiles - with smooth normals computed from heightmap // Uses Torque-style alternating diagonal triangulation for accurate terrain const sharedGeometry = useMemo(() => { if (!terrain) return null; - const size = squareSize * 256; const geometry = createTerrainGeometry(size, TERRAIN_SIZE); - // Displace vertices on CPU and compute smooth normals displaceTerrainAndComputeNormals(geometry, terrain.heightMap, squareSize); - return geometry; }, [squareSize, terrain]); - // Register terrain height sampler for item physics simulation. useEffect(() => { if (!terrain) return; @@ -584,30 +506,19 @@ export const TerrainBlock = memo(function TerrainBlock({ ); return () => setTerrainHeightSampler(null); }, [terrain, squareSize]); - // Get sun direction for lightmap generation - const sun = useSceneObject("Sun"); + const sun = useSceneSun(); const sunDirection = useMemo(() => { if (!sun) return new Vector3(0.57735, -0.57735, 0.57735); // Default diagonal - const directionStr = - getProperty(sun, "direction") ?? "0.57735 0.57735 -0.57735"; - const [tx, ty, tz] = directionStr - .split(" ") - .map((s: string) => parseFloat(s)); - // Convert Torque (X, Y, Z) to Three.js: swap Y/Z - const x = tx; - const y = tz; - const z = ty; + const [x, y, z] = torqueToThree(sun.direction); const len = Math.sqrt(x * x + y * y + z * z); return new Vector3(x / len, y / len, z / len); }, [sun]); - // Generate terrain lightmap for smooth per-pixel lighting const terrainLightmap = useMemo(() => { if (!terrain) return null; return generateTerrainLightmap(terrain.heightMap, sunDirection, squareSize); }, [terrain, sunDirection, squareSize]); - // Shared displacement map from heightmap - created once for all tiles const sharedDisplacementMap = useMemo(() => { if (!terrain) return null; @@ -626,53 +537,43 @@ export const TerrainBlock = memo(function TerrainBlock({ texture.needsUpdate = true; return texture; }, [terrain]); - // Visibility mask for primary tile (0,0) - may have empty squares const primaryVisibilityMask = useMemo( () => createVisibilityMask(emptySquares), [emptySquares], ); - // Visibility mask for pooled tiles - all visible (no empty squares) // This is a stable reference shared by all pooled tiles const pooledVisibilityMask = useMemo(() => createVisibilityMask([]), []); - // Shared alpha textures from terrain alphaMaps - created once for all tiles const sharedAlphaTextures = useMemo(() => { if (!terrain) return null; return terrain.alphaMaps.map((data) => setupMask(data)); }, [terrain]); - // Calculate the maximum number of tiles that can be visible at once. const poolSize = useMemo(() => { const extent = Math.ceil(visibleDistance / blockSize); const gridSize = 2 * extent + 1; return gridSize * gridSize - 1; // -1 because primary tile is separate }, [visibleDistance, blockSize]); - // Create stable pool indices for React keys const poolIndices = useMemo( () => Array.from({ length: poolSize }, (_, i) => i), [poolSize], ); - // Track which tile coordinate each pool slot is assigned to const [tileAssignments, setTileAssignments] = useState< (TileAssignment | null)[] >(() => Array(poolSize).fill(null)); - // Track previous tile bounds to avoid unnecessary state updates const prevBoundsRef = useRef({ xStart: 0, xEnd: 0, zStart: 0, zEnd: 0 }); - useFrame(() => { const relativeCamX = camera.position.x - basePosition.x; const relativeCamZ = camera.position.z - basePosition.z; - const xStart = Math.floor((relativeCamX - visibleDistance) / blockSize); const xEnd = Math.ceil((relativeCamX + visibleDistance) / blockSize); const zStart = Math.floor((relativeCamZ - visibleDistance) / blockSize); const zEnd = Math.ceil((relativeCamZ + visibleDistance) / blockSize); - // Early exit if bounds haven't changed const prev = prevBoundsRef.current; if ( @@ -687,7 +588,6 @@ export const TerrainBlock = memo(function TerrainBlock({ prev.xEnd = xEnd; prev.zStart = zStart; prev.zEnd = zEnd; - // Build new assignments array const newAssignments: (TileAssignment | null)[] = []; for (let x = xStart; x < xEnd; x++) { @@ -699,10 +599,8 @@ export const TerrainBlock = memo(function TerrainBlock({ while (newAssignments.length < poolSize) { newAssignments.push(null); } - setTileAssignments(newAssignments); }); - if ( !terrain || !sharedGeometry || @@ -711,7 +609,6 @@ export const TerrainBlock = memo(function TerrainBlock({ ) { return null; } - return ( <> {/* Primary tile at (0,0) with emptySquares applied */} diff --git a/src/components/TerrainTile.tsx b/src/components/TerrainTile.tsx index 8744885e..f353acee 100644 --- a/src/components/TerrainTile.tsx +++ b/src/components/TerrainTile.tsx @@ -42,7 +42,7 @@ interface TerrainTileProps { visible?: boolean; } -function BlendedTerrainTextures({ +const BlendedTerrainTextures = memo(function BlendedTerrainTextures({ displacementMap, visibilityMask, textureNames, @@ -136,9 +136,9 @@ function BlendedTerrainTextures({ onBeforeCompile={onBeforeCompile} /> ); -} +}); -function TerrainMaterial({ +const TerrainMaterial = memo(function TerrainMaterial({ displacementMap, visibilityMask, textureNames, @@ -170,7 +170,7 @@ function TerrainMaterial({ /> ); -} +}); export const TerrainTile = memo(function TerrainTile({ tileX, diff --git a/src/components/Turret.tsx b/src/components/Turret.tsx index 8c222f50..e6a6772b 100644 --- a/src/components/Turret.tsx +++ b/src/components/Turret.tsx @@ -4,20 +4,16 @@ import { getPosition, getProperty, getRotation, getScale } from "../mission"; import { ShapeRenderer } from "./GenericShape"; import { ShapeInfoProvider } from "./ShapeInfoProvider"; import { useDatablock } from "./useDatablock"; - export function Turret({ object }: { object: TorqueObject }) { const datablockName = getProperty(object, "dataBlock") ?? ""; const barrelDatablockName = getProperty(object, "initialBarrel"); const datablock = useDatablock(datablockName); const barrelDatablock = useDatablock(barrelDatablockName); - const position = useMemo(() => getPosition(object), [object]); const q = useMemo(() => getRotation(object), [object]); const scale = useMemo(() => getScale(object), [object]); - const shapeName = getProperty(datablock, "shapeFile"); const barrelShapeName = getProperty(barrelDatablock, "shapeFile"); - if (!shapeName) { console.error(` missing shape for datablock: ${datablockName}`); } @@ -28,7 +24,6 @@ export function Turret({ object }: { object: TorqueObject }) { ` missing shape for barrel datablock: ${barrelDatablockName}`, ); } - return ( diff --git a/src/components/WaterBlock.tsx b/src/components/WaterBlock.tsx index e540367c..7faef7c7 100644 --- a/src/components/WaterBlock.tsx +++ b/src/components/WaterBlock.tsx @@ -3,14 +3,8 @@ import { Box, useTexture } from "@react-three/drei"; import { useFrame, useThree } from "@react-three/fiber"; import { DoubleSide, NoColorSpace, PlaneGeometry, RepeatWrapping } from "three"; import { textureToUrl } from "../loaders"; -import type { TorqueObject } from "../torqueScript"; -import { - getFloat, - getPosition, - getProperty, - getRotation, - getScale, -} from "../mission"; +import type { SceneWaterBlock } from "../scene/types"; +import { torqueToThree, torqueScaleToThree, matrixFToQuaternion } from "../scene"; import { setupTexture } from "../textureUtils"; import { createWaterMaterial } from "../waterMaterial"; import { useDebug, useSettings } from "./SettingsProvider"; @@ -93,26 +87,19 @@ export function WaterMaterial({ * - Renders 9 reps (3x3 grid) centered on camera's rep */ export const WaterBlock = memo(function WaterBlock({ - object, + scene, }: { - object: TorqueObject; + scene: SceneWaterBlock; }) { const { debugMode } = useDebug(); - const q = useMemo(() => getRotation(object), [object]); - const position = useMemo(() => getPosition(object), [object]); - const scale = useMemo(() => getScale(object), [object]); + const q = useMemo(() => matrixFToQuaternion(scene.transform), [scene.transform]); + const position = useMemo(() => torqueToThree(scene.transform.position), [scene.transform]); + const scale = useMemo(() => torqueScaleToThree(scene.scale), [scene.scale]); const [scaleX, scaleY, scaleZ] = scale; const camera = useThree((state) => state.camera); const hasCameraPositionChanged = usePositionTracker(); - // Water surface height (top of water volume) - // TODO: Use this for terrain intersection masking (reject water blocks where - // terrain height > surfaceZ + waveMagnitude/2). Requires TerrainProvider. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - // const surfaceZ = position[1] + scaleY; - - // Wave magnitude affects terrain masking (Torque adds half to surface height) - const waveMagnitude = getFloat(object, "waveMagnitude") ?? 1.0; + const waveMagnitude = scene.waveMagnitude; // Convert world position to terrain space and snap to grid. // Matches Torque's UpdateFluidRegion() and fluid::SetInfo(): @@ -196,11 +183,10 @@ export const WaterBlock = memo(function WaterBlock({ }); }); - const surfaceTexture = - getProperty(object, "surfaceTexture") ?? "liquidTiles/BlueWater"; - const envMapTexture = getProperty(object, "envMapTexture"); - const opacity = getFloat(object, "surfaceOpacity") ?? 0.75; - const envMapIntensity = getFloat(object, "envMapIntensity") ?? 1.0; + const surfaceTexture = scene.surfaceName || "liquidTiles/BlueWater"; + const envMapTexture = scene.envMapName || undefined; + const opacity = scene.surfaceOpacity; + const envMapIntensity = scene.envMapIntensity; // Create subdivided plane geometry for the water surface // Tessellation matches Tribes 2 engine (5x5 vertices per block) diff --git a/src/components/WayPoint.tsx b/src/components/WayPoint.tsx index 8d76a4e4..f45deb4b 100644 --- a/src/components/WayPoint.tsx +++ b/src/components/WayPoint.tsx @@ -1,15 +1,10 @@ -import { useMemo } from "react"; -import type { TorqueObject } from "../torqueScript"; -import { getPosition, getProperty } from "../mission"; +import type { WayPointEntity } from "../state/gameEntityTypes"; import { FloatingLabel } from "./FloatingLabel"; -export function WayPoint({ object }: { object: TorqueObject }) { - const position = useMemo(() => getPosition(object), [object]); - const label = getProperty(object, "name"); - - return label ? ( - - {label} +export function WayPoint({ entity }: { entity: WayPointEntity }) { + return entity.label ? ( + + {entity.label} ) : null; } diff --git a/src/demo/streaming.ts b/src/demo/streaming.ts deleted file mode 100644 index a0b95f08..00000000 --- a/src/demo/streaming.ts +++ /dev/null @@ -1,3189 +0,0 @@ -import { - BlockTypeInfo, - BlockTypeMove, - BlockTypePacket, - DemoParser, -} from "t2-demo-parser"; -import { Matrix4, Quaternion } from "three"; -import { getTerrainHeightAt } from "../terrainHeight"; -import type { - BackpackHudState, - ChatSegment, - DemoChatMessage, - DemoThreadState, - DemoVisual, - DemoRecording, - DemoStreamCamera, - DemoStreamEntity, - DemoStreamSnapshot, - DemoStreamingPlayback, - InventoryHudSlot, - TeamScore, - WeaponImageDataBlockState, - WeaponImageState, - WeaponsHudSlot, -} from "./types"; - -type Vec3 = { x: number; y: number; z: number }; - -type RuntimeControlObject = { - ghostIndex: number; - data?: Record; - position?: Vec3; -}; - -type ControlObjectType = "camera" | "player"; - -interface MutableStreamEntity { - id: string; - ghostIndex: number; - className: string; - /** Move tick when this ghost instance first entered scope. */ - spawnTick: number; - type: string; - dataBlockId?: number; - shapeHint?: string; - dataBlock?: string; - visual?: DemoVisual; - direction?: [number, number, number]; - weaponShape?: string; - playerName?: string; - position?: [number, number, number]; - rotation: [number, number, number, number]; - velocity?: [number, number, number]; - health?: number; - energy?: number; - maxEnergy?: number; - /** Action animation index from ghost ActionMask. */ - actionAnim?: number; - /** True when the action animation has reached its final frame. */ - actionAtEnd?: boolean; - /** Torque DamageState: 0 = Enabled, 1 = Disabled (dead), 2 = Destroyed. */ - damageState?: number; - targetId?: number; - /** Physics type for per-tick simulation. */ - projectilePhysics?: "linear" | "ballistic" | "seeker"; - /** Computed velocity vector for simulation (Torque space). */ - simulatedVelocity?: [number, number, number]; - /** Datablock gravity modifier (ballistic only, default 1.0). */ - gravityMod?: number; - /** Resolved explosion DTS shape name (e.g. "disc_explosion.dts"). */ - explosionShape?: string; - /** Explosion lifetime in ticks from ExplosionData. */ - explosionLifetimeTicks?: number; - /** Prevents duplicate explosion spawning. */ - hasExploded?: boolean; - /** Marks ephemeral explosion entities. */ - isExplosion?: boolean; - /** Auto-removal tick for explosion entities. */ - expiryTick?: number; - /** Billboard toward camera (Torque's faceViewer). */ - faceViewer?: boolean; - /** Numeric ID of the ExplosionData datablock (for particle effect resolution). */ - explosionDataBlockId?: number; - /** Numeric ID of the ParticleEmitterData for in-flight trail particles. */ - maintainEmitterId?: number; - /** Target's sensor group (team number). */ - sensorGroup?: number; - /** DTS animation thread states from ghost ThreadMask data. */ - threads?: DemoThreadState[]; - /** Weapon image condition flags from ghost ImageMask data. */ - weaponImageState?: WeaponImageState; - /** Weapon image state machine states from the ShapeBaseImageData datablock. */ - weaponImageStates?: WeaponImageDataBlockState[]; - /** Tracks the datablock ID for which weaponImageStates was parsed. */ - weaponImageStatesDbId?: number; - /** Head pitch for blend animations, normalized [-1,1]. */ - headPitch?: number; - /** Head yaw for blend animations (freelook), normalized [-1,1]. */ - headYaw?: number; - /** Target render flags bitmask from the Target Manager. */ - targetRenderFlags?: number; - /** True when FlagImage is mounted in slot 3 (player is carrying a flag). */ - carryingFlag?: boolean; - /** Item physics simulation state (dropped weapons/items). */ - itemPhysics?: { - velocity: [number, number, number]; - atRest: boolean; - elasticity: number; - friction: number; - gravityMod: number; - }; -} - -interface StreamState { - moveTicks: number; - /** Absolute yaw tracking, replicated from V12 engine with [0,2π] wrapping. */ - absoluteYaw: number; - /** Absolute pitch tracking, replicated from V12 engine with clamping. */ - absolutePitch: number; - lastAbsYaw: number; - lastAbsPitch: number; - lastControlType: ControlObjectType; - isPiloting: boolean; - lastCameraMode?: number; - lastOrbitGhostIndex?: number; - lastOrbitDistance?: number; - exhausted: boolean; - latestFov: number; - latestControl: RuntimeControlObject; - controlPlayerGhostId?: string; - camera: DemoStreamCamera | null; - entitiesById: Map; - entityIdByGhostIndex: Map; - lastStatus: { health: number; energy: number }; - nextExplosionId: number; - /** The recording player's own sensor group (team). */ - playerSensorGroup: number; - chatMessages: DemoChatMessage[]; - pendingAudioEvents: Array<{ profileId: number; position?: { x: number; y: number; z: number }; timeSec: number }>; - /** Weapons HUD inventory state driven by RemoteCommandEvents. */ - weaponsHud: { - /** Map from HUD slot index to ammo count (-1 = infinite). */ - slots: Map; - /** Currently active (selected) HUD slot index, or -1 if none. */ - activeIndex: number; - }; - /** Backpack/pack HUD state. */ - backpackHud: { - packIndex: number; - active: boolean; - text: string; - }; - /** Inventory HUD state (grenades, mines, beacons, repair kits). */ - inventoryHud: { - /** Map from display slot (0-3) to item count. */ - slots: Map; - activeSlot: number; - }; - /** Team scores aggregated from the PLAYERLIST demoValues section. */ - teamScores: TeamScore[]; - /** Live player roster keyed by clientId, updated by ServerMessage events. */ - playerRoster: Map; -} - -const TICK_DURATION_MS = 32; - -/** Tribes 2 default IFF colors (sRGB 0-255). */ -const IFF_GREEN = Object.freeze({ r: 0, g: 255, b: 0 }); -const IFF_RED = Object.freeze({ r: 255, g: 0, b: 0 }); - -const vehicleClassNames = new Set([ - "FlyingVehicle", - "HoverVehicle", - "WheeledVehicle", -]); - -const projectileClassNames = new Set([ - "BombProjectile", - "EnergyProjectile", - "FlareProjectile", - "GrenadeProjectile", - "LinearFlareProjectile", - "LinearProjectile", - "Projectile", - "SeekerProjectile", - "TracerProjectile", -]); - -const linearProjectileClassNames = new Set([ - "LinearProjectile", - "TracerProjectile", - "LinearFlareProjectile", - "Projectile", -]); - -const ballisticProjectileClassNames = new Set([ - "GrenadeProjectile", - "EnergyProjectile", - "FlareProjectile", - "BombProjectile", -]); - -const seekerProjectileClassNames = new Set(["SeekerProjectile"]); - -const deployableClassNames = new Set([ - "StaticShape", - "ScopeAlwaysShape", - "Turret", - "BeaconObject", - "ForceFieldBare", -]); - -/** - * Mission keeps authority for these classes during demo playback because we do - * not yet render them from ghost data with full fidelity. - */ -const missionOwnedGhostClassNames = new Set([ - "TSStatic", - "InteriorInstance", - "TerrainBlock", - "Sky", - "Sun", - "MissionArea", - "PhysicalZone", - "MissionMarker", - "SpawnSphere", - "VehicleBlocker", - "Camera", -]); - -const CameraMode_OrbitObject = 3; -const MAX_PITCH = Math.PI * 0.494; - -const _rotMat = new Matrix4(); -const _rotQuat = new Quaternion(); - -function extractMissionInfo(demoValues: string[]): { - missionName: string | null; - gameType: string | null; -} { - let missionName: string | null = null; - let gameType: string | null = null; - - for (let i = 0; i < demoValues.length; i++) { - if (demoValues[i] !== "readplayerinfo") continue; - const value = demoValues[i + 1]; - if (!value) continue; - - if (value.startsWith("2\t")) { - const fields = value.split("\t"); - if (fields[4]) { - missionName = fields[4]; - } - continue; - } - - if (value.startsWith("3\t")) { - const fields = value.split("\t"); - if (fields[2]) { - gameType = fields[2]; - } - } - } - - return { missionName, gameType }; -} - -/** Reverse lookup from $BackpackHudData bitmap names to table indices. */ -const BACKPACK_BITMAP_TO_INDEX = new Map([ - ["gui/hud_new_packammo", 0], - ["gui/hud_new_packcloak", 1], - ["gui/hud_new_packenergy", 2], - ["gui/hud_new_packrepair", 3], - ["gui/hud_new_packsatchel", 4], - ["gui/hud_new_packshield", 5], - ["gui/hud_new_packinventory", 6], - ["gui/hud_new_packmotionsens", 7], - ["gui/hud_new_packradar", 8], - ["gui/hud_new_packturretout", 9], - ["gui/hud_new_packturretin", 10], - ["gui/hud_new_packsensjam", 11], - ["gui/hud_new_packturret", 12], // barrel packs (12-17) share icon - ["gui/hud_satchel_unarmed", 18], -]); - -function backpackBitmapToIndex(bitmap: string): number { - // Try exact match first, then case-insensitive. - const lower = bitmap.toLowerCase(); - for (const [key, val] of BACKPACK_BITMAP_TO_INDEX) { - if (key === lower) return val; - } - return -1; -} - -interface ParsedDemoValues { - weaponsHud: { slots: Map; activeIndex: number } | null; - backpackHud: { packIndex: number; active: boolean; text: string } | null; - inventoryHud: { - slots: Map; - activeSlot: number; - } | null; - teamScores: TeamScore[]; - /** Initial player roster from PLAYERLIST section, keyed by clientId. */ - playerRoster: Map; - chatMessages: string[]; - gravity: number; -} - -/** - * Parse the $DemoValue[] array to extract initial HUD state. - * - * Sections are written sequentially by saveDemoSettings/getState in - * recordings.cs: MISC, PLAYERLIST, RETICLE, BACKPACK, WEAPON, INVENTORY, - * SCORE, CLOCK, CHAT, GRAVITY. - */ -function parseDemoValues(demoValues: string[]): ParsedDemoValues { - const result: ParsedDemoValues = { - weaponsHud: null, - backpackHud: null, - inventoryHud: null, - teamScores: [], - playerRoster: new Map(), - chatMessages: [], - gravity: -20, - }; - if (!demoValues.length) return result; - - let idx = 0; - const next = () => { - const v = demoValues[idx++]; - return v === "" ? "" : (v ?? ""); - }; - - // MISC: 1 value - next(); - - // PLAYERLIST: count + count entries - // Fields per player: name(0) guid(1) clientId(2) targetId(3) teamId(4) - // score(5) ping(6) packetLoss(7) ... (16 fields total) - if (idx >= demoValues.length) return result; - const playerCount = parseInt(next(), 10) || 0; - const playerCountByTeam = new Map(); - for (let i = 0; i < playerCount; i++) { - const fields = next().split("\t"); - const name = fields[0] ?? ""; - const clientId = parseInt(fields[2], 10); - const teamId = parseInt(fields[4], 10); - if (!isNaN(clientId) && !isNaN(teamId)) { - result.playerRoster.set(clientId, { name, teamId }); - } - if (!isNaN(teamId) && teamId > 0) { - playerCountByTeam.set(teamId, (playerCountByTeam.get(teamId) ?? 0) + 1); - } - } - - // RETICLE: 1 value - if (idx >= demoValues.length) return result; - next(); - - // BACKPACK: 1 value (bitmap TAB visible TAB text TAB textVisible TAB pack) - if (idx >= demoValues.length) return result; - { - const backpackVal = next(); - const fields = backpackVal.split("\t"); - const bitmap = fields[0] ?? ""; - const visible = fields[1] === "1" || fields[1] === "true"; - const text = fields[2] ?? ""; - const pack = fields[4] === "1" || fields[4] === "true"; - if (visible && bitmap) { - const packIndex = backpackBitmapToIndex(bitmap); - result.backpackHud = { packIndex, active: pack, text }; - } - } - - // WEAPON: header + count bitmap entries + slotCount slot entries - if (idx >= demoValues.length) return result; - const weaponHeader = next().split("\t"); - const weaponCount = parseInt(weaponHeader[4], 10) || 0; - const weaponSlotCount = parseInt(weaponHeader[5], 10) || 0; - const weaponActive = parseInt(weaponHeader[6], 10); - - for (let i = 0; i < weaponCount; i++) next(); - - const slots = new Map(); - for (let i = 0; i < weaponSlotCount; i++) { - const fields = next().split("\t"); - const slotId = parseInt(fields[0], 10); - const ammo = parseInt(fields[1], 10); - if (!isNaN(slotId)) { - slots.set(slotId, isNaN(ammo) ? -1 : ammo); - } - } - result.weaponsHud = { - slots, - activeIndex: isNaN(weaponActive) ? -1 : weaponActive, - }; - - // INVENTORY: header + count bitmap entries + slotCount slot entries - if (idx >= demoValues.length) return result; - const invHeader = next().split("\t"); - const invCount = parseInt(invHeader[4], 10) || 0; - const invSlotCount = parseInt(invHeader[5], 10) || 0; - const invActive = parseInt(invHeader[6], 10); - // Skip bitmap entries (we use our own icon mapping). - for (let i = 0; i < invCount; i++) next(); - { - const invSlots = new Map(); - for (let i = 0; i < invSlotCount; i++) { - const fields = next().split("\t"); - const slotId = parseInt(fields[0], 10); - const count = parseInt(fields[1], 10); - if (!isNaN(slotId) && !isNaN(count) && count > 0) { - invSlots.set(slotId, count); - } - } - if (invSlots.size > 0) { - result.inventoryHud = { - slots: invSlots, - activeSlot: isNaN(invActive) ? -1 : invActive, - }; - } - } - - // SCORE: header (visible TAB gameType TAB objCount) + objCount entries. - // The objects are the objectiveHud controls serialized via getValue(). - // Their order and meaning depend on the gameType. - if (idx >= demoValues.length) return result; - const scoreHeader = next().split("\t"); - const gameType = scoreHeader[1] ?? ""; - const objCount = parseInt(scoreHeader[2], 10) || 0; - const scoreObjs: string[] = []; - for (let i = 0; i < objCount; i++) scoreObjs.push(next()); - - // Extract team names and objective scores from the SCORE section based on - // game type. Combine with player counts from PLAYERLIST. - if (gameType === "CTFGame" && objCount >= 8) { - // CTFGame objectiveHud layout (per setupObjHud in objectiveHud.cs): - // for each team (1..2): teamName, teamScore, flagLabel, flagLocation - for (let t = 0; t < 2; t++) { - const base = t * 4; - const teamId = t + 1; - result.teamScores.push({ - teamId, - name: scoreObjs[base] ?? "", - score: parseInt(scoreObjs[base + 1], 10) || 0, - playerCount: playerCountByTeam.get(teamId) ?? 0, - }); - } - } else if (gameType === "TR2Game" && objCount >= 4) { - // TR2Game objectiveHud layout (per setupObjHud in objectiveHud.cs): - // for each team (1..2): teamScore, teamName - // then: carrierName, carrierHealth - for (let t = 0; t < 2; t++) { - const base = t * 2; - const teamId = t + 1; - result.teamScores.push({ - teamId, - name: scoreObjs[base + 1] ?? "", - score: parseInt(scoreObjs[base], 10) || 0, - playerCount: playerCountByTeam.get(teamId) ?? 0, - }); - } - } - - // CLOCK: 1 value - if (idx >= demoValues.length) return result; - next(); - - // CHAT: always 10 entries - for (let i = 0; i < 10; i++) { - if (idx >= demoValues.length) break; - const line = next(); - if (line) { - result.chatMessages.push(line); - } - } - - // GRAVITY: 1 value (the server's getGravity() value). - if (idx < demoValues.length) { - const g = parseFloat(next()); - if (Number.isFinite(g)) { - result.gravity = g; - } - } - - return result; -} - -function isValidPosition( - pos: { x: number; y: number; z: number } | undefined | null, -): pos is { x: number; y: number; z: number } { - return ( - pos != null && - Number.isFinite(pos.x) && - Number.isFinite(pos.y) && - Number.isFinite(pos.z) - ); -} - -function clamp(value: number, min: number, max: number): number { - if (value < min) return min; - if (value > max) return max; - return value; -} - -function yawPitchToQuaternion( - yaw: number, - pitch: number, -): [number, number, number, number] { - const sx = Math.sin(pitch); - const cx = Math.cos(pitch); - const sz = Math.sin(yaw); - const cz = Math.cos(yaw); - - _rotMat.set( - -sz, - cz * sx, - -cz * cx, - 0, - 0, - cx, - sx, - 0, - cz, - sz * sx, - -sz * cx, - 0, - 0, - 0, - 0, - 1, - ); - - _rotQuat.setFromRotationMatrix(_rotMat); - return [_rotQuat.x, _rotQuat.y, _rotQuat.z, _rotQuat.w]; -} - -function playerYawToQuaternion(rotZ: number): [number, number, number, number] { - const halfAngle = -rotZ / 2; - return [0, Math.sin(halfAngle), 0, Math.cos(halfAngle)]; -} - -function torqueQuatToThreeJS(q: { - x: number; - y: number; - z: number; - w: number; -}): [number, number, number, number] | null { - if ( - !Number.isFinite(q.x) || - !Number.isFinite(q.y) || - !Number.isFinite(q.z) || - !Number.isFinite(q.w) - ) { - return null; - } - - // Match mission axis-angle conversion: axis swizzle (x,y,z)->(y,z,x) - // and inverted rotation direction (negated imaginary components). - const x = -q.y; - const y = -q.z; - const z = -q.x; - const w = q.w; - - const lenSq = x * x + y * y + z * z + w * w; - if (lenSq <= 1e-12) { - return null; - } - - const invLen = 1 / Math.sqrt(lenSq); - return [x * invLen, y * invLen, z * invLen, w * invLen]; -} - -function shouldRenderGhostEntity(entity: MutableStreamEntity): boolean { - if (entity.spawnTick > 0) return true; - return !missionOwnedGhostClassNames.has(entity.className); -} - -function stripTaggedStringMarkup(s: string): string { - let stripped = ""; - for (let i = 0; i < s.length; i++) { - if (s.charCodeAt(i) >= 0x20) { - stripped += s[i]; - } - } - return stripped; -} - -/** - * Byte-to-fontColors-index remap table from the Torque V12 renderer (dgl.cc). - * - * TorqueScript `\cN` escapes are encoded via `collapseRemap` in scan.l, - * producing byte values that skip \t (0x9), \n (0xa), and \r (0xd): - * \c0→0x2, \c1→0x3, \c2→0x4, \c3→0x5, \c4→0x6, - * \c5→0x7, \c6→0x8, \c7→0xb, \c8→0xc, \c9→0xe - * - * The renderer remaps those bytes back to fontColors[0–9]: - * byte 0x2→0, 0x3→1, 0x4→2, 0x5→3, 0x6→4, - * 0x7→5, 0x8→6, 0xb→7, 0xc→8, 0xe→9 - */ -const BYTE_TO_COLOR_INDEX: Record = { - 0x2: 0, - 0x3: 1, - 0x4: 2, - 0x5: 3, - 0x6: 4, - 0x7: 5, - 0x8: 6, - 0xb: 7, - 0xc: 8, - 0xe: 9, -}; - -/** Special bytes: \cr = 0xf (reset), \cp = 0x10 (push), \co = 0x11 (pop). */ -const BYTE_COLOR_RESET = 0x0f; -const BYTE_COLOR_PUSH = 0x10; -const BYTE_COLOR_POP = 0x11; - -/** - * Extract the leading Torque \c color index (0–9) from a tagged string. - * Raw bytes are remapped from the collapseRemap encoding to fontColors indices. - */ -function detectColorCode(s: string): number | undefined { - for (let i = 0; i < s.length; i++) { - const code = s.charCodeAt(i); - const colorIndex = BYTE_TO_COLOR_INDEX[code]; - if (colorIndex !== undefined) return colorIndex; - if (code >= 0x20) return undefined; - } - return undefined; -} - -/** - * Parse a raw Torque HudMessageVector line into colored segments. - * Handles tagged string markup (\cp=0x10 push / \co=0x11 pop regions for - * player names), color code switches (remapped byte values), and \cr=0x0f - * color reset. - */ -function parseColorSegments(raw: string): ChatSegment[] { - const segments: ChatSegment[] = []; - let currentColor = 0; - let currentText = ""; - let inTaggedString = false; - - for (let i = 0; i < raw.length; i++) { - const code = raw.charCodeAt(i); - - if (code === BYTE_COLOR_PUSH) { - // \cp — push color / start of tagged string region. - inTaggedString = true; - continue; - } - if (code === BYTE_COLOR_POP) { - // \co — pop color / end of tagged string region. - inTaggedString = false; - continue; - } - - if (inTaggedString) { - // Inside tagged string: only keep printable chars, skip markup bytes. - if (code >= 0x20) { - currentText += raw[i]; - } - continue; - } - - // Outside tagged string. - const colorIndex = BYTE_TO_COLOR_INDEX[code]; - if (colorIndex !== undefined) { - // Color code switch. - if (currentText) { - segments.push({ text: currentText, colorCode: currentColor }); - currentText = ""; - } - currentColor = colorIndex; - } else if (code === BYTE_COLOR_RESET) { - // \cr — reset to default color. - if (currentText) { - segments.push({ text: currentText, colorCode: currentColor }); - currentText = ""; - } - currentColor = 0; - } else if (code >= 0x20) { - currentText += raw[i]; - } - } - - if (currentText) { - segments.push({ text: currentText, colorCode: currentColor }); - } - return segments; -} - -/** Extract an embedded `~w` sound tag from a message string. */ -function extractWavTag(text: string): { text: string; wavPath: string | null } { - const idx = text.indexOf("~w"); - if (idx === -1) return { text, wavPath: null }; - return { - text: text.substring(0, idx), - wavPath: text.substring(idx + 2), - }; -} - -function toEntityType(className: string): string { - if (className === "Player") return "Player"; - if (vehicleClassNames.has(className)) return "Vehicle"; - if (className === "Item") return "Item"; - if (projectileClassNames.has(className)) return "Projectile"; - if (deployableClassNames.has(className)) return "Deployable"; - return "Ghost"; -} - -function toEntityId(className: string, ghostIndex: number): string { - if (className === "Player") return `player_${ghostIndex}`; - if (vehicleClassNames.has(className)) return `vehicle_${ghostIndex}`; - if (className === "Item") return `item_${ghostIndex}`; - if (projectileClassNames.has(className)) return `projectile_${ghostIndex}`; - if (deployableClassNames.has(className)) return `deployable_${ghostIndex}`; - return `ghost_${ghostIndex}`; -} - -function isQuatLike(value: unknown): value is { - x: number; - y: number; - z: number; - w: number; -} { - return ( - !!value && - typeof value === "object" && - typeof (value as { x?: unknown }).x === "number" && - typeof (value as { y?: unknown }).y === "number" && - typeof (value as { z?: unknown }).z === "number" && - typeof (value as { w?: unknown }).w === "number" - ); -} - -function isVec3Like( - value: unknown, -): value is { x: number; y: number; z: number } { - return ( - !!value && - typeof value === "object" && - typeof (value as { x?: unknown }).x === "number" && - typeof (value as { y?: unknown }).y === "number" && - typeof (value as { z?: unknown }).z === "number" - ); -} - -function toShapeNameFromDataBlock( - data: Record | undefined, -): string | undefined { - if (!data) return undefined; - const candidates = [ - data.shapeName, - data.projectileShapeName, - data.shapeFileName, - data.shapeFile, - data.model, - ]; - for (const candidate of candidates) { - if (typeof candidate === "string" && candidate.length > 0) { - return candidate; - } - } - return undefined; -} - -function getNumberField( - data: Record | undefined, - keys: readonly string[], -): number | undefined { - if (!data) return undefined; - for (const key of keys) { - const value = data[key]; - if (typeof value === "number" && Number.isFinite(value)) { - return value; - } - } - return undefined; -} - -/** - * Extract the weapon image state machine states from a ShapeBaseImageData - * datablock. The parser emits a dense array (skipping unnamed states), but - * the transition indices reference original positions 0-30. - * - * CRITICAL: The parser's field names for transitions are MISALIGNED with - * the actual engine packing order. The V12 engine packs transitions as: - * loaded[0], loaded[1], ammo[0], ammo[1], target[0], target[1], - * wet[0], wet[1], trigger[0], trigger[1], timeout - * But the parser named the first two "transitionOnAmmo/transitionOnNoAmmo" - * when they're actually loaded[0]/loaded[1]. Every field is shifted by 2. - * - * Additionally, the engine writes `value+1` (to encode -1 as 0) but the - * parser reads the raw value without subtracting 1. So the raw sentinel - * for "no transition" is 0, and all state indices are off by +1. - */ -function parseWeaponImageStates( - blockData: Record, -): WeaponImageDataBlockState[] | undefined { - const rawStates = blockData.states as - | Array> - | undefined; - if (!Array.isArray(rawStates) || rawStates.length === 0) return undefined; - - return rawStates.map((s) => { - // Subtract 1 to reverse the engine's +1 offset. Raw 0 → -1 (no transition). - const remap = (v: unknown): number => { - const n = v as number; - if (n == null) return -1; - return n - 1; - }; - - // Remap parser field names to actual engine field meanings. - // Parser reads 11 values in order, but names them wrong: - // Parser field → Actual engine field - // transitionOnAmmo → loaded[0] (notLoaded) - // transitionOnNoAmmo → loaded[1] (loaded) - // transitionOnTarget → ammo[0] (noAmmo) - // transitionOnNoTarget → ammo[1] (ammo) - // transitionOnWet → target[0] (noTarget) - // transitionOnNotWet → target[1] (target) - // transitionOnTriggerUp → wet[0] (notWet) - // transitionOnTriggerDown → wet[1] (wet) - // transitionOnTimeout → trigger[0](triggerUp) - // transitionGeneric0In → trigger[1](triggerDown) - // transitionGeneric0Out → timeout - return { - name: (s.name as string) ?? "", - transitionOnNotLoaded: remap(s.transitionOnAmmo), - transitionOnLoaded: remap(s.transitionOnNoAmmo), - transitionOnNoAmmo: remap(s.transitionOnTarget), - transitionOnAmmo: remap(s.transitionOnNoTarget), - transitionOnNoTarget: remap(s.transitionOnWet), - transitionOnTarget: remap(s.transitionOnNotWet), - transitionOnNotWet: remap(s.transitionOnTriggerUp), - transitionOnWet: remap(s.transitionOnTriggerDown), - transitionOnTriggerUp: remap(s.transitionOnTimeout), - transitionOnTriggerDown: remap(s.transitionGeneric0In), - transitionOnTimeout: remap(s.transitionGeneric0Out), - timeoutValue: s.timeoutValue as number | undefined, - waitForTimeout: (s.waitForTimeout as boolean) ?? false, - fire: (s.fire as boolean) ?? false, - sequence: s.sequence as number | undefined, - spin: (s.spin as number) ?? 0, - direction: (s.direction as boolean) ?? true, - scaleAnimation: (s.scaleAnimation as boolean) ?? false, - loaded: (s.loaded as number) ?? 0, - soundDataBlockId: (s.sound as number) ?? -1, - }; - }); -} - -function getStringField( - data: Record | undefined, - keys: readonly string[], -): string | undefined { - if (!data) return undefined; - for (const key of keys) { - const value = data[key]; - if (typeof value === "string" && value.length > 0) { - return value; - } - } - return undefined; -} - -function getBooleanField( - data: Record | undefined, - keys: readonly string[], -): boolean | undefined { - if (!data) return undefined; - for (const key of keys) { - const value = data[key]; - if (typeof value === "boolean") { - return value; - } - } - return undefined; -} - -function resolveTracerVisual( - className: string, - data: Record | undefined, -): DemoVisual | undefined { - if (!data) return undefined; - - const texture = - getStringField(data, ["tracerTex0", "textureName0", "texture0"]) ?? ""; - const hasTracerHints = - className === "TracerProjectile" || - (texture.length > 0 && getNumberField(data, ["tracerLength"]) != null); - if (!hasTracerHints || !texture) return undefined; - - const crossTexture = getStringField(data, [ - "tracerTex1", - "textureName1", - "texture1", - ]); - - // t2-demo-parser vends TracerProjectileData fields with some legacy names. - // Accept both canonical script names and parser-specific aliases. - const tracerLength = getNumberField(data, ["tracerLength"]) ?? 10; - const canonicalTracerWidth = getNumberField(data, ["tracerWidth"]); - const aliasTracerWidth = getNumberField(data, ["tracerAlpha"]); - const tracerWidth = - canonicalTracerWidth != null && - (getNumberField(data, ["crossViewAng"]) != null || - canonicalTracerWidth <= 0.7) - ? canonicalTracerWidth - : (aliasTracerWidth ?? canonicalTracerWidth ?? 0.5); - const crossViewAng = - getNumberField(data, ["crossViewAng", "crossViewFraction"]) ?? - // Parser alias fallback: "tracerWidth" may actually contain crossViewAng. - (typeof data.tracerWidth === "number" && data.tracerWidth > 0.7 - ? data.tracerWidth - : 0.98); - const crossSize = - getNumberField(data, ["crossSize", "muzzleVelocity"]) ?? 0.45; - const renderCross = - getBooleanField(data, ["renderCross", "proximityRadius"]) ?? true; - - return { - kind: "tracer", - texture, - crossTexture, - tracerLength, - tracerWidth, - crossViewAng, - crossSize, - renderCross, - }; -} - -/** - * Resolve a billboard-sprite visual for flare-style projectiles - * (LinearFlareProjectile, FlareProjectile). These render as camera-facing - * quads in the engine rather than 3D models. - */ -function resolveSpriteVisual( - className: string, - data: Record | undefined, -): DemoVisual | undefined { - if (!data) return undefined; - - if (className === "LinearFlareProjectile") { - // Parser fields: flareTexture (flareModTexture in script), - // smokeTexture (flareBaseTexture in script — the circular glow). - const texture = getStringField(data, ["smokeTexture", "flareTexture"]); - if (!texture) return undefined; - const color = data.flareColor as - | { r: number; g: number; b: number } - | undefined; - const size = getNumberField(data, ["size"]) ?? 0.5; - return { - kind: "sprite", - texture, - color: color - ? { r: color.r, g: color.g, b: color.b } - : { r: 1, g: 1, b: 1 }, - size, - }; - } - - if (className === "FlareProjectile") { - const texture = getStringField(data, ["flareTexture"]); - if (!texture) return undefined; - const size = getNumberField(data, ["size"]) ?? 4.0; - return { - kind: "sprite", - texture, - color: { r: 1, g: 0.9, b: 0.5 }, - size, - }; - } - - return undefined; -} - -function detectControlObjectType( - data: Record | undefined, -): ControlObjectType | null { - if (!data) return null; - if (typeof data.cameraMode === "number") return "camera"; - if (typeof data.rotationZ === "number") return "player"; - return null; -} - -class StreamingPlayback implements DemoStreamingPlayback { - private readonly parser: DemoParser; - private readonly initialBlock: { - dataBlocks: Map< - number, - { className: string; data: Record } - >; - initialGhosts: Array<{ - index: number; - type: "create" | "update" | "delete"; - classId?: number; - parsedData?: Record; - }>; - controlObjectGhostIndex: number; - controlObjectData?: Record; - targetEntries: Array<{ - targetId: number; - name?: string; - sensorGroup: number; - targetData: number; - }>; - sensorGroupColors: Array<{ - group: number; - targetGroup: number; - r: number; - g: number; - b: number; - }>; - taggedStrings: Map; - initialEvents: Array<{ - classId: number; - parsedData?: Record; - }>; - demoValues: string[]; - }; - private readonly registry; - private readonly netStrings = new Map(); - private readonly targetNames = new Map(); - private readonly targetTeams = new Map(); - private readonly targetRenderFlags = new Map(); - /** IFF color map: for the viewer's sensorGroup, map target sensorGroup → RGB. */ - private readonly sensorGroupColors = new Map< - number, - Map - >(); - private state: StreamState; - - // Generation counters for derived-array caching in buildSnapshot(). - private _teamScoresGen = 0; - private _rosterGen = 0; - private _weaponsHudGen = 0; - private _inventoryHudGen = 0; - - // Cached snapshot returned when no ticks advance between stepToTime() calls. - private _cachedSnapshot: DemoStreamSnapshot | null = null; - private _cachedSnapshotTick = -1; - - // Cached derived arrays from the last buildSnapshot() call. - private _snap: { - teamScoresGen: number; - rosterGen: number; - teamScores: TeamScore[]; - weaponsHudGen: number; - weaponsHud: { slots: WeaponsHudSlot[]; activeIndex: number }; - inventoryHudGen: number; - inventoryHud: { slots: InventoryHudSlot[]; activeSlot: number }; - backpackPackIndex: number; - backpackActive: boolean; - backpackText: string; - backpackHud: BackpackHudState | null; - } | null = null; - - constructor(parser: DemoParser) { - this.parser = parser; - this.registry = parser.getRegistry(); - const initial = parser.initialBlock; - this.initialBlock = { - dataBlocks: initial.dataBlocks, - initialGhosts: initial.initialGhosts, - controlObjectGhostIndex: initial.controlObjectGhostIndex, - controlObjectData: initial.controlObjectData, - targetEntries: initial.targetEntries, - sensorGroupColors: initial.sensorGroupColors, - taggedStrings: initial.taggedStrings, - initialEvents: initial.initialEvents, - demoValues: initial.demoValues, - }; - - this.state = { - moveTicks: 0, - absoluteYaw: 0, - absolutePitch: 0, - lastAbsYaw: 0, - lastAbsPitch: 0, - lastControlType: "player", - isPiloting: false, - lastOrbitDistance: undefined, - exhausted: false, - latestFov: 100, - latestControl: { - ghostIndex: initial.controlObjectGhostIndex, - data: initial.controlObjectData, - position: isValidPosition(initial.controlObjectData?.position as Vec3) - ? (initial.controlObjectData?.position as Vec3) - : undefined, - }, - camera: null, - entitiesById: new Map(), - entityIdByGhostIndex: new Map(), - lastStatus: { health: 1, energy: 1 }, - nextExplosionId: 0, - playerSensorGroup: 0, - chatMessages: [], - pendingAudioEvents: [], - weaponsHud: { slots: new Map(), activeIndex: -1 }, - backpackHud: { packIndex: -1, active: false, text: "" }, - inventoryHud: { slots: new Map(), activeSlot: -1 }, - teamScores: [], - playerRoster: new Map(), - }; - - this.reset(); - } - - reset(): void { - this.parser.reset(); - this._cachedSnapshot = null; - this._cachedSnapshotTick = -1; - this._snap = null; - - this.netStrings.clear(); - this.targetNames.clear(); - this.targetTeams.clear(); - this.targetRenderFlags.clear(); - this.sensorGroupColors.clear(); - this.state.entitiesById.clear(); - this.state.entityIdByGhostIndex.clear(); - - for (const [id, value] of this.initialBlock.taggedStrings) { - this.netStrings.set(id, value); - } - for (const entry of this.initialBlock.targetEntries) { - if (entry.name) { - this.targetNames.set( - entry.targetId, - stripTaggedStringMarkup(entry.name), - ); - } - this.targetTeams.set(entry.targetId, entry.sensorGroup); - this.targetRenderFlags.set(entry.targetId, entry.targetData); - } - // Seed IFF color table from the initial block. - for (const c of this.initialBlock.sensorGroupColors) { - let map = this.sensorGroupColors.get(c.group); - if (!map) { - map = new Map(); - this.sensorGroupColors.set(c.group, map); - } - map.set(c.targetGroup, { r: c.r, g: c.g, b: c.b }); - } - - this.state.playerSensorGroup = 0; - this.state.chatMessages = []; - this.state.pendingAudioEvents = []; - this.state.weaponsHud = { slots: new Map(), activeIndex: -1 }; - this.state.backpackHud = { packIndex: -1, active: false, text: "" }; - this.state.inventoryHud = { slots: new Map(), activeSlot: -1 }; - this.state.teamScores = []; - this.state.playerRoster = new Map(); - this.state.moveTicks = 0; - this.state.absoluteYaw = 0; - this.state.absolutePitch = 0; - this.state.lastAbsYaw = 0; - this.state.lastAbsPitch = 0; - this.state.lastControlType = - detectControlObjectType(this.initialBlock.controlObjectData) ?? "player"; - this.state.isPiloting = - this.state.lastControlType === "player" - ? !!( - this.initialBlock.controlObjectData?.pilot || - this.initialBlock.controlObjectData?.controlObjectGhost != null - ) - : false; - this.state.lastCameraMode = - this.state.lastControlType === "camera" && - typeof this.initialBlock.controlObjectData?.cameraMode === "number" - ? this.initialBlock.controlObjectData.cameraMode - : undefined; - this.state.lastOrbitGhostIndex = - this.state.lastControlType === "camera" && - typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex === - "number" - ? this.initialBlock.controlObjectData.orbitObjectGhostIndex - : undefined; - if (this.state.lastControlType === "camera") { - const minOrbit = this.initialBlock.controlObjectData?.minOrbitDist as - | number - | undefined; - const maxOrbit = this.initialBlock.controlObjectData?.maxOrbitDist as - | number - | undefined; - const curOrbit = this.initialBlock.controlObjectData?.curOrbitDist as - | number - | undefined; - if ( - typeof minOrbit === "number" && - typeof maxOrbit === "number" && - Number.isFinite(minOrbit) && - Number.isFinite(maxOrbit) - ) { - this.state.lastOrbitDistance = Math.max(0, maxOrbit - minOrbit); - } else if (typeof curOrbit === "number" && Number.isFinite(curOrbit)) { - this.state.lastOrbitDistance = Math.max(0, curOrbit); - } else { - this.state.lastOrbitDistance = undefined; - } - } else { - this.state.lastOrbitDistance = undefined; - } - const initialAbsRot = this.getAbsoluteRotation( - this.initialBlock.controlObjectData, - ); - if (initialAbsRot) { - this.state.absoluteYaw = initialAbsRot.yaw; - this.state.absolutePitch = initialAbsRot.pitch; - this.state.lastAbsYaw = initialAbsRot.yaw; - this.state.lastAbsPitch = initialAbsRot.pitch; - } - this.state.exhausted = false; - this.state.latestFov = 100; - this.state.latestControl = { - ghostIndex: this.initialBlock.controlObjectGhostIndex, - data: this.initialBlock.controlObjectData, - position: isValidPosition( - this.initialBlock.controlObjectData?.position as Vec3, - ) - ? (this.initialBlock.controlObjectData?.position as Vec3) - : undefined, - }; - this.state.controlPlayerGhostId = - this.state.lastControlType === "player" && - this.initialBlock.controlObjectGhostIndex >= 0 - ? `player_${this.initialBlock.controlObjectGhostIndex}` - : undefined; - this.state.camera = null; - this.state.lastStatus = { health: 1, energy: 1 }; - this.state.nextExplosionId = 0; - - for (const ghost of this.initialBlock.initialGhosts) { - if (ghost.type !== "create" || ghost.classId == null) continue; - const className = - this.registry.getGhostParser(ghost.classId)?.name ?? - `ghost_${ghost.classId}`; - const id = toEntityId(className, ghost.index); - const entity: MutableStreamEntity = { - id, - ghostIndex: ghost.index, - className, - spawnTick: 0, - type: toEntityType(className), - rotation: [0, 0, 0, 1], - }; - this.applyGhostData(entity, ghost.parsedData); - this.state.entitiesById.set(id, entity); - this.state.entityIdByGhostIndex.set(ghost.index, id); - } - - // Derive playerSensorGroup from the control player entity if not yet set - // (the SetSensorGroupEvent may not have arrived in the initial block). - if ( - this.state.playerSensorGroup === 0 && - this.state.lastControlType === "player" && - this.state.latestControl.ghostIndex >= 0 - ) { - const ctrlId = this.state.entityIdByGhostIndex.get( - this.state.latestControl.ghostIndex, - ); - const ctrlEntity = ctrlId - ? this.state.entitiesById.get(ctrlId) - : undefined; - if (ctrlEntity?.sensorGroup != null && ctrlEntity.sensorGroup > 0) { - this.state.playerSensorGroup = ctrlEntity.sensorGroup; - } - } - - // Process initial events (guaranteed events pending in the connection's - // event queue at recording start). - for (const evt of this.initialBlock.initialEvents) { - const eventName = this.registry.getEventParser(evt.classId)?.name; - if (eventName === "SetSensorGroupEvent" && evt.parsedData) { - const sg = evt.parsedData.sensorGroup as number | undefined; - if (sg != null) this.state.playerSensorGroup = sg; - } else if (eventName === "RemoteCommandEvent" && evt.parsedData) { - const funcName = this.resolveNetString( - evt.parsedData.funcName as string, - ); - const args = evt.parsedData.args as string[]; - if (funcName === "ServerMessage") { - this.handleServerMessage(args); - } - this.handleHudRemoteCommand(funcName, args); - } - } - - // Seed HUD state from demoValues (the $DemoValue console variable - // snapshot captured at recording start by saveDemoSettings/getState). - const parsed = parseDemoValues(this.initialBlock.demoValues); - if (parsed.weaponsHud) { - this.state.weaponsHud.slots = parsed.weaponsHud.slots; - this.state.weaponsHud.activeIndex = parsed.weaponsHud.activeIndex; - } - if (parsed.backpackHud) { - this.state.backpackHud.packIndex = parsed.backpackHud.packIndex; - this.state.backpackHud.active = parsed.backpackHud.active; - this.state.backpackHud.text = parsed.backpackHud.text; - } - if (parsed.inventoryHud) { - this.state.inventoryHud.slots = parsed.inventoryHud.slots; - this.state.inventoryHud.activeSlot = parsed.inventoryHud.activeSlot; - } - this.state.teamScores = parsed.teamScores; - this.state.playerRoster = new Map(parsed.playerRoster); - // Seed chat messages at time 0 so they appear at start and fade naturally. - // Raw lines from HudMessageVector contain Torque control chars: collapsed - // color bytes (0x02–0x0e via collapseRemap), tagged string markup - // (\x10/\x11 for player names), and color reset (\x0f). - for (const rawLine of parsed.chatMessages) { - const segments = parseColorSegments(rawLine); - if (!segments.length) continue; - const fullText = segments.map((s) => s.text).join(""); - if (!fullText.trim()) continue; - // Determine overall color and kind from the first segment. - const primaryColor = segments[0].colorCode; - // Player chat lines use \c3 (team green, byte 0x05) or \c4 (global - // cyan, byte 0x06). Canned chat (voicebinds) may start with a c0 - // "[VGS] " prefix before the colored name. Detect player chat by - // looking for a ": " separator and a chat color in any segment. - const hasChatColor = segments.some( - (s) => s.colorCode === 3 || s.colorCode === 4 - ); - const isPlayerChat = hasChatColor && fullText.includes(": "); - if (isPlayerChat) { - const colonIdx = fullText.indexOf(": "); - this.state.chatMessages.push({ - timeSec: 0, - sender: fullText.slice(0, colonIdx), - text: fullText.slice(colonIdx + 2), - kind: "chat", - colorCode: primaryColor, - segments, - }); - } else { - this.state.chatMessages.push({ - timeSec: 0, - sender: "", - text: fullText, - kind: "server", - colorCode: primaryColor, - segments, - }); - } - } - - this.updateCameraAndHud(); - } - - getSnapshot(): DemoStreamSnapshot { - if (this._cachedSnapshot && this._cachedSnapshotTick === this.state.moveTicks) { - return this._cachedSnapshot; - } - const snapshot = this.buildSnapshot(); - this._cachedSnapshot = snapshot; - this._cachedSnapshotTick = this.state.moveTicks; - return snapshot; - } - - getEffectShapes(): string[] { - const shapes = new Set(); - const collectShapesFromExplosion = (expBlock: Record) => { - const shape = expBlock.dtsFileName as string | undefined; - if (shape) shapes.add(shape); - // Sub-explosions also have DTS shapes (e.g. mortar sub-explosions). - const subExplosions = expBlock.subExplosions as (number | null)[] | undefined; - if (Array.isArray(subExplosions)) { - for (const subId of subExplosions) { - if (subId == null) continue; - const subBlock = this.getDataBlockData(subId); - if (subBlock?.dtsFileName) { - shapes.add(subBlock.dtsFileName as string); - } - } - } - }; - for (const [, block] of this.initialBlock.dataBlocks) { - const explosionId = block.data?.explosion as number | undefined; - if (explosionId == null) continue; - const expBlock = this.getDataBlockData(explosionId); - if (expBlock) collectShapesFromExplosion(expBlock); - } - return [...shapes]; - } - - stepToTime( - targetTimeSec: number, - maxMoveTicks = Number.POSITIVE_INFINITY, - ): DemoStreamSnapshot { - const safeTargetSec = Number.isFinite(targetTimeSec) - ? Math.max(0, targetTimeSec) - : 0; - const targetTicks = Math.floor((safeTargetSec * 1000) / TICK_DURATION_MS); - - let didReset = false; - if (targetTicks < this.state.moveTicks) { - this.reset(); - didReset = true; - } - - const wasExhausted = this.state.exhausted; - let movesProcessed = 0; - while ( - !this.state.exhausted && - this.state.moveTicks < targetTicks && - movesProcessed < maxMoveTicks - ) { - if (!this.stepOneMoveTick()) { - break; - } - movesProcessed += 1; - } - - if ( - movesProcessed === 0 && - !didReset && - wasExhausted === this.state.exhausted && - this._cachedSnapshot && - this._cachedSnapshotTick === this.state.moveTicks - ) { - return this._cachedSnapshot; - } - - const snapshot = this.buildSnapshot(); - this._cachedSnapshot = snapshot; - this._cachedSnapshotTick = this.state.moveTicks; - return snapshot; - } - - private stepOneMoveTick(): boolean { - while (true) { - const block = this.parser.nextBlock(); - if (!block) { - this.state.exhausted = true; - return false; - } - - this.handleBlock(block); - - if (block.type === BlockTypeMove) { - this.state.moveTicks += 1; - this.advanceProjectiles(); - this.advanceItems(); - this.removeExpiredExplosions(); - this.updateCameraAndHud(); - return true; - } - } - } - - private handleBlock(block: { type: number; parsed?: unknown }): void { - if (block.type === BlockTypePacket && this.isPacketData(block.parsed)) { - const packet = block.parsed; - const controlData = packet.gameState.controlObjectData; - const prevControl = this.state.latestControl; - const nextGhostIndex = - typeof packet.gameState.controlObjectGhostIndex === "number" - ? packet.gameState.controlObjectGhostIndex - : prevControl.ghostIndex; - const compressionPoint = packet.gameState.compressionPoint; - const controlPosition = isValidPosition(controlData?.position as Vec3) - ? (controlData?.position as Vec3) - : isValidPosition(compressionPoint) - ? compressionPoint - : prevControl.position; - - this.state.latestControl = { - ghostIndex: nextGhostIndex, - data: controlData, - position: controlPosition, - }; - - // When the control object changes, try to derive playerSensorGroup - // from the new ghost's already-known sensorGroup. - if (nextGhostIndex !== prevControl.ghostIndex) { - const entityId = this.state.entityIdByGhostIndex.get(nextGhostIndex); - const entity = entityId - ? this.state.entitiesById.get(entityId) - : undefined; - if (entity?.sensorGroup != null && entity.sensorGroup > 0) { - this.state.playerSensorGroup = entity.sensorGroup; - } - } - - if (controlData) { - const detected = detectControlObjectType(controlData); - if (detected) { - this.state.lastControlType = detected; - } - - if (this.state.lastControlType === "player") { - this.state.isPiloting = !!( - controlData.pilot || controlData.controlObjectGhost != null - ); - } else { - this.state.isPiloting = false; - if (typeof controlData.cameraMode === "number") { - this.state.lastCameraMode = controlData.cameraMode; - if (controlData.cameraMode === CameraMode_OrbitObject) { - if (typeof controlData.orbitObjectGhostIndex === "number") { - this.state.lastOrbitGhostIndex = - controlData.orbitObjectGhostIndex; - } - const minOrbit = controlData.minOrbitDist as number | undefined; - const maxOrbit = controlData.maxOrbitDist as number | undefined; - const curOrbit = controlData.curOrbitDist as number | undefined; - if ( - typeof minOrbit === "number" && - typeof maxOrbit === "number" && - Number.isFinite(minOrbit) && - Number.isFinite(maxOrbit) - ) { - this.state.lastOrbitDistance = Math.max(0, maxOrbit - minOrbit); - } else if ( - typeof curOrbit === "number" && - Number.isFinite(curOrbit) - ) { - this.state.lastOrbitDistance = Math.max(0, curOrbit); - } - } else { - this.state.lastOrbitGhostIndex = undefined; - this.state.lastOrbitDistance = undefined; - } - } - } - - // Apply ghost rotation to absolute tracking. This must happen before - // the next move delta so that our tracking stays calibrated to V12. - const absRot = this.getAbsoluteRotation(controlData); - if (absRot) { - this.state.absoluteYaw = absRot.yaw; - this.state.absolutePitch = absRot.pitch; - this.state.lastAbsYaw = absRot.yaw; - this.state.lastAbsPitch = absRot.pitch; - } - } - - for (const evt of packet.events) { - const eventName = this.registry.getEventParser(evt.classId)?.name; - if (eventName === "NetStringEvent" && evt.parsedData) { - const id = evt.parsedData.id as number | undefined; - const value = evt.parsedData.value as string | undefined; - if (id != null && typeof value === "string") { - this.netStrings.set(id, value); - } - continue; - } - - if (eventName === "TargetInfoEvent" && evt.parsedData) { - const targetId = evt.parsedData.targetId as number | undefined; - const nameTag = evt.parsedData.nameTag as number | undefined; - if (targetId != null && nameTag != null) { - const resolved = this.netStrings.get(nameTag); - if (resolved) { - this.targetNames.set(targetId, stripTaggedStringMarkup(resolved)); - } - } - const sensorGroup = evt.parsedData.sensorGroup as number | undefined; - if (targetId != null && sensorGroup != null) { - this.targetTeams.set(targetId, sensorGroup); - } - const renderFlags = evt.parsedData.renderFlags as number | undefined; - if (targetId != null && renderFlags != null) { - this.targetRenderFlags.set(targetId, renderFlags); - // Propagate to any entity bound to this target so render flags - // take effect immediately (e.g. clearing bit 0x2 when a player - // drops a flag) rather than waiting for the next ghost update. - for (const entity of this.state.entitiesById.values()) { - if (entity.targetId === targetId) { - entity.targetRenderFlags = renderFlags; - } - } - } - } else if (eventName === "SetSensorGroupEvent" && evt.parsedData) { - const sg = evt.parsedData.sensorGroup as number | undefined; - if (sg != null) this.state.playerSensorGroup = sg; - } else if (eventName === "SensorGroupColorEvent" && evt.parsedData) { - const sg = evt.parsedData.sensorGroup as number; - const colors = evt.parsedData.colors as - | Array<{ - index: number; - r?: number; - g?: number; - b?: number; - default?: boolean; - }> - | undefined; - if (colors) { - let map = this.sensorGroupColors.get(sg); - if (!map) { - map = new Map(); - this.sensorGroupColors.set(sg, map); - } - for (const c of colors) { - if (c.default) { - map.delete(c.index); - } else { - map.set(c.index, { - r: c.r ?? 0, - g: c.g ?? 0, - b: c.b ?? 0, - }); - } - } - } - } else if (eventName === "RemoteCommandEvent" && evt.parsedData) { - const funcName = this.resolveNetString( - evt.parsedData.funcName as string, - ); - const args = evt.parsedData.args as string[]; - const timeSec = this.state.moveTicks * (TICK_DURATION_MS / 1000); - - if (funcName === "ChatMessage" && args.length >= 4) { - // ChatMessage args: 0=clientId, 1=voice, 2=pitch, - // 3=template (e.g. '\c3%1: %2'), 4+=substitution args. - // Detect team (\c3) vs global (\c4) from the template's - // leading color code before it's stripped. - const rawTemplate = this.resolveNetString(args[3]); - const colorCode = detectColorCode(rawTemplate); - // Extract sender name from args[4] (%1) and message from - // the formatted text. args[0] is the client object ID, not - // the player name. - const sender = args[4] - ? stripTaggedStringMarkup(this.resolveNetString(args[4])) - : ""; - const rawText = this.formatRemoteArgs(args[3], args.slice(4)); - if (rawText) { - // The formatted text is "Name: message"; extract just the - // message portion since we already have the sender name. - const colonIdx = rawText.indexOf(": "); - const text = colonIdx >= 0 ? rawText.slice(colonIdx + 2) : rawText; - const { text: displayText, wavPath } = extractWavTag(text); - let soundPath: string | undefined; - let soundPitch: number | undefined; - if (wavPath) { - const voice = this.resolveNetString(args[1]); - if (voice) { - soundPath = `voice/${voice}/${wavPath}.wav`; - } else { - soundPath = wavPath; - } - const pitchStr = this.resolveNetString(args[2]); - if (pitchStr) { - const p = parseFloat(pitchStr); - if (Number.isFinite(p)) { - soundPitch = Math.max(0.5, Math.min(2.0, p)); - } - } - } - const cc = colorCode ?? 0; - this.pushChatMessage({ - timeSec, - sender, - text: displayText, - kind: "chat", - colorCode: cc, - segments: [ - { - text: sender ? `${sender}: ${displayText}` : displayText, - colorCode: cc, - }, - ], - soundPath, - soundPitch, - }); - } - } else if ( - funcName === "CannedChatMessage" && - args.length >= 6 - ) { - // CannedChatMessage args (from cannedChatMessageClient): - // 0: sender (client ID), 1: msgString (template with %1/%2), - // 2: name, 3: string (voice text, may contain ~w), - // 4: keys (e.g. "VGS"), 5: voiceTag, 6: voicePitch - // The template uses %1=name, %2=string. The ~w tag is typically - // embedded in args[3], so it only appears after substitution. - const cannedColorCode = detectColorCode( - this.resolveNetString(args[1]), - ); - const name = stripTaggedStringMarkup( - this.resolveNetString(args[2]), - ); - const keys = stripTaggedStringMarkup( - this.resolveNetString(args[4]), - ); - const sender = name; - // Substitute %1/%2 in the template, then extract ~w. - const rawText = this.formatRemoteArgs(args[1], args.slice(2)); - if (rawText) { - const { wavPath } = extractWavTag(rawText); - // Build display text from the individual resolved components - // rather than the template (which includes "name: " redundantly - // with the separate sender field). - const voiceLine = extractWavTag( - stripTaggedStringMarkup(this.resolveNetString(args[3])), - ).text; - const text = voiceLine; - - let soundPath: string | undefined; - let soundPitch: number | undefined; - if (wavPath) { - const voice = this.resolveNetString(args[5]); - if (voice) { - soundPath = `voice/${voice}/${wavPath}.wav`; - } else { - soundPath = wavPath; - } - if (args[6]) { - const p = parseFloat(this.resolveNetString(args[6])); - if (Number.isFinite(p)) { - soundPitch = Math.max(0.5, Math.min(2.0, p)); - } - } - } - const cc = cannedColorCode ?? 0; - const cannedSegments: ChatSegment[] = []; - if (keys) { - cannedSegments.push({ - text: `[${keys}] `, - colorCode: 0, - }); - } - cannedSegments.push({ - text: sender ? `${sender}: ${text}` : text, - colorCode: cc, - }); - this.pushChatMessage({ - timeSec, - sender, - text, - kind: "chat", - colorCode: cc, - segments: cannedSegments, - soundPath, - soundPitch, - }); - } - } else if (funcName === "ServerMessage" && args.length >= 2) { - this.handleServerMessage(args); - const rawTemplate = this.resolveNetString(args[1]); - const serverColorCode = detectColorCode(rawTemplate); - const rawText = this.formatRemoteArgs(args[1], args.slice(2)); - if (rawText) { - const { text, wavPath } = extractWavTag(rawText); - const scc = serverColorCode ?? 0; - this.pushChatMessage({ - timeSec, - sender: "", - text, - kind: "server", - colorCode: scc, - segments: [{ text, colorCode: scc }], - soundPath: wavPath ?? undefined, - }); - } - } else { - this.handleHudRemoteCommand(funcName, args); - } - } else if ( - (eventName === "Sim3DAudioEvent" || - eventName === "Sim2DAudioEvent") && - evt.parsedData - ) { - const profileId = evt.parsedData.profileId as number; - if (typeof profileId === "number") { - const timeSec = this.state.moveTicks * (TICK_DURATION_MS / 1000); - const position = - eventName === "Sim3DAudioEvent" - ? (evt.parsedData.position as - | { x: number; y: number; z: number } - | undefined) - : undefined; - this.state.pendingAudioEvents.push({ profileId, position, timeSec }); - if (this.state.pendingAudioEvents.length > 100) { - this.state.pendingAudioEvents.splice( - 0, - this.state.pendingAudioEvents.length - 100, - ); - } - } - } - } - - for (const ghost of packet.ghosts) { - this.applyPacketGhost(ghost); - } - - return; - } - - if (block.type === BlockTypeInfo && this.isInfoData(block.parsed)) { - if (Number.isFinite(block.parsed.value2)) { - this.state.latestFov = block.parsed.value2; - } - return; - } - - if (block.type === BlockTypeMove && this.isMoveData(block.parsed)) { - // Replicate V12 Player::updateMove(): apply delta then wrap/clamp. - this.state.absoluteYaw += block.parsed.yaw ?? 0; - // V12 wraps yaw to [0, 2π] each tick. - const TWO_PI = Math.PI * 2; - this.state.absoluteYaw = - ((this.state.absoluteYaw % TWO_PI) + TWO_PI) % TWO_PI; - // V12 clamps pitch to [minLookAngle, maxLookAngle] each tick. - this.state.absolutePitch = clamp( - this.state.absolutePitch + (block.parsed.pitch ?? 0), - -MAX_PITCH, - MAX_PITCH, - ); - } - } - - private applyPacketGhost(ghost: { - index: number; - type: "create" | "update" | "delete"; - classId?: number; - parsedData?: Record; - }): void { - const ghostIndex = ghost.index; - const prevEntityId = this.state.entityIdByGhostIndex.get(ghostIndex); - - // When a projectile entity is being removed (ghost delete, ghost index - // reuse, or same-class index reuse), spawn an explosion at its last known - // position if it hasn't already exploded. Explosion positions usually - // arrive via ExplosionMask in ghost updates (the server has a 13-tick / - // 416ms DeleteWaitTicks window before KillGhost fires), but this fallback - // catches cases where the explicit data was missed — e.g. network - // congestion or the projectile going out of scope before the update. - if (prevEntityId) { - const prevEntity = this.state.entitiesById.get(prevEntityId); - if ( - prevEntity && - prevEntity.type === "Projectile" && - !prevEntity.hasExploded && - prevEntity.explosionDataBlockId != null && - prevEntity.position && - // Ghost is being deleted or its index is being reassigned to a new - // ghost (either a different class or a fresh create of the same class). - (ghost.type === "delete" || ghost.type === "create") - ) { - this.spawnExplosion(prevEntity, [...prevEntity.position] as [ - number, - number, - number, - ]); - } - } - - if (ghost.type === "delete") { - if (prevEntityId) { - this.state.entitiesById.delete(prevEntityId); - this.state.entityIdByGhostIndex.delete(ghostIndex); - } - return; - } - - const className = this.resolveGhostClassName(ghostIndex, ghost.classId); - if (!className) { - return; - } - - const entityId = toEntityId(className, ghostIndex); - if (prevEntityId && prevEntityId !== entityId) { - this.state.entitiesById.delete(prevEntityId); - } - - let entity: MutableStreamEntity; - const existingEntity = this.state.entitiesById.get(entityId); - if (existingEntity && ghost.type === "create") { - // Same-class ghost index reuse: reset the entity for the new ghost - // to avoid stale fields (hasExploded, explosionShape, etc.) from the - // previous occupant leaking into the new one. - existingEntity.spawnTick = this.state.moveTicks; - existingEntity.rotation = [0, 0, 0, 1]; - existingEntity.hasExploded = undefined; - existingEntity.explosionShape = undefined; - existingEntity.explosionLifetimeTicks = undefined; - existingEntity.faceViewer = undefined; - existingEntity.simulatedVelocity = undefined; - existingEntity.projectilePhysics = undefined; - existingEntity.gravityMod = undefined; - existingEntity.direction = undefined; - existingEntity.velocity = undefined; - existingEntity.position = undefined; - existingEntity.dataBlock = undefined; - existingEntity.dataBlockId = undefined; - existingEntity.shapeHint = undefined; - existingEntity.visual = undefined; - existingEntity.targetId = undefined; - existingEntity.targetRenderFlags = undefined; - existingEntity.carryingFlag = undefined; - existingEntity.sensorGroup = undefined; - existingEntity.playerName = undefined; - existingEntity.weaponShape = undefined; - existingEntity.weaponImageState = undefined; - existingEntity.weaponImageStates = undefined; - existingEntity.weaponImageStatesDbId = undefined; - existingEntity.itemPhysics = undefined; - existingEntity.threads = undefined; - existingEntity.headPitch = undefined; - existingEntity.headYaw = undefined; - existingEntity.health = undefined; - existingEntity.energy = undefined; - existingEntity.maxEnergy = undefined; - existingEntity.damageState = undefined; - existingEntity.actionAnim = undefined; - existingEntity.actionAtEnd = undefined; - existingEntity.explosionDataBlockId = undefined; - existingEntity.maintainEmitterId = undefined; - entity = existingEntity; - } else if (existingEntity) { - entity = existingEntity; - } else { - entity = { - id: entityId, - ghostIndex, - className, - spawnTick: this.state.moveTicks, - type: toEntityType(className), - rotation: [0, 0, 0, 1], - }; - this.state.entitiesById.set(entityId, entity); - } - - entity.ghostIndex = ghostIndex; - entity.className = className; - entity.type = toEntityType(className); - this.state.entityIdByGhostIndex.set(ghostIndex, entityId); - this.applyGhostData(entity, ghost.parsedData); - } - - private resolveGhostClassName( - ghostIndex: number, - classId: number | undefined, - ): string | undefined { - if (typeof classId === "number") { - const fromClassId = this.registry.getGhostParser(classId)?.name; - if (fromClassId) { - return fromClassId; - } - } - - const entityId = this.state.entityIdByGhostIndex.get(ghostIndex); - if (entityId) { - const entity = this.state.entitiesById.get(entityId); - if (entity?.className) { - return entity.className; - } - } - - const trackerGhost = this.parser.getGhostTracker().getGhost(ghostIndex); - if (trackerGhost?.className) { - return trackerGhost.className; - } - - return undefined; - } - - private resolveEntityIdForGhostIndex(ghostIndex: number): string | undefined { - const byMap = this.state.entityIdByGhostIndex.get(ghostIndex); - if (byMap) { - return byMap; - } - const trackerGhost = this.parser.getGhostTracker().getGhost(ghostIndex); - if (trackerGhost) { - return toEntityId(trackerGhost.className, ghostIndex); - } - return undefined; - } - - getDataBlockData(dataBlockId: number): Record | undefined { - const initialBlock = this.initialBlock.dataBlocks.get(dataBlockId); - if (initialBlock?.data) { - return initialBlock.data; - } - - const packetParser = this.parser.getPacketParser() as unknown as { - dataBlockDataMap?: Map>; - }; - return packetParser.dataBlockDataMap?.get(dataBlockId); - } - - private resolveExplosionInfo(projDataBlockId: number): - | { - shape: string; - faceViewer: boolean; - lifetimeTicks: number; - explosionDataBlockId: number; - } - | undefined { - const projBlock = this.getDataBlockData(projDataBlockId); - if (!projBlock) return undefined; - const explosionId = projBlock.explosion as number | undefined; - if (explosionId == null) return undefined; - const expBlock = this.getDataBlockData(explosionId); - if (!expBlock) return undefined; - // dtsFileName may be empty for particle-only explosions (e.g. grenades, - // energy projectiles). Still return info so we can spawn the explosion - // entity for position tracking and particle effects. - const shape = (expBlock.dtsFileName as string | undefined) || undefined; - // The parser's lifetimeMS field is actually in ticks (32ms each), not ms. - const lifetimeTicks = (expBlock.lifetimeMS as number | undefined) ?? 31; - return { - shape, - faceViewer: expBlock.faceViewer !== false && expBlock.faceViewer !== 0, - lifetimeTicks, - explosionDataBlockId: explosionId, - }; - } - - private applyGhostData( - entity: MutableStreamEntity, - rawData: Record | undefined, - ): void { - if (!rawData) return; - - const data = rawData; - - const dataBlockId = data.dataBlockId as number | undefined; - if (dataBlockId != null) { - entity.dataBlockId = dataBlockId; - const blockData = this.getDataBlockData(dataBlockId); - const shapeName = toShapeNameFromDataBlock(blockData); - entity.visual = - resolveTracerVisual(entity.className, blockData) ?? - resolveSpriteVisual(entity.className, blockData); - if (typeof shapeName === "string") { - entity.shapeHint = shapeName; - entity.dataBlock = shapeName; - } - if ( - entity.type === "Player" && - typeof blockData?.maxEnergy === "number" - ) { - entity.maxEnergy = blockData.maxEnergy; - } - - // Classify projectile physics and extract simulation parameters. - if (entity.type === "Projectile") { - if (linearProjectileClassNames.has(entity.className)) { - entity.projectilePhysics = "linear"; - } else if (ballisticProjectileClassNames.has(entity.className)) { - entity.projectilePhysics = "ballistic"; - entity.gravityMod = - getNumberField(blockData, ["gravityMod"]) ?? 1.0; - } else if (seekerProjectileClassNames.has(entity.className)) { - entity.projectilePhysics = "seeker"; - } - } - - // Resolve explosion shape info for projectiles (once per entity). - if (entity.type === "Projectile" && entity.explosionDataBlockId == null) { - const info = this.resolveExplosionInfo(dataBlockId); - if (info) { - entity.explosionShape = info.shape; - entity.faceViewer = info.faceViewer; - entity.explosionLifetimeTicks = info.lifetimeTicks; - entity.explosionDataBlockId = info.explosionDataBlockId; - } - } - - // Resolve trail particle emitter for projectiles (once per entity). - if (entity.type === "Projectile" && entity.maintainEmitterId == null) { - const trailEmitterId = blockData?.baseEmitter as number | null; - if (typeof trailEmitterId === "number" && trailEmitterId > 0) { - entity.maintainEmitterId = trailEmitterId; - } - } - } - - if (entity.type === "Player") { - const images = data.images as - | Array<{ - index?: number; - dataBlockId?: number; - triggerDown?: boolean; - ammo?: boolean; - loaded?: boolean; - target?: boolean; - wet?: boolean; - fireCount?: number; - }> - | undefined; - if (Array.isArray(images) && images.length > 0) { - // Find slot 0 (weapon) — the array is compact and only includes dirty - // slots, so images[0] may be a backpack or other non-weapon slot. - const weaponImage = images.find((img) => img.index === 0); - if (weaponImage?.dataBlockId && weaponImage.dataBlockId > 0) { - const blockData = this.getDataBlockData(weaponImage.dataBlockId); - const weaponShape = toShapeNameFromDataBlock(blockData); - if (weaponShape) { - const mountPoint = blockData?.mountPoint as number | undefined; - if ( - (mountPoint == null || mountPoint <= 0) && - !/pack_/i.test(weaponShape) - ) { - entity.weaponShape = weaponShape; - } - } - - // Extract weapon image condition flags for the weapon state machine. - // Ghost updates are partial — only changed fields are present. Merge - // with the previous state so unchanged flags aren't reset to defaults. - const prev = entity.weaponImageState; - entity.weaponImageState = { - dataBlockId: weaponImage.dataBlockId, - triggerDown: weaponImage.triggerDown ?? prev?.triggerDown ?? false, - ammo: weaponImage.ammo ?? prev?.ammo ?? true, - loaded: weaponImage.loaded ?? prev?.loaded ?? true, - target: weaponImage.target ?? prev?.target ?? false, - wet: weaponImage.wet ?? prev?.wet ?? false, - fireCount: weaponImage.fireCount ?? prev?.fireCount ?? 0, - }; - - // Cache the weapon datablock states array (only reparse on weapon change). - if ( - blockData && - entity.weaponImageStatesDbId !== weaponImage.dataBlockId - ) { - entity.weaponImageStates = parseWeaponImageStates(blockData); - entity.weaponImageStatesDbId = weaponImage.dataBlockId; - } - } else if (weaponImage && !weaponImage.dataBlockId) { - // Server explicitly unmounted the weapon (dataBlockId = 0), e.g. on - // player death. Clear the weapon so it stops rendering. - entity.weaponShape = undefined; - entity.weaponImageState = undefined; - entity.weaponImageStates = undefined; - } - - // Track FlagImage in slot 3 ($FlagSlot). The server mounts FlagImage - // when a player picks up a flag and unmounts it on drop. buildSnapshot - // uses carryingFlag to gate the flag icon on Players, which prevents - // dead corpses (sharing the same targetId) from showing duplicate icons. - const flagImage = images.find((img) => img.index === 3); - if (flagImage) { - const hasFlag = !!flagImage.dataBlockId && flagImage.dataBlockId > 0; - entity.carryingFlag = hasFlag; - if (entity.targetId != null && entity.targetId >= 0) { - const prev = this.targetRenderFlags.get(entity.targetId) ?? 0; - const updated = hasFlag ? prev | 0x2 : prev & ~0x2; - if (updated !== prev) { - this.targetRenderFlags.set(entity.targetId, updated); - entity.targetRenderFlags = updated; - } - } - } - } - } - - const position = isValidPosition(data.position as Vec3) - ? (data.position as Vec3) - : isValidPosition(data.initialPosition as Vec3) - ? (data.initialPosition as Vec3) - : isValidPosition(data.explodePosition as Vec3) - ? (data.explodePosition as Vec3) - : isValidPosition(data.endPoint as Vec3) - ? (data.endPoint as Vec3) - : isValidPosition( - (data.transform as { position?: Vec3 } | undefined)?.position, - ) - ? ((data.transform as { position: Vec3 }).position as Vec3) - : undefined; - if (position) { - entity.position = [position.x, position.y, position.z]; - } - - const direction = isVec3Like(data.direction) ? data.direction : undefined; - if (direction) { - entity.direction = [direction.x, direction.y, direction.z]; - } - - if (entity.type === "Player" && typeof data.rotationZ === "number") { - entity.rotation = playerYawToQuaternion(data.rotationZ); - } - - // Non-control players: headX/headZ are normalized [-1,1] from ghost data. - if (entity.type === "Player") { - if (typeof data.headX === "number") { - entity.headPitch = data.headX; - } - if (typeof data.headZ === "number") { - entity.headYaw = data.headZ; - } - } - - if (isQuatLike(data.angPosition)) { - const converted = torqueQuatToThreeJS(data.angPosition); - if (converted) { - entity.rotation = converted; - } - } else if ( - isQuatLike( - (data.transform as { rotation?: unknown } | undefined)?.rotation, - ) - ) { - const converted = torqueQuatToThreeJS( - ( - data.transform as { - rotation: { x: number; y: number; z: number; w: number }; - } - ).rotation, - ); - if (converted) { - entity.rotation = converted; - } - } else if ( - entity.type === "Item" && - typeof (data.rotation as { angle?: unknown } | undefined)?.angle === - "number" - ) { - const rot = data.rotation as { angle: number; zSign?: number }; - entity.rotation = playerYawToQuaternion((rot.zSign ?? 1) * rot.angle); - } else if (entity.type === "Projectile") { - const vec = - (data.velocity as Vec3 | undefined) ?? - (data.direction as Vec3 | undefined) ?? - (isValidPosition(data.initialPosition as Vec3) && - isValidPosition(data.endPos as Vec3) - ? { - x: (data.endPos as Vec3).x - (data.initialPosition as Vec3).x, - y: (data.endPos as Vec3).y - (data.initialPosition as Vec3).y, - z: (data.endPos as Vec3).z - (data.initialPosition as Vec3).z, - } - : undefined); - if (isVec3Like(vec) && (vec.x !== 0 || vec.y !== 0)) { - entity.rotation = playerYawToQuaternion(Math.atan2(vec.x, vec.y)); - } - } - - if (isVec3Like(data.velocity)) { - entity.velocity = [data.velocity.x, data.velocity.y, data.velocity.z]; - if (!entity.direction) { - entity.direction = [data.velocity.x, data.velocity.y, data.velocity.z]; - } - } - - // Item physics: simulate dropped items falling under gravity and bouncing. - if (entity.type === "Item") { - const atRest = data.atRest as boolean | undefined; - const warp = data.warp as boolean | undefined; - if (atRest === true || warp === false) { - // At rest, or position authoritatively set (e.g. flag returned to - // base via setTransform → NoWarpMask) — stop simulating. - entity.itemPhysics = undefined; - } else if (atRest === false && isVec3Like(data.velocity)) { - // Item is moving — initialize or update physics simulation. - const blockData = - entity.dataBlockId != null - ? this.getDataBlockData(entity.dataBlockId) - : undefined; - entity.itemPhysics = { - velocity: [data.velocity.x, data.velocity.y, data.velocity.z], - atRest: false, - elasticity: getNumberField(blockData, ["elasticity"]) ?? 0.2, - friction: getNumberField(blockData, ["friction"]) ?? 0.6, - gravityMod: getNumberField(blockData, ["gravityMod"]) ?? 1.0, - }; - } else if (position && !isVec3Like(data.velocity)) { - // Server snapped position without velocity — stop simulating. - entity.itemPhysics = undefined; - } - } - - // Compute simulatedVelocity for projectile physics. Mirrors the engine's - // unpackUpdate: velocity is only set on InitialUpdateMask or BounceMask, - // so we only (re)initialize when this update actually transmits velocity - // or direction data. Between updates, advanceProjectiles() accumulates - // gravity on the existing simulatedVelocity. - if (entity.projectilePhysics) { - if (entity.projectilePhysics === "linear") { - // Linear projectiles transmit direction + dryVelocity from datablock, - // plus optional inherited velocity (excessDir * excessVel). - const blockData = - entity.dataBlockId != null - ? this.getDataBlockData(entity.dataBlockId) - : undefined; - const dryVelocity = - getNumberField(blockData, [ - "dryVelocity", - "muzzleVelocity", - "bulletVelocity", - ]) ?? 80; - const dir = entity.direction ?? [0, 1, 0]; - let vx = dir[0] * dryVelocity; - let vy = dir[1] * dryVelocity; - let vz = dir[2] * dryVelocity; - // Add inherited velocity from firing object. - const excessVel = data.excessVel as number | undefined; - const excessDir = data.excessDir as Vec3 | undefined; - if ( - typeof excessVel === "number" && - excessVel > 0 && - isVec3Like(excessDir) - ) { - vx += excessDir.x * excessVel; - vy += excessDir.y * excessVel; - vz += excessDir.z * excessVel; - } - entity.simulatedVelocity = [vx, vy, vz]; - } else if (isVec3Like(data.velocity)) { - // Ballistic/seeker: set velocity only when this ghost update transmits - // it (initial create or BounceMask). The engine's unpackUpdate only - // writes mCurrVelocity on these two mask bits. - entity.simulatedVelocity = [ - data.velocity.x, - data.velocity.y, - data.velocity.z, - ]; - } - } - if (entity.projectilePhysics) { - - // Fast-forward by currTick: the initial position is the firing point - // and currTick tells us how many ticks have already elapsed. - const currTick = data.currTick as number | undefined; - if ( - typeof currTick === "number" && - currTick > 0 && - entity.simulatedVelocity && - entity.position - ) { - const dt = (TICK_DURATION_MS / 1000) * currTick; - const v = entity.simulatedVelocity; - entity.position[0] += v[0] * dt; - entity.position[1] += v[1] * dt; - entity.position[2] += v[2] * dt; - // For ballistic projectiles, also apply gravity during fast-forward. - if (entity.projectilePhysics === "ballistic") { - // GrenadeProjectile::computeNewState uses -9.81 * gravityMod - // (globalGravity * 0.4905 * gravityMod, where 0.4905 = 9.81/20). - const g = -9.81 * (entity.gravityMod ?? 1); - // v.z changes linearly, position.z changes quadratically. - entity.position[2] += 0.5 * g * dt * dt; - v[2] += g * dt; - } - } - } - - // Detect projectile explosion. LinearProjectile/SeekerProjectile send - // `explodePosition`; GrenadeProjectile/BombProjectile send `explodePoint`. - // LinearProjectile initial creates of already-exploded projectiles also - // set `hidden: true` alongside `explodePosition`. - const explodePos = isValidPosition(data.explodePosition as Vec3) - ? (data.explodePosition as Vec3) - : isValidPosition(data.explodePoint as Vec3) - ? (data.explodePoint as Vec3) - : undefined; - if ( - entity.type === "Projectile" && - !entity.hasExploded && - explodePos && - entity.explosionDataBlockId != null - ) { - this.spawnExplosion(entity, [explodePos.x, explodePos.y, explodePos.z]); - } - - if (typeof data.damageLevel === "number") { - entity.health = clamp(1 - data.damageLevel, 0, 1); - } - if (typeof data.damageState === "number") { - entity.damageState = data.damageState; - } - - if (typeof data.action === "number") { - entity.actionAnim = data.action; - entity.actionAtEnd = !!data.actionAtEnd; - } - - if (Array.isArray(data.threads)) { - // Ghost ThreadMask updates are differential — only changed (and active) - // slots are included. Merge with existing state so unchanged slots - // (like a clamped deploy or looping power) aren't lost. - const incoming = data.threads as DemoThreadState[]; - if (entity.threads) { - const merged = [...entity.threads]; - for (const t of incoming) { - const existingIdx = merged.findIndex((m) => m.index === t.index); - if (existingIdx >= 0) { - merged[existingIdx] = t; - } else { - merged.push(t); - } - } - entity.threads = merged; - } else { - entity.threads = incoming; - } - } - - if (typeof data.energy === "number") { - entity.energy = clamp(data.energy, 0, 1); - } - - if (typeof data.targetId === "number") { - entity.targetId = data.targetId; - const playerName = this.targetNames.get(data.targetId); - if (playerName) { - entity.playerName = playerName; - } - const team = this.targetTeams.get(data.targetId); - if (team != null) { - entity.sensorGroup = team; - // If this is the control player, update the viewer's sensor group. - if ( - entity.ghostIndex === this.state.latestControl.ghostIndex && - this.state.lastControlType === "player" - ) { - this.state.playerSensorGroup = team; - } - } - const renderFlags = this.targetRenderFlags.get(data.targetId); - if (renderFlags != null) { - entity.targetRenderFlags = renderFlags; - } - } - - // SoundMask: ghost-level playAudio() calls (e.g. station activation). - // Convert playing sounds to pending audio events so they play through the - // same pipeline as Sim3DAudioEvent. - const sounds = data.sounds as - | Array<{ index: number; playing: boolean; profileId?: number }> - | undefined; - if (Array.isArray(sounds)) { - const timeSec = this.state.moveTicks * (TICK_DURATION_MS / 1000); - for (const s of sounds) { - if (s.playing && typeof s.profileId === "number") { - const pos = entity.position; - this.state.pendingAudioEvents.push({ - profileId: s.profileId, - position: pos - ? { x: pos[0], y: pos[1], z: pos[2] } - : undefined, - timeSec, - }); - } - } - } - } - - private advanceProjectiles(): void { - const dt = TICK_DURATION_MS / 1000; - for (const entity of this.state.entitiesById.values()) { - if (!entity.simulatedVelocity || !entity.position) continue; - const v = entity.simulatedVelocity; - const p = entity.position; - - if (entity.projectilePhysics === "ballistic") { - // GrenadeProjectile::computeNewState: -9.81 * gravityMod per tick. - v[2] += -9.81 * (entity.gravityMod ?? 1) * dt; - } - - p[0] += v[0] * dt; - p[1] += v[1] * dt; - p[2] += v[2] * dt; - - // Update rotation to face velocity direction. - if (v[0] !== 0 || v[1] !== 0) { - entity.rotation = playerYawToQuaternion(Math.atan2(v[0], v[1])); - } - } - } - - private advanceItems(): void { - const dt = TICK_DURATION_MS / 1000; // 0.032 - for (const entity of this.state.entitiesById.values()) { - const phys = entity.itemPhysics; - if (!phys || phys.atRest || !entity.position) continue; - const v = phys.velocity; - const p = entity.position; - - // Gravity: Tribes 2 uses -20 m/s² (Torque Z-up). - v[2] += -20 * phys.gravityMod * dt; - - // Move - p[0] += v[0] * dt; - p[1] += v[1] * dt; - p[2] += v[2] * dt; - - // Terrain collision (flat normal approximation: [0, 0, 1]) - const groundZ = getTerrainHeightAt(p[0], p[1]); - if (groundZ != null && p[2] < groundZ) { - p[2] = groundZ; - const bd = Math.abs(v[2]); // normal impact speed - v[2] = bd * phys.elasticity; // reflect with restitution - // Friction: reduce horizontal speed proportional to impact - const friction = bd * phys.friction; - const hSpeed = Math.sqrt(v[0] * v[0] + v[1] * v[1]); - if (hSpeed > 0) { - const scale = Math.max(0, 1 - friction / hSpeed); - v[0] *= scale; - v[1] *= scale; - } - // At-rest check - const speed = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); - if (speed < 0.15) { - v[0] = v[1] = v[2] = 0; - phys.atRest = true; - } - } - } - } - - /** Create a synthetic explosion entity from a projectile. */ - private spawnExplosion( - entity: MutableStreamEntity, - position: [number, number, number], - ): void { - entity.hasExploded = true; - const lifetimeTicks = entity.explosionLifetimeTicks ?? 31; - - // Spawn the main explosion entity. - const fxId = `fx_${this.state.nextExplosionId++}`; - const fxEntity: MutableStreamEntity = { - id: fxId, - ghostIndex: -1, - className: "Explosion", - spawnTick: this.state.moveTicks, - type: "Explosion", - dataBlock: entity.explosionShape, - explosionDataBlockId: entity.explosionDataBlockId, - position, - rotation: [0, 0, 0, 1], - isExplosion: true, - faceViewer: entity.faceViewer !== false, - expiryTick: this.state.moveTicks + lifetimeTicks, - }; - this.state.entitiesById.set(fxId, fxEntity); - - // Spawn sub-explosion entities (e.g. MortarSubExplosion1/2/3 carry the - // actual DTS shapes while the main MortarExplosion has none). - if (entity.explosionDataBlockId != null) { - const expBlock = this.getDataBlockData(entity.explosionDataBlockId); - const subExplosions = expBlock?.subExplosions as - | (number | null)[] - | undefined; - if (Array.isArray(subExplosions)) { - for (const subId of subExplosions) { - if (subId == null) continue; - const subBlock = this.getDataBlockData(subId); - if (!subBlock) continue; - const subShape = - (subBlock.dtsFileName as string | undefined) || undefined; - if (!subShape) continue; - - const subLifetimeTicks = - (subBlock.lifetimeMS as number | undefined) ?? 31; - const offset = (subBlock.offset as number | undefined) ?? 0; - - // Randomize position offset in XY plane (Torque convention). - const angle = Math.random() * Math.PI * 2; - const subPos: [number, number, number] = [ - position[0] + Math.cos(angle) * offset, - position[1] + Math.sin(angle) * offset, - position[2], - ]; - - const subFxId = `fx_${this.state.nextExplosionId++}`; - const subFxEntity: MutableStreamEntity = { - id: subFxId, - ghostIndex: -1, - className: "Explosion", - spawnTick: this.state.moveTicks, - type: "Explosion", - dataBlock: subShape, - explosionDataBlockId: subId, - position: subPos, - rotation: [0, 0, 0, 1], - isExplosion: true, - faceViewer: - subBlock.faceViewer !== false && subBlock.faceViewer !== 0, - expiryTick: this.state.moveTicks + subLifetimeTicks, - }; - this.state.entitiesById.set(subFxId, subFxEntity); - } - } - } - - // Stop the projectile — the explosion takes over visually. - entity.position = undefined; - entity.simulatedVelocity = undefined; - } - - private removeExpiredExplosions(): void { - for (const [id, entity] of this.state.entitiesById) { - if ( - entity.isExplosion && - entity.expiryTick != null && - this.state.moveTicks >= entity.expiryTick - ) { - this.state.entitiesById.delete(id); - } - } - } - - private updateCameraAndHud(): void { - const control = this.state.latestControl; - const timeSec = this.state.moveTicks * (TICK_DURATION_MS / 1000); - const data = control.data; - const controlType = this.state.lastControlType; - - if (control.position) { - const hasMoves = !this.state.isPiloting && controlType === "player"; - // Use absolute tracking (with V12-style clamp/wrap) when we have moves, - // otherwise fall back to the last ghost-provided rotation. - let yaw = hasMoves ? this.state.absoluteYaw : this.state.lastAbsYaw; - let pitch = hasMoves ? this.state.absolutePitch : this.state.lastAbsPitch; - - if (hasMoves) { - this.state.lastAbsYaw = yaw; - this.state.lastAbsPitch = pitch; - } - - this.state.camera = { - time: timeSec, - position: [control.position.x, control.position.y, control.position.z], - rotation: yawPitchToQuaternion( - yaw, - clamp(pitch, -MAX_PITCH, MAX_PITCH), - ), - fov: this.state.latestFov, - mode: "observer", - yaw, - pitch, - }; - - if (controlType === "camera") { - const cameraMode = - typeof data?.cameraMode === "number" - ? data.cameraMode - : this.state.lastCameraMode; - if (cameraMode === CameraMode_OrbitObject) { - this.state.camera.mode = "third-person"; - if (typeof this.state.lastOrbitDistance === "number") { - this.state.camera.orbitDistance = this.state.lastOrbitDistance; - } - const orbitIndex = - typeof data?.orbitObjectGhostIndex === "number" - ? (data.orbitObjectGhostIndex as number) - : this.state.lastOrbitGhostIndex; - if (typeof orbitIndex === "number" && orbitIndex >= 0) { - this.state.camera.orbitTargetId = - this.resolveEntityIdForGhostIndex(orbitIndex); - } - } else { - this.state.camera.mode = "observer"; - } - } else { - this.state.camera.mode = "first-person"; - if (control.ghostIndex >= 0) { - this.state.controlPlayerGhostId = `player_${control.ghostIndex}`; - } - if (this.state.controlPlayerGhostId) { - this.state.camera.controlEntityId = this.state.controlPlayerGhostId; - } - } - - // Sync the control player ghost entity's position from the control - // object data. During demo playback, the control object's state is - // transmitted through a dedicated channel separate from ghost updates, - // so the ghost entity's position would otherwise remain stale. - if ( - controlType === "player" && - !this.state.isPiloting && - this.state.controlPlayerGhostId && - control.position - ) { - const ghostEntity = this.state.entitiesById.get( - this.state.controlPlayerGhostId, - ); - if (ghostEntity) { - ghostEntity.position = [ - control.position.x, - control.position.y, - control.position.z, - ]; - ghostEntity.rotation = playerYawToQuaternion(yaw); - // Control player: derive headPitch from absolutePitch (ghost data - // skips headX/headZ for the control object). - ghostEntity.headPitch = clamp( - this.state.absolutePitch / MAX_PITCH, - -1, - 1, - ); - } - } - } else if (this.state.camera) { - this.state.camera = { - ...this.state.camera, - time: timeSec, - fov: this.state.latestFov, - }; - } - - const status = { health: 1, energy: 1 }; - if (this.state.camera?.mode === "first-person") { - const controlGhostId = this.state.controlPlayerGhostId; - const ghostEntity = controlGhostId - ? this.state.entitiesById.get(controlGhostId) - : undefined; - status.health = ghostEntity?.health ?? 1; - - const coEnergyLevel = data?.energyLevel; - if (typeof coEnergyLevel === "number") { - const maxEnergy = ghostEntity?.maxEnergy ?? 60; - if (maxEnergy > 0) { - status.energy = clamp(coEnergyLevel / maxEnergy, 0, 1); - } - } else { - status.energy = ghostEntity?.energy ?? 1; - } - } else if ( - this.state.camera?.mode === "third-person" && - this.state.camera.orbitTargetId - ) { - const orbitEntity = this.state.entitiesById.get( - this.state.camera.orbitTargetId, - ); - status.health = orbitEntity?.health ?? 1; - status.energy = orbitEntity?.energy ?? 1; - } - - this.state.lastStatus = status; - } - - private pushChatMessage(msg: DemoChatMessage): void { - this.state.chatMessages.push(msg); - if (this.state.chatMessages.length > 200) { - this.state.chatMessages.splice(0, this.state.chatMessages.length - 200); - } - } - - /** Process ServerMessage events that update team scores and player roster. */ - private handleServerMessage(args: string[]): void { - if (args.length < 2) return; - const msgType = this.resolveNetString(args[0]); - - if (msgType === "MsgTeamScoreIs" && args.length >= 4) { - // args: [msgType, "", teamId, newScore] - const teamId = parseInt(this.resolveNetString(args[2]), 10); - const newScore = parseInt(this.resolveNetString(args[3]), 10); - if (!isNaN(teamId) && !isNaN(newScore)) { - const entry = this.state.teamScores.find((t) => t.teamId === teamId); - if (entry) { - entry.score = newScore; - this._teamScoresGen++; - } - } - } else if (msgType === "MsgCTFAddTeam" && args.length >= 6) { - // args: [msgType, "", teamIdx, teamName, flagStatus, score] - const teamIdx = parseInt(this.resolveNetString(args[2]), 10); - const teamName = stripTaggedStringMarkup(this.resolveNetString(args[3])); - const score = parseInt(this.resolveNetString(args[5]), 10); - if (!isNaN(teamIdx)) { - const teamId = teamIdx + 1; - const existing = this.state.teamScores.find( - (t) => t.teamId === teamId, - ); - if (existing) { - existing.name = teamName; - existing.score = isNaN(score) ? existing.score : score; - this._teamScoresGen++; - } else { - this.state.teamScores.push({ - teamId, - name: teamName, - score: isNaN(score) ? 0 : score, - playerCount: 0, - }); - this._teamScoresGen++; - } - } - } else if (msgType === "MsgClientJoin" && args.length >= 4) { - // args: [msgType, "", clientId, name, ...] - const clientId = parseInt(this.resolveNetString(args[2]), 10); - const name = stripTaggedStringMarkup(this.resolveNetString(args[3])); - if (!isNaN(clientId)) { - const existing = this.state.playerRoster.get(clientId); - this.state.playerRoster.set(clientId, { - name, - teamId: existing?.teamId ?? 0, - }); - this._rosterGen++; - } - } else if (msgType === "MsgClientDrop" && args.length >= 3) { - // args: [msgType, "", clientId, ...] - const clientId = parseInt(this.resolveNetString(args[2]), 10); - if (!isNaN(clientId)) { - this.state.playerRoster.delete(clientId); - this._rosterGen++; - } - } else if (msgType === "MsgClientJoinTeam" && args.length >= 4) { - // args: [msgType, "", clientId, teamId, ...] - const clientId = parseInt(this.resolveNetString(args[2]), 10); - const teamId = parseInt(this.resolveNetString(args[3]), 10); - if (!isNaN(clientId) && !isNaN(teamId)) { - const existing = this.state.playerRoster.get(clientId); - if (existing) { - existing.teamId = teamId; - } else { - this.state.playerRoster.set(clientId, { name: "", teamId }); - } - this._rosterGen++; - } - } - } - - private handleHudRemoteCommand(funcName: string, args: string[]): void { - // ── Weapons HUD ── - if (funcName === "setWeaponsHudItem" && args.length >= 3) { - const slot = parseInt(args[0], 10); - const ammo = parseInt(args[1], 10); - const add = args[2] === "1" || args[2] === "true"; - if (!isNaN(slot)) { - if (add) { - this.state.weaponsHud.slots.set(slot, isNaN(ammo) ? -1 : ammo); - } else { - this.state.weaponsHud.slots.delete(slot); - } - this._weaponsHudGen++; - } - } else if (funcName === "setWeaponsHudAmmo" && args.length >= 2) { - const slot = parseInt(args[0], 10); - const ammo = parseInt(args[1], 10); - if (!isNaN(slot)) { - // Treat ammo updates as implicit inventory presence — the - // initial setWeaponsHudItem may have been sent before recording. - this.state.weaponsHud.slots.set(slot, isNaN(ammo) ? -1 : ammo); - this._weaponsHudGen++; - } - } else if (funcName === "setWeaponsHudActive" && args.length >= 1) { - const slot = parseInt(args[0], 10); - this.state.weaponsHud.activeIndex = isNaN(slot) ? -1 : slot; - // Treat activation as implicit inventory presence. - if (!isNaN(slot) && slot >= 0) { - if (!this.state.weaponsHud.slots.has(slot)) { - this.state.weaponsHud.slots.set(slot, -1); - } - } - this._weaponsHudGen++; - } else if (funcName === "setWeaponsHudClearAll") { - this.state.weaponsHud.slots.clear(); - this.state.weaponsHud.activeIndex = -1; - this._weaponsHudGen++; - - // ── Backpack HUD ── - } else if (funcName === "setBackpackHudItem" && args.length >= 2) { - const num = parseInt(args[0], 10); - const add = args[1] === "1" || args[1] === "true"; - if (add && !isNaN(num)) { - this.state.backpackHud.packIndex = num; - this.state.backpackHud.active = false; - this.state.backpackHud.text = ""; - } else { - this.state.backpackHud.packIndex = -1; - this.state.backpackHud.active = false; - this.state.backpackHud.text = ""; - } - } else if (funcName === "setSatchelArmed") { - this.state.backpackHud.active = true; - } else if ( - funcName === "setCloakIconOn" || - funcName === "setRepairPackIconOn" || - funcName === "setShieldIconOn" || - funcName === "setSenJamIconOn" - ) { - this.state.backpackHud.active = true; - } else if ( - funcName === "setCloakIconOff" || - funcName === "setRepairPackIconOff" || - funcName === "setShieldIconOff" || - funcName === "setSenJamIconOff" - ) { - this.state.backpackHud.active = false; - } else if (funcName === "updatePackText" && args.length >= 1) { - this.state.backpackHud.text = args[0] ?? ""; - - // ── Inventory HUD (grenades, mines, beacons, repair kits) ── - } else if (funcName === "setInventoryHudItem" && args.length >= 3) { - const slot = parseInt(args[0], 10); - const amount = parseInt(args[1], 10); - const add = args[2] === "1" || args[2] === "true"; - if (!isNaN(slot)) { - if (add && !isNaN(amount)) { - this.state.inventoryHud.slots.set(slot, amount); - } else { - this.state.inventoryHud.slots.delete(slot); - } - this._inventoryHudGen++; - } - } else if (funcName === "setInventoryHudAmount" && args.length >= 2) { - const slot = parseInt(args[0], 10); - const amount = parseInt(args[1], 10); - if (!isNaN(slot) && !isNaN(amount)) { - this.state.inventoryHud.slots.set(slot, amount); - this._inventoryHudGen++; - } - } else if (funcName === "setInventoryHudClearAll") { - this.state.inventoryHud.slots.clear(); - this.state.inventoryHud.activeSlot = -1; - this._inventoryHudGen++; - } - } - - private buildSnapshot(): DemoStreamSnapshot { - const entities: DemoStreamEntity[] = []; - for (const entity of this.state.entitiesById.values()) { - if (!shouldRenderGhostEntity(entity)) { - continue; - } - // Read the latest targetRenderFlags from the map (source of truth - // from TargetInfoEvents and FlagImage slot tracking) rather than the - // entity cache, which may be stale. - let renderFlags = - entity.targetId != null && entity.targetId >= 0 - ? (this.targetRenderFlags.get(entity.targetId) ?? - entity.targetRenderFlags) - : entity.targetRenderFlags; - // For Players, only show the flag icon if this specific entity has - // FlagImage mounted in slot 3. Dead corpses share the same targetId as - // the alive player but don't have FlagImage, so this prevents duplicates. - if (entity.type === "Player" && !entity.carryingFlag) { - renderFlags = renderFlags != null ? renderFlags & ~0x2 : renderFlags; - } - entities.push({ - id: entity.id, - type: entity.type, - visual: entity.visual, - direction: entity.direction, - ghostIndex: entity.ghostIndex, - className: entity.className, - dataBlockId: entity.dataBlockId, - shapeHint: entity.shapeHint, - dataBlock: entity.dataBlock, - weaponShape: entity.weaponShape, - playerName: entity.playerName, - targetRenderFlags: renderFlags, - iffColor: - (entity.type === "Player" || - ((renderFlags ?? 0) & 0x2) !== 0) && - entity.sensorGroup != null - ? this.resolveIffColor(entity.sensorGroup) - : undefined, - // Only clone position for entities whose position is mutated in-place - // by advanceProjectiles() or advanceItems(). Other entities get new - // arrays from applyGhostData(), so the old reference stays valid. - position: - entity.position && - (entity.simulatedVelocity || - (entity.itemPhysics && !entity.itemPhysics.atRest)) - ? ([...entity.position] as [number, number, number]) - : entity.position, - // Rotation is always replaced (never mutated in-place), so no clone. - rotation: entity.rotation, - velocity: entity.velocity, - health: entity.health, - energy: entity.energy, - actionAnim: entity.actionAnim, - actionAtEnd: entity.actionAtEnd, - damageState: entity.damageState, - faceViewer: entity.faceViewer, - threads: entity.threads, - explosionDataBlockId: entity.explosionDataBlockId, - maintainEmitterId: entity.maintainEmitterId, - weaponImageState: entity.weaponImageState, - weaponImageStates: entity.weaponImageStates, - headPitch: entity.headPitch, - headYaw: entity.headYaw, - }); - } - - const timeSec = this.state.moveTicks * (TICK_DURATION_MS / 1000); - const prev = this._snap; - - const chatMessages = this.state.chatMessages.filter( - (m) => m.timeSec > timeSec - 15, - ); - - const audioEvents = this.state.pendingAudioEvents.filter( - (e) => e.timeSec > timeSec - 0.5 && e.timeSec <= timeSec, - ); - - const weaponsHud = - prev && prev.weaponsHudGen === this._weaponsHudGen - ? prev.weaponsHud - : { - slots: Array.from(this.state.weaponsHud.slots.entries()).map( - ([index, ammo]): WeaponsHudSlot => ({ index, ammo }), - ), - activeIndex: this.state.weaponsHud.activeIndex, - }; - - const inventoryHud = - prev && prev.inventoryHudGen === this._inventoryHudGen - ? prev.inventoryHud - : { - slots: Array.from(this.state.inventoryHud.slots.entries()).map( - ([slot, count]): InventoryHudSlot => ({ slot, count }), - ), - activeSlot: this.state.inventoryHud.activeSlot, - }; - - const backpackHud = - prev && - prev.backpackPackIndex === this.state.backpackHud.packIndex && - prev.backpackActive === this.state.backpackHud.active && - prev.backpackText === this.state.backpackHud.text - ? prev.backpackHud - : this.state.backpackHud.packIndex >= 0 - ? { ...this.state.backpackHud } - : null; - - let teamScores: TeamScore[]; - if ( - prev && - prev.teamScoresGen === this._teamScoresGen && - prev.rosterGen === this._rosterGen - ) { - teamScores = prev.teamScores; - } else { - teamScores = this.state.teamScores.map((ts) => ({ ...ts })); - const teamCounts = new Map(); - for (const { teamId } of this.state.playerRoster.values()) { - if (teamId > 0) { - teamCounts.set(teamId, (teamCounts.get(teamId) ?? 0) + 1); - } - } - for (const ts of teamScores) { - ts.playerCount = teamCounts.get(ts.teamId) ?? 0; - } - } - - this._snap = { - teamScoresGen: this._teamScoresGen, - rosterGen: this._rosterGen, - teamScores, - weaponsHudGen: this._weaponsHudGen, - weaponsHud, - inventoryHudGen: this._inventoryHudGen, - inventoryHud, - backpackPackIndex: this.state.backpackHud.packIndex, - backpackActive: this.state.backpackHud.active, - backpackText: this.state.backpackHud.text, - backpackHud, - }; - - return { - timeSec, - exhausted: this.state.exhausted, - camera: this.state.camera, - entities, - controlPlayerGhostId: this.state.controlPlayerGhostId, - playerSensorGroup: this.state.playerSensorGroup, - status: this.state.lastStatus, - chatMessages, - audioEvents, - weaponsHud, - backpackHud, - inventoryHud, - teamScores, - }; - } - - private resolveIffColor( - targetSensorGroup: number, - ): { r: number; g: number; b: number } | undefined { - if (this.state.playerSensorGroup === 0) return undefined; - const colorMap = this.sensorGroupColors.get(this.state.playerSensorGroup); - if (colorMap) { - const color = colorMap.get(targetSensorGroup); - if (color) return color; - } - // Tribes 2 defaults: same team = green, different team = red. - if (targetSensorGroup === this.state.playerSensorGroup) return IFF_GREEN; - if (targetSensorGroup !== 0) return IFF_RED; - return undefined; - } - - private getAbsoluteRotation( - data: Record | undefined, - ): { yaw: number; pitch: number } | null { - if (!data) return null; - - if (typeof data.rotationZ === "number" && typeof data.headX === "number") { - return { yaw: data.rotationZ, pitch: data.headX }; - } - - if (typeof data.rotZ === "number" && typeof data.rotX === "number") { - return { yaw: data.rotZ, pitch: data.rotX }; - } - - return null; - } - - private isPacketData(parsed: unknown): parsed is { - gameState: { - controlObjectGhostIndex?: number; - controlObjectData?: Record; - compressionPoint?: Vec3; - }; - events: Array<{ - classId: number; - parsedData?: Record; - }>; - ghosts: Array<{ - index: number; - type: "create" | "update" | "delete"; - classId?: number; - parsedData?: Record; - }>; - } { - return ( - !!parsed && - typeof parsed === "object" && - "gameState" in parsed && - "events" in parsed && - "ghosts" in parsed - ); - } - - private isMoveData( - parsed: unknown, - ): parsed is { yaw?: number; pitch?: number } { - return !!parsed && typeof parsed === "object" && "yaw" in parsed; - } - - private isInfoData(parsed: unknown): parsed is { value2: number } { - return ( - !!parsed && - typeof parsed === "object" && - "value2" in parsed && - typeof (parsed as { value2?: unknown }).value2 === "number" - ); - } - - /** Resolve a string that may contain a tagged string reference (`\x01`). */ - private resolveNetString(s: string): string { - if (s.length >= 2 && s.charCodeAt(0) === 1) { - const id = parseInt(s.slice(1), 10); - if (Number.isFinite(id)) { - return this.netStrings.get(id) ?? s; - } - } - return s; - } - - /** Apply Torque `%N` format substitution and strip markup. */ - private formatRemoteArgs(template: string, args: string[]): string { - let resolved = this.resolveNetString(template); - for (let i = 0; i < args.length; i++) { - const placeholder = `%${i + 1}`; - if (resolved.includes(placeholder)) { - resolved = resolved.replaceAll( - placeholder, - stripTaggedStringMarkup(this.resolveNetString(args[i])), - ); - } - } - // Torque drops trailing empty string args from commandToClient, so the - // template may reference %N tokens beyond the supplied args (e.g. a - // plural "s" that evaluates to ""). Replace any remaining placeholders. - resolved = resolved.replace(/%\d+/g, ""); - return stripTaggedStringMarkup(resolved); - } -} - -export async function createDemoStreamingRecording( - data: ArrayBuffer, -): Promise { - const parser = new DemoParser(new Uint8Array(data)); - const { header, initialBlock } = await parser.load(); - const { missionName: infoMissionName, gameType } = extractMissionInfo( - initialBlock.demoValues, - ); - - return { - duration: header.demoLengthMs / 1000, - missionName: infoMissionName ?? initialBlock.missionName ?? null, - gameType, - streamingPlayback: new StreamingPlayback(parser), - }; -} diff --git a/src/file.vert b/src/file.vert deleted file mode 100644 index a7f82df0..00000000 --- a/src/file.vert +++ /dev/null @@ -1,112 +0,0 @@ -#ifdef USE_FOG -// Check runtime fog enabled uniform - allows toggling without shader recompilation -if (fogEnabled) { - // Fog disabled at runtime, skip all fog calculations -} else { - float dist = vFogDepth; - - // Discard fragments at or beyond visible distance - matches Torque's behavior - // where objects beyond visibleDistance are not rendered at all. - // This prevents fully-fogged geometry from showing as silhouettes against - // the sky's fog-to-sky gradient. - if (dist >= fogFar) { - discard; - } - - // Step 1: Calculate distance-based haze (quadratic falloff) - // Since we discard at fogFar, haze never reaches 1.0 here - float haze = 0.0; - if (dist > fogNear) { - float fogScale = 1.0 / (fogFar - fogNear); - float distFactor = (dist - fogNear) * fogScale - 1.0; - haze = 1.0 - distFactor * distFactor; - } - - // Step 2: Calculate fog volume contributions - // Note: Per-volume colors are NOT used in Tribes 2 ($specialFog defaults to false) - // All fog uses the global fogColor - see Tribes2_Fog_System.md for details - float volumeFog = 0.0; - - #ifdef USE_VOLUMETRIC_FOG - { - #ifdef USE_FOG_WORLD_POSITION - float fragmentHeight = vFogWorldPosition.y; - #else - float fragmentHeight = cameraHeight; - #endif - - float deltaY = fragmentHeight - cameraHeight; - float absDeltaY = abs(deltaY); - - // Determine if we're going up (positive) or down (negative) - if (absDeltaY > 0.01) { - // Non-horizontal ray: ray-march through fog volumes - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = allFogVolumes[offset + 0]; - float volMinH = allFogVolumes[offset + 1]; - float volMaxH = allFogVolumes[offset + 2]; - float volPct = allFogVolumes[offset + 3]; - - // Skip inactive volumes (visibleDistance = 0) - if (volVisDist <= 0.0) continue; - - // Calculate fog factor for this volume - // From Torque: factor = (1 / (volumeVisDist * visFactor)) * percentage - // where visFactor is smVisibleDistanceMod (a user quality pref, default 1.0) - // Since we don't have quality settings, we use visFactor = 1.0 - float factor = (1.0 / volVisDist) * volPct; - - // Find ray intersection with this volume's height range - float rayMinY = min(cameraHeight, fragmentHeight); - float rayMaxY = max(cameraHeight, fragmentHeight); - - // Check if ray intersects volume height range - if (rayMinY < volMaxH && rayMaxY > volMinH) { - float intersectMin = max(rayMinY, volMinH); - float intersectMax = min(rayMaxY, volMaxH); - float intersectHeight = intersectMax - intersectMin; - - // Calculate distance traveled through this volume using similar triangles: - // subDist / dist = intersectHeight / absDeltaY - float subDist = dist * (intersectHeight / absDeltaY); - - // Accumulate fog: fog += subDist * factor - volumeFog += subDist * factor; - } - } - } else { - // Near-horizontal ray: if camera is inside a volume, apply full fog for that volume - for (int i = 0; i < 3; i++) { - int offset = i * 4; - float volVisDist = allFogVolumes[offset + 0]; - float volMinH = allFogVolumes[offset + 1]; - float volMaxH = allFogVolumes[offset + 2]; - float volPct = allFogVolumes[offset + 3]; - - if (volVisDist <= 0.0) continue; - - // If camera is inside this volume, apply fog for full distance - if (cameraHeight >= volMinH && cameraHeight <= volMaxH) { - float factor = (1.0 / volVisDist) * volPct; - volumeFog += dist * factor; - } - } - } - } - #endif - - // Step 3: Combine haze and volume fog - // Torque's clamping: if (bandPct + hazePct > 1) hazePct = 1 - bandPct - // This gives fog volumes priority over haze - float volPct = min(volumeFog, 1.0); - float hazePct = haze; - if (volPct + hazePct > 1.0) { - hazePct = 1.0 - volPct; - } - float fogFactor = hazePct + volPct; - - // Apply fog using global fogColor (per-volume colors not used in Tribes 2) - gl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor); -} -#endif diff --git a/src/manifest.ts b/src/manifest.ts index 52c016b4..b99c414c 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -143,18 +143,3 @@ export function getMissionInfo(missionName: string) { export function getMissionList() { return Object.keys(manifest.missions); } - -const missionsByNormalizedName = new Map( - Object.keys(manifest.missions).map((key) => [key.toLowerCase(), key]), -); - -/** - * Find a manifest mission key from a demo mission name like "S5-WoodyMyrk". - * Returns null if no match is found. - */ -export function findMissionByDemoName( - demoMissionName: string, -): string | null { - const normalized = demoMissionName.replace(/-/g, "_").toLowerCase(); - return missionsByNormalizedName.get(normalized) ?? null; -} diff --git a/src/scene/coordinates.spec.ts b/src/scene/coordinates.spec.ts new file mode 100644 index 00000000..167c4a85 --- /dev/null +++ b/src/scene/coordinates.spec.ts @@ -0,0 +1,211 @@ +import { describe, it, expect } from "vitest"; +import { Quaternion, Vector3 } from "three"; +import { + torqueToThree, + torqueScaleToThree, + matrixFToQuaternion, + torqueAxisAngleToQuaternion, +} from "./coordinates"; +import type { MatrixF } from "./types"; +import { IDENTITY_MATRIX } from "./types"; + +describe("torqueToThree", () => { + it("swizzles Torque (X,Y,Z) to Three.js (Y,Z,X)", () => { + expect(torqueToThree({ x: 1, y: 2, z: 3 })).toEqual([2, 3, 1]); + }); + + it("handles zero vector", () => { + expect(torqueToThree({ x: 0, y: 0, z: 0 })).toEqual([0, 0, 0]); + }); +}); + +describe("torqueScaleToThree", () => { + it("applies same swizzle as position", () => { + expect(torqueScaleToThree({ x: 10, y: 20, z: 30 })).toEqual([20, 30, 10]); + }); +}); + +describe("matrixFToQuaternion", () => { + it("returns identity quaternion for identity matrix", () => { + const q = matrixFToQuaternion(IDENTITY_MATRIX); + expect(q.x).toBeCloseTo(0, 5); + expect(q.y).toBeCloseTo(0, 5); + expect(q.z).toBeCloseTo(0, 5); + expect(q.w).toBeCloseTo(1, 5); + }); + + it("handles 90° rotation around Torque Z-axis (up)", () => { + // Torque Z-up → Three.js Y-up + // 90° around Torque Z maps to -90° around Three.js Y + // (negative due to conjugation for row-vector → column-vector convention) + const angleRad = Math.PI / 2; + const c = Math.cos(angleRad); + const s = Math.sin(angleRad); + + const elements = [ + c, s, 0, 0, + -s, c, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, + ]; + + const m: MatrixF = { elements, position: { x: 0, y: 0, z: 0 } }; + const q = matrixFToQuaternion(m); + + const expected = new Quaternion().setFromAxisAngle( + new Vector3(0, 1, 0), + -angleRad, + ); + + expect(q.x).toBeCloseTo(expected.x, 4); + expect(q.y).toBeCloseTo(expected.y, 4); + expect(q.z).toBeCloseTo(expected.z, 4); + expect(q.w).toBeCloseTo(expected.w, 4); + }); + + it("handles 90° rotation around Torque X-axis (right)", () => { + // Torque X → Three.js Z, angle negated + const angleRad = Math.PI / 2; + const c = Math.cos(angleRad); + const s = Math.sin(angleRad); + + const elements = [ + 1, 0, 0, 0, + 0, c, s, 0, + 0, -s, c, 0, + 0, 0, 0, 1, + ]; + + const m: MatrixF = { elements, position: { x: 0, y: 0, z: 0 } }; + const q = matrixFToQuaternion(m); + + const expected = new Quaternion().setFromAxisAngle( + new Vector3(0, 0, 1), + -angleRad, + ); + + expect(q.x).toBeCloseTo(expected.x, 4); + expect(q.y).toBeCloseTo(expected.y, 4); + expect(q.z).toBeCloseTo(expected.z, 4); + expect(q.w).toBeCloseTo(expected.w, 4); + }); + + it("handles 90° rotation around Torque Y-axis (forward)", () => { + // Torque Y → Three.js X, angle negated + const angleRad = Math.PI / 2; + const c = Math.cos(angleRad); + const s = Math.sin(angleRad); + + const elements = [ + c, 0, -s, 0, + 0, 1, 0, 0, + s, 0, c, 0, + 0, 0, 0, 1, + ]; + + const m: MatrixF = { elements, position: { x: 0, y: 0, z: 0 } }; + const q = matrixFToQuaternion(m); + + const expected = new Quaternion().setFromAxisAngle( + new Vector3(1, 0, 0), + -angleRad, + ); + + expect(q.x).toBeCloseTo(expected.x, 4); + expect(q.y).toBeCloseTo(expected.y, 4); + expect(q.z).toBeCloseTo(expected.z, 4); + expect(q.w).toBeCloseTo(expected.w, 4); + }); + + it("produces unit quaternion from valid rotation matrix", () => { + // Arbitrary rotation: 45° around Torque (1,1,0) normalized + const len = Math.sqrt(2); + const nx = 1 / len, ny = 1 / len, nz = 0; + const angle = Math.PI / 4; + const c = Math.cos(angle); + const s = Math.sin(angle); + const t = 1 - c; + + const elements = new Array(16).fill(0); + elements[0] = t * nx * nx + c; + elements[1] = t * nx * ny + s * nz; + elements[2] = t * nx * nz - s * ny; + elements[4] = t * nx * ny - s * nz; + elements[5] = t * ny * ny + c; + elements[6] = t * ny * nz + s * nx; + elements[8] = t * nx * nz + s * ny; + elements[9] = t * ny * nz - s * nx; + elements[10] = t * nz * nz + c; + elements[15] = 1; + + const m: MatrixF = { elements, position: { x: 0, y: 0, z: 0 } }; + const q = matrixFToQuaternion(m); + const qLen = Math.sqrt(q.x ** 2 + q.y ** 2 + q.z ** 2 + q.w ** 2); + expect(qLen).toBeCloseTo(1, 5); + }); +}); + +describe("torqueAxisAngleToQuaternion", () => { + it("returns identity for zero angle", () => { + const q = torqueAxisAngleToQuaternion(1, 0, 0, 0); + expect(q.x).toBeCloseTo(0, 5); + expect(q.y).toBeCloseTo(0, 5); + expect(q.z).toBeCloseTo(0, 5); + expect(q.w).toBeCloseTo(1, 5); + }); + + it("returns identity for zero-length axis", () => { + const q = torqueAxisAngleToQuaternion(0, 0, 0, 90); + expect(q.w).toBeCloseTo(1, 5); + }); + + it("90° around Torque Z maps to Three.js Y rotation", () => { + // Torque Z-axis = (0,0,1), swizzled to Three.js = (0,1,0) + const q = torqueAxisAngleToQuaternion(0, 0, 1, 90); + + // Negative angle because of coordinate system handedness flip + const expected = new Quaternion().setFromAxisAngle( + new Vector3(0, 1, 0), + -90 * (Math.PI / 180), + ); + + expect(q.x).toBeCloseTo(expected.x, 4); + expect(q.y).toBeCloseTo(expected.y, 4); + expect(q.z).toBeCloseTo(expected.z, 4); + expect(q.w).toBeCloseTo(expected.w, 4); + }); + + it("produces unit quaternion", () => { + const q = torqueAxisAngleToQuaternion(1, 2, 3, 45); + const len = Math.sqrt(q.x ** 2 + q.y ** 2 + q.z ** 2 + q.w ** 2); + expect(len).toBeCloseTo(1, 5); + }); + + it("agrees with matrixFToQuaternion for same rotation", () => { + // 60° around Torque Z-axis + // Both functions should produce the same quaternion. + const ax = 0, ay = 0, az = 1, angleDeg = 60; + const angleRad = angleDeg * (Math.PI / 180); + + const c = Math.cos(angleRad); + const s = Math.sin(angleRad); + const elements = [ + c, s, 0, 0, + -s, c, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, + ]; + const m: MatrixF = { elements, position: { x: 0, y: 0, z: 0 } }; + + const qFromMatrix = matrixFToQuaternion(m); + const qFromAxisAngle = torqueAxisAngleToQuaternion(ax, ay, az, angleDeg); + + const dot = + qFromMatrix.x * qFromAxisAngle.x + + qFromMatrix.y * qFromAxisAngle.y + + qFromMatrix.z * qFromAxisAngle.z + + qFromMatrix.w * qFromAxisAngle.w; + + expect(Math.abs(dot)).toBeCloseTo(1, 4); + }); +}); diff --git a/src/scene/coordinates.ts b/src/scene/coordinates.ts new file mode 100644 index 00000000..59225215 --- /dev/null +++ b/src/scene/coordinates.ts @@ -0,0 +1,113 @@ +import { Matrix4, Quaternion } from "three"; +import type { MatrixF, Vec3 } from "./types"; + +/** + * Convert a Torque Vec3 (X-right, Y-forward, Z-up) to Three.js (X-right, Y-up, Z-backward). + * Swizzle: three.x = torque.y, three.y = torque.z, three.z = torque.x + * + * Note: this is the same swizzle used by getPosition() in mission.ts. + */ +export function torqueToThree(v: Vec3): [number, number, number] { + return [v.y, v.z, v.x]; +} + +/** Convert a Torque scale Vec3 to Three.js axis order. */ +export function torqueScaleToThree(v: Vec3): [number, number, number] { + return [v.y, v.z, v.x]; +} + +/** + * Convert a Torque MatrixF to a Three.js Quaternion. + * + * Torque MatrixF layout (row-major, idx = row*4 + col): + * [0] [1] [2] [3] m00 m01 m02 tx + * [4] [5] [6] [7] = m10 m11 m12 ty + * [8] [9] [10] [11] m20 m21 m22 tz + * [12] [13] [14] [15] 0 0 0 1 + * + * Three.js Matrix4 is column-major, with elements in the same index layout + * but interpreted differently. We extract the 3×3 rotation, apply the + * Torque→Three.js coordinate transform, then decompose to quaternion. + */ +export function matrixFToQuaternion(m: MatrixF): Quaternion { + const e = m.elements; + + // Extract the Torque 3×3 rotation columns (row-major storage) + // Column 0: e[0], e[1], e[2] + // Column 1: e[4], e[5], e[6] + // Column 2: e[8], e[9], e[10] + + // Apply Torque→Three.js coordinate transform to the rotation matrix. + // Torque (X,Y,Z) → Three.js (Y,Z,X) means: + // Three.js row i, col j = Torque row swizzle[i], col swizzle[j] + // where swizzle maps Three axis → Torque axis: X→Y(1), Y→Z(2), Z→X(0) + // + // Build a Three.js column-major Matrix4 from the transformed rotation. + const mat4 = new Matrix4(); + // Three.js Matrix4.elements is column-major: + // [m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44] + const t = mat4.elements; + + // Torque col 0 (X-axis) maps to Three.js col 2 (Z-axis after swizzle) + // Torque col 1 (Y-axis) maps to Three.js col 0 (X-axis after swizzle) + // Torque col 2 (Z-axis) maps to Three.js col 1 (Y-axis after swizzle) + // + // Within each column, rows are also swizzled: + // Torque row 0 (X) → Three.js row 2 (Z) + // Torque row 1 (Y) → Three.js row 0 (X) + // Torque row 2 (Z) → Three.js row 1 (Y) + + // Three.js column 0 ← Torque column 1 (Y→X), rows swizzled + t[0] = e[5]; // T_Y_Y → Three X_X + t[1] = e[6]; // T_Z_Y → Three Y_X + t[2] = e[4]; // T_X_Y → Three Z_X + t[3] = 0; + + // Three.js column 1 ← Torque column 2 (Z→Y), rows swizzled + t[4] = e[9]; // T_Y_Z → Three X_Y + t[5] = e[10]; // T_Z_Z → Three Y_Y + t[6] = e[8]; // T_X_Z → Three Z_Y + t[7] = 0; + + // Three.js column 2 ← Torque column 0 (X→Z), rows swizzled + t[8] = e[1]; // T_Y_X → Three X_Z + t[9] = e[2]; // T_Z_X → Three Y_Z + t[10] = e[0]; // T_X_X → Three Z_Z + t[11] = 0; + + // Translation column (not used for quaternion, but set for completeness) + t[12] = 0; + t[13] = 0; + t[14] = 0; + t[15] = 1; + + const q = new Quaternion(); + q.setFromRotationMatrix(mat4); + // Torque uses row-vector convention (v * M), Three.js uses column-vector (M * v). + // The extracted rotation is the transpose, so conjugate to invert. + q.conjugate(); + return q; +} + +/** + * Convert a Torque axis-angle rotation string ("ax ay az angleDeg") to a Quaternion. + * This is the format used in .mis files. The axis is in Torque coordinates. + */ +export function torqueAxisAngleToQuaternion( + ax: number, + ay: number, + az: number, + angleDeg: number, +): Quaternion { + // Swizzle axis: Torque (X,Y,Z) → Three.js (Y,Z,X) + const threeAx = ay; + const threeAy = az; + const threeAz = ax; + const len = Math.sqrt(threeAx * threeAx + threeAy * threeAy + threeAz * threeAz); + if (len < 1e-8) return new Quaternion(); + const angleRad = -angleDeg * (Math.PI / 180); + return new Quaternion().setFromAxisAngle( + { x: threeAx / len, y: threeAy / len, z: threeAz / len } as any, + angleRad, + ); +} diff --git a/src/scene/crossValidation.spec.ts b/src/scene/crossValidation.spec.ts new file mode 100644 index 00000000..15014b7a --- /dev/null +++ b/src/scene/crossValidation.spec.ts @@ -0,0 +1,171 @@ +/** + * Cross-validation: misToScene and ghostToScene should produce equivalent + * scene objects for the same logical data. This catches drift between the + * two adapter paths. + */ +import { describe, it, expect } from "vitest"; +import { interiorFromMis, tsStaticFromMis, skyFromMis } from "./misToScene"; +import { + interiorFromGhost, + tsStaticFromGhost, + skyFromGhost, +} from "./ghostToScene"; +import type { TorqueObject } from "../torqueScript"; + +function makeObj( + className: string, + props: Record, + id = 42, +): TorqueObject { + const obj: TorqueObject = { + _class: className.toLowerCase(), + _className: className, + _name: "", + _id: id, + _children: [], + }; + for (const [k, v] of Object.entries(props)) { + obj[k.toLowerCase()] = v; + } + return obj; +} + +describe("misToScene ↔ ghostToScene cross-validation", () => { + it("InteriorInstance: identity rotation produces same transform", () => { + const misResult = interiorFromMis( + makeObj("InteriorInstance", { + interiorFile: "building.dif", + position: "100 200 300", + rotation: "1 0 0 0", + scale: "1 1 1", + showTerrainInside: "0", + }), + ); + + const ghostResult = interiorFromGhost(42, { + interiorFile: "building.dif", + transform: { + elements: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 200, 300, 1], + position: { x: 100, y: 200, z: 300 }, + }, + scale: { x: 1, y: 1, z: 1 }, + showTerrainInside: false, + skinBase: "", + alarmState: false, + }); + + expect(misResult.interiorFile).toBe(ghostResult.interiorFile); + expect(misResult.scale).toEqual(ghostResult.scale); + expect(misResult.showTerrainInside).toBe(ghostResult.showTerrainInside); + + // Transform position + expect(misResult.transform.position.x).toBeCloseTo( + ghostResult.transform.position.x, + ); + expect(misResult.transform.position.y).toBeCloseTo( + ghostResult.transform.position.y, + ); + expect(misResult.transform.position.z).toBeCloseTo( + ghostResult.transform.position.z, + ); + + // Rotation elements (identity case) + for (let i = 0; i < 16; i++) { + expect(misResult.transform.elements[i]).toBeCloseTo( + ghostResult.transform.elements[i], + 4, + ); + } + }); + + it("InteriorInstance: 90° Z rotation matches", () => { + const misResult = interiorFromMis( + makeObj("InteriorInstance", { + interiorFile: "building.dif", + position: "0 0 0", + rotation: "0 0 1 90", + }), + ); + + // Build the same matrix manually: 90° around Z + const c = Math.cos(Math.PI / 2); + const s = Math.sin(Math.PI / 2); + const elements = [ + c, s, 0, 0, + -s, c, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1, + ]; + + const ghostResult = interiorFromGhost(42, { + interiorFile: "building.dif", + transform: { elements, position: { x: 0, y: 0, z: 0 } }, + scale: { x: 1, y: 1, z: 1 }, + }); + + for (let i = 0; i < 16; i++) { + expect(misResult.transform.elements[i]).toBeCloseTo( + ghostResult.transform.elements[i], + 4, + ); + } + }); + + it("TSStatic: position and scale match", () => { + const misResult = tsStaticFromMis( + makeObj("TSStatic", { + shapeName: "tree.dts", + position: "50 60 70", + rotation: "1 0 0 0", + scale: "2 3 4", + }), + ); + + const ghostResult = tsStaticFromGhost(42, { + shapeName: "tree.dts", + transform: { + elements: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 60, 70, 1], + position: { x: 50, y: 60, z: 70 }, + }, + scale: { x: 2, y: 3, z: 4 }, + }); + + expect(misResult.shapeName).toBe(ghostResult.shapeName); + expect(misResult.scale).toEqual(ghostResult.scale); + expect(misResult.transform.position).toEqual(ghostResult.transform.position); + }); + + it("Sky: fog and cloud data match", () => { + const misResult = skyFromMis( + makeObj("Sky", { + materialList: "sky_ice.dml", + fogColor: "0.5 0.6 0.7", + visibleDistance: "2000", + fogDistance: "500", + SkySolidColor: "0.1 0.2 0.3", + useSkyTextures: "1", + windVelocity: "1 0 0", + }), + ); + + const ghostResult = skyFromGhost(42, { + materialList: "sky_ice.dml", + fogColor: { r: 0.5, g: 0.6, b: 0.7 }, + visibleDistance: 2000, + fogDistance: 500, + skySolidColor: { r: 0.1, g: 0.2, b: 0.3 }, + useSkyTextures: true, + fogVolumes: [], + cloudLayers: [], + windVelocity: { x: 1, y: 0, z: 0 }, + }); + + expect(misResult.materialList).toBe(ghostResult.materialList); + expect(misResult.fogColor).toEqual(ghostResult.fogColor); + expect(misResult.visibleDistance).toBe(ghostResult.visibleDistance); + expect(misResult.fogDistance).toBe(ghostResult.fogDistance); + expect(misResult.skySolidColor).toEqual(ghostResult.skySolidColor); + expect(misResult.useSkyTextures).toBe(ghostResult.useSkyTextures); + expect(misResult.windVelocity).toEqual(ghostResult.windVelocity); + }); +}); diff --git a/src/scene/ghostToScene.spec.ts b/src/scene/ghostToScene.spec.ts new file mode 100644 index 00000000..2b999f2a --- /dev/null +++ b/src/scene/ghostToScene.spec.ts @@ -0,0 +1,159 @@ +import { describe, it, expect } from "vitest"; +import { + terrainFromGhost, + interiorFromGhost, + skyFromGhost, + sunFromGhost, + missionAreaFromGhost, + waterBlockFromGhost, + ghostToSceneObject, +} from "./ghostToScene"; + +describe("terrainFromGhost", () => { + it("extracts terrain fields", () => { + const result = terrainFromGhost(5, { + terrFileName: "ice.ter", + detailTextureName: "details/detail1.png", + squareSize: 8, + emptySquareRuns: [0, 10, 256, 5], + }); + expect(result.className).toBe("TerrainBlock"); + expect(result.ghostIndex).toBe(5); + expect(result.terrFileName).toBe("ice.ter"); + expect(result.squareSize).toBe(8); + expect(result.emptySquareRuns).toEqual([0, 10, 256, 5]); + }); + + it("uses defaults for missing fields", () => { + const result = terrainFromGhost(0, {}); + expect(result.terrFileName).toBe(""); + expect(result.squareSize).toBe(8); + expect(result.emptySquareRuns).toBeUndefined(); + }); +}); + +describe("interiorFromGhost", () => { + it("extracts transform and scale", () => { + const transform = { + elements: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 200, 300, 1], + position: { x: 100, y: 200, z: 300 }, + }; + const result = interiorFromGhost(10, { + interiorFile: "building.dif", + transform, + scale: { x: 2, y: 3, z: 4 }, + showTerrainInside: true, + skinBase: "base", + alarmState: false, + }); + expect(result.interiorFile).toBe("building.dif"); + expect(result.transform).toBe(transform); + expect(result.scale).toEqual({ x: 2, y: 3, z: 4 }); + expect(result.showTerrainInside).toBe(true); + }); + + it("uses identity transform for missing data", () => { + const result = interiorFromGhost(0, {}); + expect(result.transform.elements).toEqual([ + 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, + ]); + expect(result.scale).toEqual({ x: 1, y: 1, z: 1 }); + }); +}); + +describe("skyFromGhost", () => { + it("extracts fog volumes and cloud layers", () => { + const result = skyFromGhost(1, { + materialList: "sky_ice.dml", + fogColor: { r: 0.5, g: 0.5, b: 0.5 }, + visibleDistance: 2000, + fogDistance: 500, + skySolidColor: { r: 0.1, g: 0.2, b: 0.3 }, + useSkyTextures: true, + fogVolumes: [ + { visibleDistance: 500, minHeight: 0, maxHeight: 300, color: { r: 0.5, g: 0.5, b: 0.5 } }, + ], + cloudLayers: [ + { texture: "cloud1.png", heightPercent: 0.35, speed: 0.001 }, + ], + windVelocity: { x: 1, y: 0, z: 0 }, + }); + expect(result.fogVolumes).toHaveLength(1); + expect(result.fogVolumes[0].visibleDistance).toBe(500); + expect(result.cloudLayers).toHaveLength(1); + expect(result.cloudLayers[0].texture).toBe("cloud1.png"); + expect(result.visibleDistance).toBe(2000); + }); + + it("defaults to empty arrays for missing volumes/layers", () => { + const result = skyFromGhost(1, {}); + expect(result.fogVolumes).toEqual([]); + expect(result.cloudLayers).toEqual([]); + }); +}); + +describe("sunFromGhost", () => { + it("extracts direction and colors", () => { + const result = sunFromGhost(2, { + direction: { x: 0.57735, y: 0.57735, z: -0.57735 }, + color: { r: 0.8, g: 0.8, b: 0.7, a: 1.0 }, + ambient: { r: 0.3, g: 0.3, b: 0.4, a: 1.0 }, + textures: ["sun.png"], + }); + expect(result.direction.x).toBeCloseTo(0.57735); + expect(result.color.r).toBe(0.8); + expect(result.textures).toEqual(["sun.png"]); + }); + + it("uses defaults for missing data", () => { + const result = sunFromGhost(0, {}); + expect(result.direction).toEqual({ x: 0.57735, y: 0.57735, z: -0.57735 }); + expect(result.color).toEqual({ r: 0.7, g: 0.7, b: 0.7, a: 1 }); + }); +}); + +describe("missionAreaFromGhost", () => { + it("extracts area and flight ceiling", () => { + const result = missionAreaFromGhost(3, { + area: { x: -1024, y: -1024, w: 2048, h: 2048 }, + flightCeiling: 5000, + flightCeilingRange: 100, + }); + expect(result.area).toEqual({ x: -1024, y: -1024, w: 2048, h: 2048 }); + expect(result.flightCeiling).toBe(5000); + }); +}); + +describe("waterBlockFromGhost", () => { + it("extracts surface textures", () => { + const result = waterBlockFromGhost(4, { + surfaceName: "water.png", + envMapName: "envmap.png", + scale: { x: 512, y: 512, z: 10 }, + }); + expect(result.surfaceName).toBe("water.png"); + expect(result.envMapName).toBe("envmap.png"); + }); +}); + +describe("ghostToSceneObject", () => { + it("dispatches by className", () => { + const terrain = ghostToSceneObject("TerrainBlock", 1, { + terrFileName: "test.ter", + }); + expect(terrain?.className).toBe("TerrainBlock"); + + const interior = ghostToSceneObject("InteriorInstance", 2, { + interiorFile: "test.dif", + }); + expect(interior?.className).toBe("InteriorInstance"); + + const sky = ghostToSceneObject("Sky", 3, {}); + expect(sky?.className).toBe("Sky"); + }); + + it("returns null for non-scene classes", () => { + expect(ghostToSceneObject("Player", 1, {})).toBeNull(); + expect(ghostToSceneObject("Vehicle", 2, {})).toBeNull(); + }); +}); diff --git a/src/scene/ghostToScene.ts b/src/scene/ghostToScene.ts new file mode 100644 index 00000000..dc22d1ee --- /dev/null +++ b/src/scene/ghostToScene.ts @@ -0,0 +1,231 @@ +import type { + SceneTerrainBlock, + SceneInteriorInstance, + SceneTSStatic, + SceneSky, + SceneSun, + SceneMissionArea, + SceneWaterBlock, + SceneObject, + MatrixF, + Vec3, + Color3, + Color4, +} from "./types"; + +type GhostData = Record; + +function vec3(v: unknown, fallback: Vec3 = { x: 0, y: 0, z: 0 }): Vec3 { + if (v && typeof v === "object" && "x" in v) return v as Vec3; + return fallback; +} + +function color3(v: unknown, fallback: Color3 = { r: 0, g: 0, b: 0 }): Color3 { + if (v && typeof v === "object" && "r" in v) return v as Color3; + return fallback; +} + +function color4( + v: unknown, + fallback: Color4 = { r: 0.5, g: 0.5, b: 0.5, a: 1 }, +): Color4 { + if (v && typeof v === "object" && "r" in v) return v as Color4; + return fallback; +} + +function matrixF(v: unknown): MatrixF { + if ( + v && + typeof v === "object" && + "elements" in v && + Array.isArray((v as any).elements) + ) { + return v as MatrixF; + } + // readAffineTransform() returns {position, rotation} — convert to MatrixF. + if ( + v && + typeof v === "object" && + "position" in v && + "rotation" in v + ) { + const { position: pos, rotation: q } = v as { + position: { x: number; y: number; z: number }; + rotation: { x: number; y: number; z: number; w: number }; + }; + // Quaternion to column-major 4×4 matrix (idx = row + col*4). + const xx = q.x * q.x, yy = q.y * q.y, zz = q.z * q.z; + const xy = q.x * q.y, xz = q.x * q.z, yz = q.y * q.z; + const wx = q.w * q.x, wy = q.w * q.y, wz = q.w * q.z; + return { + elements: [ + 1 - 2 * (yy + zz), 2 * (xy + wz), 2 * (xz - wy), 0, + 2 * (xy - wz), 1 - 2 * (xx + zz), 2 * (yz + wx), 0, + 2 * (xz + wy), 2 * (yz - wx), 1 - 2 * (xx + yy), 0, + pos.x, pos.y, pos.z, 1, + ], + position: { x: pos.x, y: pos.y, z: pos.z }, + }; + } + return { + elements: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], + position: { x: 0, y: 0, z: 0 }, + }; +} + +export function terrainFromGhost( + ghostIndex: number, + data: GhostData, +): SceneTerrainBlock { + return { + className: "TerrainBlock", + ghostIndex, + terrFileName: (data.terrFileName as string) ?? "", + detailTextureName: (data.detailTextureName as string) ?? "", + squareSize: (data.squareSize as number) ?? 8, + emptySquareRuns: data.emptySquareRuns as number[] | undefined, + }; +} + +export function interiorFromGhost( + ghostIndex: number, + data: GhostData, +): SceneInteriorInstance { + return { + className: "InteriorInstance", + ghostIndex, + interiorFile: (data.interiorFile as string) ?? "", + transform: matrixF(data.transform), + scale: vec3(data.scale, { x: 1, y: 1, z: 1 }), + showTerrainInside: (data.showTerrainInside as boolean) ?? false, + skinBase: (data.skinBase as string) ?? "", + alarmState: (data.alarmState as boolean) ?? false, + }; +} + +export function tsStaticFromGhost( + ghostIndex: number, + data: GhostData, +): SceneTSStatic { + return { + className: "TSStatic", + ghostIndex, + shapeName: (data.shapeName as string) ?? "", + transform: matrixF(data.transform), + scale: vec3(data.scale, { x: 1, y: 1, z: 1 }), + }; +} + +export function skyFromGhost(ghostIndex: number, data: GhostData): SceneSky { + const fogVolumes = Array.isArray(data.fogVolumes) + ? (data.fogVolumes as Array<{ + visibleDistance?: number; + minHeight?: number; + maxHeight?: number; + color?: Color3; + }>).map((v) => ({ + visibleDistance: v.visibleDistance ?? 0, + minHeight: v.minHeight ?? 0, + maxHeight: v.maxHeight ?? 0, + color: color3(v.color), + })) + : []; + + const cloudLayers = Array.isArray(data.cloudLayers) + ? (data.cloudLayers as Array<{ + texture?: string; + heightPercent?: number; + speed?: number; + }>).map((c) => ({ + texture: c.texture ?? "", + heightPercent: c.heightPercent ?? 0, + speed: c.speed ?? 0, + })) + : []; + + return { + className: "Sky", + ghostIndex, + materialList: (data.materialList as string) ?? "", + fogColor: color3(data.fogColor), + visibleDistance: (data.visibleDistance as number) ?? 1000, + fogDistance: (data.fogDistance as number) ?? 0, + skySolidColor: color3(data.skySolidColor), + useSkyTextures: (data.useSkyTextures as boolean) ?? true, + fogVolumes, + cloudLayers, + windVelocity: vec3(data.windVelocity), + }; +} + +export function sunFromGhost(ghostIndex: number, data: GhostData): SceneSun { + return { + className: "Sun", + ghostIndex, + direction: vec3(data.direction, { x: 0.57735, y: 0.57735, z: -0.57735 }), + color: color4(data.color, { r: 0.7, g: 0.7, b: 0.7, a: 1 }), + ambient: color4(data.ambient, { r: 0.5, g: 0.5, b: 0.5, a: 1 }), + textures: Array.isArray(data.textures) + ? (data.textures as string[]) + : undefined, + }; +} + +export function missionAreaFromGhost( + ghostIndex: number, + data: GhostData, +): SceneMissionArea { + const area = data.area as + | { x: number; y: number; w: number; h: number } + | undefined; + return { + className: "MissionArea", + ghostIndex, + area: area ?? { x: -512, y: -512, w: 1024, h: 1024 }, + flightCeiling: (data.flightCeiling as number) ?? 2000, + flightCeilingRange: (data.flightCeilingRange as number) ?? 50, + }; +} + +export function waterBlockFromGhost( + ghostIndex: number, + data: GhostData, +): SceneWaterBlock { + return { + className: "WaterBlock", + ghostIndex, + transform: matrixF(data.transform), + scale: vec3(data.scale, { x: 1, y: 1, z: 1 }), + surfaceName: (data.surfaceName as string) ?? "", + envMapName: (data.envMapName as string) ?? "", + surfaceOpacity: (data.surfaceOpacity as number) ?? 0.75, + waveMagnitude: (data.waveMagnitude as number) ?? 1.0, + envMapIntensity: (data.envMapIntensity as number) ?? 1.0, + }; +} + +/** Convert a ghost update to a typed scene object, or null if not a scene type. */ +export function ghostToSceneObject( + className: string, + ghostIndex: number, + data: GhostData, +): SceneObject | null { + switch (className) { + case "TerrainBlock": + return terrainFromGhost(ghostIndex, data); + case "InteriorInstance": + return interiorFromGhost(ghostIndex, data); + case "TSStatic": + return tsStaticFromGhost(ghostIndex, data); + case "Sky": + return skyFromGhost(ghostIndex, data); + case "Sun": + return sunFromGhost(ghostIndex, data); + case "MissionArea": + return missionAreaFromGhost(ghostIndex, data); + case "WaterBlock": + return waterBlockFromGhost(ghostIndex, data); + default: + return null; + } +} diff --git a/src/scene/index.ts b/src/scene/index.ts new file mode 100644 index 00000000..636136ee --- /dev/null +++ b/src/scene/index.ts @@ -0,0 +1,25 @@ +export type { + Vec3, + Color3, + Color4, + MatrixF, + SceneTerrainBlock, + SceneInteriorInstance, + SceneTSStatic, + SceneSky, + SceneSkyFogVolume, + SceneSkyCloudLayer, + SceneSun, + SceneMissionArea, + SceneWaterBlock, + SceneObject, +} from "./types"; +export { IDENTITY_MATRIX } from "./types"; +export { ghostToSceneObject } from "./ghostToScene"; +export { misToSceneObject } from "./misToScene"; +export { + torqueToThree, + torqueScaleToThree, + matrixFToQuaternion, + torqueAxisAngleToQuaternion, +} from "./coordinates"; diff --git a/src/scene/misToScene.spec.ts b/src/scene/misToScene.spec.ts new file mode 100644 index 00000000..a103e965 --- /dev/null +++ b/src/scene/misToScene.spec.ts @@ -0,0 +1,248 @@ +import { describe, it, expect } from "vitest"; +import { + terrainFromMis, + interiorFromMis, + skyFromMis, + sunFromMis, + missionAreaFromMis, + waterBlockFromMis, + misToSceneObject, +} from "./misToScene"; +import type { TorqueObject } from "../torqueScript"; + +function makeObj( + className: string, + props: Record, + id = 0, +): TorqueObject { + const obj: TorqueObject = { + _class: className.toLowerCase(), + _className: className, + _name: "", + _id: id, + _children: [], + }; + for (const [k, v] of Object.entries(props)) { + obj[k.toLowerCase()] = v; + } + return obj; +} + +describe("terrainFromMis", () => { + it("extracts terrain properties", () => { + const obj = makeObj("TerrainBlock", { + terrainFile: "ice.ter", + detailTexture: "details/detail1.png", + squareSize: "8", + }); + const result = terrainFromMis(obj); + expect(result.className).toBe("TerrainBlock"); + expect(result.terrFileName).toBe("ice.ter"); + expect(result.detailTextureName).toBe("details/detail1.png"); + expect(result.squareSize).toBe(8); + }); + + it("uses defaults for missing properties", () => { + const result = terrainFromMis(makeObj("TerrainBlock", {})); + expect(result.terrFileName).toBe(""); + expect(result.squareSize).toBe(8); + }); + + it("parses emptySquares", () => { + const obj = makeObj("TerrainBlock", { + terrainFile: "ice.ter", + emptySquares: "0 10 256 5", + }); + const result = terrainFromMis(obj); + expect(result.emptySquareRuns).toEqual([0, 10, 256, 5]); + }); +}); + +describe("interiorFromMis", () => { + it("builds transform from position and rotation", () => { + const obj = makeObj("InteriorInstance", { + interiorFile: "building.dif", + position: "100 200 300", + rotation: "0 0 1 90", + scale: "2 3 4", + }); + const result = interiorFromMis(obj); + expect(result.className).toBe("InteriorInstance"); + expect(result.interiorFile).toBe("building.dif"); + + // Position should be at elements[12..14] + const e = result.transform.elements; + expect(e[12]).toBeCloseTo(100); + expect(e[13]).toBeCloseTo(200); + expect(e[14]).toBeCloseTo(300); + + // Position object should match + expect(result.transform.position).toEqual({ x: 100, y: 200, z: 300 }); + + // Scale + expect(result.scale).toEqual({ x: 2, y: 3, z: 4 }); + }); + + it("handles identity rotation (0 0 1 0)", () => { + const obj = makeObj("InteriorInstance", { + interiorFile: "test.dif", + position: "10 20 30", + rotation: "1 0 0 0", + }); + const result = interiorFromMis(obj); + const e = result.transform.elements; + // Should be identity rotation + expect(e[0]).toBeCloseTo(1); + expect(e[5]).toBeCloseTo(1); + expect(e[10]).toBeCloseTo(1); + // Off-diagonals should be 0 + expect(e[1]).toBeCloseTo(0); + expect(e[2]).toBeCloseTo(0); + expect(e[4]).toBeCloseTo(0); + }); + + it("90° rotation around Z produces correct rotation matrix", () => { + const obj = makeObj("InteriorInstance", { + interiorFile: "test.dif", + position: "0 0 0", + rotation: "0 0 1 90", + }); + const result = interiorFromMis(obj); + const e = result.transform.elements; + + // Rotation around Z by 90°: + // cos(90°) = 0, sin(90°) = 1 + // Row-major, idx = row + col*4: + // [0]=cos [4]=-sin [8]=0 + // [1]=sin [5]=cos [9]=0 + // [2]=0 [6]=0 [10]=1 + expect(e[0]).toBeCloseTo(0, 4); + expect(e[1]).toBeCloseTo(1, 4); + expect(e[4]).toBeCloseTo(-1, 4); + expect(e[5]).toBeCloseTo(0, 4); + expect(e[10]).toBeCloseTo(1, 4); + }); + + it("180° rotation is self-consistent", () => { + const obj = makeObj("InteriorInstance", { + interiorFile: "test.dif", + position: "0 0 0", + rotation: "0 0 1 180", + }); + const result = interiorFromMis(obj); + const e = result.transform.elements; + // cos(180°) = -1, sin(180°) = 0 + expect(e[0]).toBeCloseTo(-1, 4); + expect(e[5]).toBeCloseTo(-1, 4); + expect(e[10]).toBeCloseTo(1, 4); + }); +}); + +describe("skyFromMis", () => { + it("parses fog volumes", () => { + const obj = makeObj("Sky", { + materialList: "sky_ice.dml", + fogVolume1: "500 0 300", + fogVolume2: "0 0 0", + fogVolume3: "1000 100 500", + visibleDistance: "2000", + fogDistance: "500", + }); + const result = skyFromMis(obj); + expect(result.className).toBe("Sky"); + // fogVolume2 is all zeros, should be filtered out + expect(result.fogVolumes).toHaveLength(2); + expect(result.fogVolumes[0].visibleDistance).toBe(500); + expect(result.fogVolumes[0].maxHeight).toBe(300); + expect(result.fogVolumes[1].visibleDistance).toBe(1000); + }); + + it("parses cloud layers", () => { + const obj = makeObj("Sky", { + cloudText1: "cloud1.png", + cloudText2: "cloud2.png", + cloudText3: "", + "cloudheightper0": "0.35", + "cloudheightper1": "0.25", + cloudSpeed1: "0.001", + }); + const result = skyFromMis(obj); + expect(result.cloudLayers).toHaveLength(3); + expect(result.cloudLayers[0].texture).toBe("cloud1.png"); + expect(result.cloudLayers[0].heightPercent).toBeCloseTo(0.35); + expect(result.cloudLayers[0].speed).toBeCloseTo(0.001); + }); + + it("parses fog and sky colors", () => { + const obj = makeObj("Sky", { + fogColor: "0.5 0.6 0.7", + SkySolidColor: "0.1 0.2 0.3", + }); + const result = skyFromMis(obj); + expect(result.fogColor).toEqual({ r: 0.5, g: 0.6, b: 0.7 }); + expect(result.skySolidColor).toEqual({ r: 0.1, g: 0.2, b: 0.3 }); + }); +}); + +describe("sunFromMis", () => { + it("parses direction and colors", () => { + const obj = makeObj("Sun", { + direction: "0.57735 0.57735 -0.57735", + color: "0.8 0.8 0.7 1.0", + ambient: "0.3 0.3 0.4 1.0", + }); + const result = sunFromMis(obj); + expect(result.direction.x).toBeCloseTo(0.57735); + expect(result.color).toEqual({ r: 0.8, g: 0.8, b: 0.7, a: 1.0 }); + expect(result.ambient).toEqual({ r: 0.3, g: 0.3, b: 0.4, a: 1.0 }); + }); +}); + +describe("missionAreaFromMis", () => { + it("parses area string", () => { + const obj = makeObj("MissionArea", { + area: "-1024 -1024 2048 2048", + flightCeiling: "5000", + flightCeilingRange: "100", + }); + const result = missionAreaFromMis(obj); + expect(result.area).toEqual({ x: -1024, y: -1024, w: 2048, h: 2048 }); + expect(result.flightCeiling).toBe(5000); + expect(result.flightCeilingRange).toBe(100); + }); +}); + +describe("waterBlockFromMis", () => { + it("extracts surface and env map", () => { + const obj = makeObj("WaterBlock", { + position: "0 0 50", + rotation: "1 0 0 0", + scale: "512 512 10", + surfaceTexture: "water.png", + envMapTexture: "envmap.png", + }); + const result = waterBlockFromMis(obj); + expect(result.surfaceName).toBe("water.png"); + expect(result.envMapName).toBe("envmap.png"); + expect(result.scale).toEqual({ x: 512, y: 512, z: 10 }); + }); +}); + +describe("misToSceneObject", () => { + it("dispatches to correct converter by className", () => { + const terrain = misToSceneObject( + makeObj("TerrainBlock", { terrainFile: "test.ter" }), + ); + expect(terrain?.className).toBe("TerrainBlock"); + + const interior = misToSceneObject( + makeObj("InteriorInstance", { interiorFile: "test.dif" }), + ); + expect(interior?.className).toBe("InteriorInstance"); + }); + + it("returns null for unknown className", () => { + expect(misToSceneObject(makeObj("Player", {}))).toBeNull(); + expect(misToSceneObject(makeObj("SimGroup", {}))).toBeNull(); + }); +}); diff --git a/src/scene/misToScene.ts b/src/scene/misToScene.ts new file mode 100644 index 00000000..76200d88 --- /dev/null +++ b/src/scene/misToScene.ts @@ -0,0 +1,288 @@ +/** + * Convert .mis TorqueObject data (string properties) into typed scene objects. + * This is the adapter layer that makes .mis data look like ghost parsedData. + */ + +import type { TorqueObject } from "../torqueScript"; +import type { + SceneTerrainBlock, + SceneInteriorInstance, + SceneTSStatic, + SceneSky, + SceneSun, + SceneMissionArea, + SceneWaterBlock, + SceneObject, + MatrixF, + Vec3, + Color3, + Color4, + SceneSkyFogVolume, + SceneSkyCloudLayer, +} from "./types"; + +// ── String parsing helpers ── + +function prop(obj: TorqueObject, name: string): string | undefined { + return obj[name.toLowerCase()]; +} + +function propFloat(obj: TorqueObject, name: string): number | undefined { + const v = prop(obj, name); + if (v == null) return undefined; + const n = parseFloat(v); + return Number.isFinite(n) ? n : undefined; +} + +function propInt(obj: TorqueObject, name: string): number | undefined { + const v = prop(obj, name); + if (v == null) return undefined; + const n = parseInt(v, 10); + return Number.isFinite(n) ? n : undefined; +} + +function parseVec3(s: string | undefined, fallback: Vec3 = { x: 0, y: 0, z: 0 }): Vec3 { + if (!s) return fallback; + const parts = s.split(" ").map(Number); + return { + x: parts[0] ?? fallback.x, + y: parts[1] ?? fallback.y, + z: parts[2] ?? fallback.z, + }; +} + +function parseColor3(s: string | undefined, fallback: Color3 = { r: 0, g: 0, b: 0 }): Color3 { + if (!s) return fallback; + const parts = s.split(" ").map(Number); + return { + r: parts[0] ?? fallback.r, + g: parts[1] ?? fallback.g, + b: parts[2] ?? fallback.b, + }; +} + +function parseColor4( + s: string | undefined, + fallback: Color4 = { r: 0.5, g: 0.5, b: 0.5, a: 1 }, +): Color4 { + if (!s) return fallback; + const parts = s.split(" ").map(Number); + return { + r: parts[0] ?? fallback.r, + g: parts[1] ?? fallback.g, + b: parts[2] ?? fallback.b, + a: parts[3] ?? fallback.a, + }; +} + +/** + * Build a MatrixF from .mis position ("x y z") and rotation ("ax ay az angleDeg"). + * Torque stores rotation as axis-angle in degrees. + */ +function buildMatrixF( + positionStr: string | undefined, + rotationStr: string | undefined, +): MatrixF { + const pos = parseVec3(positionStr); + const rotParts = (rotationStr ?? "1 0 0 0").split(" ").map(Number); + const ax = rotParts[0] ?? 1; + const ay = rotParts[1] ?? 0; + const az = rotParts[2] ?? 0; + const angleDeg = rotParts[3] ?? 0; + const angleRad = angleDeg * (Math.PI / 180); + + // Normalize axis + const len = Math.sqrt(ax * ax + ay * ay + az * az); + let nx = 0, ny = 0, nz = 1; + if (len > 1e-8) { + nx = ax / len; + ny = ay / len; + nz = az / len; + } + + // Axis-angle to rotation matrix (Rodrigues) + const c = Math.cos(angleRad); + const s = Math.sin(angleRad); + const t = 1 - c; + + // Row-major MatrixF: idx(row, col) = row + col * 4 + const elements = new Array(16).fill(0); + elements[0] = t * nx * nx + c; + elements[1] = t * nx * ny + s * nz; + elements[2] = t * nx * nz - s * ny; + elements[4] = t * nx * ny - s * nz; + elements[5] = t * ny * ny + c; + elements[6] = t * ny * nz + s * nx; + elements[8] = t * nx * nz + s * ny; + elements[9] = t * ny * nz - s * nx; + elements[10] = t * nz * nz + c; + elements[12] = pos.x; + elements[13] = pos.y; + elements[14] = pos.z; + elements[15] = 1; + + return { elements, position: pos }; +} + +function parseEmptySquares(s: string | undefined): number[] | undefined { + if (!s) return undefined; + const runs = s.split(/\s+/).map(Number).filter(Number.isFinite); + return runs.length > 0 ? runs : undefined; +} + +function parseFogVolume(s: string | undefined): SceneSkyFogVolume | null { + if (!s) return null; + const parts = s.split(/\s+/).map(Number); + const visDist = parts[0] ?? 0; + const minH = parts[1] ?? 0; + const maxH = parts[2] ?? 0; + if (visDist === 0 && minH === 0 && maxH === 0) return null; + return { + visibleDistance: visDist, + minHeight: minH, + maxHeight: maxH, + color: { r: 0.5, g: 0.5, b: 0.5 }, // fogVolumeColor is cosmetic only in T2 + }; +} + +// ── Conversion functions ── + +export function terrainFromMis(obj: TorqueObject): SceneTerrainBlock { + return { + className: "TerrainBlock", + ghostIndex: obj._id, + terrFileName: prop(obj, "terrainFile") ?? "", + detailTextureName: prop(obj, "detailTexture") ?? "", + squareSize: propInt(obj, "squareSize") ?? 8, + emptySquareRuns: parseEmptySquares(prop(obj, "emptySquares")), + }; +} + +export function interiorFromMis(obj: TorqueObject): SceneInteriorInstance { + return { + className: "InteriorInstance", + ghostIndex: obj._id, + interiorFile: prop(obj, "interiorFile") ?? "", + transform: buildMatrixF(prop(obj, "position"), prop(obj, "rotation")), + scale: parseVec3(prop(obj, "scale"), { x: 1, y: 1, z: 1 }), + showTerrainInside: prop(obj, "showTerrainInside") === "1", + skinBase: prop(obj, "skinBase") ?? "", + alarmState: false, + }; +} + +export function tsStaticFromMis(obj: TorqueObject): SceneTSStatic { + return { + className: "TSStatic", + ghostIndex: obj._id, + shapeName: prop(obj, "shapeName") ?? "", + transform: buildMatrixF(prop(obj, "position"), prop(obj, "rotation")), + scale: parseVec3(prop(obj, "scale"), { x: 1, y: 1, z: 1 }), + }; +} + +export function skyFromMis(obj: TorqueObject): SceneSky { + const fogVolumes: SceneSkyFogVolume[] = []; + for (let i = 1; i <= 3; i++) { + const vol = parseFogVolume(prop(obj, `fogVolume${i}`)); + if (vol) fogVolumes.push(vol); + } + + const cloudLayers: SceneSkyCloudLayer[] = []; + for (let i = 0; i < 3; i++) { + const texture = prop(obj, `cloudText${i + 1}`) ?? ""; + const heightPercent = propFloat(obj, `cloudHeightPer[${i}]`) ?? propFloat(obj, `cloudheightper${i}`) ?? [0.35, 0.25, 0.2][i]; + const speed = propFloat(obj, `cloudSpeed${i + 1}`) ?? [0.0001, 0.0002, 0.0003][i]; + cloudLayers.push({ texture, heightPercent, speed }); + } + + return { + className: "Sky", + ghostIndex: obj._id, + materialList: prop(obj, "materialList") ?? "", + fogColor: parseColor3(prop(obj, "fogColor")), + visibleDistance: propFloat(obj, "visibleDistance") ?? 1000, + fogDistance: propFloat(obj, "fogDistance") ?? 0, + skySolidColor: parseColor3(prop(obj, "SkySolidColor")), + useSkyTextures: (propInt(obj, "useSkyTextures") ?? 1) !== 0, + fogVolumes, + cloudLayers, + windVelocity: parseVec3(prop(obj, "windVelocity")), + }; +} + +export function sunFromMis(obj: TorqueObject): SceneSun { + return { + className: "Sun", + ghostIndex: obj._id, + direction: parseVec3(prop(obj, "direction"), { + x: 0.57735, + y: 0.57735, + z: -0.57735, + }), + color: parseColor4(prop(obj, "color"), { r: 0.7, g: 0.7, b: 0.7, a: 1 }), + ambient: parseColor4(prop(obj, "ambient"), { + r: 0.5, + g: 0.5, + b: 0.5, + a: 1, + }), + }; +} + +export function missionAreaFromMis(obj: TorqueObject): SceneMissionArea { + const areaStr = prop(obj, "area"); + let area = { x: -512, y: -512, w: 1024, h: 1024 }; + if (areaStr) { + const parts = areaStr.split(/\s+/).map(Number); + area = { + x: parts[0] ?? area.x, + y: parts[1] ?? area.y, + w: parts[2] ?? area.w, + h: parts[3] ?? area.h, + }; + } + return { + className: "MissionArea", + ghostIndex: obj._id, + area, + flightCeiling: propFloat(obj, "flightCeiling") ?? 2000, + flightCeilingRange: propFloat(obj, "flightCeilingRange") ?? 50, + }; +} + +export function waterBlockFromMis(obj: TorqueObject): SceneWaterBlock { + return { + className: "WaterBlock", + ghostIndex: obj._id, + transform: buildMatrixF(prop(obj, "position"), prop(obj, "rotation")), + scale: parseVec3(prop(obj, "scale"), { x: 1, y: 1, z: 1 }), + surfaceName: prop(obj, "surfaceTexture") ?? "", + envMapName: prop(obj, "envMapTexture") ?? "", + surfaceOpacity: propFloat(obj, "surfaceOpacity") ?? 0.75, + waveMagnitude: propFloat(obj, "waveMagnitude") ?? 1.0, + envMapIntensity: propFloat(obj, "envMapIntensity") ?? 1.0, + }; +} + +/** Convert a .mis TorqueObject to a typed scene object based on className. */ +export function misToSceneObject(obj: TorqueObject): SceneObject | null { + switch (obj._className) { + case "TerrainBlock": + return terrainFromMis(obj); + case "InteriorInstance": + return interiorFromMis(obj); + case "TSStatic": + return tsStaticFromMis(obj); + case "Sky": + return skyFromMis(obj); + case "Sun": + return sunFromMis(obj); + case "MissionArea": + return missionAreaFromMis(obj); + case "WaterBlock": + return waterBlockFromMis(obj); + default: + return null; + } +} diff --git a/src/scene/types.ts b/src/scene/types.ts new file mode 100644 index 00000000..aef53051 --- /dev/null +++ b/src/scene/types.ts @@ -0,0 +1,131 @@ +/** 3D vector in Torque coordinate space (X-right, Y-forward, Z-up). */ +export interface Vec3 { + x: number; + y: number; + z: number; +} + +export interface Color3 { + r: number; + g: number; + b: number; +} + +export interface Color4 { + r: number; + g: number; + b: number; + a: number; +} + +/** + * Row-major 4×4 transform matrix as used by Torque's MatrixF. + * Index formula: idx(row, col) = row + col * 4. + * Position is at elements[12], elements[13], elements[14]. + */ +export interface MatrixF { + elements: number[]; + position: Vec3; +} + +/** Identity MatrixF. */ +export const IDENTITY_MATRIX: MatrixF = { + elements: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], + position: { x: 0, y: 0, z: 0 }, +}; + +// ── Mission scene object types ── +// These match the ghost parsedData structures from t2-demo-parser. + +export interface SceneTerrainBlock { + className: "TerrainBlock"; + ghostIndex: number; + terrFileName: string; + detailTextureName: string; + squareSize: number; + emptySquareRuns?: number[]; +} + +export interface SceneInteriorInstance { + className: "InteriorInstance"; + ghostIndex: number; + interiorFile: string; + transform: MatrixF; + scale: Vec3; + showTerrainInside: boolean; + skinBase: string; + alarmState: boolean; +} + +export interface SceneTSStatic { + className: "TSStatic"; + ghostIndex: number; + shapeName: string; + transform: MatrixF; + scale: Vec3; +} + +export interface SceneSkyFogVolume { + visibleDistance: number; + minHeight: number; + maxHeight: number; + color: Color3; +} + +export interface SceneSkyCloudLayer { + texture: string; + heightPercent: number; + speed: number; +} + +export interface SceneSky { + className: "Sky"; + ghostIndex: number; + materialList: string; + fogColor: Color3; + visibleDistance: number; + fogDistance: number; + skySolidColor: Color3; + useSkyTextures: boolean; + fogVolumes: SceneSkyFogVolume[]; + cloudLayers: SceneSkyCloudLayer[]; + windVelocity: Vec3; +} + +export interface SceneSun { + className: "Sun"; + ghostIndex: number; + direction: Vec3; + color: Color4; + ambient: Color4; + textures?: string[]; +} + +export interface SceneMissionArea { + className: "MissionArea"; + ghostIndex: number; + area: { x: number; y: number; w: number; h: number }; + flightCeiling: number; + flightCeilingRange: number; +} + +export interface SceneWaterBlock { + className: "WaterBlock"; + ghostIndex: number; + transform: MatrixF; + scale: Vec3; + surfaceName: string; + envMapName: string; + surfaceOpacity: number; + waveMagnitude: number; + envMapIntensity: number; +} + +export type SceneObject = + | SceneTerrainBlock + | SceneInteriorInstance + | SceneTSStatic + | SceneSky + | SceneSun + | SceneMissionArea + | SceneWaterBlock; diff --git a/src/state/engineStore.ts b/src/state/engineStore.ts index e7aed38b..8b58e3a9 100644 --- a/src/state/engineStore.ts +++ b/src/state/engineStore.ts @@ -1,7 +1,7 @@ import { createStore } from "zustand/vanilla"; import { subscribeWithSelector } from "zustand/middleware"; import { useStoreWithEqualityFn } from "zustand/traditional"; -import type { DemoRecording, DemoStreamSnapshot } from "../demo/types"; +import type { StreamRecording, StreamSnapshot } from "../stream/types"; import type { RuntimeMutationEvent, TorqueObject, @@ -25,12 +25,12 @@ export interface RuntimeSliceState { } export interface PlaybackSliceState { - recording: DemoRecording | null; + recording: StreamRecording | null; status: PlaybackStatus; timeMs: number; rate: number; durationMs: number; - streamSnapshot: DemoStreamSnapshot | null; + streamSnapshot: StreamSnapshot | null; } export interface RuntimeTickInfo { @@ -43,11 +43,11 @@ export interface EngineStoreState { setRuntime(runtime: TorqueRuntime): void; clearRuntime(): void; applyRuntimeBatch(events: RuntimeMutationEvent[], tickInfo?: RuntimeTickInfo): void; - setDemoRecording(recording: DemoRecording | null): void; + setRecording(recording: StreamRecording | null): void; setPlaybackTime(ms: number): void; setPlaybackStatus(status: PlaybackStatus): void; setPlaybackRate(rate: number): void; - setPlaybackStreamSnapshot(snapshot: DemoStreamSnapshot | null): void; + setPlaybackStreamSnapshot(snapshot: StreamSnapshot | null): void; } function normalizeName(name: string): string { @@ -104,7 +104,7 @@ const initialState: Omit< | "setRuntime" | "clearRuntime" | "applyRuntimeBatch" - | "setDemoRecording" + | "setRecording" | "setPlaybackTime" | "setPlaybackStatus" | "setPlaybackRate" @@ -243,7 +243,7 @@ export const engineStore = createStore()( }); }, - setDemoRecording(recording: DemoRecording | null) { + setRecording(recording: StreamRecording | null) { const durationMs = Math.max(0, (recording?.duration ?? 0) * 1000); set((state) => ({ ...state, @@ -292,7 +292,7 @@ export const engineStore = createStore()( })); }, - setPlaybackStreamSnapshot(snapshot: DemoStreamSnapshot | null) { + setPlaybackStreamSnapshot(snapshot: StreamSnapshot | null) { set((state) => ({ ...state, playback: { @@ -308,10 +308,10 @@ export const engineStore = createStore()( // ── Rate-scaled effect clock ── // // A monotonic clock that advances by (frameDelta × playbackRate) each frame. -// Components use demoEffectNow() instead of performance.now() so that effect +// Components use effectNow() instead of performance.now() so that effect // timers (explosions, particles, shockwaves, animation threads) automatically // pause when the demo is paused and speed up / slow down with the playback -// rate. The main DemoPlaybackStreaming component calls advanceEffectClock() +// rate. The DemoPlaybackController component calls advanceEffectClock() // once per frame. let _effectClockMs = 0; @@ -321,13 +321,13 @@ let _effectClockMs = 0; * Analogous to performance.now() but only advances when playing, * scaled by the playback rate. */ -export function demoEffectNow(): number { +export function effectNow(): number { return _effectClockMs; } /** * Advance the effect clock. Called once per frame from - * DemoPlaybackStreaming before other useFrame callbacks run. + * DemoPlaybackController before other useFrame callbacks run. */ export function advanceEffectClock(deltaSec: number, rate: number): void { _effectClockMs += deltaSec * rate * 1000; diff --git a/src/state/gameEntityStore.ts b/src/state/gameEntityStore.ts new file mode 100644 index 00000000..f3df2c7c --- /dev/null +++ b/src/state/gameEntityStore.ts @@ -0,0 +1,298 @@ +import { createStore } from "zustand/vanilla"; +import { useStoreWithEqualityFn } from "zustand/traditional"; +import type { GameEntity, RenderType } from "./gameEntityTypes"; + +export interface GameEntityState { + /** + * Mission-authored entities (from .mis TorqueObject tree). + * Persists while the mission is loaded. Overridden by streamEntities + * when streaming is active. + */ + missionEntities: Map; + /** + * Stream entities from demo playback or live server connection. + * When non-empty, these are rendered instead of missionEntities. + */ + streamEntities: Map; + /** True when a demo/live source is actively driving entity state. */ + isStreaming: boolean; + /** Monotonically increasing version counter, bumped on any mutation. */ + version: number; + + // ── Mission entity mutations ── + setEntity(entity: GameEntity): void; + deleteEntity(id: string): void; + setEntities(entities: GameEntity[]): void; + setAllEntities(entities: GameEntity[]): void; + clearEntities(): void; + + // ── Stream entity mutations ── + /** Begin streaming mode. Stream entities will be rendered instead of mission entities. */ + beginStreaming(): void; + /** End streaming mode and clear stream entities. Mission entities become active again. */ + endStreaming(): void; + setStreamEntity(entity: GameEntity): void; + deleteStreamEntity(id: string): void; + setStreamEntities(entities: GameEntity[]): void; + setAllStreamEntities(entities: GameEntity[]): void; + clearStreamEntities(): void; +} + +export const gameEntityStore = createStore()((set) => ({ + missionEntities: new Map(), + streamEntities: new Map(), + isStreaming: false, + version: 0, + + // ── Mission entity mutations ── + + setEntity(entity: GameEntity) { + set((state) => { + const next = new Map(state.missionEntities); + next.set(entity.id, entity); + return { missionEntities: next, version: state.version + 1 }; + }); + }, + + deleteEntity(id: string) { + set((state) => { + if (!state.missionEntities.has(id)) return state; + const next = new Map(state.missionEntities); + next.delete(id); + return { missionEntities: next, version: state.version + 1 }; + }); + }, + + setEntities(entities: GameEntity[]) { + set((state) => { + const next = new Map(state.missionEntities); + for (const entity of entities) { + next.set(entity.id, entity); + } + return { missionEntities: next, version: state.version + 1 }; + }); + }, + + setAllEntities(entities: GameEntity[]) { + set(() => { + const next = new Map(); + for (const entity of entities) { + next.set(entity.id, entity); + } + return { missionEntities: next }; + }); + }, + + clearEntities() { + set((state) => { + if (state.missionEntities.size === 0) return state; + return { missionEntities: new Map(), version: state.version + 1 }; + }); + }, + + // ── Stream entity mutations ── + + beginStreaming() { + set((state) => { + if (state.isStreaming) return state; + return { isStreaming: true, streamEntities: new Map(), version: state.version + 1 }; + }); + }, + + endStreaming() { + set((state) => { + if (!state.isStreaming) return state; + return { isStreaming: false, streamEntities: new Map(), version: state.version + 1 }; + }); + }, + + setStreamEntity(entity: GameEntity) { + set((state) => { + const next = new Map(state.streamEntities); + next.set(entity.id, entity); + return { streamEntities: next, version: state.version + 1 }; + }); + }, + + deleteStreamEntity(id: string) { + set((state) => { + if (!state.streamEntities.has(id)) return state; + const next = new Map(state.streamEntities); + next.delete(id); + return { streamEntities: next, version: state.version + 1 }; + }); + }, + + setStreamEntities(entities: GameEntity[]) { + set((state) => { + const next = new Map(state.streamEntities); + for (const entity of entities) { + next.set(entity.id, entity); + } + return { streamEntities: next, version: state.version + 1 }; + }); + }, + + setAllStreamEntities(entities: GameEntity[]) { + set((state) => { + const prev = state.streamEntities; + const next = new Map(); + for (const entity of entities) { + next.set(entity.id, entity); + } + // Only update (and bump version) when the entity set changed + // (adds/removes). Render-field-only updates (threads, colors, etc.) + // are applied via mutateStreamEntities below instead. This prevents + // frequent Zustand set() calls from starving React Suspense. + if (next.size === prev.size && [...next.keys()].every((id) => prev.has(id))) { + return state; // same set — no store update at all + } + return { streamEntities: next, version: state.version + 1 }; + }); + }, + + clearStreamEntities() { + set((state) => { + if (state.streamEntities.size === 0) return state; + return { streamEntities: new Map(), version: state.version + 1 }; + }); + }, +})); + +// ── Selectors ── + +function selectActiveEntities(state: GameEntityState) { + return state.isStreaming ? state.streamEntities : state.missionEntities; +} + +function selectVersion(state: GameEntityState) { + return state.version; +} + +function useGameEntitiesInternal() { + useStoreWithEqualityFn(gameEntityStore, selectVersion); + return useStoreWithEqualityFn(gameEntityStore, selectActiveEntities); +} + +/** Hook that returns the active game entities. Re-renders on any entity change. */ +export function useGameEntities(): Map { + return useGameEntitiesInternal(); +} + +// ── All-entity selector ── + +function selectAllEntities(state: GameEntityState): GameEntity[] { + const entities = state.isStreaming + ? state.streamEntities + : state.missionEntities; + const result: GameEntity[] = []; + for (const entity of entities.values()) { + if (entity.renderType !== "None") { + result.push(entity); + } + } + return result; +} + +/** Compare entity sets by reference identity. Field-only mutations + * (threads, colors, position) reuse the same object so this won't trigger. + * Identity rebuilds (new datablock, shape change) create new objects, + * which correctly triggers a re-render to pick up the new entity. */ +function entitySetEqual(a: GameEntity[], b: GameEntity[]): boolean { + if (a.length !== b.length) return false; + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) return false; + } + return true; +} + +/** + * Hook that returns all renderable entities (renderType !== "None"). + * Re-renders when entities are added, removed, or identity-rebuilt + * (new datablock/shape → new object reference). Does NOT re-render + * for in-place field mutations (threads, colors, position). + */ +export function useAllGameEntities(): GameEntity[] { + return useStoreWithEqualityFn( + gameEntityStore, + selectAllEntities, + entitySetEqual, + ); +} + +/** Hook returning entities filtered by render type. */ +export function useGameEntitiesByRenderType(renderType: RenderType): GameEntity[] { + const entities = useGameEntitiesInternal(); + const result: GameEntity[] = []; + for (const entity of entities.values()) { + if (entity.renderType === renderType) result.push(entity); + } + return result; +} + +/** Hook returning entities filtered by class name. */ +export function useGameEntitiesByClass(className: string): GameEntity[] { + const entities = useGameEntitiesInternal(); + const result: GameEntity[] = []; + for (const entity of entities.values()) { + if (entity.className === className) result.push(entity); + } + return result; +} + +/** Hook returning a single entity by id, or undefined. */ +export function useGameEntity(id: string): GameEntity | undefined { + const entities = useGameEntitiesInternal(); + return entities.get(id); +} + +// ── Scene infrastructure queries ── + +import type { + SceneSky, + SceneSun, + SceneMissionArea, +} from "../scene/types"; + +// Scene infrastructure selectors use Object.is equality (default) on the +// extracted data object — these are set once and referentially stable, so +// the hooks won't re-render when unrelated (dynamic) entities update. + +function selectSkyData(state: GameEntityState): SceneSky | null { + const entities = state.isStreaming ? state.streamEntities : state.missionEntities; + for (const e of entities.values()) { + if (e.renderType === "Sky") return e.skyData; + } + return null; +} + +function selectSunData(state: GameEntityState): SceneSun | null { + const entities = state.isStreaming ? state.streamEntities : state.missionEntities; + for (const e of entities.values()) { + if (e.renderType === "Sun") return e.sunData; + } + return null; +} + +function selectMissionAreaData(state: GameEntityState): SceneMissionArea | null { + const entities = state.isStreaming ? state.streamEntities : state.missionEntities; + for (const e of entities.values()) { + if (e.renderType === "MissionArea") return e.missionAreaData; + } + return null; +} + +/** Hook returning the Sky data, or null if no sky entity exists. */ +export function useSceneSky(): SceneSky | null { + return useStoreWithEqualityFn(gameEntityStore, selectSkyData); +} + +/** Hook returning the Sun data, or null if no sun entity exists. */ +export function useSceneSun(): SceneSun | null { + return useStoreWithEqualityFn(gameEntityStore, selectSunData); +} + +/** Hook returning the MissionArea data, or null if none exists. */ +export function useSceneMissionArea(): SceneMissionArea | null { + return useStoreWithEqualityFn(gameEntityStore, selectMissionAreaData); +} diff --git a/src/state/gameEntityTypes.ts b/src/state/gameEntityTypes.ts new file mode 100644 index 00000000..e5ac698f --- /dev/null +++ b/src/state/gameEntityTypes.ts @@ -0,0 +1,241 @@ +import type { + Keyframe, + ThreadState, + TracerVisual, + SpriteVisual, + WeaponImageState, + WeaponImageDataBlockState, +} from "../stream/types"; +import type { + SceneTerrainBlock, + SceneInteriorInstance, + SceneSky, + SceneSun, + SceneWaterBlock, + SceneMissionArea, +} from "../scene/types"; + +/** + * Determines which renderer handles this entity. Uses engine class names + * where there's a 1:1 mapping; functional names for cross-class renderers. + */ +export type RenderType = + // Scene infrastructure (handle own positioning) + | "TerrainBlock" + | "InteriorInstance" + | "Sky" + | "Sun" + | "WaterBlock" + | "MissionArea" + // Gameplay entities (positioned by interpolation loop) + | "Shape" + | "Player" + | "ForceFieldBare" + | "Explosion" + | "Tracer" + | "Sprite" + | "AudioEmitter" + | "Camera" + | "WayPoint" + | "None"; + +// ── Common base ── + +interface EntityBase { + id: string; + className: string; + renderType: RenderType; + ghostIndex?: number; + dataBlockId?: number; + shapeHint?: string; + spawnTime?: number; + runtimeObject?: unknown; + missionTypesList?: string; +} + +// ── Scene infrastructure entities ── + +export interface TerrainBlockEntity extends EntityBase { + renderType: "TerrainBlock"; + terrainData: SceneTerrainBlock; +} + +export interface InteriorInstanceEntity extends EntityBase { + renderType: "InteriorInstance"; + interiorData: SceneInteriorInstance; +} + +export interface SkyEntity extends EntityBase { + renderType: "Sky"; + skyData: SceneSky; +} + +export interface SunEntity extends EntityBase { + renderType: "Sun"; + sunData: SceneSun; +} + +export interface WaterBlockEntity extends EntityBase { + renderType: "WaterBlock"; + waterData: SceneWaterBlock; +} + +export interface MissionAreaEntity extends EntityBase { + renderType: "MissionArea"; + missionAreaData: SceneMissionArea; +} + +export type SceneEntity = + | TerrainBlockEntity + | InteriorInstanceEntity + | SkyEntity + | SunEntity + | WaterBlockEntity + | MissionAreaEntity; + +export function isSceneEntity(entity: GameEntity): entity is SceneEntity { + switch (entity.renderType) { + case "TerrainBlock": + case "InteriorInstance": + case "Sky": + case "Sun": + case "WaterBlock": + case "MissionArea": + return true; + default: + return false; + } +} + +// ── Positioned entity base ── + +interface PositionedBase extends EntityBase { + position?: [number, number, number]; + rotation?: [number, number, number, number]; + scale?: [number, number, number]; + velocity?: [number, number, number]; + keyframes?: Keyframe[]; +} + +// ── Gameplay entities ── + +/** Generic DTS-rendered entity (StaticShape, Turret, Item, TSStatic, etc.). */ +export interface ShapeEntity extends PositionedBase { + renderType: "Shape"; + shapeName?: string; + shapeType?: string; + dataBlock?: string; + threads?: ThreadState[]; + rotate?: boolean; + teamId?: number; + barrelShapeName?: string; + targetRenderFlags?: number; + iffColor?: { r: number; g: number; b: number }; + weaponShape?: string; +} + +export interface PlayerEntity extends PositionedBase { + renderType: "Player"; + shapeName?: string; + dataBlock?: string; + weaponShape?: string; + playerName?: string; + iffColor?: { r: number; g: number; b: number }; + threads?: ThreadState[]; + weaponImageState?: WeaponImageState; + weaponImageStates?: WeaponImageDataBlockState[]; + headPitch?: number; + headYaw?: number; + health?: number; + energy?: number; + actionAnim?: number; + actionAtEnd?: boolean; + damageState?: number; + targetRenderFlags?: number; +} + +export interface ForceFieldBareEntity extends PositionedBase { + renderType: "ForceFieldBare"; + forceFieldData?: ForceFieldData; +} + +export interface ExplosionEntity extends PositionedBase { + renderType: "Explosion"; + shapeName?: string; + dataBlock?: string; + explosionDataBlockId?: number; + faceViewer?: boolean; +} + +export interface TracerEntity extends PositionedBase { + renderType: "Tracer"; + visual: TracerVisual; + dataBlock?: string; + direction?: [number, number, number]; +} + +export interface SpriteEntity extends PositionedBase { + renderType: "Sprite"; + visual: SpriteVisual; +} + +export interface AudioEmitterEntity extends PositionedBase { + renderType: "AudioEmitter"; + audioFileName?: string; + audioVolume?: number; + audioIs3D?: boolean; + audioIsLooping?: boolean; + audioMinDistance?: number; + audioMaxDistance?: number; + audioMinLoopGap?: number; + audioMaxLoopGap?: number; +} + +export interface CameraEntity extends PositionedBase { + renderType: "Camera"; + cameraDataBlock?: string; +} + +export interface WayPointEntity extends PositionedBase { + renderType: "WayPoint"; + label?: string; +} + +export interface NoneEntity extends EntityBase { + renderType: "None"; +} + +export type PositionedEntity = Exclude; + +// ── Union type ── + +export type GameEntity = + | TerrainBlockEntity + | InteriorInstanceEntity + | SkyEntity + | SunEntity + | WaterBlockEntity + | MissionAreaEntity + | ShapeEntity + | PlayerEntity + | ForceFieldBareEntity + | ExplosionEntity + | TracerEntity + | SpriteEntity + | AudioEmitterEntity + | CameraEntity + | WayPointEntity + | NoneEntity; + +export interface ForceFieldData { + textures: string[]; + color: [number, number, number]; + baseTranslucency: number; + numFrames: number; + framesPerSec: number; + scrollSpeed: number; + umapping: number; + vmapping: number; + /** Box dimensions in Three.js space [x, y, z]. NOT a transform scale. */ + dimensions: [number, number, number]; +} diff --git a/src/state/index.ts b/src/state/index.ts index 5dc8f6a4..015ed9f4 100644 --- a/src/state/index.ts +++ b/src/state/index.ts @@ -8,7 +8,7 @@ export type { export { engineStore, - demoEffectNow, + effectNow, advanceEffectClock, resetEffectClock, useEngineSelector, @@ -20,3 +20,43 @@ export { useDatablockByName, useRuntimeChildIds, } from "./engineStore"; + +export type { + GameEntity, + PositionedEntity, + SceneEntity, + RenderType, + ForceFieldData, + ShapeEntity, + PlayerEntity, + ForceFieldBareEntity, + ExplosionEntity, + TracerEntity, + SpriteEntity, + AudioEmitterEntity, + CameraEntity, + WayPointEntity, + NoneEntity, + TerrainBlockEntity, + InteriorInstanceEntity, + SkyEntity, + SunEntity, + WaterBlockEntity, + MissionAreaEntity, +} from "./gameEntityTypes"; + +export { isSceneEntity } from "./gameEntityTypes"; + +export type { GameEntityState } from "./gameEntityStore"; + +export { + gameEntityStore, + useGameEntities, + useAllGameEntities, + useGameEntitiesByRenderType, + useGameEntitiesByClass, + useGameEntity, + useSceneSky, + useSceneSun, + useSceneMissionArea, +} from "./gameEntityStore"; diff --git a/src/state/streamPlaybackStore.ts b/src/state/streamPlaybackStore.ts new file mode 100644 index 00000000..21c6290d --- /dev/null +++ b/src/state/streamPlaybackStore.ts @@ -0,0 +1,44 @@ +import { createStore } from "zustand/vanilla"; +import type { Group } from "three"; +import type { StreamingPlayback } from "../stream/types"; +import type { GameEntity } from "./gameEntityTypes"; + +/** + * Store for mutable streaming playback state that needs to be shared between + * the playback controller (writer) and entity rendering components (readers). + * + * These values are updated every frame and read imperatively in useFrame + * callbacks — they intentionally bypass React's render cycle. Use + * `streamPlaybackStore.getState()` to read current values. + */ +export interface StreamPlaybackState { + /** Current playback time in seconds, updated every frame. */ + time: number; + /** The active streaming playback source (demo or live). */ + playback: StreamingPlayback | null; + /** The Three.js group node containing all entity children. */ + root: Group | null; + /** + * When true, ObserverControls drives the camera instead of the stream. + * Toggled by 'O' key during live observation. + */ + freeFlyCamera: boolean; + /** Live entity map, updated every frame. Components read from this in + * useFrame to get the latest render fields (threads, weapons, etc.) + * without triggering React re-renders. */ + entities: Map; +} + +export const streamPlaybackStore = createStore()(() => ({ + time: 0, + playback: null, + root: null, + freeFlyCamera: false, + entities: new Map(), +})); + +/** Reset all streaming playback state. Called when streaming ends. */ +export function resetStreamPlayback(): void { + streamPlaybackStore.setState({ time: 0, playback: null, freeFlyCamera: false }); + // root is managed by the React ref callback in EntityScene — don't clear it +} diff --git a/src/stream/StreamEngine.ts b/src/stream/StreamEngine.ts new file mode 100644 index 00000000..b2036f7f --- /dev/null +++ b/src/stream/StreamEngine.ts @@ -0,0 +1,1868 @@ +import { ghostToSceneObject } from "../scene"; +import { getTerrainHeightAt } from "../terrainHeight"; +import type { SceneObject } from "../scene/types"; +import { + linearProjectileClassNames, + ballisticProjectileClassNames, + seekerProjectileClassNames, + toEntityType, + toEntityId, + IFF_GREEN, + IFF_RED, + TICK_DURATION_MS, +} from "./entityClassification"; +import { + clamp, + MAX_PITCH, + CameraMode_OrbitObject, + yawPitchToQuaternion, + playerYawToQuaternion, + torqueQuatToThreeJS, + isValidPosition, + isVec3Like, + isQuatLike, + resolveShapeName, + getNumberField, + resolveTracerVisual, + resolveSpriteVisual, + parseWeaponImageStates, + stripTaggedStringMarkup, + detectColorCode, + extractWavTag, + detectControlObjectType, +} from "./streamHelpers"; +import type { Vec3 } from "./streamHelpers"; +import type { + BackpackHudState, + ChatSegment, + ChatMessage, + ThreadState, + StreamVisual, + StreamCamera, + StreamEntity, + StreamSnapshot, + StreamingPlayback, + InventoryHudSlot, + PendingAudioEvent, + TeamScore, + WeaponsHudSlot, + WeaponImageState, + WeaponImageDataBlockState, +} from "./types"; + +export type { Vec3 }; + +// ── Internal mutable entity type ── + +export interface MutableEntity { + id: string; + ghostIndex: number; + className: string; + /** Move tick when this ghost instance first entered scope. */ + spawnTick: number; + type: string; + dataBlockId?: number; + shapeHint?: string; + dataBlock?: string; + visual?: StreamVisual; + direction?: [number, number, number]; + weaponShape?: string; + playerName?: string; + position?: [number, number, number]; + rotation: [number, number, number, number]; + velocity?: [number, number, number]; + health?: number; + energy?: number; + maxEnergy?: number; + actionAnim?: number; + actionAtEnd?: boolean; + damageState?: number; + targetId?: number; + projectilePhysics?: "linear" | "ballistic" | "seeker"; + simulatedVelocity?: [number, number, number]; + gravityMod?: number; + explosionShape?: string; + explosionLifetimeTicks?: number; + hasExploded?: boolean; + isExplosion?: boolean; + expiryTick?: number; + faceViewer?: boolean; + explosionDataBlockId?: number; + maintainEmitterId?: number; + sensorGroup?: number; + threads?: ThreadState[]; + weaponImageState?: WeaponImageState; + weaponImageStates?: WeaponImageDataBlockState[]; + weaponImageStatesDbId?: number; + headPitch?: number; + headYaw?: number; + targetRenderFlags?: number; + carryingFlag?: boolean; + /** Item physics simulation state (dropped weapons/items). */ + itemPhysics?: { + velocity: [number, number, number]; + atRest: boolean; + elasticity: number; + friction: number; + gravityMod: number; + }; + label?: string; + audioFileName?: string; + audioVolume?: number; + audioIs3D?: boolean; + audioIsLooping?: boolean; + audioMinDistance?: number; + audioMaxDistance?: number; + audioMinLoopGap?: number; + audioMaxLoopGap?: number; + sceneData?: SceneObject; +} + +export type RuntimeControlObject = { + ghostIndex: number; + data?: Record; + position?: Vec3; +}; + +/** Minimal interface for the parser registry (ghost/event class lookup). */ +export interface ParserRegistry { + getGhostParser(classId: number): { name: string } | undefined; + getEventParser(classId: number): { name: string } | undefined; +} + +/** Minimal interface for ghost tracking (class name by ghost index). */ +export interface GhostTrackerLike { + getGhost(ghostIndex: number): { className: string } | undefined; + clear?(): void; +} + +/** + * Shared engine that processes parsed packet data (events, ghosts, control + * object state) and maintains all game state. Subclasses provide the data + * source: DemoParser blocks for demo playback, or PacketParser for live. + */ +export abstract class StreamEngine implements StreamingPlayback { + // ── Parser infrastructure (set by subclass constructors) ── + protected registry!: ParserRegistry; + protected ghostTracker!: GhostTrackerLike; + + // ── Entities ── + protected entities = new Map(); + protected entityIdByGhostIndex = new Map(); + + // ── Tick / time ── + protected tickCount = 0; + + // ── Camera ── + protected camera: StreamCamera | null = null; + + // ── Chat & audio ── + protected chatMessages: ChatMessage[] = []; + protected audioEvents: PendingAudioEvent[] = []; + + // ── Net strings ── + protected netStrings = new Map(); + + // ── Target system ── + protected targetNames = new Map(); + protected targetTeams = new Map(); + protected targetRenderFlags = new Map(); + /** Deferred nameTag→targetId for TargetInfoEvents that arrived before their NetStringEvent. */ + protected pendingNameTags = new Map(); + protected sensorGroupColors = new Map< + number, + Map + >(); + protected playerSensorGroup = 0; + + // ── Control object ── + protected lastStatus = { health: 1, energy: 1 }; + protected latestControl: RuntimeControlObject = { ghostIndex: -1 }; + protected controlPlayerGhostId?: string; + protected lastControlType: "camera" | "player" = "camera"; + protected isPiloting = false; + protected lastCameraMode?: number; + protected lastOrbitGhostIndex?: number; + protected lastOrbitDistance?: number; + protected latestFov = 90; + + // ── HUD state ── + protected weaponsHud = { slots: new Map(), activeIndex: -1 }; + protected backpackHud = { packIndex: -1, active: false, text: "" }; + protected inventoryHud = { slots: new Map(), activeSlot: -1 }; + protected teamScores: TeamScore[] = []; + protected playerRoster = new Map(); + + // ── Explosions ── + protected nextExplosionId = 0; + + // ── Abstract methods ── + + /** Resolve datablock data by numeric ID. */ + abstract getDataBlockData(id: number): Record | undefined; + + /** Get TSShapeConstructor sequence entries for a shape name. */ + abstract getShapeConstructorSequences( + shapeName: string, + ): string[] | undefined; + + /** Get the current playback time in seconds. */ + protected abstract getTimeSec(): number; + + /** + * Get camera yaw/pitch for this tick. Demo accumulates from move deltas; + * live reads from server-provided rotation. + */ + protected abstract getCameraYawPitch( + data: Record | undefined, + ): { yaw: number; pitch: number }; + + /** DTS shape names for weapon effects that should be preloaded. */ + abstract getEffectShapes(): string[]; + + // ── Ghost/entity resolution (shared, uses registry + ghostTracker) ── + + protected resolveGhostClassName( + ghostIndex: number, + classId: number | undefined, + ): string | undefined { + if (typeof classId === "number") { + const fromClassId = this.registry.getGhostParser(classId)?.name; + if (fromClassId) return fromClassId; + } + const entityId = this.entityIdByGhostIndex.get(ghostIndex); + if (entityId) { + const entity = this.entities.get(entityId); + if (entity?.className) return entity.className; + } + const trackerGhost = this.ghostTracker.getGhost(ghostIndex); + if (trackerGhost?.className) return trackerGhost.className; + return undefined; + } + + protected resolveEntityIdForGhostIndex( + ghostIndex: number, + ): string | undefined { + const byMap = this.entityIdByGhostIndex.get(ghostIndex); + if (byMap) return byMap; + const trackerGhost = this.ghostTracker.getGhost(ghostIndex); + if (trackerGhost) return toEntityId(trackerGhost.className, ghostIndex); + return undefined; + } + + // ── StreamingPlayback interface ── + + abstract reset(): void; + abstract getSnapshot(): StreamSnapshot; + abstract stepToTime( + targetTimeSec: number, + maxMoveTicks?: number, + ): StreamSnapshot; + + // ── Shared reset logic ── + + protected resetSharedState(): void { + this.entities.clear(); + this.entityIdByGhostIndex.clear(); + this.tickCount = 0; + this.camera = null; + this.chatMessages = []; + this.audioEvents = []; + this.netStrings.clear(); + this.targetNames.clear(); + this.targetTeams.clear(); + this.targetRenderFlags.clear(); + this.sensorGroupColors.clear(); + this.playerSensorGroup = 0; + this.lastStatus = { health: 1, energy: 1 }; + this.latestControl = { ghostIndex: -1 }; + this.controlPlayerGhostId = undefined; + this.lastControlType = "camera"; + this.isPiloting = false; + this.lastCameraMode = undefined; + this.lastOrbitGhostIndex = undefined; + this.lastOrbitDistance = undefined; + this.latestFov = 90; + this.weaponsHud = { slots: new Map(), activeIndex: -1 }; + this.backpackHud = { packIndex: -1, active: false, text: "" }; + this.inventoryHud = { slots: new Map(), activeSlot: -1 }; + this.teamScores = []; + this.playerRoster.clear(); + this.nextExplosionId = 0; + } + + // ── Net string resolution ── + + protected resolveNetString(s: string): string { + if (s.length >= 2 && s.charCodeAt(0) === 1) { + const id = parseInt(s.slice(1), 10); + if (Number.isFinite(id)) return this.netStrings.get(id) ?? s; + } + return s; + } + + protected formatRemoteArgs(template: string, args: string[]): string { + let resolved = this.resolveNetString(template); + for (let i = 0; i < args.length; i++) { + const placeholder = `%${i + 1}`; + if (resolved.includes(placeholder)) { + resolved = resolved.replaceAll( + placeholder, + stripTaggedStringMarkup(this.resolveNetString(args[i])), + ); + } + } + resolved = resolved.replace(/%\d+/g, ""); + return stripTaggedStringMarkup(resolved); + } + + // ── Control object processing ── + + protected processControlObject(gameState: { + controlObjectGhostIndex?: number; + controlObjectData?: Record; + compressionPoint?: Vec3; + cameraFov?: number; + }): void { + const controlData = gameState.controlObjectData; + const prevControl = this.latestControl; + const nextGhostIndex = + typeof gameState.controlObjectGhostIndex === "number" + ? gameState.controlObjectGhostIndex + : prevControl.ghostIndex; + const compressionPoint = gameState.compressionPoint; + const controlPosition = isValidPosition(controlData?.position as Vec3) + ? (controlData?.position as Vec3) + : isValidPosition(compressionPoint) + ? compressionPoint + : prevControl.position; + + this.latestControl = { + ghostIndex: nextGhostIndex, + data: controlData, + position: controlPosition, + }; + + if (nextGhostIndex !== prevControl.ghostIndex) { + const entityId = this.entityIdByGhostIndex.get(nextGhostIndex); + const entity = entityId ? this.entities.get(entityId) : undefined; + if (entity?.sensorGroup != null && entity.sensorGroup > 0) { + this.playerSensorGroup = entity.sensorGroup; + } + } + + if (controlData) { + const detected = detectControlObjectType(controlData); + if (detected) this.lastControlType = detected; + + if (this.lastControlType === "player") { + this.isPiloting = !!( + controlData.pilot || controlData.controlObjectGhost != null + ); + } else { + this.isPiloting = false; + if (typeof controlData.cameraMode === "number") { + this.lastCameraMode = controlData.cameraMode; + if (controlData.cameraMode === CameraMode_OrbitObject) { + if (typeof controlData.orbitObjectGhostIndex === "number") { + this.lastOrbitGhostIndex = controlData.orbitObjectGhostIndex; + } + const minOrbit = controlData.minOrbitDist as number | undefined; + const maxOrbit = controlData.maxOrbitDist as number | undefined; + const curOrbit = controlData.curOrbitDist as number | undefined; + if ( + typeof minOrbit === "number" && + typeof maxOrbit === "number" && + Number.isFinite(minOrbit) && + Number.isFinite(maxOrbit) + ) { + this.lastOrbitDistance = Math.max(0, maxOrbit - minOrbit); + } else if ( + typeof curOrbit === "number" && + Number.isFinite(curOrbit) + ) { + this.lastOrbitDistance = Math.max(0, curOrbit); + } + } else { + this.lastOrbitGhostIndex = undefined; + this.lastOrbitDistance = undefined; + } + } + } + } + + if (gameState.cameraFov !== undefined) { + this.latestFov = gameState.cameraFov; + } + } + + // ── Event processing ── + + protected processEvent( + event: { classId: number; parsedData?: Record }, + eventName: string | undefined, + ): void { + const data = event.parsedData; + if (!data) return; + const type = data.type as string | undefined; + + // GhostAlwaysObjectEvent — scope-always objects (terrain, sky, interiors). + // These arrive as events, not ghost updates, but contain full ghost data. + // Create entities from them so scene infrastructure renders. + if (type === "GhostAlwaysObjectEvent") { + const ghostIndex = data.ghostIndex as number | undefined; + const classId = data.classId as number | undefined; + const objectData = data.objectData as Record | undefined; + if (ghostIndex != null && classId != null) { + this.processGhostUpdate({ + index: ghostIndex, + type: "create", + classId, + parsedData: objectData, + }); + } + return; + } + + if (type === "NetStringEvent" || eventName === "NetStringEvent") { + const id = data.id as number; + const value = data.value as string; + if (id != null && typeof value === "string") { + this.netStrings.set(id, value); + // Resolve any TargetInfoEvents that were waiting for this string. + const pendingTargetId = this.pendingNameTags.get(id); + if (pendingTargetId != null) { + this.pendingNameTags.delete(id); + const name = stripTaggedStringMarkup(value); + this.targetNames.set(pendingTargetId, name); + for (const entity of this.entities.values()) { + if (entity.targetId === pendingTargetId) { + entity.playerName = name; + } + } + } + } + return; + } + + if (type === "TargetInfoEvent" || eventName === "TargetInfoEvent") { + const targetId = data.targetId as number | undefined; + const nameTag = data.nameTag as number | undefined; + if (targetId != null && nameTag != null) { + const resolved = this.netStrings.get(nameTag); + if (resolved) { + this.targetNames.set(targetId, stripTaggedStringMarkup(resolved)); + } else { + // NetStringEvent hasn't arrived yet — defer resolution. + this.pendingNameTags.set(nameTag, targetId); + } + } + const sensorGroup = data.sensorGroup as number | undefined; + if (targetId != null && sensorGroup != null) { + this.targetTeams.set(targetId, sensorGroup); + } + const renderFlags = data.renderFlags as number | undefined; + if (targetId != null && renderFlags != null) { + this.targetRenderFlags.set(targetId, renderFlags); + } + // Apply all known target info to existing entities. + if (targetId != null) { + const name = this.targetNames.get(targetId); + const team = this.targetTeams.get(targetId); + const rf = this.targetRenderFlags.get(targetId); + for (const entity of this.entities.values()) { + if (entity.targetId === targetId) { + if (name) entity.playerName = name; + if (team != null) entity.sensorGroup = team; + if (rf != null) entity.targetRenderFlags = rf; + } + } + } + return; + } + + if ( + type === "SetSensorGroupEvent" || + eventName === "SetSensorGroupEvent" + ) { + const sg = data.sensorGroup as number | undefined; + if (sg != null) this.playerSensorGroup = sg; + return; + } + + if ( + type === "SensorGroupColorEvent" || + eventName === "SensorGroupColorEvent" + ) { + const sg = data.sensorGroup as number; + const colors = data.colors as + | Array<{ + index: number; + r?: number; + g?: number; + b?: number; + default?: boolean; + }> + | undefined; + if (colors) { + let map = this.sensorGroupColors.get(sg); + if (!map) { + map = new Map(); + this.sensorGroupColors.set(sg, map); + } + for (const c of colors) { + if (c.default) { + map.delete(c.index); + } else { + map.set(c.index, { r: c.r ?? 0, g: c.g ?? 0, b: c.b ?? 0 }); + } + } + } + return; + } + + if ( + type === "RemoteCommandEvent" || + eventName === "RemoteCommandEvent" + ) { + const funcName = this.resolveNetString(data.funcName as string); + const args = data.args as string[]; + const timeSec = this.getTimeSec(); + + if (funcName === "ChatMessage" && args.length >= 4) { + const rawTemplate = this.resolveNetString(args[3]); + const colorCode = detectColorCode(rawTemplate); + const sender = args[4] + ? stripTaggedStringMarkup(this.resolveNetString(args[4])) + : ""; + const rawText = this.formatRemoteArgs(args[3], args.slice(4)); + if (rawText) { + const colonIdx = rawText.indexOf(": "); + const text = colonIdx >= 0 ? rawText.slice(colonIdx + 2) : rawText; + const { text: displayText, wavPath } = extractWavTag(text); + let soundPath: string | undefined; + let soundPitch: number | undefined; + if (wavPath) { + const voice = this.resolveNetString(args[1]); + soundPath = voice ? `voice/${voice}/${wavPath}.wav` : wavPath; + const pitchStr = this.resolveNetString(args[2]); + if (pitchStr) { + const p = parseFloat(pitchStr); + if (Number.isFinite(p)) + soundPitch = Math.max(0.5, Math.min(2.0, p)); + } + } + const cc = colorCode ?? 0; + this.pushChatMessage({ + timeSec, + sender, + text: displayText, + kind: "chat", + colorCode: cc, + segments: [ + { + text: sender ? `${sender}: ${displayText}` : displayText, + colorCode: cc, + }, + ], + soundPath, + soundPitch, + }); + } + } else if (funcName === "CannedChatMessage" && args.length >= 6) { + const cannedColorCode = detectColorCode( + this.resolveNetString(args[1]), + ); + const name = stripTaggedStringMarkup(this.resolveNetString(args[2])); + const keys = stripTaggedStringMarkup(this.resolveNetString(args[4])); + const rawText = this.formatRemoteArgs(args[1], args.slice(2)); + if (rawText) { + const { wavPath } = extractWavTag(rawText); + const voiceLine = extractWavTag( + stripTaggedStringMarkup(this.resolveNetString(args[3])), + ).text; + let soundPath: string | undefined; + let soundPitch: number | undefined; + if (wavPath) { + const voice = this.resolveNetString(args[5]); + soundPath = voice ? `voice/${voice}/${wavPath}.wav` : wavPath; + if (args[6]) { + const p = parseFloat(this.resolveNetString(args[6])); + if (Number.isFinite(p)) + soundPitch = Math.max(0.5, Math.min(2.0, p)); + } + } + const cc = cannedColorCode ?? 0; + const cannedSegments: ChatSegment[] = []; + if (keys) cannedSegments.push({ text: `[${keys}] `, colorCode: 0 }); + cannedSegments.push({ + text: name ? `${name}: ${voiceLine}` : voiceLine, + colorCode: cc, + }); + this.pushChatMessage({ + timeSec, + sender: name, + text: voiceLine, + kind: "chat", + colorCode: cc, + segments: cannedSegments, + soundPath, + soundPitch, + }); + } + } else if (funcName === "ServerMessage" && args.length >= 2) { + this.handleServerMessage(args); + const rawTemplate = this.resolveNetString(args[1]); + const serverColorCode = detectColorCode(rawTemplate); + const rawText = this.formatRemoteArgs(args[1], args.slice(2)); + if (rawText) { + const { text, wavPath } = extractWavTag(rawText); + const scc = serverColorCode ?? 0; + this.pushChatMessage({ + timeSec, + sender: "", + text, + kind: "server", + colorCode: scc, + segments: [{ text, colorCode: scc }], + soundPath: wavPath ?? undefined, + }); + } + } else { + this.handleHudRemoteCommand(funcName, args); + } + return; + } + + if ( + type === "Sim3DAudioEvent" || + type === "Sim2DAudioEvent" || + eventName === "Sim3DAudioEvent" || + eventName === "Sim2DAudioEvent" + ) { + const profileId = data.profileId as number; + if (typeof profileId === "number") { + const timeSec = this.getTimeSec(); + const is3D = + type === "Sim3DAudioEvent" || eventName === "Sim3DAudioEvent"; + const position = is3D + ? (data.position as Vec3 | undefined) + : undefined; + this.audioEvents.push({ profileId, position, timeSec }); + if (this.audioEvents.length > 100) { + this.audioEvents.splice(0, this.audioEvents.length - 100); + } + } + } + } + + // ── Ghost processing ── + + protected processGhostUpdate(ghost: { + index: number; + type: "create" | "update" | "delete"; + classId?: number; + parsedData?: Record; + }): void { + const ghostIndex = ghost.index; + const prevEntityId = this.entityIdByGhostIndex.get(ghostIndex); + + // Spawn explosion for projectiles being removed + if (prevEntityId) { + const prevEntity = this.entities.get(prevEntityId); + if ( + prevEntity && + prevEntity.type === "Projectile" && + !prevEntity.hasExploded && + prevEntity.explosionDataBlockId != null && + prevEntity.position && + (ghost.type === "delete" || ghost.type === "create") + ) { + this.spawnExplosion(prevEntity, [...prevEntity.position] as [ + number, + number, + number, + ]); + } + } + + if (ghost.type === "delete") { + if (prevEntityId) { + this.removeSoundSlotEntities(prevEntityId); + this.entities.delete(prevEntityId); + this.entityIdByGhostIndex.delete(ghostIndex); + } + return; + } + + const className = this.resolveGhostClassName(ghostIndex, ghost.classId); + if (!className) { + if (ghost.type === "create") { + throw new Error( + `No ghost parser for classId ${ghost.classId} (ghost index ${ghostIndex})`, + ); + } + return; + } + + const entityId = toEntityId(className, ghostIndex); + if (prevEntityId && prevEntityId !== entityId) { + this.removeSoundSlotEntities(prevEntityId); + this.entities.delete(prevEntityId); + } + + let entity: MutableEntity; + const existingEntity = this.entities.get(entityId); + if (existingEntity && ghost.type === "create") { + this.removeSoundSlotEntities(entityId); + existingEntity.spawnTick = this.tickCount; + this.resetEntity(existingEntity); + entity = existingEntity; + } else if (existingEntity) { + entity = existingEntity; + } else { + entity = { + id: entityId, + ghostIndex, + className, + spawnTick: this.tickCount, + type: toEntityType(className), + rotation: [0, 0, 0, 1], + }; + this.entities.set(entityId, entity); + } + + entity.ghostIndex = ghostIndex; + entity.className = className; + entity.type = toEntityType(className); + this.entityIdByGhostIndex.set(ghostIndex, entityId); + this.applyGhostData(entity, ghost.parsedData); + // Only set sceneData on ghost creates — updates contain sparse fields + // that would overwrite the initial data with defaults (e.g. empty + // interiorFile, identity transform). + if (ghost.type === "create" && ghost.parsedData) { + const sceneObj = ghostToSceneObject( + className, + ghostIndex, + ghost.parsedData as Record, + ); + if (sceneObj) entity.sceneData = sceneObj; + } + } + + protected resetEntity(entity: MutableEntity): void { + entity.rotation = [0, 0, 0, 1]; + entity.hasExploded = undefined; + entity.explosionShape = undefined; + entity.explosionLifetimeTicks = undefined; + entity.faceViewer = undefined; + entity.simulatedVelocity = undefined; + entity.projectilePhysics = undefined; + entity.gravityMod = undefined; + entity.direction = undefined; + entity.velocity = undefined; + entity.position = undefined; + entity.dataBlock = undefined; + entity.dataBlockId = undefined; + entity.shapeHint = undefined; + entity.visual = undefined; + entity.targetId = undefined; + entity.targetRenderFlags = undefined; + entity.carryingFlag = undefined; + entity.sensorGroup = undefined; + entity.playerName = undefined; + entity.weaponShape = undefined; + entity.weaponImageState = undefined; + entity.weaponImageStates = undefined; + entity.weaponImageStatesDbId = undefined; + entity.itemPhysics = undefined; + entity.threads = undefined; + entity.headPitch = undefined; + entity.headYaw = undefined; + entity.health = undefined; + entity.energy = undefined; + entity.maxEnergy = undefined; + entity.damageState = undefined; + entity.actionAnim = undefined; + entity.actionAtEnd = undefined; + entity.explosionDataBlockId = undefined; + entity.maintainEmitterId = undefined; + } + + // ── Apply ghost data ── + + protected applyGhostData( + entity: MutableEntity, + rawData: Record | undefined, + ): void { + if (!rawData) return; + const data = rawData; + + const dataBlockId = data.dataBlockId as number | undefined; + if (dataBlockId != null) { + entity.dataBlockId = dataBlockId; + const blockData = this.getDataBlockData(dataBlockId); + const shapeName = resolveShapeName(entity.className, blockData); + entity.visual = + resolveTracerVisual(entity.className, blockData) ?? + resolveSpriteVisual(entity.className, blockData); + if (typeof shapeName === "string") { + entity.shapeHint = shapeName; + entity.dataBlock = shapeName; + } + if ( + entity.type === "Player" && + typeof blockData?.maxEnergy === "number" + ) { + entity.maxEnergy = blockData.maxEnergy; + } + + // Classify projectile physics + if (entity.type === "Projectile") { + if (linearProjectileClassNames.has(entity.className)) { + entity.projectilePhysics = "linear"; + } else if (ballisticProjectileClassNames.has(entity.className)) { + entity.projectilePhysics = "ballistic"; + entity.gravityMod = + getNumberField(blockData, ["gravityMod"]) ?? 1.0; + } else if (seekerProjectileClassNames.has(entity.className)) { + entity.projectilePhysics = "seeker"; + } + } + + // Resolve explosion shape + if (entity.type === "Projectile" && entity.explosionDataBlockId == null) { + const info = this.resolveExplosionInfo(dataBlockId); + if (info) { + entity.explosionShape = info.shape; + entity.faceViewer = info.faceViewer; + entity.explosionLifetimeTicks = info.lifetimeTicks; + entity.explosionDataBlockId = info.explosionDataBlockId; + } + } + + // Trail emitter + if (entity.type === "Projectile" && entity.maintainEmitterId == null) { + const trailEmitterId = blockData?.baseEmitter as number | null; + if (typeof trailEmitterId === "number" && trailEmitterId > 0) { + entity.maintainEmitterId = trailEmitterId; + } + } + } + + // Weapon images (Player) + if (entity.type === "Player") { + const images = data.images as + | Array<{ + index?: number; + dataBlockId?: number; + triggerDown?: boolean; + ammo?: boolean; + loaded?: boolean; + target?: boolean; + wet?: boolean; + fireCount?: number; + }> + | undefined; + if (Array.isArray(images) && images.length > 0) { + const weaponImage = images.find((img) => img.index === 0); + if (weaponImage?.dataBlockId && weaponImage.dataBlockId > 0) { + const blockData = this.getDataBlockData(weaponImage.dataBlockId); + const weaponShape = resolveShapeName("ShapeBaseImageData", blockData); + if (weaponShape) { + const mountPoint = blockData?.mountPoint as number | undefined; + if ( + (mountPoint == null || mountPoint <= 0) && + !/pack_/i.test(weaponShape) + ) { + entity.weaponShape = weaponShape; + } + } + + const prev = entity.weaponImageState; + entity.weaponImageState = { + dataBlockId: weaponImage.dataBlockId, + triggerDown: weaponImage.triggerDown ?? prev?.triggerDown ?? false, + ammo: weaponImage.ammo ?? prev?.ammo ?? true, + loaded: weaponImage.loaded ?? prev?.loaded ?? true, + target: weaponImage.target ?? prev?.target ?? false, + wet: weaponImage.wet ?? prev?.wet ?? false, + fireCount: weaponImage.fireCount ?? prev?.fireCount ?? 0, + }; + + if ( + blockData && + entity.weaponImageStatesDbId !== weaponImage.dataBlockId + ) { + entity.weaponImageStates = parseWeaponImageStates(blockData); + entity.weaponImageStatesDbId = weaponImage.dataBlockId; + } + } else if (weaponImage && !weaponImage.dataBlockId) { + entity.weaponShape = undefined; + entity.weaponImageState = undefined; + entity.weaponImageStates = undefined; + } + + // Flag tracking + const flagImage = images.find((img) => img.index === 3); + if (flagImage) { + const hasFlag = !!flagImage.dataBlockId && flagImage.dataBlockId > 0; + entity.carryingFlag = hasFlag; + if (entity.targetId != null && entity.targetId >= 0) { + const prev = this.targetRenderFlags.get(entity.targetId) ?? 0; + const updated = hasFlag ? prev | 0x2 : prev & ~0x2; + if (updated !== prev) { + this.targetRenderFlags.set(entity.targetId, updated); + entity.targetRenderFlags = updated; + } + } + } + } + } + + // Position + const position = isValidPosition(data.position as Vec3) + ? (data.position as Vec3) + : isValidPosition(data.initialPosition as Vec3) + ? (data.initialPosition as Vec3) + : isValidPosition(data.explodePosition as Vec3) + ? (data.explodePosition as Vec3) + : isValidPosition(data.endPoint as Vec3) + ? (data.endPoint as Vec3) + : isValidPosition( + (data.transform as { position?: Vec3 } | undefined)?.position, + ) + ? ((data.transform as { position: Vec3 }).position as Vec3) + : undefined; + if (position) { + entity.position = [position.x, position.y, position.z]; + // Sync any sound-slot child entities with the new position. + this.updateSoundSlotPositions(entity); + } + + // Direction + const direction = isVec3Like(data.direction) ? data.direction : undefined; + if (direction) { + entity.direction = [direction.x, direction.y, direction.z]; + } + + // Rotation + if (entity.type === "Player" && typeof data.rotationZ === "number") { + entity.rotation = playerYawToQuaternion(data.rotationZ); + } + + // Head pitch/yaw + if (entity.type === "Player") { + if (typeof data.headX === "number") entity.headPitch = data.headX; + if (typeof data.headZ === "number") entity.headYaw = data.headZ; + } + + if (isQuatLike(data.angPosition)) { + const converted = torqueQuatToThreeJS(data.angPosition); + if (converted) entity.rotation = converted; + } else if ( + isQuatLike( + (data.transform as { rotation?: unknown } | undefined)?.rotation, + ) + ) { + const converted = torqueQuatToThreeJS( + (data.transform as { + rotation: { x: number; y: number; z: number; w: number }; + }).rotation, + ); + if (converted) entity.rotation = converted; + } else if ( + entity.type === "Item" && + typeof (data.rotation as { angle?: unknown } | undefined)?.angle === + "number" + ) { + const rot = data.rotation as { angle: number; zSign?: number }; + entity.rotation = playerYawToQuaternion((rot.zSign ?? 1) * rot.angle); + } else if (entity.type === "Projectile") { + const vec = + (data.velocity as Vec3 | undefined) ?? + (data.direction as Vec3 | undefined) ?? + (isValidPosition(data.initialPosition as Vec3) && + isValidPosition(data.endPos as Vec3) + ? { + x: (data.endPos as Vec3).x - (data.initialPosition as Vec3).x, + y: (data.endPos as Vec3).y - (data.initialPosition as Vec3).y, + z: (data.endPos as Vec3).z - (data.initialPosition as Vec3).z, + } + : undefined); + if (isVec3Like(vec) && (vec.x !== 0 || vec.y !== 0)) { + entity.rotation = playerYawToQuaternion(Math.atan2(vec.x, vec.y)); + } + } + + // Velocity + if (isVec3Like(data.velocity)) { + entity.velocity = [data.velocity.x, data.velocity.y, data.velocity.z]; + if (!entity.direction) { + entity.direction = [data.velocity.x, data.velocity.y, data.velocity.z]; + } + } + + // Item physics: when the server sends a position update with + // atRest=false and a velocity, start client-side physics simulation. + if (entity.type === "Item") { + const atRest = data.atRest as boolean | undefined; + if (atRest === false && isVec3Like(data.velocity)) { + const blockData = + entity.dataBlockId != null + ? this.getDataBlockData(entity.dataBlockId) + : undefined; + entity.itemPhysics = { + velocity: [data.velocity.x, data.velocity.y, data.velocity.z], + atRest: false, + elasticity: getNumberField(blockData, ["elasticity"]) ?? 0.2, + friction: getNumberField(blockData, ["friction"]) ?? 0.6, + gravityMod: getNumberField(blockData, ["gravityMod"]) ?? 1.0, + }; + } else if (atRest === true) { + entity.itemPhysics = undefined; + } + } + + // Projectile simulation velocity + if (entity.projectilePhysics) { + if (entity.projectilePhysics === "linear") { + const blockData = + entity.dataBlockId != null + ? this.getDataBlockData(entity.dataBlockId) + : undefined; + const dryVelocity = + getNumberField(blockData, [ + "dryVelocity", + "muzzleVelocity", + "bulletVelocity", + ]) ?? 80; + const dir = entity.direction ?? [0, 1, 0]; + let vx = dir[0] * dryVelocity; + let vy = dir[1] * dryVelocity; + let vz = dir[2] * dryVelocity; + const excessVel = data.excessVel as number | undefined; + const excessDir = data.excessDir as Vec3 | undefined; + if ( + typeof excessVel === "number" && + excessVel > 0 && + isVec3Like(excessDir) + ) { + vx += excessDir.x * excessVel; + vy += excessDir.y * excessVel; + vz += excessDir.z * excessVel; + } + entity.simulatedVelocity = [vx, vy, vz]; + } else if (isVec3Like(data.velocity)) { + entity.simulatedVelocity = [ + data.velocity.x, + data.velocity.y, + data.velocity.z, + ]; + } + + // Fast-forward by currTick + const currTick = data.currTick as number | undefined; + if ( + typeof currTick === "number" && + currTick > 0 && + entity.simulatedVelocity && + entity.position + ) { + const dt = (TICK_DURATION_MS / 1000) * currTick; + const v = entity.simulatedVelocity; + entity.position[0] += v[0] * dt; + entity.position[1] += v[1] * dt; + entity.position[2] += v[2] * dt; + if (entity.projectilePhysics === "ballistic") { + const g = -9.81 * (entity.gravityMod ?? 1); + entity.position[2] += 0.5 * g * dt * dt; + v[2] += g * dt; + } + } + } + + // Explosion detection + const explodePos = isValidPosition(data.explodePosition as Vec3) + ? (data.explodePosition as Vec3) + : isValidPosition(data.explodePoint as Vec3) + ? (data.explodePoint as Vec3) + : undefined; + if ( + entity.type === "Projectile" && + !entity.hasExploded && + explodePos && + entity.explosionDataBlockId != null + ) { + this.spawnExplosion(entity, [explodePos.x, explodePos.y, explodePos.z]); + } + + // Damage + if (typeof data.damageLevel === "number") { + entity.health = clamp(1 - data.damageLevel, 0, 1); + } + if (typeof data.damageState === "number") { + entity.damageState = data.damageState; + } + if (typeof data.action === "number") { + entity.actionAnim = data.action; + entity.actionAtEnd = !!data.actionAtEnd; + } + + // Threads + if (Array.isArray(data.threads)) { + const incoming = data.threads as ThreadState[]; + if (entity.threads) { + const merged = [...entity.threads]; + for (const t of incoming) { + const existingIdx = merged.findIndex((m) => m.index === t.index); + if (existingIdx >= 0) merged[existingIdx] = t; + else merged.push(t); + } + entity.threads = merged; + } else { + entity.threads = incoming; + } + } + + if (typeof data.energy === "number") { + entity.energy = clamp(data.energy, 0, 1); + } + + // Target system + if (typeof data.targetId === "number") { + entity.targetId = data.targetId; + const playerName = this.targetNames.get(data.targetId); + if (playerName) entity.playerName = playerName; + const team = this.targetTeams.get(data.targetId); + if (team != null) { + entity.sensorGroup = team; + if ( + entity.ghostIndex === this.latestControl.ghostIndex && + this.lastControlType === "player" + ) { + this.playerSensorGroup = team; + } + } + const renderFlags = this.targetRenderFlags.get(data.targetId); + if (renderFlags != null) entity.targetRenderFlags = renderFlags; + } + + // Ghost-level audio — spawn/remove synthetic AudioEmitter children + const sounds = data.sounds as + | Array<{ index: number; playing: boolean; profileId?: number }> + | undefined; + if (Array.isArray(sounds)) { + this.syncSoundSlotEntities(entity, sounds); + } + + // WayPoint ghost fields + if (entity.className === "WayPoint") { + if (typeof data.name === "string") entity.label = data.name; + } + + // AudioEmitter ghost fields + if (entity.className === "AudioEmitter") { + if (typeof data.filename === "string") + entity.audioFileName = data.filename; + if (typeof data.volume === "number") entity.audioVolume = data.volume; + if (typeof data.is3D === "boolean") entity.audioIs3D = data.is3D; + if (typeof data.isLooping === "boolean") + entity.audioIsLooping = data.isLooping; + if (typeof data.minDistance === "number") + entity.audioMinDistance = data.minDistance; + if (typeof data.maxDistance === "number") + entity.audioMaxDistance = data.maxDistance; + if (typeof data.minLoopGap === "number") + entity.audioMinLoopGap = data.minLoopGap; + if (typeof data.maxLoopGap === "number") + entity.audioMaxLoopGap = data.maxLoopGap; + } + } + + // ── Sound slot entities ── + + /** + * Sync synthetic AudioEmitter entities for a parent ghost's sound slots. + * Each active sound slot spawns a child entity; inactive slots remove theirs. + */ + protected syncSoundSlotEntities( + parent: MutableEntity, + sounds: Array<{ index: number; playing: boolean; profileId?: number }>, + ): void { + for (const s of sounds) { + const childId = `${parent.id}:sound:${s.index}`; + + if (s.playing && typeof s.profileId === "number") { + // Resolve AudioProfile → AudioDescription + const profileBlock = this.getDataBlockData(s.profileId); + const rawFilename = profileBlock?.filename as string | undefined; + if (!rawFilename) continue; + const filename = rawFilename.endsWith(".wav") + ? rawFilename + : `${rawFilename}.wav`; + + const descId = profileBlock.description as number | undefined; + const descBlock = + descId != null ? this.getDataBlockData(descId) : undefined; + + const existing = this.entities.get(childId); + if (existing) { + // Update position to track parent + existing.position = parent.position; + } else { + // Create synthetic AudioEmitter entity + this.entities.set(childId, { + id: childId, + ghostIndex: parent.ghostIndex, + className: "AudioEmitter", + type: "AudioEmitter", + spawnTick: this.tickCount, + position: parent.position, + rotation: [0, 0, 0, 1], + audioFileName: filename, + audioVolume: (descBlock?.volume as number) ?? 1, + audioIs3D: (descBlock?.is3D as boolean) ?? true, + audioIsLooping: (descBlock?.isLooping as boolean) ?? false, + audioMinDistance: + (descBlock?.referenceDistance as number) ?? 20, + audioMaxDistance: (descBlock?.maxDistance as number) ?? 100, + audioMinLoopGap: (descBlock?.minLoopGap as number) ?? 0, + audioMaxLoopGap: (descBlock?.maxLoopGap as number) ?? 0, + }); + } + } else { + // Sound stopped — remove synthetic entity + this.entities.delete(childId); + } + } + } + + /** Update positions of sound-slot children to track their parent. */ + protected updateSoundSlotPositions(parent: MutableEntity): void { + for (let i = 0; i < 4; i++) { + const child = this.entities.get(`${parent.id}:sound:${i}`); + if (child) child.position = parent.position; + } + } + + /** Remove any synthetic sound-slot entities belonging to a parent entity. */ + protected removeSoundSlotEntities(parentId: string): void { + for (let i = 0; i < 4; i++) { + this.entities.delete(`${parentId}:sound:${i}`); + } + } + + // ── Explosion spawning ── + + protected resolveExplosionInfo(projDataBlockId: number): + | { + shape?: string; + faceViewer: boolean; + lifetimeTicks: number; + explosionDataBlockId: number; + } + | undefined { + const projBlock = this.getDataBlockData(projDataBlockId); + if (!projBlock) return undefined; + const explosionId = projBlock.explosion as number | undefined; + if (explosionId == null) return undefined; + const expBlock = this.getDataBlockData(explosionId); + if (!expBlock) return undefined; + const shape = (expBlock.dtsFileName as string | undefined) || undefined; + const lifetimeTicks = (expBlock.lifetimeMS as number | undefined) ?? 31; + return { + shape, + faceViewer: expBlock.faceViewer !== false && expBlock.faceViewer !== 0, + lifetimeTicks, + explosionDataBlockId: explosionId, + }; + } + + protected spawnExplosion( + projectile: MutableEntity, + position: [number, number, number], + ): void { + projectile.hasExploded = true; + const lifetimeTicks = projectile.explosionLifetimeTicks ?? 31; + + const fxId = `fx_${this.nextExplosionId++}`; + const fxEntity: MutableEntity = { + id: fxId, + ghostIndex: -1, + className: "Explosion", + spawnTick: this.tickCount, + type: "Explosion", + dataBlock: projectile.explosionShape, + explosionDataBlockId: projectile.explosionDataBlockId, + position, + rotation: [0, 0, 0, 1], + isExplosion: true, + faceViewer: projectile.faceViewer !== false, + expiryTick: this.tickCount + lifetimeTicks, + }; + this.entities.set(fxId, fxEntity); + + // Spawn sub-explosion entities + if (projectile.explosionDataBlockId != null) { + const expBlock = this.getDataBlockData(projectile.explosionDataBlockId); + const subExplosions = expBlock?.subExplosions as + | (number | null)[] + | undefined; + if (Array.isArray(subExplosions)) { + for (const subId of subExplosions) { + if (subId == null) continue; + const subBlock = this.getDataBlockData(subId); + if (!subBlock) continue; + const subShape = + (subBlock.dtsFileName as string | undefined) || undefined; + if (!subShape) continue; + const subLifetimeTicks = + (subBlock.lifetimeMS as number | undefined) ?? 31; + const offset = (subBlock.offset as number | undefined) ?? 0; + const angle = Math.random() * Math.PI * 2; + const subPos: [number, number, number] = [ + position[0] + Math.cos(angle) * offset, + position[1] + Math.sin(angle) * offset, + position[2], + ]; + const subFxId = `fx_${this.nextExplosionId++}`; + const subFxEntity: MutableEntity = { + id: subFxId, + ghostIndex: -1, + className: "Explosion", + spawnTick: this.tickCount, + type: "Explosion", + dataBlock: subShape, + explosionDataBlockId: subId, + position: subPos, + rotation: [0, 0, 0, 1], + isExplosion: true, + faceViewer: + subBlock.faceViewer !== false && subBlock.faceViewer !== 0, + expiryTick: this.tickCount + subLifetimeTicks, + }; + this.entities.set(subFxId, subFxEntity); + } + } + } + + // Stop the projectile + projectile.position = undefined; + projectile.simulatedVelocity = undefined; + } + + // ── Per-tick physics simulation ── + + /** Advance projectile positions by one tick using their simulated velocity. */ + protected advanceProjectiles(): void { + const dt = TICK_DURATION_MS / 1000; + for (const entity of this.entities.values()) { + if (!entity.simulatedVelocity || !entity.position) continue; + const v = entity.simulatedVelocity; + const p = entity.position; + + if (entity.projectilePhysics === "ballistic") { + v[2] += -9.81 * (entity.gravityMod ?? 1) * dt; + } + + p[0] += v[0] * dt; + p[1] += v[1] * dt; + p[2] += v[2] * dt; + + if (v[0] !== 0 || v[1] !== 0) { + entity.rotation = playerYawToQuaternion(Math.atan2(v[0], v[1])); + } + } + } + + /** Advance dropped item physics (gravity, terrain collision, friction). */ + protected advanceItems(): void { + const dt = TICK_DURATION_MS / 1000; + for (const entity of this.entities.values()) { + const phys = entity.itemPhysics; + if (!phys || phys.atRest || !entity.position) continue; + const v = phys.velocity; + const p = entity.position; + + // Gravity: Tribes 2 uses -20 m/s² (Torque Z-up). + v[2] += -20 * phys.gravityMod * dt; + + p[0] += v[0] * dt; + p[1] += v[1] * dt; + p[2] += v[2] * dt; + + // Terrain collision (flat normal approximation: [0, 0, 1]) + const groundZ = getTerrainHeightAt(p[0], p[1]); + if (groundZ != null && p[2] < groundZ) { + p[2] = groundZ; + const bd = Math.abs(v[2]); // normal impact speed + v[2] = bd * phys.elasticity; // reflect with restitution + // Friction: reduce horizontal speed proportional to impact + const friction = bd * phys.friction; + const hSpeed = Math.sqrt(v[0] * v[0] + v[1] * v[1]); + if (hSpeed > 0) { + const scale = Math.max(0, 1 - friction / hSpeed); + v[0] *= scale; + v[1] *= scale; + } + // At-rest check + const speed = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + if (speed < 0.15) { + v[0] = v[1] = v[2] = 0; + phys.atRest = true; + } + } + } + } + + protected removeExpiredExplosions(): void { + for (const [id, entity] of this.entities) { + if ( + entity.isExplosion && + entity.expiryTick != null && + this.tickCount >= entity.expiryTick + ) { + this.entities.delete(id); + } + } + } + + // ── Camera and HUD ── + + protected updateCameraAndHud(): void { + const control = this.latestControl; + const timeSec = this.getTimeSec(); + const data = control.data; + const controlType = this.lastControlType; + + this.removeExpiredExplosions(); + + if (control.position) { + const { yaw, pitch } = this.getCameraYawPitch(data); + + this.camera = { + time: timeSec, + position: [control.position.x, control.position.y, control.position.z], + rotation: yawPitchToQuaternion( + yaw, + clamp(pitch, -MAX_PITCH, MAX_PITCH), + ), + fov: this.latestFov, + mode: "observer", + yaw, + pitch, + }; + + if (controlType === "camera") { + const cameraMode = + typeof data?.cameraMode === "number" + ? data.cameraMode + : this.lastCameraMode; + if (cameraMode === CameraMode_OrbitObject) { + this.camera.mode = "third-person"; + if (typeof this.lastOrbitDistance === "number") { + this.camera.orbitDistance = this.lastOrbitDistance; + } + const orbitIndex = + typeof data?.orbitObjectGhostIndex === "number" + ? (data.orbitObjectGhostIndex as number) + : this.lastOrbitGhostIndex; + if (typeof orbitIndex === "number" && orbitIndex >= 0) { + this.camera.orbitTargetId = + this.resolveEntityIdForGhostIndex(orbitIndex); + } + } else { + this.camera.mode = "observer"; + } + } else { + this.camera.mode = "first-person"; + if (control.ghostIndex >= 0) { + this.controlPlayerGhostId = + this.resolveEntityIdForGhostIndex(control.ghostIndex); + } + if (this.controlPlayerGhostId) { + this.camera.controlEntityId = this.controlPlayerGhostId; + } + } + + // Sync control player position + if ( + controlType === "player" && + !this.isPiloting && + this.controlPlayerGhostId && + control.position + ) { + const ghostEntity = this.entities.get(this.controlPlayerGhostId); + if (ghostEntity) { + ghostEntity.position = [ + control.position.x, + control.position.y, + control.position.z, + ]; + ghostEntity.rotation = playerYawToQuaternion(yaw); + ghostEntity.headPitch = this.getControlPlayerHeadPitch(pitch); + } + } + } else if (this.camera) { + this.camera = { + ...this.camera, + time: timeSec, + fov: this.latestFov, + }; + } + + // Health/energy status + const status = { health: 1, energy: 1 }; + if (this.camera?.mode === "first-person") { + const controlGhostId = this.controlPlayerGhostId; + const ghostEntity = controlGhostId + ? this.entities.get(controlGhostId) + : undefined; + status.health = ghostEntity?.health ?? 1; + const coEnergyLevel = data?.energyLevel; + if (typeof coEnergyLevel === "number") { + const maxEnergy = ghostEntity?.maxEnergy ?? 60; + if (maxEnergy > 0) + status.energy = clamp(coEnergyLevel / maxEnergy, 0, 1); + } else { + status.energy = ghostEntity?.energy ?? 1; + } + } else if ( + this.camera?.mode === "third-person" && + this.camera.orbitTargetId + ) { + const orbitEntity = this.entities.get(this.camera.orbitTargetId); + status.health = orbitEntity?.health ?? 1; + status.energy = orbitEntity?.energy ?? 1; + } + this.lastStatus = status; + } + + /** Compute headPitch for the control player ghost. Subclasses can override. */ + protected getControlPlayerHeadPitch(pitch: number): number { + return clamp(pitch / MAX_PITCH, -1, 1); + } + + protected getAbsoluteRotation( + data: Record | undefined, + ): { yaw: number; pitch: number } | null { + if (!data) return null; + if (typeof data.rotationZ === "number" && typeof data.headX === "number") { + return { yaw: data.rotationZ, pitch: data.headX }; + } + if (typeof data.rotZ === "number" && typeof data.rotX === "number") { + return { yaw: data.rotZ, pitch: data.rotX }; + } + return null; + } + + // ── IFF color ── + + protected resolveIffColor( + targetSensorGroup: number, + ): { r: number; g: number; b: number } | undefined { + if (this.playerSensorGroup === 0) return undefined; + const colorMap = this.sensorGroupColors.get(this.playerSensorGroup); + if (colorMap) { + const color = colorMap.get(targetSensorGroup); + if (color) return color; + } + if (targetSensorGroup === this.playerSensorGroup) return IFF_GREEN; + if (targetSensorGroup !== 0) return IFF_RED; + return undefined; + } + + // ── Chat + HUD ── + + protected pushChatMessage(msg: ChatMessage): void { + this.chatMessages.push(msg); + if (this.chatMessages.length > 200) { + this.chatMessages.splice(0, this.chatMessages.length - 200); + } + } + + protected handleServerMessage(args: string[]): void { + if (args.length < 2) return; + const msgType = this.resolveNetString(args[0]); + + if (msgType === "MsgTeamScoreIs" && args.length >= 4) { + const teamId = parseInt(this.resolveNetString(args[2]), 10); + const newScore = parseInt(this.resolveNetString(args[3]), 10); + if (!isNaN(teamId) && !isNaN(newScore)) { + const entry = this.teamScores.find((t) => t.teamId === teamId); + if (entry) { + entry.score = newScore; + this.onTeamScoresChanged(); + } + } + } else if (msgType === "MsgCTFAddTeam" && args.length >= 6) { + const teamIdx = parseInt(this.resolveNetString(args[2]), 10); + const teamName = stripTaggedStringMarkup(this.resolveNetString(args[3])); + const score = parseInt(this.resolveNetString(args[5]), 10); + if (!isNaN(teamIdx)) { + const teamId = teamIdx + 1; + const existing = this.teamScores.find((t) => t.teamId === teamId); + if (existing) { + existing.name = teamName; + existing.score = isNaN(score) ? existing.score : score; + } else { + this.teamScores.push({ + teamId, + name: teamName, + score: isNaN(score) ? 0 : score, + playerCount: 0, + }); + } + this.onTeamScoresChanged(); + } + } else if (msgType === "MsgClientJoin" && args.length >= 4) { + const clientId = parseInt(this.resolveNetString(args[2]), 10); + const name = stripTaggedStringMarkup(this.resolveNetString(args[3])); + if (!isNaN(clientId)) { + const existing = this.playerRoster.get(clientId); + this.playerRoster.set(clientId, { + name, + teamId: existing?.teamId ?? 0, + }); + this.onRosterChanged(); + } + } else if (msgType === "MsgClientDrop" && args.length >= 3) { + const clientId = parseInt(this.resolveNetString(args[2]), 10); + if (!isNaN(clientId)) { + this.playerRoster.delete(clientId); + this.onRosterChanged(); + } + } else if (msgType === "MsgClientJoinTeam" && args.length >= 4) { + const clientId = parseInt(this.resolveNetString(args[2]), 10); + const teamId = parseInt(this.resolveNetString(args[3]), 10); + if (!isNaN(clientId) && !isNaN(teamId)) { + const existing = this.playerRoster.get(clientId); + if (existing) { + existing.teamId = teamId; + } else { + this.playerRoster.set(clientId, { name: "", teamId }); + } + this.onRosterChanged(); + } + } + } + + /** Hook for subclasses to react to team score changes (e.g. generation counters). */ + protected onTeamScoresChanged(): void {} + + /** Hook for subclasses to react to roster changes (e.g. generation counters). */ + protected onRosterChanged(): void {} + + protected handleHudRemoteCommand(funcName: string, args: string[]): void { + if (funcName === "setWeaponsHudItem" && args.length >= 3) { + const slot = parseInt(args[0], 10); + const ammo = parseInt(args[1], 10); + const add = args[2] === "1" || args[2] === "true"; + if (!isNaN(slot)) { + if (add) this.weaponsHud.slots.set(slot, isNaN(ammo) ? -1 : ammo); + else this.weaponsHud.slots.delete(slot); + this.onWeaponsHudChanged(); + } + } else if (funcName === "setWeaponsHudAmmo" && args.length >= 2) { + const slot = parseInt(args[0], 10); + const ammo = parseInt(args[1], 10); + if (!isNaN(slot)) { + this.weaponsHud.slots.set(slot, isNaN(ammo) ? -1 : ammo); + this.onWeaponsHudChanged(); + } + } else if (funcName === "setWeaponsHudActive" && args.length >= 1) { + const slot = parseInt(args[0], 10); + this.weaponsHud.activeIndex = isNaN(slot) ? -1 : slot; + if (!isNaN(slot) && slot >= 0 && !this.weaponsHud.slots.has(slot)) { + this.weaponsHud.slots.set(slot, -1); + } + this.onWeaponsHudChanged(); + } else if (funcName === "setWeaponsHudClearAll") { + this.weaponsHud.slots.clear(); + this.weaponsHud.activeIndex = -1; + this.onWeaponsHudChanged(); + } else if (funcName === "setBackpackHudItem" && args.length >= 2) { + const num = parseInt(args[0], 10); + const add = args[1] === "1" || args[1] === "true"; + if (add && !isNaN(num)) { + this.backpackHud.packIndex = num; + this.backpackHud.active = false; + this.backpackHud.text = ""; + } else { + this.backpackHud.packIndex = -1; + this.backpackHud.active = false; + this.backpackHud.text = ""; + } + } else if (funcName === "setSatchelArmed") { + this.backpackHud.active = true; + } else if ( + funcName === "setCloakIconOn" || + funcName === "setRepairPackIconOn" || + funcName === "setShieldIconOn" || + funcName === "setSenJamIconOn" + ) { + this.backpackHud.active = true; + } else if ( + funcName === "setCloakIconOff" || + funcName === "setRepairPackIconOff" || + funcName === "setShieldIconOff" || + funcName === "setSenJamIconOff" + ) { + this.backpackHud.active = false; + } else if (funcName === "updatePackText" && args.length >= 1) { + this.backpackHud.text = args[0] ?? ""; + } else if (funcName === "setInventoryHudItem" && args.length >= 3) { + const slot = parseInt(args[0], 10); + const amount = parseInt(args[1], 10); + const add = args[2] === "1" || args[2] === "true"; + if (!isNaN(slot)) { + if (add && !isNaN(amount)) this.inventoryHud.slots.set(slot, amount); + else this.inventoryHud.slots.delete(slot); + this.onInventoryHudChanged(); + } + } else if (funcName === "setInventoryHudAmount" && args.length >= 2) { + const slot = parseInt(args[0], 10); + const amount = parseInt(args[1], 10); + if (!isNaN(slot) && !isNaN(amount)) { + this.inventoryHud.slots.set(slot, amount); + this.onInventoryHudChanged(); + } + } else if (funcName === "setInventoryHudClearAll") { + this.inventoryHud.slots.clear(); + this.inventoryHud.activeSlot = -1; + this.onInventoryHudChanged(); + } + } + + /** Hook for subclasses to react to weapons HUD changes (e.g. generation counters). */ + protected onWeaponsHudChanged(): void {} + + /** Hook for subclasses to react to inventory HUD changes (e.g. generation counters). */ + protected onInventoryHudChanged(): void {} + + // ── Snapshot building ── + + /** Build entity list for snapshot, optionally filtering with a predicate. */ + protected buildEntityList( + shouldInclude?: (entity: MutableEntity) => boolean, + ): StreamEntity[] { + const entities: StreamEntity[] = []; + for (const entity of this.entities.values()) { + if (shouldInclude && !shouldInclude(entity)) continue; + + let renderFlags = + entity.targetId != null && entity.targetId >= 0 + ? (this.targetRenderFlags.get(entity.targetId) ?? + entity.targetRenderFlags) + : entity.targetRenderFlags; + if (entity.type === "Player" && !entity.carryingFlag) { + renderFlags = renderFlags != null ? renderFlags & ~0x2 : renderFlags; + } + + entities.push({ + id: entity.id, + type: entity.type, + visual: entity.visual, + direction: entity.direction, + ghostIndex: entity.ghostIndex, + className: entity.className, + dataBlockId: entity.dataBlockId, + shapeHint: entity.shapeHint, + dataBlock: entity.dataBlock, + weaponShape: entity.weaponShape, + playerName: entity.playerName, + targetRenderFlags: renderFlags, + iffColor: + (entity.type === "Player" || + ((renderFlags ?? 0) & 0x2) !== 0) && + entity.sensorGroup != null + ? this.resolveIffColor(entity.sensorGroup) + : undefined, + position: + entity.position && + (entity.simulatedVelocity || + (entity.itemPhysics && !entity.itemPhysics.atRest)) + ? ([...entity.position] as [number, number, number]) + : entity.position, + rotation: entity.rotation, + velocity: entity.velocity, + health: entity.health, + energy: entity.energy, + actionAnim: entity.actionAnim, + actionAtEnd: entity.actionAtEnd, + damageState: entity.damageState, + faceViewer: entity.faceViewer, + threads: entity.threads, + explosionDataBlockId: entity.explosionDataBlockId, + maintainEmitterId: entity.maintainEmitterId, + weaponImageState: entity.weaponImageState, + weaponImageStates: entity.weaponImageStates, + headPitch: entity.headPitch, + headYaw: entity.headYaw, + label: entity.label, + audioFileName: entity.audioFileName, + audioVolume: entity.audioVolume, + audioIs3D: entity.audioIs3D, + audioIsLooping: entity.audioIsLooping, + audioMinDistance: entity.audioMinDistance, + audioMaxDistance: entity.audioMaxDistance, + audioMinLoopGap: entity.audioMinLoopGap, + audioMaxLoopGap: entity.audioMaxLoopGap, + sceneData: entity.sceneData, + }); + } + return entities; + } + + /** Build HUD arrays for snapshot. */ + protected buildHudState(): { + weaponsHud: { slots: WeaponsHudSlot[]; activeIndex: number }; + inventoryHud: { slots: InventoryHudSlot[]; activeSlot: number }; + backpackHud: BackpackHudState | null; + teamScores: TeamScore[]; + } { + const weaponsHud = { + slots: Array.from(this.weaponsHud.slots.entries()).map( + ([index, ammo]): WeaponsHudSlot => ({ index, ammo }), + ), + activeIndex: this.weaponsHud.activeIndex, + }; + + const inventoryHud = { + slots: Array.from(this.inventoryHud.slots.entries()).map( + ([slot, count]): InventoryHudSlot => ({ slot, count }), + ), + activeSlot: this.inventoryHud.activeSlot, + }; + + const backpackHud: BackpackHudState | null = + this.backpackHud.packIndex >= 0 ? { ...this.backpackHud } : null; + + const teamScores = this.teamScores.map((ts) => ({ ...ts })); + const teamCounts = new Map(); + for (const { teamId } of this.playerRoster.values()) { + if (teamId > 0) + teamCounts.set(teamId, (teamCounts.get(teamId) ?? 0) + 1); + } + for (const ts of teamScores) { + ts.playerCount = teamCounts.get(ts.teamId) ?? 0; + } + + return { weaponsHud, inventoryHud, backpackHud, teamScores }; + } + + /** Build filtered chat and audio event arrays for the current time. */ + protected buildTimeFilteredEvents(timeSec: number): { + chatMessages: ChatMessage[]; + audioEvents: PendingAudioEvent[]; + } { + const chatMessages = this.chatMessages.filter( + (m) => m.timeSec > timeSec - 15, + ); + const audioEvents = this.audioEvents.filter( + (e) => e.timeSec > timeSec - 0.5 && e.timeSec <= timeSec, + ); + return { chatMessages, audioEvents }; + } +} diff --git a/src/stream/demoStreaming.ts b/src/stream/demoStreaming.ts new file mode 100644 index 00000000..97d48a2c --- /dev/null +++ b/src/stream/demoStreaming.ts @@ -0,0 +1,948 @@ +import { + BlockTypeInfo, + BlockTypeMove, + BlockTypePacket, + DemoParser, +} from "t2-demo-parser"; +import { ghostToSceneObject } from "../scene"; +import { + toEntityType, + toEntityId, + TICK_DURATION_MS, +} from "./entityClassification"; +import { + clamp, + MAX_PITCH, + isValidPosition, + stripTaggedStringMarkup, + detectControlObjectType, + parseColorSegments, + backpackBitmapToIndex, +} from "./streamHelpers"; +import type { Vec3 } from "./streamHelpers"; +import type { + StreamRecording, + StreamSnapshot, + TeamScore, + WeaponsHudSlot, + InventoryHudSlot, + BackpackHudState, +} from "./types"; +import { StreamEngine, type MutableEntity } from "./StreamEngine"; + +function extractMissionInfo(demoValues: string[]): { + missionName: string | null; + gameType: string | null; +} { + let missionName: string | null = null; + let gameType: string | null = null; + + for (let i = 0; i < demoValues.length; i++) { + if (demoValues[i] !== "readplayerinfo") continue; + const value = demoValues[i + 1]; + if (!value) continue; + + if (value.startsWith("2\t")) { + const fields = value.split("\t"); + if (fields[4]) { + missionName = fields[4]; + } + continue; + } + + if (value.startsWith("3\t")) { + const fields = value.split("\t"); + if (fields[2]) { + gameType = fields[2]; + } + } + } + + return { missionName, gameType }; +} + +interface ParsedDemoValues { + weaponsHud: { slots: Map; activeIndex: number } | null; + backpackHud: { packIndex: number; active: boolean; text: string } | null; + inventoryHud: { + slots: Map; + activeSlot: number; + } | null; + teamScores: TeamScore[]; + playerRoster: Map; + chatMessages: string[]; + gravity: number; +} + +/** + * Parse the $DemoValue[] array to extract initial HUD state. + * + * Sections are written sequentially by saveDemoSettings/getState in + * recordings.cs: MISC, PLAYERLIST, RETICLE, BACKPACK, WEAPON, INVENTORY, + * SCORE, CLOCK, CHAT, GRAVITY. + */ +function parseDemoValues(demoValues: string[]): ParsedDemoValues { + const result: ParsedDemoValues = { + weaponsHud: null, + backpackHud: null, + inventoryHud: null, + teamScores: [], + playerRoster: new Map(), + chatMessages: [], + gravity: -20, + }; + if (!demoValues.length) return result; + + let idx = 0; + const next = () => { + const v = demoValues[idx++]; + return v === "" ? "" : (v ?? ""); + }; + + // MISC: 1 value + next(); + + // PLAYERLIST: count + count entries + if (idx >= demoValues.length) return result; + const playerCount = parseInt(next(), 10) || 0; + const playerCountByTeam = new Map(); + for (let i = 0; i < playerCount; i++) { + const fields = next().split("\t"); + const name = fields[0] ?? ""; + const clientId = parseInt(fields[2], 10); + const teamId = parseInt(fields[4], 10); + if (!isNaN(clientId) && !isNaN(teamId)) { + result.playerRoster.set(clientId, { name, teamId }); + } + if (!isNaN(teamId) && teamId > 0) { + playerCountByTeam.set(teamId, (playerCountByTeam.get(teamId) ?? 0) + 1); + } + } + + // RETICLE: 1 value + if (idx >= demoValues.length) return result; + next(); + + // BACKPACK: 1 value (bitmap TAB visible TAB text TAB textVisible TAB pack) + if (idx >= demoValues.length) return result; + { + const backpackVal = next(); + const fields = backpackVal.split("\t"); + const bitmap = fields[0] ?? ""; + const visible = fields[1] === "1" || fields[1] === "true"; + const text = fields[2] ?? ""; + const pack = fields[4] === "1" || fields[4] === "true"; + if (visible && bitmap) { + const packIndex = backpackBitmapToIndex(bitmap); + result.backpackHud = { packIndex, active: pack, text }; + } + } + + // WEAPON: header + count bitmap entries + slotCount slot entries + if (idx >= demoValues.length) return result; + const weaponHeader = next().split("\t"); + const weaponCount = parseInt(weaponHeader[4], 10) || 0; + const weaponSlotCount = parseInt(weaponHeader[5], 10) || 0; + const weaponActive = parseInt(weaponHeader[6], 10); + + for (let i = 0; i < weaponCount; i++) next(); + + const slots = new Map(); + for (let i = 0; i < weaponSlotCount; i++) { + const fields = next().split("\t"); + const slotId = parseInt(fields[0], 10); + const ammo = parseInt(fields[1], 10); + if (!isNaN(slotId)) { + slots.set(slotId, isNaN(ammo) ? -1 : ammo); + } + } + result.weaponsHud = { + slots, + activeIndex: isNaN(weaponActive) ? -1 : weaponActive, + }; + + // INVENTORY: header + count bitmap entries + slotCount slot entries + if (idx >= demoValues.length) return result; + const invHeader = next().split("\t"); + const invCount = parseInt(invHeader[4], 10) || 0; + const invSlotCount = parseInt(invHeader[5], 10) || 0; + const invActive = parseInt(invHeader[6], 10); + for (let i = 0; i < invCount; i++) next(); + { + const invSlots = new Map(); + for (let i = 0; i < invSlotCount; i++) { + const fields = next().split("\t"); + const slotId = parseInt(fields[0], 10); + const count = parseInt(fields[1], 10); + if (!isNaN(slotId) && !isNaN(count) && count > 0) { + invSlots.set(slotId, count); + } + } + if (invSlots.size > 0) { + result.inventoryHud = { + slots: invSlots, + activeSlot: isNaN(invActive) ? -1 : invActive, + }; + } + } + + // SCORE: header (visible TAB gameType TAB objCount) + objCount entries. + if (idx >= demoValues.length) return result; + const scoreHeader = next().split("\t"); + const gameType = scoreHeader[1] ?? ""; + const objCount = parseInt(scoreHeader[2], 10) || 0; + const scoreObjs: string[] = []; + for (let i = 0; i < objCount; i++) scoreObjs.push(next()); + + if (gameType === "CTFGame" && objCount >= 8) { + for (let t = 0; t < 2; t++) { + const base = t * 4; + const teamId = t + 1; + result.teamScores.push({ + teamId, + name: scoreObjs[base] ?? "", + score: parseInt(scoreObjs[base + 1], 10) || 0, + playerCount: playerCountByTeam.get(teamId) ?? 0, + }); + } + } else if (gameType === "TR2Game" && objCount >= 4) { + for (let t = 0; t < 2; t++) { + const base = t * 2; + const teamId = t + 1; + result.teamScores.push({ + teamId, + name: scoreObjs[base + 1] ?? "", + score: parseInt(scoreObjs[base], 10) || 0, + playerCount: playerCountByTeam.get(teamId) ?? 0, + }); + } + } + + // CLOCK: 1 value + if (idx >= demoValues.length) return result; + next(); + + // CHAT: always 10 entries + for (let i = 0; i < 10; i++) { + if (idx >= demoValues.length) break; + const line = next(); + if (line) { + result.chatMessages.push(line); + } + } + + // GRAVITY: 1 value + if (idx < demoValues.length) { + const g = parseFloat(next()); + if (Number.isFinite(g)) { + result.gravity = g; + } + } + + return result; +} + +class StreamingPlayback extends StreamEngine { + private readonly parser: DemoParser; + private readonly initialBlock: { + dataBlocks: Map< + number, + { className: string; data: Record } + >; + initialGhosts: Array<{ + index: number; + type: "create" | "update" | "delete"; + classId?: number; + parsedData?: Record; + }>; + controlObjectGhostIndex: number; + controlObjectData?: Record; + targetEntries: Array<{ + targetId: number; + name?: string; + sensorGroup: number; + targetData: number; + }>; + sensorGroupColors: Array<{ + group: number; + targetGroup: number; + r: number; + g: number; + b: number; + }>; + taggedStrings: Map; + initialEvents: Array<{ + classId: number; + parsedData?: Record; + }>; + demoValues: string[]; + }; + // Demo-specific: move delta tracking for V12-style camera rotation + private moveTicks = 0; + private absoluteYaw = 0; + private absolutePitch = 0; + private lastAbsYaw = 0; + private lastAbsPitch = 0; + private exhausted = false; + + // Generation counters for derived-array caching in buildSnapshot(). + private _teamScoresGen = 0; + private _rosterGen = 0; + private _weaponsHudGen = 0; + private _inventoryHudGen = 0; + + // Cached snapshot + private _cachedSnapshot: StreamSnapshot | null = null; + private _cachedSnapshotTick = -1; + + // Cached derived arrays + private _snap: { + teamScoresGen: number; + rosterGen: number; + teamScores: TeamScore[]; + weaponsHudGen: number; + weaponsHud: { slots: WeaponsHudSlot[]; activeIndex: number }; + inventoryHudGen: number; + inventoryHud: { slots: InventoryHudSlot[]; activeSlot: number }; + backpackPackIndex: number; + backpackActive: boolean; + backpackText: string; + backpackHud: BackpackHudState | null; + } | null = null; + + constructor(parser: DemoParser) { + super(); + this.parser = parser; + this.registry = parser.getRegistry(); + this.ghostTracker = parser.getGhostTracker(); + const initial = parser.initialBlock; + this.initialBlock = { + dataBlocks: initial.dataBlocks, + initialGhosts: initial.initialGhosts, + controlObjectGhostIndex: initial.controlObjectGhostIndex, + controlObjectData: initial.controlObjectData, + targetEntries: initial.targetEntries, + sensorGroupColors: initial.sensorGroupColors, + taggedStrings: initial.taggedStrings, + initialEvents: initial.initialEvents, + demoValues: initial.demoValues, + }; + + this.reset(); + } + + // ── StreamEngine abstract implementations ── + + getDataBlockData(dataBlockId: number): Record | undefined { + const initialBlock = this.initialBlock.dataBlocks.get(dataBlockId); + if (initialBlock?.data) { + return initialBlock.data; + } + const packetParser = this.parser.getPacketParser() as unknown as { + dataBlockDataMap?: Map>; + }; + return packetParser.dataBlockDataMap?.get(dataBlockId); + } + + private _shapeConstructorCache: Map | null = null; + + getShapeConstructorSequences(shapeName: string): string[] | undefined { + if (!this._shapeConstructorCache) { + this._shapeConstructorCache = new Map(); + for (const [, db] of this.initialBlock.dataBlocks) { + if (db.className !== "TSShapeConstructor" || !db.data) continue; + const shape = db.data.shape as string | undefined; + const seqs = db.data.sequences as string[] | undefined; + if (shape && seqs) { + this._shapeConstructorCache.set(shape.toLowerCase(), seqs); + } + } + } + return this._shapeConstructorCache.get(shapeName.toLowerCase()); + } + + protected getTimeSec(): number { + return this.moveTicks * (TICK_DURATION_MS / 1000); + } + + protected getCameraYawPitch( + _data: Record | undefined, + ): { yaw: number; pitch: number } { + const hasMoves = !this.isPiloting && this.lastControlType === "player"; + const yaw = hasMoves ? this.absoluteYaw : this.lastAbsYaw; + const pitch = hasMoves ? this.absolutePitch : this.lastAbsPitch; + + if (hasMoves) { + this.lastAbsYaw = yaw; + this.lastAbsPitch = pitch; + } + + return { yaw, pitch }; + } + + protected getControlPlayerHeadPitch(_pitch: number): number { + return clamp(this.absolutePitch / MAX_PITCH, -1, 1); + } + + // ── Generation counter hooks ── + + protected onTeamScoresChanged(): void { + this._teamScoresGen++; + } + + protected onRosterChanged(): void { + this._rosterGen++; + } + + protected onWeaponsHudChanged(): void { + this._weaponsHudGen++; + } + + protected onInventoryHudChanged(): void { + this._inventoryHudGen++; + } + + // ── StreamingPlayback interface ── + + reset(): void { + this.parser.reset(); + // parser.reset() creates a fresh GhostTracker internally — refresh our + // reference so resolveGhostClassName doesn't use the stale one. + this.ghostTracker = this.parser.getGhostTracker(); + this._cachedSnapshot = null; + this._cachedSnapshotTick = -1; + this._snap = null; + + this.resetSharedState(); + + // Seed net strings from initial block + for (const [id, value] of this.initialBlock.taggedStrings) { + this.netStrings.set(id, value); + } + for (const entry of this.initialBlock.targetEntries) { + if (entry.name) { + this.targetNames.set( + entry.targetId, + stripTaggedStringMarkup(entry.name), + ); + } + this.targetTeams.set(entry.targetId, entry.sensorGroup); + this.targetRenderFlags.set(entry.targetId, entry.targetData); + } + // Seed IFF color table from the initial block. + for (const c of this.initialBlock.sensorGroupColors) { + let map = this.sensorGroupColors.get(c.group); + if (!map) { + map = new Map(); + this.sensorGroupColors.set(c.group, map); + } + map.set(c.targetGroup, { r: c.r, g: c.g, b: c.b }); + } + + // Demo-specific state + this.moveTicks = 0; + this.absoluteYaw = 0; + this.absolutePitch = 0; + this.lastAbsYaw = 0; + this.lastAbsPitch = 0; + this.lastControlType = + detectControlObjectType(this.initialBlock.controlObjectData) ?? "player"; + this.isPiloting = + this.lastControlType === "player" + ? !!( + this.initialBlock.controlObjectData?.pilot || + this.initialBlock.controlObjectData?.controlObjectGhost != null + ) + : false; + this.lastCameraMode = + this.lastControlType === "camera" && + typeof this.initialBlock.controlObjectData?.cameraMode === "number" + ? this.initialBlock.controlObjectData.cameraMode + : undefined; + this.lastOrbitGhostIndex = + this.lastControlType === "camera" && + typeof this.initialBlock.controlObjectData?.orbitObjectGhostIndex === + "number" + ? this.initialBlock.controlObjectData.orbitObjectGhostIndex + : undefined; + if (this.lastControlType === "camera") { + const minOrbit = this.initialBlock.controlObjectData?.minOrbitDist as + | number + | undefined; + const maxOrbit = this.initialBlock.controlObjectData?.maxOrbitDist as + | number + | undefined; + const curOrbit = this.initialBlock.controlObjectData?.curOrbitDist as + | number + | undefined; + if ( + typeof minOrbit === "number" && + typeof maxOrbit === "number" && + Number.isFinite(minOrbit) && + Number.isFinite(maxOrbit) + ) { + this.lastOrbitDistance = Math.max(0, maxOrbit - minOrbit); + } else if (typeof curOrbit === "number" && Number.isFinite(curOrbit)) { + this.lastOrbitDistance = Math.max(0, curOrbit); + } else { + this.lastOrbitDistance = undefined; + } + } else { + this.lastOrbitDistance = undefined; + } + const initialAbsRot = this.getAbsoluteRotation( + this.initialBlock.controlObjectData, + ); + if (initialAbsRot) { + this.absoluteYaw = initialAbsRot.yaw; + this.absolutePitch = initialAbsRot.pitch; + this.lastAbsYaw = initialAbsRot.yaw; + this.lastAbsPitch = initialAbsRot.pitch; + } + this.exhausted = false; + this.latestFov = 100; + this.latestControl = { + ghostIndex: this.initialBlock.controlObjectGhostIndex, + data: this.initialBlock.controlObjectData, + position: isValidPosition( + this.initialBlock.controlObjectData?.position as Vec3, + ) + ? (this.initialBlock.controlObjectData?.position as Vec3) + : undefined, + }; + this.controlPlayerGhostId = + this.lastControlType === "player" && + this.initialBlock.controlObjectGhostIndex >= 0 + ? toEntityId("Player", this.initialBlock.controlObjectGhostIndex) + : undefined; + + for (const ghost of this.initialBlock.initialGhosts) { + if (ghost.type !== "create" || ghost.classId == null) continue; + const className = this.registry.getGhostParser(ghost.classId)?.name; + if (!className) { + throw new Error( + `No ghost parser for classId ${ghost.classId} (ghost index ${ghost.index})`, + ); + } + const id = toEntityId(className, ghost.index); + const entity: MutableEntity = { + id, + ghostIndex: ghost.index, + className, + spawnTick: 0, + type: toEntityType(className), + rotation: [0, 0, 0, 1], + }; + this.applyGhostData(entity, ghost.parsedData); + if (ghost.parsedData) { + const sceneObj = ghostToSceneObject( + className, + ghost.index, + ghost.parsedData as Record, + ); + if (sceneObj) entity.sceneData = sceneObj; + } + this.entities.set(id, entity); + this.entityIdByGhostIndex.set(ghost.index, id); + } + + // Derive playerSensorGroup from the control player entity + if ( + this.playerSensorGroup === 0 && + this.lastControlType === "player" && + this.latestControl.ghostIndex >= 0 + ) { + const ctrlId = this.entityIdByGhostIndex.get( + this.latestControl.ghostIndex, + ); + const ctrlEntity = ctrlId ? this.entities.get(ctrlId) : undefined; + if (ctrlEntity?.sensorGroup != null && ctrlEntity.sensorGroup > 0) { + this.playerSensorGroup = ctrlEntity.sensorGroup; + } + } + + // Process initial events + for (const evt of this.initialBlock.initialEvents) { + const eventName = this.registry.getEventParser(evt.classId)?.name; + if (eventName === "SetSensorGroupEvent" && evt.parsedData) { + const sg = evt.parsedData.sensorGroup as number | undefined; + if (sg != null) this.playerSensorGroup = sg; + } else if (eventName === "RemoteCommandEvent" && evt.parsedData) { + const funcName = this.resolveNetString( + evt.parsedData.funcName as string, + ); + const args = evt.parsedData.args as string[]; + if (funcName === "ServerMessage") { + this.handleServerMessage(args); + } + this.handleHudRemoteCommand(funcName, args); + } + } + + // Seed HUD state from demoValues + const parsed = parseDemoValues(this.initialBlock.demoValues); + if (parsed.weaponsHud) { + this.weaponsHud.slots = parsed.weaponsHud.slots; + this.weaponsHud.activeIndex = parsed.weaponsHud.activeIndex; + } + if (parsed.backpackHud) { + this.backpackHud.packIndex = parsed.backpackHud.packIndex; + this.backpackHud.active = parsed.backpackHud.active; + this.backpackHud.text = parsed.backpackHud.text; + } + if (parsed.inventoryHud) { + this.inventoryHud.slots = parsed.inventoryHud.slots; + this.inventoryHud.activeSlot = parsed.inventoryHud.activeSlot; + } + this.teamScores = parsed.teamScores; + this.playerRoster = new Map(parsed.playerRoster); + // Seed chat messages from demoValues + for (const rawLine of parsed.chatMessages) { + const segments = parseColorSegments(rawLine); + if (!segments.length) continue; + const fullText = segments.map((s) => s.text).join(""); + if (!fullText.trim()) continue; + const primaryColor = segments[0].colorCode; + const hasChatColor = segments.some( + (s) => s.colorCode === 3 || s.colorCode === 4, + ); + const isPlayerChat = hasChatColor && fullText.includes(": "); + if (isPlayerChat) { + const colonIdx = fullText.indexOf(": "); + this.chatMessages.push({ + timeSec: 0, + sender: fullText.slice(0, colonIdx), + text: fullText.slice(colonIdx + 2), + kind: "chat", + colorCode: primaryColor, + segments, + }); + } else { + this.chatMessages.push({ + timeSec: 0, + sender: "", + text: fullText, + kind: "server", + colorCode: primaryColor, + segments, + }); + } + } + + this.updateCameraAndHud(); + } + + getSnapshot(): StreamSnapshot { + if ( + this._cachedSnapshot && + this._cachedSnapshotTick === this.moveTicks + ) { + return this._cachedSnapshot; + } + const snapshot = this.buildSnapshot(); + this._cachedSnapshot = snapshot; + this._cachedSnapshotTick = this.moveTicks; + return snapshot; + } + + getEffectShapes(): string[] { + const shapes = new Set(); + const collectShapesFromExplosion = (expBlock: Record) => { + const shape = expBlock.dtsFileName as string | undefined; + if (shape) shapes.add(shape); + const subExplosions = expBlock.subExplosions as + | (number | null)[] + | undefined; + if (Array.isArray(subExplosions)) { + for (const subId of subExplosions) { + if (subId == null) continue; + const subBlock = this.getDataBlockData(subId); + if (subBlock?.dtsFileName) { + shapes.add(subBlock.dtsFileName as string); + } + } + } + }; + for (const [, block] of this.initialBlock.dataBlocks) { + const explosionId = block.data?.explosion as number | undefined; + if (explosionId == null) continue; + const expBlock = this.getDataBlockData(explosionId); + if (expBlock) collectShapesFromExplosion(expBlock); + } + return [...shapes]; + } + + stepToTime( + targetTimeSec: number, + maxMoveTicks = Number.POSITIVE_INFINITY, + ): StreamSnapshot { + const safeTargetSec = Number.isFinite(targetTimeSec) + ? Math.max(0, targetTimeSec) + : 0; + const targetTicks = Math.floor((safeTargetSec * 1000) / TICK_DURATION_MS); + + let didReset = false; + if (targetTicks < this.moveTicks) { + this.reset(); + didReset = true; + } + + const wasExhausted = this.exhausted; + let movesProcessed = 0; + while ( + !this.exhausted && + this.moveTicks < targetTicks && + movesProcessed < maxMoveTicks + ) { + if (!this.stepOneMoveTick()) { + break; + } + movesProcessed += 1; + } + + if ( + movesProcessed === 0 && + !didReset && + wasExhausted === this.exhausted && + this._cachedSnapshot && + this._cachedSnapshotTick === this.moveTicks + ) { + return this._cachedSnapshot; + } + + const snapshot = this.buildSnapshot(); + this._cachedSnapshot = snapshot; + this._cachedSnapshotTick = this.moveTicks; + return snapshot; + } + + // ── Demo block processing ── + + private stepOneMoveTick(): boolean { + while (true) { + const block = this.parser.nextBlock(); + if (!block) { + this.exhausted = true; + return false; + } + + this.handleBlock(block); + + if (block.type === BlockTypeMove) { + this.moveTicks += 1; + this.tickCount = this.moveTicks; + this.advanceProjectiles(); + this.advanceItems(); + this.removeExpiredExplosions(); + this.updateCameraAndHud(); + return true; + } + } + } + + private handleBlock(block: { type: number; parsed?: unknown }): void { + if (block.type === BlockTypePacket && this.isPacketData(block.parsed)) { + const packet = block.parsed; + + // Process control object + this.processControlObject(packet.gameState); + + // Apply ghost rotation to absolute tracking. This must happen before + // the next move delta so that our tracking stays calibrated to V12. + const controlData = packet.gameState.controlObjectData; + if (controlData) { + const absRot = this.getAbsoluteRotation(controlData); + if (absRot) { + this.absoluteYaw = absRot.yaw; + this.absolutePitch = absRot.pitch; + this.lastAbsYaw = absRot.yaw; + this.lastAbsPitch = absRot.pitch; + } + } + + for (const evt of packet.events) { + const eventName = this.registry.getEventParser(evt.classId)?.name; + this.processEvent(evt, eventName); + } + + for (const ghost of packet.ghosts) { + this.processGhostUpdate(ghost); + } + + return; + } + + if (block.type === BlockTypeInfo && this.isInfoData(block.parsed)) { + if (Number.isFinite(block.parsed.value2)) { + this.latestFov = block.parsed.value2; + } + return; + } + + if (block.type === BlockTypeMove && this.isMoveData(block.parsed)) { + // Replicate V12 Player::updateMove(): apply delta then wrap/clamp. + this.absoluteYaw += block.parsed.yaw ?? 0; + const TWO_PI = Math.PI * 2; + this.absoluteYaw = + ((this.absoluteYaw % TWO_PI) + TWO_PI) % TWO_PI; + this.absolutePitch = clamp( + this.absolutePitch + (block.parsed.pitch ?? 0), + -MAX_PITCH, + MAX_PITCH, + ); + } + } + + // ── Build snapshot (with generation-counter caching) ── + + private buildSnapshot(): StreamSnapshot { + const entities = this.buildEntityList(); + const timeSec = this.getTimeSec(); + const prev = this._snap; + + const { chatMessages, audioEvents } = + this.buildTimeFilteredEvents(timeSec); + + const weaponsHud = + prev && prev.weaponsHudGen === this._weaponsHudGen + ? prev.weaponsHud + : { + slots: Array.from(this.weaponsHud.slots.entries()).map( + ([index, ammo]): WeaponsHudSlot => ({ index, ammo }), + ), + activeIndex: this.weaponsHud.activeIndex, + }; + + const inventoryHud = + prev && prev.inventoryHudGen === this._inventoryHudGen + ? prev.inventoryHud + : { + slots: Array.from(this.inventoryHud.slots.entries()).map( + ([slot, count]): InventoryHudSlot => ({ slot, count }), + ), + activeSlot: this.inventoryHud.activeSlot, + }; + + const backpackHud = + prev && + prev.backpackPackIndex === this.backpackHud.packIndex && + prev.backpackActive === this.backpackHud.active && + prev.backpackText === this.backpackHud.text + ? prev.backpackHud + : this.backpackHud.packIndex >= 0 + ? { ...this.backpackHud } + : null; + + let teamScores: TeamScore[]; + if ( + prev && + prev.teamScoresGen === this._teamScoresGen && + prev.rosterGen === this._rosterGen + ) { + teamScores = prev.teamScores; + } else { + teamScores = this.teamScores.map((ts) => ({ ...ts })); + const teamCounts = new Map(); + for (const { teamId } of this.playerRoster.values()) { + if (teamId > 0) { + teamCounts.set(teamId, (teamCounts.get(teamId) ?? 0) + 1); + } + } + for (const ts of teamScores) { + ts.playerCount = teamCounts.get(ts.teamId) ?? 0; + } + } + + this._snap = { + teamScoresGen: this._teamScoresGen, + rosterGen: this._rosterGen, + teamScores, + weaponsHudGen: this._weaponsHudGen, + weaponsHud, + inventoryHudGen: this._inventoryHudGen, + inventoryHud, + backpackPackIndex: this.backpackHud.packIndex, + backpackActive: this.backpackHud.active, + backpackText: this.backpackHud.text, + backpackHud, + }; + + return { + timeSec, + exhausted: this.exhausted, + camera: this.camera, + entities, + controlPlayerGhostId: this.controlPlayerGhostId, + playerSensorGroup: this.playerSensorGroup, + status: this.lastStatus, + chatMessages, + audioEvents, + weaponsHud, + backpackHud, + inventoryHud, + teamScores, + }; + } + + // ── Type guards ── + + private isPacketData(parsed: unknown): parsed is { + gameState: { + controlObjectGhostIndex?: number; + controlObjectData?: Record; + compressionPoint?: Vec3; + cameraFov?: number; + }; + events: Array<{ + classId: number; + parsedData?: Record; + }>; + ghosts: Array<{ + index: number; + type: "create" | "update" | "delete"; + classId?: number; + parsedData?: Record; + }>; + } { + return ( + !!parsed && + typeof parsed === "object" && + "gameState" in parsed && + "events" in parsed && + "ghosts" in parsed + ); + } + + private isMoveData( + parsed: unknown, + ): parsed is { yaw?: number; pitch?: number } { + return !!parsed && typeof parsed === "object" && "yaw" in parsed; + } + + private isInfoData(parsed: unknown): parsed is { value2: number } { + return ( + !!parsed && + typeof parsed === "object" && + "value2" in parsed && + typeof (parsed as { value2?: unknown }).value2 === "number" + ); + } +} + +export async function createDemoStreamingRecording( + data: ArrayBuffer, +): Promise { + const parser = new DemoParser(new Uint8Array(data)); + const { header, initialBlock } = await parser.load(); + const { missionName: infoMissionName, gameType } = extractMissionInfo( + initialBlock.demoValues, + ); + + return { + source: "demo", + duration: header.demoLengthMs / 1000, + missionName: infoMissionName ?? initialBlock.missionName ?? null, + gameType, + streamingPlayback: new StreamingPlayback(parser), + }; +} diff --git a/src/stream/entityBridge.ts b/src/stream/entityBridge.ts new file mode 100644 index 00000000..700c0860 --- /dev/null +++ b/src/stream/entityBridge.ts @@ -0,0 +1,185 @@ +import type { StreamEntity } from "./types"; +import type { + GameEntity, + ShapeEntity, + PlayerEntity, + ForceFieldBareEntity, + ExplosionEntity, + TracerEntity, + SpriteEntity, + AudioEmitterEntity, + CameraEntity, + WayPointEntity, +} from "../state/gameEntityTypes"; +import type { SceneTSStatic } from "../scene/types"; + +/** Common fields extracted from a StreamEntity for positioned game entities. */ +function positionedBase(entity: StreamEntity, spawnTime?: number) { + return { + id: entity.id, + className: entity.className ?? entity.type, + ghostIndex: entity.ghostIndex, + dataBlockId: entity.dataBlockId, + shapeHint: entity.shapeHint, + spawnTime, + position: entity.position, + rotation: entity.rotation, + velocity: entity.velocity, + keyframes: [ + { + time: spawnTime ?? 0, + position: entity.position ?? [0, 0, 0] as [number, number, number], + rotation: entity.rotation ?? [0, 0, 0, 1] as [number, number, number, number], + }, + ], + }; +} + +/** Convert a StreamEntity to a GameEntity for the entity store. */ +export function streamEntityToGameEntity( + entity: StreamEntity, + spawnTime?: number, +): GameEntity { + // Scene infrastructure — routed from sceneData + if (entity.sceneData) { + const base = { + id: entity.id, + className: entity.className ?? entity.type, + ghostIndex: entity.ghostIndex, + dataBlockId: entity.dataBlockId, + shapeHint: entity.shapeHint, + spawnTime, + }; + switch (entity.sceneData.className) { + case "TerrainBlock": + return { ...base, renderType: "TerrainBlock", terrainData: entity.sceneData }; + case "InteriorInstance": + return { ...base, renderType: "InteriorInstance", interiorData: entity.sceneData }; + case "Sky": + return { ...base, renderType: "Sky", skyData: entity.sceneData }; + case "Sun": + return { ...base, renderType: "Sun", sunData: entity.sceneData }; + case "WaterBlock": + return { ...base, renderType: "WaterBlock", waterData: entity.sceneData }; + case "MissionArea": + return { ...base, renderType: "MissionArea", missionAreaData: entity.sceneData }; + case "TSStatic": + // TSStatic is rendered as a shape — extract shapeName from scene data. + return { + ...positionedBase(entity, spawnTime), + renderType: "Shape", + shapeName: (entity.sceneData as SceneTSStatic).shapeName, + shapeType: "TSStatic", + dataBlock: entity.dataBlock, + } satisfies ShapeEntity; + } + } + + // Projectile visuals + if (entity.visual?.kind === "tracer") { + return { + ...positionedBase(entity, spawnTime), + renderType: "Tracer", + visual: entity.visual, + dataBlock: entity.dataBlock, + direction: entity.direction, + } satisfies TracerEntity; + } + if (entity.visual?.kind === "sprite") { + return { + ...positionedBase(entity, spawnTime), + renderType: "Sprite", + visual: entity.visual, + } satisfies SpriteEntity; + } + + // Player + if (entity.type === "Player") { + return { + ...positionedBase(entity, spawnTime), + renderType: "Player", + shapeName: entity.dataBlock, + dataBlock: entity.dataBlock, + weaponShape: entity.weaponShape, + playerName: entity.playerName, + iffColor: entity.iffColor, + threads: entity.threads, + weaponImageState: entity.weaponImageState, + weaponImageStates: entity.weaponImageStates, + headPitch: entity.headPitch, + headYaw: entity.headYaw, + targetRenderFlags: entity.targetRenderFlags, + } satisfies PlayerEntity; + } + + // Explosion + if (entity.type === "Explosion") { + return { + ...positionedBase(entity, spawnTime), + renderType: "Explosion", + shapeName: entity.dataBlock, + dataBlock: entity.dataBlock, + explosionDataBlockId: entity.explosionDataBlockId, + faceViewer: entity.faceViewer, + } satisfies ExplosionEntity; + } + + // Force field + if (entity.className === "ForceFieldBare") { + return { + ...positionedBase(entity, spawnTime), + renderType: "ForceFieldBare", + } satisfies ForceFieldBareEntity; + } + + // Audio emitter + if (entity.className === "AudioEmitter") { + return { + ...positionedBase(entity, spawnTime), + renderType: "AudioEmitter", + audioFileName: entity.audioFileName, + audioVolume: entity.audioVolume, + audioIs3D: entity.audioIs3D, + audioIsLooping: entity.audioIsLooping ?? true, + audioMinDistance: entity.audioMinDistance, + audioMaxDistance: entity.audioMaxDistance, + audioMinLoopGap: entity.audioMinLoopGap, + audioMaxLoopGap: entity.audioMaxLoopGap, + } satisfies AudioEmitterEntity; + } + + // WayPoint + if (entity.className === "WayPoint") { + return { + ...positionedBase(entity, spawnTime), + renderType: "WayPoint", + label: entity.label, + } satisfies WayPointEntity; + } + + // Camera + if (entity.className === "Camera") { + return { + ...positionedBase(entity, spawnTime), + renderType: "Camera", + } satisfies CameraEntity; + } + + // Default: generic DTS shape + return { + ...positionedBase(entity, spawnTime), + renderType: "Shape", + shapeName: entity.dataBlock, + shapeType: + entity.className === "Turret" + ? "Turret" + : entity.className === "Item" + ? "Item" + : "StaticShape", + dataBlock: entity.dataBlock, + weaponShape: entity.weaponShape, + threads: entity.threads, + targetRenderFlags: entity.targetRenderFlags, + iffColor: entity.iffColor, + } satisfies ShapeEntity; +} diff --git a/src/stream/entityClassification.ts b/src/stream/entityClassification.ts new file mode 100644 index 00000000..c14c6cf8 --- /dev/null +++ b/src/stream/entityClassification.ts @@ -0,0 +1,69 @@ +/** Class names for vehicle ghosts. */ +export const vehicleClassNames = new Set([ + "FlyingVehicle", + "HoverVehicle", + "WheeledVehicle", +]); + +/** All projectile class names. */ +export const projectileClassNames = new Set([ + "BombProjectile", + "EnergyProjectile", + "FlareProjectile", + "GrenadeProjectile", + "LinearFlareProjectile", + "LinearProjectile", + "Projectile", + "SeekerProjectile", + "TracerProjectile", +]); + +/** Projectile classes with linear (constant-velocity) physics. */ +export const linearProjectileClassNames = new Set([ + "LinearProjectile", + "TracerProjectile", + "LinearFlareProjectile", + "Projectile", +]); + +/** Projectile classes with ballistic (gravity-affected) physics. */ +export const ballisticProjectileClassNames = new Set([ + "GrenadeProjectile", + "EnergyProjectile", + "FlareProjectile", + "BombProjectile", +]); + +/** Projectile classes that use seeking (homing) physics. */ +export const seekerProjectileClassNames = new Set(["SeekerProjectile"]); + +/** Deployable/placed object class names. */ +export const deployableClassNames = new Set([ + "StaticShape", + "ScopeAlwaysShape", + "Turret", + "BeaconObject", + "ForceFieldBare", +]); + +/** Map a ghost class name to a high-level entity type string. */ +export function toEntityType(className: string): string { + if (className === "Player") return "Player"; + if (vehicleClassNames.has(className)) return "Vehicle"; + if (className === "Item") return "Item"; + if (projectileClassNames.has(className)) return "Projectile"; + if (deployableClassNames.has(className)) return "Deployable"; + return "Ghost"; +} + +/** Generate a stable entity ID from ghost class name and index. */ +export function toEntityId(className: string, ghostIndex: number): string { + return `${className}_${ghostIndex}`; +} + +/** Tribes 2 default IFF colors (sRGB 0-255). */ +export const IFF_GREEN = Object.freeze({ r: 0, g: 255, b: 0 }); +export const IFF_RED = Object.freeze({ r: 255, g: 0, b: 0 }); + +/** Torque engine tick duration in milliseconds. */ +export const TICK_DURATION_MS = 32; diff --git a/src/stream/liveStreaming.ts b/src/stream/liveStreaming.ts new file mode 100644 index 00000000..4b80b9f6 --- /dev/null +++ b/src/stream/liveStreaming.ts @@ -0,0 +1,555 @@ +import { + createLiveParser, + type PacketParser, +} from "t2-demo-parser"; +import { resolveShapeName, stripTaggedStringMarkup } from "./streamHelpers"; +import type { Vec3 } from "./streamHelpers"; +import type { StreamSnapshot } from "./types"; +import { StreamEngine } from "./StreamEngine"; +import type { RelayClient } from "./relayClient"; + +// ── Player list entry ── + +export interface PlayerListEntry { + targetId: number; + name: string; + sensorGroup: number; +} + +/** + * Adapts live game packets from a relay connection into the + * StreamingPlayback interface used by the existing rendering pipeline. + */ +export class LiveStreamAdapter extends StreamEngine { + private packetParser: PacketParser; + relay: RelayClient; + + private currentTimeSec = 0; + private connectSynced = false; + private _snapshot: StreamSnapshot | null = null; + private _snapshotTick = -1; + private _ready = false; + /** Class names for datablocks, tracked from SimDataBlockEvents. */ + private dataBlockClassNames = new Map(); + + /** Called once when the first ghost entity is created. */ + onReady?: () => void; + + constructor(relay: RelayClient) { + super(); + this.relay = relay; + const { registry, ghostTracker, packetParser } = createLiveParser(); + this.packetParser = packetParser; + this.ghostTracker = ghostTracker; + this.registry = registry; + } + + // ── StreamEngine abstract implementations ── + + getDataBlockData(id: number): Record | undefined { + return this.packetParser.getDataBlockDataMap()?.get(id); + } + + private _shapeConstructorCache: Map | null = null; + + getShapeConstructorSequences(shapeName: string): string[] | undefined { + // Rebuild cache each call since datablocks arrive incrementally. + this._shapeConstructorCache = new Map(); + const dbMap = this.packetParser.getDataBlockDataMap(); + if (!dbMap) return undefined; + for (const [, block] of dbMap) { + const shape = block.shape as string | undefined; + const seqs = block.sequences as string[] | undefined; + if (shape && seqs) { + this._shapeConstructorCache.set(shape.toLowerCase(), seqs); + } + } + return this._shapeConstructorCache.get(shapeName.toLowerCase()); + } + + protected getTimeSec(): number { + return this.currentTimeSec; + } + + protected getCameraYawPitch( + data: Record | undefined, + ): { yaw: number; pitch: number } { + const absRot = this.getAbsoluteRotation(data); + return absRot ?? { yaw: 0, pitch: 0 }; + } + + getEffectShapes(): string[] { + const shapes = new Set(); + const dbMap = this.packetParser.getDataBlockDataMap(); + if (!dbMap) return []; + for (const [, block] of dbMap) { + const explosionId = block.explosion as number | undefined; + if (explosionId == null) continue; + const expBlock = dbMap.get(explosionId); + if (expBlock?.dtsFileName) { + shapes.add(expBlock.dtsFileName as string); + } + } + return [...shapes]; + } + + // ── StreamingPlayback interface ── + + reset(): void { + this.resetSharedState(); + this.ghostTracker.clear?.(); + this.currentTimeSec = 0; + this._snapshot = null; + this._snapshotTick = -1; + this.dataBlockClassNames.clear(); + this.observerMode = "fly"; + } + + getSnapshot(): StreamSnapshot { + if (this._snapshot && this._snapshotTick === this.tickCount) { + return this._snapshot; + } + return this.buildSnapshot(); + } + + stepToTime( + targetTimeSec: number, + _maxMoveTicks?: number, + ): StreamSnapshot { + this.currentTimeSec = targetTimeSec; + return this.getSnapshot(); + } + + // ── Live-specific: connect sequence sync ── + + private syncConnectSequence(data: Uint8Array): void { + if (this.connectSynced || data.length < 1) return; + this.connectSynced = true; + const connectSeqBit = (data[0] >> 1) & 1; + // The browser parser is a passive observer — it never sends packets + // (the relay handles all outgoing UDP traffic). Set lastSendSeq very + // high so the parser's ack validation (lastSendSeq < highestAck → + // reject) never fires. Without this, the parser rejects any packet + // where the server acks relay-sent sequences (e.g. auth events). + this.packetParser.setConnectionProtocolState({ + lastSeqRecvdAtSend: new Array(32).fill(0), + lastSeqRecvd: 0, + highestAckedSeq: 0, + lastSendSeq: 0x1fffffff, + ackMask: 0, + connectSequence: connectSeqBit, + lastRecvAckAck: 0, + connectionEstablished: true, + }); + } + + // ── Live-specific: feed raw packet ── + + feedPacket(data: Uint8Array): void { + this.syncConnectSequence(data); + this.processPacket(data); + } + + // ── Live-specific: auth event detection ── + + /** + * Handle RemoteCommandEvents that require relay-side responses: + * auth events, mission phase acknowledgments, etc. + */ + private handleRelayCommands(parsedData: Record): void { + if (parsedData.type !== "RemoteCommandEvent") return; + const rawFuncName = parsedData.funcName as string; + if (!rawFuncName) return; + const funcName = this.resolveNetString(rawFuncName); + + // T2csri auth events → forward to relay for crypto processing. + const authCommands = [ + "t2csri_pokeClient", + "t2csri_getChallengeChunk", + "t2csri_decryptChallenge", + ]; + if (authCommands.includes(funcName)) { + const rawArgs = (parsedData.args as string[]) ?? []; + const args = rawArgs + .map((a) => this.resolveNetString(a)) + .filter((a) => a !== ""); + console.log(`[live] auth event: ${funcName}`, args); + this.relay.sendAuthEvent(funcName, args); + return; + } + + // Mission download phase acknowledgments — the server won't proceed + // to ghosting until the client responds to each phase. + const rawArgs = (parsedData.args as string[]) ?? []; + const resolvedArgs = rawArgs.map((a) => this.resolveNetString(a)); + if (funcName === "MissionStartPhase1") { + const seq = resolvedArgs[0] ?? ""; + console.log(`[live] mission phase 1, seq=${seq}`); + this.relay.sendCommand("MissionStartPhase1Done", [seq]); + } else if (funcName === "MissionStartPhase2") { + const seq = resolvedArgs[0] ?? ""; + console.log(`[live] mission phase 2 (datablocks), seq=${seq}`); + this.relay.sendCommand("MissionStartPhase2Done", [seq]); + } else if (funcName === "MissionStartPhase3") { + const seq = resolvedArgs[0] ?? ""; + console.log(`[live] mission phase 3 (ghosting), seq=${seq}`); + // Send an empty favorites list then acknowledge phase 3. + this.relay.sendCommand("setClientFav", [""]); + this.relay.sendCommand("MissionStartPhase3Done", [seq]); + } + } + + /** Respond to CRCChallengeEvent — required for Phase 2 to begin. */ + private handleCRCChallenge(parsedData: Record): void { + if (parsedData.type !== "CRCChallengeEvent") return; + const seed = parsedData.crcValue as number; + const field1 = parsedData.field1 as number; + const field2 = parsedData.field2 as number; + // field1 bit 0 = includeTextures (from $Host::CRCTextures) + const includeTextures = (field1 & 1) !== 0; + console.log( + `[live] CRC challenge: seed=0x${(seed >>> 0).toString(16)} ` + + `f1=0x${(field1 >>> 0).toString(16)} f2=0x${(field2 >>> 0).toString(16)} ` + + `includeTextures=${includeTextures}`, + ); + + // Collect datablocks for relay-side CRC computation over game files. + const dbMap = this.packetParser.getDataBlockDataMap(); + const datablocks: { objectId: number; className: string; shapeName: string }[] = []; + if (dbMap) { + for (const [id, block] of dbMap) { + const className = this.dataBlockClassNames.get(id); + if (!className) continue; + const shapeName = resolveShapeName(className, block as Record); + datablocks.push({ + objectId: id, + className, + shapeName: shapeName ?? "", + }); + } + } + console.log(`[live] CRC: sending ${datablocks.length} datablocks for computation`); + this.relay.sendCRCCompute(seed, field2, datablocks, includeTextures); + } + + /** + * Respond to GhostingMessageEvent type 0 (GhostAlwaysDone). + * The server sends this after activateGhosting(); the client must respond + * with type 1 so the server sets mGhosting=true and begins sending ghosts. + */ + private handleGhostingMessage(parsedData: Record): void { + if (parsedData.type !== "GhostingMessageEvent") return; + const message = parsedData.message as number; + const sequence = parsedData.sequence as number; + const ghostCount = parsedData.ghostCount as number; + console.log( + `[live] GhostingMessageEvent: message=${message} sequence=${sequence} ghostCount=${ghostCount}`, + ); + if (message === 0) { + // GhostAlwaysDone → send type 1 acknowledgment + console.log(`[live] Sending ghost ack (type 1) for sequence ${sequence}`); + this.relay.sendGhostAck(sequence, ghostCount); + } + } + + /** + * Server-side observer camera mode. In "fly" mode, trigger 0 (fire) would + * make the server assign a team — so we must NEVER send fire in fly mode. + * Jump (trigger 2) transitions between modes. + */ + observerMode: "fly" | "follow" = "fly"; + + /** Enter follow mode (from fly) or cycle to next player (in follow). */ + cycleObserveNext(): void { + if (this.observerMode === "fly") { + // Jump trigger enters observerFollow from observerFly + console.log("[live] observer: fly → follow (jump trigger)"); + this.sendTrigger(2); + this.observerMode = "follow"; + } else { + // Fire trigger cycles to next player in observerFollow + console.log("[live] observer: cycle next (fire trigger)"); + this.sendTrigger(0); + } + } + + /** Toggle between follow and free-fly observer modes. */ + toggleObserverMode(): void { + if (this.observerMode === "fly") { + // Jump trigger enters observerFollow from observerFly + console.log("[live] observer: fly → follow (jump trigger)"); + this.sendTrigger(2); + this.observerMode = "follow"; + } else { + // Jump trigger returns to observerFly from observerFollow + console.log("[live] observer: follow → fly (jump trigger)"); + this.sendTrigger(2); + this.observerMode = "fly"; + } + } + + private sendTrigger(index: number): void { + const trigger: [boolean, boolean, boolean, boolean, boolean, boolean] = + [false, false, false, false, false, false]; + trigger[index] = true; + this.relay.sendMove({ + x: 0, y: 0, z: 0, + yaw: 0, pitch: 0, roll: 0, + trigger, + freeLook: false, + }); + } + + /** Get the player list (for observer cycling UI). */ + getPlayerList(): PlayerListEntry[] { + const entries: PlayerListEntry[] = []; + for (const [targetId, name] of this.targetNames) { + const sg = this.targetTeams.get(targetId) ?? 0; + entries.push({ targetId, name, sensorGroup: sg }); + } + return entries; + } + + // ── Packet processing ── + + private processPacket(data: Uint8Array): void { + try { + const rejectedBefore = this.packetParser.protocolRejected; + const noDispatchBefore = this.packetParser.protocolNoDispatch; + const parsed = this.packetParser.parsePacket(data); + const wasRejected = this.packetParser.protocolRejected > rejectedBefore; + const wasNoDispatch = this.packetParser.protocolNoDispatch > noDispatchBefore; + + if (wasRejected || wasNoDispatch) { + console.warn( + `[live] packet #${this.tickCount} ${wasRejected ? "REJECTED" : "no-dispatch"}: ${data.length} bytes` + + ` (total rejected=${this.packetParser.protocolRejected}, noDispatch=${this.packetParser.protocolNoDispatch})`, + ); + } + + const isEarlyPacket = this.tickCount < 20; + const isMilestonePacket = this.tickCount % 100 === 0; + const shouldLog = isEarlyPacket || isMilestonePacket; + + if (shouldLog) { + console.log( + `[live] packet #${this.tickCount}: ${parsed.events.length} events, ${parsed.ghosts.length} ghosts, ${data.length} bytes` + + (parsed.gameState.controlObjectGhostIndex !== undefined + ? `, control=${parsed.gameState.controlObjectGhostIndex}` + : "") + + (parsed.gameState.cameraFov !== undefined + ? `, fov=${parsed.gameState.cameraFov}` + : ""), + ); + } + + // Control object state + this.processControlObject(parsed.gameState); + + // Events + for (const event of parsed.events) { + if (event.parsedData) { + this.handleRelayCommands(event.parsedData); + this.handleCRCChallenge(event.parsedData); + this.handleGhostingMessage(event.parsedData); + const type = event.parsedData.type as string; + + // Log events in early packets + if (isEarlyPacket) { + if (type !== "NetStringEvent") { + console.log( + `[live] event: ${type}`, + type === "RemoteCommandEvent" + ? { funcName: this.resolveNetString(event.parsedData.funcName as string ?? "") } + : type === "SimDataBlockEvent" + ? { id: event.parsedData.objectId, className: event.parsedData.dataBlockClassName } + : undefined, + ); + } + } + + // Track SimDataBlockEvent class names for CRC computation. + if (type === "SimDataBlockEvent") { + const dbId = event.parsedData.objectId as number | undefined; + const dbClassName = event.parsedData.dataBlockClassName as string | undefined; + if (dbId != null && dbClassName) { + this.dataBlockClassNames.set(dbId, dbClassName); + } + if (shouldLog) { + const dbData = event.parsedData.dataBlockData as Record | undefined; + const shapeName = resolveShapeName(dbClassName ?? "", dbData); + console.log( + `[live] datablock: id=${dbId} class=${dbClassName ?? "?"}` + + (shapeName ? ` shape=${shapeName}` : ""), + ); + } + } + + const eventName = this.registry.getEventParser(event.classId)?.name; + this.processEvent(event, eventName); + + // Log net strings in early packets + if (isEarlyPacket && type === "NetStringEvent") { + const id = event.parsedData.id as number; + const value = event.parsedData.value as string; + if (id != null && typeof value === "string") { + console.log(`[live] netString #${id} = "${value.length > 60 ? value.slice(0, 60) + "…" : value}"`); + } + } + + // Log target info + if (type === "TargetInfoEvent") { + const targetId = event.parsedData.targetId as number | undefined; + const nameTag = event.parsedData.nameTag as number | undefined; + if (targetId != null && nameTag != null) { + const resolved = this.netStrings.get(nameTag); + if (resolved) { + const name = stripTaggedStringMarkup(resolved); + console.log(`[live] target #${targetId}: "${name}" team=${event.parsedData.sensorGroup ?? "?"}`); + } + } + } + + // Log sensor group changes + if (type === "SetSensorGroupEvent") { + const sg = event.parsedData.sensorGroup as number | undefined; + if (sg != null) { + console.log(`[live] sensor group changed: → ${sg}`); + } + } + + // Log sensor group colors + if (type === "SensorGroupColorEvent") { + const sg = event.parsedData.sensorGroup as number; + const colors = event.parsedData.colors as Array | undefined; + if (colors) { + console.log( + `[live] sensor group colors: group=${sg}, ${colors.length} entries`, + ); + } + } + } + } + + // Ghosts + for (const ghost of parsed.ghosts) { + if (ghost.type === "create") { + const pos = ghost.parsedData?.position as Vec3 | undefined; + const hasPos = pos && typeof pos.x === "number" && typeof pos.y === "number" && typeof pos.z === "number"; + const className = this.resolveGhostClassName(ghost.index, ghost.classId); + console.log( + `[live] ghost create: #${ghost.index} ${className ?? "?"}` + + (hasPos ? ` at (${pos.x.toFixed(1)}, ${pos.y.toFixed(1)}, ${pos.z.toFixed(1)})` : "") + + ` (${this.entities.size + 1} entities total)`, + ); + if (!this._ready) { + this._ready = true; + this.onReady?.(); + } + } else if (ghost.type === "delete") { + const prevEntityId = this.entityIdByGhostIndex.get(ghost.index); + const prevEntity = prevEntityId ? this.entities.get(prevEntityId) : undefined; + if (this.tickCount < 50 || this.tickCount % 200 === 0) { + console.log( + `[live] ghost delete: #${ghost.index} ${prevEntity?.className ?? "?"}` + + ` (${this.entities.size - 1} entities remaining)`, + ); + } + } + this.processGhostUpdate(ghost); + } + + this.tickCount++; + this.advanceProjectiles(); + this.advanceItems(); + + // Periodic status at milestones + if (isMilestonePacket && this.tickCount > 1) { + const dbMap = this.packetParser.getDataBlockDataMap(); + console.log( + `[live] status @ tick ${this.tickCount}: ${this.entities.size} entities, ` + + `${dbMap?.size ?? 0} datablocks, ` + + `rejected=${this.packetParser.protocolRejected}, noDispatch=${this.packetParser.protocolNoDispatch}`, + ); + } + + // Entity count milestones + const entityCount = this.entities.size; + if ( + this.tickCount === 1 || + (entityCount > 0 && entityCount % 25 === 0 && this.tickCount < 100) + ) { + const types = new Map(); + for (const e of this.entities.values()) { + types.set(e.type, (types.get(e.type) ?? 0) + 1); + } + const summary = [...types.entries()] + .map(([t, c]) => `${t}=${c}`) + .join(" "); + console.log( + `[live] entity count: ${entityCount} (${summary})`, + ); + } + + this.updateCameraAndHud(); + + // Log camera position for early packets + if (this.tickCount <= 5 && this.camera) { + const [cx, cy, cz] = this.camera.position; + console.log( + `[live] camera: mode=${this.camera.mode} pos=(${cx.toFixed(1)}, ${cy.toFixed(1)}, ${cz.toFixed(1)}) fov=${this.camera.fov}`, + ); + } + } catch (e) { + const errorContext = { + tickCount: this.tickCount, + entityCount: this.entities.size, + dataLength: data.length, + controlGhost: this.latestControl.ghostIndex, + connectSynced: this.connectSynced, + }; + console.error("Failed to process live packet:", e, errorContext); + } + } + + // ── Build snapshot ── + + private buildSnapshot(): StreamSnapshot { + const entities = this.buildEntityList(); + const timeSec = this.currentTimeSec; + const { chatMessages, audioEvents } = this.buildTimeFilteredEvents(timeSec); + const { weaponsHud, inventoryHud, backpackHud, teamScores } = + this.buildHudState(); + + // Default observer camera if none exists + if (!this.camera) { + this.camera = { + time: timeSec, + position: [0, 0, 200], + rotation: [0, 0, 0, 1], + fov: 90, + mode: "observer", + }; + } + + const snapshot: StreamSnapshot = { + timeSec, + exhausted: false, + camera: this.camera, + entities, + controlPlayerGhostId: this.controlPlayerGhostId, + playerSensorGroup: this.playerSensorGroup, + status: this.lastStatus, + chatMessages, + audioEvents, + weaponsHud, + backpackHud, + inventoryHud, + teamScores, + }; + + this._snapshot = snapshot; + this._snapshotTick = this.tickCount; + return snapshot; + } +} diff --git a/src/stream/missionEntityBridge.ts b/src/stream/missionEntityBridge.ts new file mode 100644 index 00000000..b4081828 --- /dev/null +++ b/src/stream/missionEntityBridge.ts @@ -0,0 +1,297 @@ +import type { TorqueObject, TorqueRuntime } from "../torqueScript"; +import type { + GameEntity, + ShapeEntity, + ForceFieldBareEntity, + AudioEmitterEntity, + CameraEntity, + WayPointEntity, +} from "../state/gameEntityTypes"; +import { getPosition, getProperty, getScale } from "../mission"; +import { + terrainFromMis, + interiorFromMis, + skyFromMis, + sunFromMis, + missionAreaFromMis, + waterBlockFromMis, +} from "../scene/misToScene"; + +/** Resolve a named datablock from the runtime. */ +function resolveDatablock( + runtime: TorqueRuntime, + name: string | undefined, +): TorqueObject | undefined { + if (!name) return undefined; + return runtime.state.datablocks.get(name); +} + +/** Handles TorqueScript's various truthy representations. */ +function isTruthy(value: unknown): boolean { + if (typeof value === "string") { + const lower = value.toLowerCase(); + return lower !== "0" && lower !== "false" && lower !== ""; + } + return !!value; +} + +function parseColor3(colorStr: string): [number, number, number] { + const parts = colorStr.split(" ").map((s) => parseFloat(s)); + return [parts[0] ?? 0, parts[1] ?? 0, parts[2] ?? 0]; +} + +function parseRotationToQuat( + rotationStr: string, +): [number, number, number, number] { + const [ax, ay, az, angleDeg] = rotationStr.split(" ").map(parseFloat); + // Convert Torque axis-angle to Three.js quaternion (with coordinate swap + // and angle negation matching getRotation() in mission.ts). + const halfRad = (-(angleDeg || 0) * Math.PI) / 360; + const s = Math.sin(halfRad); + const c = Math.cos(halfRad); + const len = Math.sqrt( + (ay || 0) * (ay || 0) + (az || 0) * (az || 0) + (ax || 0) * (ax || 0), + ); + if (len < 1e-8) return [0, 0, 0, 1]; + // Three.js quaternion [x, y, z, w] with Torque→Three axis swap (x→y, y→z, z→x) + return [ + ((ay || 0) / len) * s, + ((az || 0) / len) * s, + ((ax || 0) / len) * s, + c, + ]; +} + +/** + * Build a GameEntity from a mission TorqueObject. Returns null if the + * object's className is not a renderable entity type. + */ +export function buildGameEntityFromMission( + object: TorqueObject, + runtime: TorqueRuntime, + teamId?: number, +): GameEntity | null { + const className = object._className; + const id = `mission_${object._id}`; + const position = getPosition(object); + const scale = getScale(object); + const rotStr = object.rotation ?? "1 0 0 0"; + const rotation = parseRotationToQuat(rotStr); + const datablockName = getProperty(object, "dataBlock") ?? ""; + const datablock = resolveDatablock(runtime, datablockName); + const missionTypesList = getProperty(object, "missionTypesList"); + + const base = { + id, + className, + runtimeObject: object, + missionTypesList, + }; + const posBase = { ...base, position, rotation, scale }; + + switch (className) { + // Scene infrastructure + case "TerrainBlock": + return { ...base, renderType: "TerrainBlock", terrainData: terrainFromMis(object) }; + case "InteriorInstance": + return { ...base, renderType: "InteriorInstance", interiorData: interiorFromMis(object) }; + case "Sky": + return { ...base, renderType: "Sky", skyData: skyFromMis(object) }; + case "Sun": + return { ...base, renderType: "Sun", sunData: sunFromMis(object) }; + case "WaterBlock": + return { ...base, renderType: "WaterBlock", waterData: waterBlockFromMis(object) }; + case "MissionArea": + return { ...base, renderType: "MissionArea", missionAreaData: missionAreaFromMis(object) }; + + // Shapes + case "StaticShape": + case "Item": + case "Turret": + case "TSStatic": + return buildShapeEntity(posBase, object, datablock, runtime, className, teamId, datablockName); + + // Force field + case "ForceFieldBare": + return buildForceFieldEntity(posBase, object, datablock, scale); + + // Audio + case "AudioEmitter": + return { + ...posBase, + renderType: "AudioEmitter", + audioFileName: getProperty(object, "fileName") ?? undefined, + audioVolume: parseFloat(getProperty(object, "volume")) || 1, + audioIs3D: (getProperty(object, "is3D") ?? "0") !== "0", + audioIsLooping: (getProperty(object, "isLooping") ?? "0") !== "0", + audioMinDistance: parseFloat(getProperty(object, "minDistance")) || 1, + audioMaxDistance: parseFloat(getProperty(object, "maxDistance")) || 1, + audioMinLoopGap: parseFloat(getProperty(object, "minLoopGap")) || 0, + audioMaxLoopGap: parseFloat(getProperty(object, "maxLoopGap")) || 0, + } satisfies AudioEmitterEntity; + + case "Camera": + return { + ...posBase, + renderType: "Camera", + cameraDataBlock: datablockName || undefined, + } satisfies CameraEntity; + + case "WayPoint": + return { + ...posBase, + renderType: "WayPoint", + label: getProperty(object, "name") || undefined, + } satisfies WayPointEntity; + + default: + return null; + } +} + +function buildShapeEntity( + posBase: { + id: string; + className: string; + runtimeObject: unknown; + missionTypesList?: string; + position?: [number, number, number]; + rotation?: [number, number, number, number]; + scale?: [number, number, number]; + }, + object: TorqueObject, + datablock: TorqueObject | undefined, + runtime: TorqueRuntime, + className: string, + teamId: number | undefined, + datablockName: string, +): ShapeEntity { + const shapeName = className === "TSStatic" + ? getProperty(object, "shapeName") + : getProperty(datablock, "shapeFile"); + const shapeType = + className === "Turret" ? "Turret" + : className === "Item" ? "Item" + : className === "TSStatic" ? "TSStatic" + : "StaticShape"; + + const entity: ShapeEntity = { + ...posBase, + renderType: "Shape", + shapeName, + shapeType, + dataBlock: datablockName || undefined, + teamId, + }; + + if (className === "Item") { + entity.rotate = isTruthy( + getProperty(object, "rotate") ?? getProperty(datablock, "rotate"), + ); + } + + if (className === "Turret") { + const barrelName = getProperty(object, "initialBarrel"); + if (barrelName) { + const barrelDb = resolveDatablock(runtime, barrelName); + entity.barrelShapeName = getProperty(barrelDb, "shapeFile"); + } + } + + return entity; +} + +function buildForceFieldEntity( + posBase: { + id: string; + className: string; + runtimeObject: unknown; + missionTypesList?: string; + position?: [number, number, number]; + rotation?: [number, number, number, number]; + scale?: [number, number, number]; + }, + object: TorqueObject, + datablock: TorqueObject | undefined, + rawScale: [number, number, number] | undefined, +): ForceFieldBareEntity { + const colorStr = getProperty(datablock, "color"); + const color = colorStr + ? parseColor3(colorStr) + : ([1, 1, 1] as [number, number, number]); + const baseTranslucency = + parseFloat(getProperty(datablock, "baseTranslucency")) || 1; + const numFrames = parseInt(getProperty(datablock, "numFrames"), 10) || 1; + const framesPerSec = parseFloat(getProperty(datablock, "framesPerSec")) || 1; + const scrollSpeed = parseFloat(getProperty(datablock, "scrollSpeed")) || 0; + const umapping = parseFloat(getProperty(datablock, "umapping")) || 1; + const vmapping = parseFloat(getProperty(datablock, "vmapping")) || 1; + + const textures: string[] = []; + for (let i = 0; i < numFrames; i++) { + const texturePath = getProperty(datablock, `texture${i}`); + if (texturePath) { + textures.push(texturePath); + } + } + + // ForceFieldBare uses "scale" as box dimensions, not as a transform scale. + const dimensions = rawScale ?? [1, 1, 1]; + + return { + ...posBase, + scale: undefined, // Don't apply scale as a group transform + renderType: "ForceFieldBare", + forceFieldData: { + textures, + color, + baseTranslucency, + numFrames, + framesPerSec, + scrollSpeed, + umapping, + vmapping, + dimensions, + }, + }; +} + +/** + * Walk a TorqueObject tree and extract all GameEntities. + * Respects team assignment from SimGroup hierarchy. + */ +export function walkMissionTree( + root: TorqueObject, + runtime: TorqueRuntime, + teamId?: number, +): GameEntity[] { + const entities: GameEntity[] = []; + + // Determine team from SimGroup hierarchy + let currentTeam = teamId; + if (root._className === "SimGroup") { + if (root._name?.toLowerCase() === "teams") { + currentTeam = undefined; + } else if (currentTeam === undefined && root._name) { + const match = root._name.match(/^team(\d+)$/i); + if (match) { + currentTeam = parseInt(match[1], 10); + } + } + } + + // Try to build entity for this object + const entity = buildGameEntityFromMission(root, runtime, currentTeam); + if (entity) { + entities.push(entity); + } + + // Recurse into children + if (root._children) { + for (const child of root._children) { + entities.push(...walkMissionTree(child, runtime, currentTeam)); + } + } + + return entities; +} diff --git a/src/demo/demoPlaybackUtils.ts b/src/stream/playbackUtils.ts similarity index 85% rename from src/demo/demoPlaybackUtils.ts rename to src/stream/playbackUtils.ts index 0469d199..59d6b0e8 100644 --- a/src/demo/demoPlaybackUtils.ts +++ b/src/stream/playbackUtils.ts @@ -21,6 +21,7 @@ import { createMaterialFromFlags, applyShapeShaderModifications, } from "../components/GenericShape"; +import { isOrganicShape } from "../components/ShapeInfoProvider"; import { loadIflAtlas, getFrameIndexForTime, @@ -29,10 +30,7 @@ import { import { getHullBoneIndices, filterGeometryByVertexGroups } from "../meshUtils"; import { loadTexture, setupTexture } from "../textureUtils"; import { textureToUrl } from "../loaders"; -import type { - DemoEntity, - DemoKeyframe, -} from "./types"; +import type { Keyframe } from "./types"; /** Fallback eye height when the player model isn't loaded or has no Cam node. */ export const DEFAULT_EYE_HEIGHT = 2.1; @@ -124,9 +122,9 @@ export function setQuaternionFromDir(dir: Vector3, out: Quaternion): void { /** Binary search for the keyframe at or before the given time. */ export function getKeyframeAtTime( - keyframes: DemoKeyframe[], + keyframes: Keyframe[], time: number, -): DemoKeyframe | null { +): Keyframe | null { if (keyframes.length === 0) return null; if (time <= keyframes[0].time) return keyframes[0]; if (time >= keyframes[keyframes.length - 1].time) @@ -247,6 +245,8 @@ export function smoothVertexNormals(geometry: BufferGeometry): void { export interface ShapeMaterialResult { material: Material; + /** Back-face material for organic/translucent two-pass rendering. */ + backMaterial?: Material; /** For IFL materials: loads atlas, configures texture, sets up animation. */ initialize?: (mesh: Object3D, getTime: () => number) => Promise<() => void>; } @@ -260,6 +260,7 @@ export interface ShapeMaterialResult { export function replaceWithShapeMaterial( mat: MeshStandardMaterial, vis: number, + isOrganic = false, ): ShapeMaterialResult { const resourcePath: string | undefined = mat.userData?.resource_path; const flagNames = new Set(mat.userData?.flag_names ?? []); @@ -279,12 +280,22 @@ export function replaceWithShapeMaterial( // "Resource not found" warnings from textureToUrl, and return an initializer // that loads the atlas and sets up per-frame animation. if (flagNames.has("IflMaterial")) { - const result = createMaterialFromFlags(mat, null, flagNames, false, vis); - const material = Array.isArray(result) ? result[1] : result; + const result = createMaterialFromFlags( + mat, null, flagNames, isOrganic, vis, + ); + if (Array.isArray(result)) { + const material = result[1]; + return { + material, + backMaterial: result[0], + initialize: (mesh, getTime) => + initializeIflMaterial(material, resourcePath, mesh, getTime), + }; + } return { - material, + material: result, initialize: (mesh, getTime) => - initializeIflMaterial(material, resourcePath, mesh, getTime), + initializeIflMaterial(result, resourcePath, mesh, getTime), }; } @@ -293,13 +304,20 @@ export function replaceWithShapeMaterial( // Three.js re-renders automatically once loaded. const url = textureToUrl(resourcePath); const texture = loadTexture(url); - setupTexture(texture); + const isTranslucent = flagNames.has("Translucent"); + if (isOrganic || isTranslucent) { + setupTexture(texture, { disableMipmaps: true }); + } else { + setupTexture(texture); + } - const result = createMaterialFromFlags(mat, texture, flagNames, false, vis); - // createMaterialFromFlags may return a [back, front] pair for translucent - // materials. Use the front material since we can't split meshes imperatively. - const material = Array.isArray(result) ? result[1] : result; - return { material }; + const result = createMaterialFromFlags( + mat, texture, flagNames, isOrganic, vis, + ); + if (Array.isArray(result)) { + return { material: result[1], backMaterial: result[0] }; + } + return { material: result }; } export interface IflInitializer { @@ -338,8 +356,12 @@ async function initializeIflMaterial( * normals, and replace PBR materials with diffuse-only Lambert materials. * Returns IFL initializers for any IFL materials found. */ -export function processShapeScene(scene: Object3D): IflInitializer[] { +export function processShapeScene( + scene: Object3D, + shapeName?: string, +): IflInitializer[] { const iflInitializers: IflInitializer[] = []; + const isOrganic = shapeName ? isOrganicShape(shapeName) : false; // Find skeleton for hull bone filtering. let skeleton: any = null; @@ -350,6 +372,9 @@ export function processShapeScene(scene: Object3D): IflInitializer[] { ? getHullBoneIndices(skeleton) : new Set(); + // Collect back-face meshes to add after traversal (can't modify during traverse). + const backFaceMeshes: Array<{ parent: Object3D; mesh: any }> = []; + scene.traverse((node: any) => { if (!node.isMesh) return; @@ -384,61 +409,37 @@ export function processShapeScene(scene: Object3D): IflInitializer[] { const vis: number = hasVisSequence ? 1 : (node.userData?.vis ?? 1); if (Array.isArray(node.material)) { node.material = node.material.map((m: MeshStandardMaterial) => { - const result = replaceWithShapeMaterial(m, vis); + const result = replaceWithShapeMaterial(m, vis, isOrganic); if (result.initialize) { iflInitializers.push({ mesh: node, initialize: result.initialize }); } + if (result.backMaterial && node.parent) { + const backMesh = node.clone(); + backMesh.material = result.backMaterial; + backFaceMeshes.push({ parent: node.parent, mesh: backMesh }); + } return result.material; }); } else if (node.material) { - const result = replaceWithShapeMaterial(node.material, vis); + const result = replaceWithShapeMaterial(node.material, vis, isOrganic); if (result.initialize) { iflInitializers.push({ mesh: node, initialize: result.initialize }); } node.material = result.material; + if (result.backMaterial && node.parent) { + const backMesh = node.clone(); + backMesh.material = result.backMaterial; + backFaceMeshes.push({ parent: node.parent, mesh: backMesh }); + } } }); - return iflInitializers; -} + // Add back-face meshes for two-pass organic/translucent rendering. + for (const { parent, mesh } of backFaceMeshes) { + parent.add(mesh); + } -export function buildStreamDemoEntity( - id: string, - type: string, - dataBlock: string | undefined, - visual: DemoEntity["visual"] | undefined, - direction: DemoEntity["direction"] | undefined, - weaponShape: string | undefined, - playerName: string | undefined, - className: string | undefined, - ghostIndex: number | undefined, - dataBlockId: number | undefined, - shapeHint: string | undefined, - explosionDataBlockId?: number, - faceViewer?: boolean, -): DemoEntity { - return { - id, - type, - dataBlock, - visual, - direction, - weaponShape, - playerName, - className, - ghostIndex, - dataBlockId, - shapeHint, - explosionDataBlockId, - faceViewer, - keyframes: [ - { - time: 0, - position: [0, 0, 0], - rotation: [0, 0, 0, 1], - }, - ], - }; + return iflInitializers; } export function entityTypeColor(type: string): string { diff --git a/src/demo/playerAnimation.ts b/src/stream/playerAnimation.ts similarity index 99% rename from src/demo/playerAnimation.ts rename to src/stream/playerAnimation.ts index bf8c9d36..87bbb8d6 100644 --- a/src/demo/playerAnimation.ts +++ b/src/stream/playerAnimation.ts @@ -2,20 +2,16 @@ * Movement animation selection logic replicating Torque's * Player::pickActionAnimation() (player.cc:2280). */ - /** Torque falling threshold: Z velocity below this = falling. */ const FALLING_THRESHOLD = -10; - /** Minimum velocity dot product to count as intentional movement. */ const MOVE_THRESHOLD = 0.1; - export interface MoveAnimationResult { /** Engine alias name (e.g. "root", "run", "back", "side", "fall"). */ animation: string; /** 1 for forward playback, -1 for reversed (right strafe). */ timeScale: number; } - /** * Extract body yaw (Torque rotationZ) from a Three.js quaternion produced by * `playerYawToQuaternion()`. That function builds a Y-axis rotation: @@ -25,7 +21,6 @@ export interface MoveAnimationResult { function quaternionToBodyYaw(q: [number, number, number, number]): number { return -2 * Math.atan2(q[1], q[3]); } - /** * Pick the movement animation for a player based on their velocity and * body orientation, matching Torque's pickActionAnimation(). @@ -40,35 +35,27 @@ export function pickMoveAnimation( if (!velocity) { return { animation: "root", timeScale: 1 }; } - const [vx, vy, vz] = velocity; - // Falling: Torque Z velocity below threshold. if (vz < FALLING_THRESHOLD) { return { animation: "fall", timeScale: 1 }; } - // Convert world velocity to player object space using body yaw. const yaw = quaternionToBodyYaw(rotation); const cosY = Math.cos(yaw); const sinY = Math.sin(yaw); - // Torque object space: localY = forward, localX = right. const localX = vx * cosY + vy * sinY; const localY = -vx * sinY + vy * cosY; - // Pick direction with largest dot product. const forwardDot = localY; const backDot = -localY; const leftDot = -localX; const rightDot = localX; - const maxDot = Math.max(forwardDot, backDot, leftDot, rightDot); - if (maxDot < MOVE_THRESHOLD) { return { animation: "root", timeScale: 1 }; } - if (maxDot === forwardDot) { return { animation: "run", timeScale: 1 }; } diff --git a/src/stream/relayClient.ts b/src/stream/relayClient.ts new file mode 100644 index 00000000..a53cc411 --- /dev/null +++ b/src/stream/relayClient.ts @@ -0,0 +1,197 @@ +import type { + ClientMessage, + ClientMove, + ServerMessage, + ServerInfo, + ConnectionStatus, +} from "../../relay/types"; + +export type RelayEventHandler = { + onOpen?: () => void; + onStatus?: (status: ConnectionStatus, message?: string, connectSequence?: number, mapName?: string) => void; + onServerList?: (servers: ServerInfo[]) => void; + onGamePacket?: (data: Uint8Array) => void; + /** Relay↔T2 server RTT. */ + onPing?: (ms: number) => void; + /** Browser↔relay WebSocket RTT. */ + onWsPing?: (ms: number) => void; + onError?: (message: string) => void; + onClose?: () => void; +}; + +/** + * WebSocket client that connects to the relay server. + * Handles JSON control messages and binary game packet forwarding. + */ +export class RelayClient { + private ws: WebSocket | null = null; + private handlers: RelayEventHandler; + private url: string; + private _connected = false; + private wsPingInterval: ReturnType | null = null; + private smoothedWsPing = 0; + + constructor(url: string, handlers: RelayEventHandler) { + this.url = url; + this.handlers = handlers; + } + + get connected(): boolean { + return this._connected; + } + + connect(): void { + this.ws = new WebSocket(this.url); + this.ws.binaryType = "arraybuffer"; + + this.ws.onopen = () => { + console.log("[relay] WebSocket connected to", this.url); + this._connected = true; + this.startWsPing(); + this.handlers.onOpen?.(); + }; + + this.ws.onmessage = (event) => { + if (event.data instanceof ArrayBuffer) { + // Binary message — game packet from server + this.handlers.onGamePacket?.(new Uint8Array(event.data)); + } else { + // JSON control message + try { + const message: ServerMessage = JSON.parse(event.data as string); + this.handleMessage(message); + } catch (e) { + console.error("Failed to parse relay message:", e); + } + } + }; + + this.ws.onclose = () => { + console.log("[relay] WebSocket disconnected"); + this._connected = false; + this.stopWsPing(); + this.handlers.onClose?.(); + }; + + this.ws.onerror = () => { + console.error("[relay] WebSocket error"); + this.handlers.onError?.("WebSocket connection error"); + }; + } + + private handleMessage(message: ServerMessage): void { + switch (message.type) { + case "serverList": + this.handlers.onServerList?.(message.servers); + break; + case "status": + this.handlers.onStatus?.(message.status, message.message, message.connectSequence, message.mapName); + break; + case "ping": + this.handlers.onPing?.(message.ms); + break; + case "wsPong": { + const rtt = Date.now() - message.ts; + this.smoothedWsPing = + this.smoothedWsPing === 0 + ? rtt + : this.smoothedWsPing * 0.5 + rtt * 0.5; + this.handlers.onWsPing?.(Math.round(this.smoothedWsPing)); + break; + } + case "error": + this.handlers.onError?.(message.message); + break; + } + } + + /** Request the server list from the master server. */ + listServers(): void { + this.send({ type: "listServers" }); + } + + /** Send a WebSocket ping to measure browser↔relay RTT. */ + sendWsPing(): void { + this.send({ type: "wsPing", ts: Date.now() }); + } + + /** Join a specific game server. */ + joinServer(address: string): void { + console.log("[relay] Joining server:", address); + this.send({ type: "joinServer", address }); + } + + /** Disconnect from the current game server. */ + disconnectServer(): void { + this.send({ type: "disconnect" }); + } + + /** Forward a T2csri auth event to the relay. */ + sendAuthEvent(command: string, args: string[]): void { + this.send({ type: "sendCommand", command, args }); + } + + /** Send a commandToServer through the relay. */ + sendCommand(command: string, args: string[]): void { + this.send({ type: "sendCommand", command, args }); + } + + /** Send a CRC challenge response through the relay (legacy echo). */ + sendCRCResponse(crcValue: number, field1: number, field2: number): void { + this.send({ type: "sendCRCResponse", crcValue, field1, field2 }); + } + + /** Send datablock info for relay-side CRC computation over game files. */ + sendCRCCompute( + seed: number, + field2: number, + datablocks: { objectId: number; className: string; shapeName: string }[], + includeTextures: boolean, + ): void { + this.send({ type: "sendCRCCompute", seed, field2, includeTextures, datablocks }); + } + + /** Send a GhostAlwaysDone acknowledgment through the relay. */ + sendGhostAck(sequence: number, ghostCount: number): void { + this.send({ type: "sendGhostAck", sequence, ghostCount }); + } + + /** Send a move struct to the relay for forwarding to the game server. */ + sendMove(move: ClientMove): void { + this.send({ type: "sendMove", move }); + } + + /** Close the WebSocket connection entirely. */ + close(): void { + this.stopWsPing(); + if (this.ws) { + this.ws.close(); + this.ws = null; + } + this._connected = false; + } + + private startWsPing(): void { + this.smoothedWsPing = 0; + // Send immediately so we have a measurement before the server list arrives. + this.send({ type: "wsPing", ts: Date.now() }); + this.wsPingInterval = setInterval(() => { + this.send({ type: "wsPing", ts: Date.now() }); + }, 7000); + } + + private stopWsPing(): void { + if (this.wsPingInterval != null) { + clearInterval(this.wsPingInterval); + this.wsPingInterval = null; + } + } + + private send(message: ClientMessage): void { + if (this.ws?.readyState === WebSocket.OPEN) { + this.ws.send(JSON.stringify(message)); + } else { + console.warn("[relay] send dropped (ws not open):", message.type); + } + } +} diff --git a/src/stream/streamHelpers.ts b/src/stream/streamHelpers.ts new file mode 100644 index 00000000..378b12e1 --- /dev/null +++ b/src/stream/streamHelpers.ts @@ -0,0 +1,468 @@ +import { Matrix4, Quaternion } from "three"; +import type { + StreamVisual, + WeaponImageDataBlockState, + ChatSegment, +} from "./types"; +import { projectileClassNames } from "./entityClassification"; + +export type Vec3 = { x: number; y: number; z: number }; + +// ── Math helpers ── + +const _rotMat = new Matrix4(); +const _rotQuat = new Quaternion(); + +export function clamp(value: number, min: number, max: number): number { + if (value < min) return min; + if (value > max) return max; + return value; +} + +export const MAX_PITCH = Math.PI * 0.494; +export const CameraMode_OrbitObject = 3; + +/** + * Build a Three.js quaternion from Torque observer yaw/pitch angles. + * Uses a shared Matrix4/Quaternion to avoid per-frame allocations. + */ +export function yawPitchToQuaternion( + yaw: number, + pitch: number, +): [number, number, number, number] { + const sx = Math.sin(pitch); + const cx = Math.cos(pitch); + const sz = Math.sin(yaw); + const cz = Math.cos(yaw); + + _rotMat.set( + -sz, cz * sx, -cz * cx, 0, + 0, cx, sx, 0, + cz, sz * sx, -sz * cx, 0, + 0, 0, 0, 1, + ); + + _rotQuat.setFromRotationMatrix(_rotMat); + return [_rotQuat.x, _rotQuat.y, _rotQuat.z, _rotQuat.w]; +} + +/** Player body rotation: yaw only, around Three.js Y axis. */ +export function playerYawToQuaternion( + rotZ: number, +): [number, number, number, number] { + const halfAngle = -rotZ / 2; + return [0, Math.sin(halfAngle), 0, Math.cos(halfAngle)]; +} + +/** Convert a Torque quaternion (x-right, y-forward, z-up) to Three.js. */ +export function torqueQuatToThreeJS(q: { + x: number; + y: number; + z: number; + w: number; +}): [number, number, number, number] | null { + if ( + !Number.isFinite(q.x) || + !Number.isFinite(q.y) || + !Number.isFinite(q.z) || + !Number.isFinite(q.w) + ) { + return null; + } + + // Axis swizzle (x,y,z)->(y,z,x) and inverted rotation direction. + const x = -q.y; + const y = -q.z; + const z = -q.x; + const w = q.w; + + const lenSq = x * x + y * y + z * z + w * w; + if (lenSq <= 1e-12) return null; + + const invLen = 1 / Math.sqrt(lenSq); + return [x * invLen, y * invLen, z * invLen, w * invLen]; +} + +// ── Position / type guards ── + +export function isValidPosition( + pos: { x: number; y: number; z: number } | undefined | null, +): pos is { x: number; y: number; z: number } { + return ( + pos != null && + Number.isFinite(pos.x) && + Number.isFinite(pos.y) && + Number.isFinite(pos.z) + ); +} + +export function isVec3Like( + value: unknown, +): value is { x: number; y: number; z: number } { + return ( + !!value && + typeof value === "object" && + typeof (value as { x?: unknown }).x === "number" && + typeof (value as { y?: unknown }).y === "number" && + typeof (value as { z?: unknown }).z === "number" + ); +} + +export function isQuatLike(value: unknown): value is { + x: number; + y: number; + z: number; + w: number; +} { + return ( + !!value && + typeof value === "object" && + typeof (value as { x?: unknown }).x === "number" && + typeof (value as { y?: unknown }).y === "number" && + typeof (value as { z?: unknown }).z === "number" && + typeof (value as { w?: unknown }).w === "number" + ); +} + +// ── DataBlock field accessors ── + +/** + * Resolve the DTS shape path from a datablock's parsed data. + * Accepts either a ghost className (e.g. "LinearProjectile") or a datablock + * className (e.g. "LinearProjectileData") to determine which field holds the + * shape path. + */ +export function resolveShapeName( + className: string, + data: Record | undefined, +): string | undefined { + if (!data) return undefined; + + let value: unknown; + if ( + projectileClassNames.has(className) || + className.endsWith("ProjectileData") + ) { + value = data.projectileShapeName; + } else if (className === "DebrisData") { + value = data.shapeFileName; + } else { + value = data.shapeName; + } + return typeof value === "string" && value.length > 0 ? value : undefined; +} + +export function getNumberField( + data: Record | undefined, + keys: readonly string[], +): number | undefined { + if (!data) return undefined; + for (const key of keys) { + const value = data[key]; + if (typeof value === "number" && Number.isFinite(value)) return value; + } + return undefined; +} + +export function getStringField( + data: Record | undefined, + keys: readonly string[], +): string | undefined { + if (!data) return undefined; + for (const key of keys) { + const value = data[key]; + if (typeof value === "string" && value.length > 0) return value; + } + return undefined; +} + +export function getBooleanField( + data: Record | undefined, + keys: readonly string[], +): boolean | undefined { + if (!data) return undefined; + for (const key of keys) { + const value = data[key]; + if (typeof value === "boolean") return value; + } + return undefined; +} + +// ── Visual resolution ── + +export function resolveTracerVisual( + className: string, + data: Record | undefined, +): StreamVisual | undefined { + if (!data) return undefined; + + const texture = + getStringField(data, ["tracerTex0", "textureName0", "texture0"]) ?? ""; + const hasTracerHints = + className === "TracerProjectile" || + (texture.length > 0 && getNumberField(data, ["tracerLength"]) != null); + if (!hasTracerHints || !texture) return undefined; + + const crossTexture = getStringField(data, [ + "tracerTex1", + "textureName1", + "texture1", + ]); + + const tracerLength = getNumberField(data, ["tracerLength"]) ?? 10; + const canonicalTracerWidth = getNumberField(data, ["tracerWidth"]); + const aliasTracerWidth = getNumberField(data, ["tracerAlpha"]); + const tracerWidth = + canonicalTracerWidth != null && + (getNumberField(data, ["crossViewAng"]) != null || + canonicalTracerWidth <= 0.7) + ? canonicalTracerWidth + : (aliasTracerWidth ?? canonicalTracerWidth ?? 0.5); + const crossViewAng = + getNumberField(data, ["crossViewAng", "crossViewFraction"]) ?? + (typeof data.tracerWidth === "number" && data.tracerWidth > 0.7 + ? data.tracerWidth + : 0.98); + const crossSize = + getNumberField(data, ["crossSize", "muzzleVelocity"]) ?? 0.45; + const renderCross = + getBooleanField(data, ["renderCross", "proximityRadius"]) ?? true; + + return { + kind: "tracer", + texture, + crossTexture, + tracerLength, + tracerWidth, + crossViewAng, + crossSize, + renderCross, + }; +} + +export function resolveSpriteVisual( + className: string, + data: Record | undefined, +): StreamVisual | undefined { + if (!data) return undefined; + + if (className === "LinearFlareProjectile") { + const texture = getStringField(data, ["smokeTexture", "flareTexture"]); + if (!texture) return undefined; + const color = data.flareColor as + | { r: number; g: number; b: number } + | undefined; + const size = getNumberField(data, ["size"]) ?? 0.5; + return { + kind: "sprite", + texture, + color: color + ? { r: color.r, g: color.g, b: color.b } + : { r: 1, g: 1, b: 1 }, + size, + }; + } + + if (className === "FlareProjectile") { + const texture = getStringField(data, ["flareTexture"]); + if (!texture) return undefined; + const size = getNumberField(data, ["size"]) ?? 4.0; + return { + kind: "sprite", + texture, + color: { r: 1, g: 0.9, b: 0.5 }, + size, + }; + } + + return undefined; +} + +// ── Weapon image state parsing ── + +/** + * Parse weapon image state machine from a ShapeBaseImageData datablock. + * + * CRITICAL: The parser's field names for transitions are MISALIGNED with + * the actual engine packing order. See demoStreaming.ts for details on the + * remap table. + */ +export function parseWeaponImageStates( + blockData: Record, +): WeaponImageDataBlockState[] | undefined { + const rawStates = blockData.states as + | Array> + | undefined; + if (!Array.isArray(rawStates) || rawStates.length === 0) return undefined; + + return rawStates.map((s) => { + const remap = (v: unknown): number => { + const n = v as number; + if (n == null) return -1; + return n - 1; + }; + + return { + name: (s.name as string) ?? "", + transitionOnNotLoaded: remap(s.transitionOnAmmo), + transitionOnLoaded: remap(s.transitionOnNoAmmo), + transitionOnNoAmmo: remap(s.transitionOnTarget), + transitionOnAmmo: remap(s.transitionOnNoTarget), + transitionOnNoTarget: remap(s.transitionOnWet), + transitionOnTarget: remap(s.transitionOnNotWet), + transitionOnNotWet: remap(s.transitionOnTriggerUp), + transitionOnWet: remap(s.transitionOnTriggerDown), + transitionOnTriggerUp: remap(s.transitionOnTimeout), + transitionOnTriggerDown: remap(s.transitionGeneric0In), + transitionOnTimeout: remap(s.transitionGeneric0Out), + timeoutValue: s.timeoutValue as number | undefined, + waitForTimeout: (s.waitForTimeout as boolean) ?? false, + fire: (s.fire as boolean) ?? false, + sequence: s.sequence as number | undefined, + spin: (s.spin as number) ?? 0, + direction: (s.direction as boolean) ?? true, + scaleAnimation: (s.scaleAnimation as boolean) ?? false, + loaded: (s.loaded as number) ?? 0, + soundDataBlockId: (s.sound as number) ?? -1, + }; + }); +} + +// ── Chat / text helpers ── + +/** Strip non-printable Torque tagged string markup from a string. */ +export function stripTaggedStringMarkup(s: string): string { + let stripped = ""; + for (let i = 0; i < s.length; i++) { + if (s.charCodeAt(i) >= 0x20) stripped += s[i]; + } + return stripped; +} + +/** + * Byte-to-fontColors-index remap table from the Torque V12 renderer (dgl.cc). + * + * TorqueScript `\cN` escapes are encoded via `collapseRemap` in scan.l, + * producing byte values that skip \t (0x9), \n (0xa), and \r (0xd). + */ +const BYTE_TO_COLOR_INDEX: Record = { + 0x2: 0, 0x3: 1, 0x4: 2, 0x5: 3, 0x6: 4, + 0x7: 5, 0x8: 6, 0xb: 7, 0xc: 8, 0xe: 9, +}; + +const BYTE_COLOR_RESET = 0x0f; +const BYTE_COLOR_PUSH = 0x10; +const BYTE_COLOR_POP = 0x11; + +/** + * Extract the leading Torque \c color index (0–9) from a tagged string. + */ +export function detectColorCode(s: string): number | undefined { + for (let i = 0; i < s.length; i++) { + const code = s.charCodeAt(i); + const colorIndex = BYTE_TO_COLOR_INDEX[code]; + if (colorIndex !== undefined) return colorIndex; + if (code >= 0x20) return undefined; + } + return undefined; +} + +/** Parse a raw Torque HudMessageVector line into colored segments. */ +export function parseColorSegments(raw: string): ChatSegment[] { + const segments: ChatSegment[] = []; + let currentColor = 0; + let currentText = ""; + let inTaggedString = false; + + for (let i = 0; i < raw.length; i++) { + const code = raw.charCodeAt(i); + + if (code === BYTE_COLOR_PUSH) { + inTaggedString = true; + continue; + } + if (code === BYTE_COLOR_POP) { + inTaggedString = false; + continue; + } + + if (inTaggedString) { + if (code >= 0x20) currentText += raw[i]; + continue; + } + + const colorIndex = BYTE_TO_COLOR_INDEX[code]; + if (colorIndex !== undefined) { + if (currentText) { + segments.push({ text: currentText, colorCode: currentColor }); + currentText = ""; + } + currentColor = colorIndex; + } else if (code === BYTE_COLOR_RESET) { + if (currentText) { + segments.push({ text: currentText, colorCode: currentColor }); + currentText = ""; + } + currentColor = 0; + } else if (code >= 0x20) { + currentText += raw[i]; + } + } + + if (currentText) { + segments.push({ text: currentText, colorCode: currentColor }); + } + return segments; +} + +/** Extract an embedded `~w` sound tag from a message string. */ +export function extractWavTag( + text: string, +): { text: string; wavPath: string | null } { + const idx = text.indexOf("~w"); + if (idx === -1) return { text, wavPath: null }; + return { + text: text.substring(0, idx), + wavPath: text.substring(idx + 2), + }; +} + +// ── Control object detection ── + +export type ControlObjectType = "camera" | "player"; + +export function detectControlObjectType( + data: Record | undefined, +): ControlObjectType | null { + if (!data) return null; + if (typeof data.cameraMode === "number") return "camera"; + if (typeof data.rotationZ === "number") return "player"; + return null; +} + +// ── Backpack HUD ── + +const BACKPACK_BITMAP_TO_INDEX = new Map([ + ["gui/hud_new_packammo", 0], + ["gui/hud_new_packcloak", 1], + ["gui/hud_new_packenergy", 2], + ["gui/hud_new_packrepair", 3], + ["gui/hud_new_packsatchel", 4], + ["gui/hud_new_packshield", 5], + ["gui/hud_new_packinventory", 6], + ["gui/hud_new_packmotionsens", 7], + ["gui/hud_new_packradar", 8], + ["gui/hud_new_packturretout", 9], + ["gui/hud_new_packturretin", 10], + ["gui/hud_new_packsensjam", 11], + ["gui/hud_new_packturret", 12], + ["gui/hud_satchel_unarmed", 18], +]); + +export function backpackBitmapToIndex(bitmap: string): number { + const lower = bitmap.toLowerCase(); + for (const [key, val] of BACKPACK_BITMAP_TO_INDEX) { + if (key === lower) return val; + } + return -1; +} diff --git a/src/demo/types.ts b/src/stream/types.ts similarity index 72% rename from src/demo/types.ts rename to src/stream/types.ts index bc5aded8..a5d87be4 100644 --- a/src/demo/types.ts +++ b/src/stream/types.ts @@ -1,4 +1,7 @@ -export interface DemoThreadState { +import type { SceneObject } from "../scene/types"; + +/** DTS animation thread state from ghost ThreadMask data. */ +export interface ThreadState { index: number; sequence: number; state: number; @@ -41,7 +44,7 @@ export interface WeaponImageDataBlockState { soundDataBlockId: number; } -export interface DemoKeyframe { +export interface Keyframe { time: number; /** Position in Torque space [x, y, z]. */ position: [number, number, number]; @@ -64,7 +67,7 @@ export interface DemoKeyframe { actionAtEnd?: boolean; } -export interface DemoTracerVisual { +export interface TracerVisual { kind: "tracer"; /** Main tracer streak texture (e.g. "special/tracer00"). */ texture: string; @@ -77,7 +80,7 @@ export interface DemoTracerVisual { renderCross: boolean; } -export interface DemoSpriteVisual { +export interface SpriteVisual { kind: "sprite"; /** Sprite texture (e.g. "flarebase"). */ texture: string; @@ -87,67 +90,13 @@ export interface DemoSpriteVisual { size: number; } -export type DemoVisual = DemoTracerVisual | DemoSpriteVisual; +export type StreamVisual = TracerVisual | SpriteVisual; -export interface DemoEntity { - id: number | string; - type: string; - dataBlock?: string; - visual?: DemoVisual; - /** Projectile forward direction in Torque space [x, y, z]. */ - direction?: [number, number, number]; - /** Ghost index for streamed entities (debug/inspection). */ - ghostIndex?: number; - /** Ghost class name for streamed entities (debug/inspection). */ - className?: string; - /** Last seen datablock object id (debug/inspection). */ - dataBlockId?: number; - /** Datablock-derived shape hint, if any (debug/inspection). */ - shapeHint?: string; - /** Time (seconds) when this entity enters ghost scope. */ - spawnTime?: number; - /** Time (seconds) when this entity leaves ghost scope. */ - despawnTime?: number; - keyframes: DemoKeyframe[]; - /** DTS animation thread states from ghost ThreadMask data. */ - threads?: DemoThreadState[]; - /** Weapon shape file name for Player entities (e.g. "weapon_disc.dts"). */ - weaponShape?: string; - /** Player name resolved from the target system string table. */ - playerName?: string; - /** IFF color resolved from the sensor group color table (sRGB 0-255). */ - iffColor?: { r: number; g: number; b: number }; - /** Target render flags bitmask from the Target Manager. */ - targetRenderFlags?: number; - /** Weapon image condition flags from ghost ImageMask data. */ - weaponImageState?: WeaponImageState; - /** Weapon image state machine states from the ShapeBaseImageData datablock. */ - weaponImageStates?: WeaponImageDataBlockState[]; - /** Head pitch for blend animations, normalized [-1,1]. -1 = max down, 1 = max up. */ - headPitch?: number; - /** Head yaw for blend animations (freelook), normalized [-1,1]. -1 = max right, 1 = max left. */ - headYaw?: number; - /** Numeric ID of the ExplosionData datablock (for explosion shape rendering). */ - explosionDataBlockId?: number; - /** Billboard toward camera (Torque's faceViewer). */ - faceViewer?: boolean; -} - -export interface DemoRecording { - duration: number; - /** Mission name as it appears in the demo (e.g. "S5-WoodyMyrk"). */ - missionName: string | null; - /** Game type display name from the demo (e.g. "Capture the Flag"). */ - gameType: string | null; - /** Streaming parser session used for Move-tick-driven playback. */ - streamingPlayback: DemoStreamingPlayback; -} - -export interface DemoStreamEntity { +export interface StreamEntity { id: string; type: string; dataBlock?: string; - visual?: DemoVisual; + visual?: StreamVisual; direction?: [number, number, number]; weaponShape?: string; playerName?: string; @@ -172,7 +121,7 @@ export interface DemoStreamEntity { damageState?: number; faceViewer?: boolean; /** DTS animation thread states from ghost ThreadMask data. */ - threads?: DemoThreadState[]; + threads?: ThreadState[]; /** Numeric ID of the ExplosionData datablock (for particle effect resolution). */ explosionDataBlockId?: number; /** Numeric ID of the ParticleEmitterData for in-flight trail particles. */ @@ -185,9 +134,22 @@ export interface DemoStreamEntity { headPitch?: number; /** Head yaw for blend animations (freelook), normalized [-1,1]. -1 = max right, 1 = max left. */ headYaw?: number; + /** WayPoint display label. */ + label?: string; + // AudioEmitter ghost fields + audioFileName?: string; + audioVolume?: number; + audioIs3D?: boolean; + audioIsLooping?: boolean; + audioMinDistance?: number; + audioMaxDistance?: number; + audioMinLoopGap?: number; + audioMaxLoopGap?: number; + /** Scene infrastructure data (terrain, interior, sky, etc.). */ + sceneData?: SceneObject; } -export interface DemoStreamCamera { +export interface StreamCamera { /** Timestamp in seconds for the current camera state. */ time: number; /** Position in Torque space [x, y, z]. */ @@ -213,7 +175,7 @@ export interface ChatSegment { colorCode: number; } -export interface DemoChatMessage { +export interface ChatMessage { timeSec: number; sender: string; text: string; @@ -268,16 +230,16 @@ export interface PendingAudioEvent { timeSec: number; } -export interface DemoStreamSnapshot { +export interface StreamSnapshot { timeSec: number; exhausted: boolean; - camera: DemoStreamCamera | null; - entities: DemoStreamEntity[]; + camera: StreamCamera | null; + entities: StreamEntity[]; controlPlayerGhostId?: string; /** Recording player's sensor group (team number). */ playerSensorGroup: number; status: { health: number; energy: number }; - chatMessages: DemoChatMessage[]; + chatMessages: ChatMessage[]; /** One-shot audio events from Sim3DAudioEvent / Sim2DAudioEvent. */ audioEvents: PendingAudioEvent[]; /** Weapons HUD state from inventory RemoteCommandEvents. */ @@ -298,12 +260,29 @@ export interface DemoStreamSnapshot { teamScores: TeamScore[]; } -export interface DemoStreamingPlayback { +export interface StreamingPlayback { reset(): void; - getSnapshot(): DemoStreamSnapshot; - stepToTime(targetTimeSec: number, maxMoveTicks?: number): DemoStreamSnapshot; + getSnapshot(): StreamSnapshot; + stepToTime(targetTimeSec: number, maxMoveTicks?: number): StreamSnapshot; /** DTS shape names for weapon effects (explosions) that should be preloaded. */ getEffectShapes(): string[]; /** Resolve a datablock by its numeric ID. */ getDataBlockData(id: number): Record | undefined; + /** + * Get TSShapeConstructor sequence entries for a shape (e.g. "heavy_male.dts"). + * Returns the raw sequence strings like `"heavy_male_root.dsq root"`. + */ + getShapeConstructorSequences(shapeName: string): string[] | undefined; +} + +export interface StreamRecording { + /** "demo" for .rec file playback, "live" for live server observation. */ + source: "demo" | "live"; + duration: number; + /** Mission name (e.g. "S5-WoodyMyrk"). */ + missionName: string | null; + /** Game type display name (e.g. "Capture the Flag"). */ + gameType: string | null; + /** Streaming parser session for tick-driven playback. */ + streamingPlayback: StreamingPlayback; } diff --git a/src/demo/weaponStateMachine.ts b/src/stream/weaponStateMachine.ts similarity index 100% rename from src/demo/weaponStateMachine.ts rename to src/stream/weaponStateMachine.ts diff --git a/src/terrainHeight.ts b/src/terrainHeight.ts index 5592a043..5135c9ce 100644 --- a/src/terrainHeight.ts +++ b/src/terrainHeight.ts @@ -30,8 +30,8 @@ export function getTerrainHeightAt( * Uses bilinear interpolation and clamps to terrain bounds. * * Coordinate mapping (derived from terrain geometry rotations): - * - Torque X → heightmap row - * - Torque Y → heightmap col + * - Torque X → heightmap col + * - Torque Y → heightmap row */ export function createTerrainHeightSampler( heightMap: Uint16Array, @@ -41,8 +41,11 @@ export function createTerrainHeightSampler( // Convert Torque world coords to fractional heightmap coords. // The terrain origin is at (-squareSize * 128, -squareSize * 128, 0), // so grid center (128, 128) corresponds to Torque (0, 0). - const col = torqueY / squareSize + HALF_SIZE; - const row = torqueX / squareSize + HALF_SIZE; + // Row/col mapping must match the terrain geometry displacement: + // after UV flip and geometry rotations, row corresponds to Torque Y + // and col corresponds to Torque X. + const col = torqueX / squareSize + HALF_SIZE; + const row = torqueY / squareSize + HALF_SIZE; // Clamp to valid range const clampedCol = Math.max(0, Math.min(TERRAIN_SIZE - 1, col)); diff --git a/src/torqueScript/shapeConstructor.ts b/src/torqueScript/shapeConstructor.ts index 256f27bd..168fd72b 100644 --- a/src/torqueScript/shapeConstructor.ts +++ b/src/torqueScript/shapeConstructor.ts @@ -7,6 +7,7 @@ import type { TorqueRuntime } from "./types"; */ export type SequenceAliasMap = Map>; + /** * Build sequence alias maps from TSShapeConstructor datablocks already * registered in the runtime. Each datablock has `baseshape` and @@ -64,6 +65,7 @@ export function buildSequenceAliasMap(runtime: TorqueRuntime): SequenceAliasMap return result; } + /** * Build a case-insensitive action map from GLB clips, augmented with * TSShapeConstructor aliases. Both the original clip name and the alias diff --git a/tsconfig.json b/tsconfig.json index e16712bc..9a2d416b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "ES2017", + "target": "ES2022", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,